Updated contribs from Lorne White
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12779 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -5,9 +5,12 @@
|
|||||||
#
|
#
|
||||||
# Author: Lorne White (email: lorne.white@telusplanet.net)
|
# Author: Lorne White (email: lorne.white@telusplanet.net)
|
||||||
#
|
#
|
||||||
# Version 0.5
|
# Version 0.6
|
||||||
# Date: Feb 26, 2001
|
# Date: Nov 14, 2001
|
||||||
# Licence: wxWindows license
|
# Licence: wxWindows license
|
||||||
|
|
||||||
|
# Change Log: Add Label parameter to accommodate updated library code
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
from wxPython.wx import *
|
from wxPython.wx import *
|
||||||
@@ -45,10 +48,13 @@ class TestColourSelect(wxPanel):
|
|||||||
for i in range(len(colours)):
|
for i in range(len(colours)):
|
||||||
wxStaticText(self, -1, names[i], wxPoint(self.x_pos, self.y_pos), wxSize(-1, -1)) # name
|
wxStaticText(self, -1, names[i], wxPoint(self.x_pos, self.y_pos), wxSize(-1, -1)) # name
|
||||||
|
|
||||||
val = ColourSelect(self, -1, colours[i], wxPoint(self.x_pos+100, self.y_pos), sizes[i]) # colour selection button
|
val = ColourSelect(self, -1, "", colours[i], wxPoint(self.x_pos+100, self.y_pos), sizes[i]) # colour selection button
|
||||||
self.set_val.append(val) # store control for reference
|
self.set_val.append(val) # store control for reference
|
||||||
self.y_pos = self.y_pos + delta
|
self.y_pos = self.y_pos + delta
|
||||||
|
|
||||||
|
self.y_pos = self.y_pos - delta
|
||||||
|
ColourSelect(self, -1, "Color Label", colours[0], wxPoint(self.x_pos+200, self.y_pos), sizes[0]) # colour selection button
|
||||||
|
|
||||||
|
|
||||||
def OnClick(self, event):
|
def OnClick(self, event):
|
||||||
result = []
|
result = []
|
||||||
|
@@ -40,7 +40,7 @@ class TablePanel(wxPanel):
|
|||||||
eval(code)
|
eval(code)
|
||||||
|
|
||||||
def ReadData(self):
|
def ReadData(self):
|
||||||
test_file = "./data/TestTable.txt"
|
test_file = "./data/testtable.txt"
|
||||||
file = open(test_file,'r',1)
|
file = open(test_file,'r',1)
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
@@ -75,6 +75,7 @@ class TablePanel(wxPanel):
|
|||||||
|
|
||||||
prt.SetHeader("wxWindows Applications")
|
prt.SetHeader("wxWindows Applications")
|
||||||
prt.SetFooter()
|
prt.SetFooter()
|
||||||
|
prt.SetFooter("Date: ", type = "Date", align=wxALIGN_RIGHT, indent = -2, colour = wxNamedColour('RED'))
|
||||||
prt.Preview()
|
prt.Preview()
|
||||||
|
|
||||||
def PreviewNarrow(self):
|
def PreviewNarrow(self):
|
||||||
@@ -104,7 +105,7 @@ class TablePanel(wxPanel):
|
|||||||
prt.label_font_colour = wxNamedColour('WHITE')
|
prt.label_font_colour = wxNamedColour('WHITE')
|
||||||
prt.SetHeader("wxWindows Applications", colour = wxNamedColour('RED'))
|
prt.SetHeader("wxWindows Applications", colour = wxNamedColour('RED'))
|
||||||
|
|
||||||
prt.SetHeader("Date", align=wxALIGN_RIGHT, indent = -2, colour = wxNamedColour('BLUE'))
|
prt.SetHeader("Printed: ", type = "Date & Time", align=wxALIGN_RIGHT, indent = -2, colour = wxNamedColour('BLUE'))
|
||||||
prt.SetFooter("Page No", colour = wxNamedColour('RED'), type ="Num")
|
prt.SetFooter("Page No", colour = wxNamedColour('RED'), type ="Num")
|
||||||
prt.Preview()
|
prt.Preview()
|
||||||
|
|
||||||
|
@@ -5,8 +5,8 @@
|
|||||||
# Author: Lorne White (email: lorne.white@telusplanet.net)
|
# Author: Lorne White (email: lorne.white@telusplanet.net)
|
||||||
#
|
#
|
||||||
# Created:
|
# Created:
|
||||||
# Version 0.90
|
# Version 0.92
|
||||||
# Date: July 19, 2001
|
# Date: Nov 26, 2001
|
||||||
# Licence: wxWindows license
|
# Licence: wxWindows license
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
# Author: Lorne White, Lorne.White@telusplanet.net
|
# Author: Lorne White, Lorne.White@telusplanet.net
|
||||||
#
|
#
|
||||||
# Created: Sept 4, 2001
|
# Created: Feb 25, 2001
|
||||||
# Licence: wxWindows license
|
# Licence: wxWindows license
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -18,44 +18,55 @@ from wxPython.wx import *
|
|||||||
# Updates:
|
# Updates:
|
||||||
# call back to function if changes made
|
# call back to function if changes made
|
||||||
|
|
||||||
|
# Cliff Wells, logiplexsoftware@earthlink.net:
|
||||||
|
# - Made ColourSelect into "is a button" rather than "has a button"
|
||||||
|
# - Added label parameter and logic to adjust the label colour according to the background
|
||||||
|
# colour
|
||||||
|
# - Added id argument
|
||||||
|
# - Rearranged arguments to more closely follow wx conventions
|
||||||
|
# - Simplified some of the code
|
||||||
|
|
||||||
|
|
||||||
class ColourSelect(wxButton):
|
class ColourSelect(wxButton):
|
||||||
def __init__(self, parent, ID, bcolour=[0, 0, 0], pos=wxPoint(20, 20), size=wxSize(20, 20), style=0, callback=None):
|
def __init__(self, parent, id, label = "", bcolour=(0, 0, 0),
|
||||||
wxButton.__init__(self, parent, ID, "", pos, size, style)
|
pos = wxDefaultPosition, size = wxDefaultSize,
|
||||||
self.win = parent
|
callback = None):
|
||||||
|
wxButton.__init__(self, parent, id, label, pos=pos, size=size)
|
||||||
|
self.SetColour(bcolour)
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
EVT_BUTTON(self, ID, self.OnClick)
|
EVT_BUTTON(parent, self.GetId(), self.OnClick)
|
||||||
self.SetColourValue(bcolour)
|
|
||||||
|
|
||||||
def SetColour(self, bcolour):
|
|
||||||
self.SetBackgroundColour(bcolour)
|
|
||||||
|
|
||||||
def SetColourValue(self, bcolour):
|
|
||||||
self.set_colour = bcolour
|
|
||||||
self.SetBackgroundColour(self.Get_wxColour())
|
|
||||||
self.SetForegroundColour(wxWHITE)
|
|
||||||
|
|
||||||
def SetValue(self, bcolour):
|
|
||||||
self.SetColourValue(bcolour)
|
|
||||||
|
|
||||||
def GetColour(self):
|
def GetColour(self):
|
||||||
return self.set_colour
|
return self.set_colour
|
||||||
|
|
||||||
def Get_wxColour(self):
|
def GetValue(self):
|
||||||
return wxColour(self.set_colour[0], self.set_colour[1], self.set_colour[2])
|
return self.set_colour
|
||||||
|
|
||||||
|
def SetColour(self, bcolour):
|
||||||
|
self.set_colour_val = wxColor(bcolour[0], bcolour[1], bcolour[2])
|
||||||
|
self.SetBackgroundColour(self.set_colour_val)
|
||||||
|
avg = reduce(lambda a, b: a + b, bcolour) / 3
|
||||||
|
fcolour = avg > 128 and (0, 0, 0) or (255, 255, 255)
|
||||||
|
self.SetForegroundColour(apply(wxColour, fcolour))
|
||||||
|
self.set_colour = bcolour
|
||||||
|
|
||||||
|
def SetValue(self, bcolour):
|
||||||
|
self.SetColour(bcolour)
|
||||||
|
|
||||||
def OnChange(self):
|
def OnChange(self):
|
||||||
if self.callback != None:
|
if self.callback is not None:
|
||||||
self.callback()
|
self.callback()
|
||||||
|
|
||||||
def OnClick(self, event):
|
def OnClick(self, event):
|
||||||
data = wxColourData()
|
data = wxColourData()
|
||||||
data.SetChooseFull(true)
|
data.SetChooseFull(true)
|
||||||
data.SetColour(self.Get_wxColour())
|
data.SetColour(self.set_colour_val)
|
||||||
dlg = wxColourDialog(self.win, data)
|
dlg = wxColourDialog(self.GetParent(), data)
|
||||||
if dlg.ShowModal() == wxID_OK:
|
changed = dlg.ShowModal() == wxID_OK
|
||||||
|
if changed:
|
||||||
data = dlg.GetColourData()
|
data = dlg.GetColourData()
|
||||||
self.set_colour = set = data.GetColour().Get()
|
self.SetColour(data.GetColour().Get())
|
||||||
self.SetBackgroundColour(self.Get_wxColour())
|
|
||||||
self.OnChange()
|
|
||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
|
|
||||||
|
if changed:
|
||||||
|
self.OnChange() # moved after dlg.Destroy, since who knows what the callback will do...
|
||||||
|
@@ -5,8 +5,8 @@
|
|||||||
# Author: Lorne White (email: lorne.white@telusplanet.net)
|
# Author: Lorne White (email: lorne.white@telusplanet.net)
|
||||||
#
|
#
|
||||||
# Created:
|
# Created:
|
||||||
# Version 0.72
|
# Version 0.75
|
||||||
# Date: Sept 8, 2001
|
# Date: Sept 18, 2001
|
||||||
# Licence: wxWindows license
|
# Licence: wxWindows license
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -16,6 +16,30 @@ from wxPython.wx import *
|
|||||||
import copy
|
import copy
|
||||||
|
|
||||||
class PrintBase:
|
class PrintBase:
|
||||||
|
def SetPrintFont(self, font): # set the DC font parameters
|
||||||
|
fattr = font["Attr"]
|
||||||
|
if fattr[0] == 1:
|
||||||
|
weight = wxBOLD
|
||||||
|
else:
|
||||||
|
weight = wxNORMAL
|
||||||
|
|
||||||
|
if fattr[1] == 1:
|
||||||
|
set_style = wxITALIC
|
||||||
|
else:
|
||||||
|
set_style = wxNORMAL
|
||||||
|
|
||||||
|
underline = fattr[2]
|
||||||
|
fcolour = self.GetFontColour(font)
|
||||||
|
self.DC.SetTextForeground(fcolour)
|
||||||
|
|
||||||
|
setfont = wxFont(font["Size"], wxSWISS, set_style, weight, underline)
|
||||||
|
setfont.SetFaceName(font["Name"])
|
||||||
|
self.DC.SetFont(setfont)
|
||||||
|
|
||||||
|
def GetFontColour(self, font):
|
||||||
|
fcolour = font["Colour"]
|
||||||
|
return wxColour(fcolour[0], fcolour[1], fcolour[2])
|
||||||
|
|
||||||
def OutTextRegion(self, textout, txtdraw = TRUE):
|
def OutTextRegion(self, textout, txtdraw = TRUE):
|
||||||
textlines = string.splitfields(textout, '\n')
|
textlines = string.splitfields(textout, '\n')
|
||||||
y = copy.copy(self.y) + self.pt_space_before
|
y = copy.copy(self.y) + self.pt_space_before
|
||||||
@@ -123,6 +147,21 @@ class PrintBase:
|
|||||||
y = y + y_line
|
y = y + y_line
|
||||||
return y - y_line
|
return y - y_line
|
||||||
|
|
||||||
|
def GetDate(self):
|
||||||
|
date, time = self.GetNow()
|
||||||
|
return date
|
||||||
|
|
||||||
|
def GetDateTime(self):
|
||||||
|
date, time = self.GetNow()
|
||||||
|
return date + ' ' + time
|
||||||
|
|
||||||
|
def GetNow(self):
|
||||||
|
full = str(wxDateTime_Now()) # get the current date and time in print format
|
||||||
|
flds = string.splitfields(full)
|
||||||
|
date = flds[0]
|
||||||
|
time = flds[1]
|
||||||
|
return date, time
|
||||||
|
|
||||||
def SetPreview(self, preview):
|
def SetPreview(self, preview):
|
||||||
self.preview = preview
|
self.preview = preview
|
||||||
|
|
||||||
@@ -183,12 +222,8 @@ class PrintTableDraw(wxScrolledWindow, PrintBase):
|
|||||||
self.column_def_line_colour = self.parent.column_def_line_colour
|
self.column_def_line_colour = self.parent.column_def_line_colour
|
||||||
|
|
||||||
self.text_font = self.parent.text_font
|
self.text_font = self.parent.text_font
|
||||||
self.text_font_name = self.parent.text_font_name
|
|
||||||
self.text_font_colour = self.parent.text_font_colour
|
|
||||||
|
|
||||||
self.label_font = self.parent.label_font
|
self.label_font = self.parent.label_font
|
||||||
self.label_font_name = self.parent.label_font_name
|
|
||||||
self.label_font_colour = self.parent.label_font_colour
|
|
||||||
|
|
||||||
def AdjustValues(self):
|
def AdjustValues(self):
|
||||||
self.vertical_offset = self.pheight * self.parent.vertical_offset
|
self.vertical_offset = self.pheight * self.parent.vertical_offset
|
||||||
@@ -262,7 +297,8 @@ class PrintTableDraw(wxScrolledWindow, PrintBase):
|
|||||||
try:
|
try:
|
||||||
colour = set_column_txtcolour[col] # check if custom column text colour
|
colour = set_column_txtcolour[col] # check if custom column text colour
|
||||||
except:
|
except:
|
||||||
colour = self.parent.text_font_colour
|
colour = self.GetFontColour(self.parent.text_font)
|
||||||
|
|
||||||
self.column_txtcolour.append(colour)
|
self.column_txtcolour.append(colour)
|
||||||
|
|
||||||
col = col + 1
|
col = col + 1
|
||||||
@@ -270,7 +306,7 @@ class PrintTableDraw(wxScrolledWindow, PrintBase):
|
|||||||
def SetPointAdjust(self):
|
def SetPointAdjust(self):
|
||||||
f = wxFont(10, wxSWISS, wxNORMAL, wxNORMAL) # setup using 10 point
|
f = wxFont(10, wxSWISS, wxNORMAL, wxNORMAL) # setup using 10 point
|
||||||
self.DC.SetFont(f)
|
self.DC.SetFont(f)
|
||||||
f.SetFaceName(self.text_font_name)
|
f.SetFaceName(self.text_font["Name"])
|
||||||
x, y = self.DC.GetTextExtent("W")
|
x, y = self.DC.GetTextExtent("W")
|
||||||
|
|
||||||
self.label_pt_space_before = self.parent.label_pt_adj_before * y/10 # extra spacing for label per point value
|
self.label_pt_space_before = self.parent.label_pt_adj_before * y/10 # extra spacing for label per point value
|
||||||
@@ -292,13 +328,13 @@ class PrintTableDraw(wxScrolledWindow, PrintBase):
|
|||||||
self.y_start = self.ptop_margin + self.vertical_offset
|
self.y_start = self.ptop_margin + self.vertical_offset
|
||||||
self.y_end = self.parent.page_height * self.pheight - self.pbottom_margin + self.vertical_offset
|
self.y_end = self.parent.page_height * self.pheight - self.pbottom_margin + self.vertical_offset
|
||||||
|
|
||||||
self.text_font.SetFaceName(self.label_font_name)
|
self.SetPrintFont(self.label_font)
|
||||||
self.DC.SetFont(self.label_font)
|
|
||||||
x, y = self.DC.GetTextExtent("W")
|
x, y = self.DC.GetTextExtent("W")
|
||||||
self.label_space = y
|
self.label_space = y
|
||||||
|
|
||||||
self.text_font.SetFaceName(self.text_font_name)
|
self.SetPrintFont(self.text_font)
|
||||||
self.DC.SetFont(self.text_font)
|
|
||||||
x, y = self.DC.GetTextExtent("W")
|
x, y = self.DC.GetTextExtent("W")
|
||||||
self.space = y
|
self.space = y
|
||||||
|
|
||||||
@@ -382,9 +418,7 @@ class PrintTableDraw(wxScrolledWindow, PrintBase):
|
|||||||
self.pt_space_after = self.label_pt_space_after
|
self.pt_space_after = self.label_pt_space_after
|
||||||
|
|
||||||
self.LabelColorRow(self.label_colour)
|
self.LabelColorRow(self.label_colour)
|
||||||
self.label_font.SetFaceName(self.label_font_name)
|
self.SetPrintFont(self.label_font)
|
||||||
self.DC.SetFont(self.label_font)
|
|
||||||
self.DC.SetTextForeground(self.label_font_colour)
|
|
||||||
|
|
||||||
self.col = 0
|
self.col = 0
|
||||||
max_y = 0
|
max_y = 0
|
||||||
@@ -407,15 +441,20 @@ class PrintTableDraw(wxScrolledWindow, PrintBase):
|
|||||||
return
|
return
|
||||||
|
|
||||||
for val in self.parent.header:
|
for val in self.parent.header:
|
||||||
f = wxFont(val["Size"], wxSWISS, wxNORMAL, val["Attr"])
|
self.SetPrintFont(val["Font"])
|
||||||
self.DC.SetFont(f)
|
|
||||||
fontname = val["Name"]
|
|
||||||
|
|
||||||
f.SetFaceName(fontname)
|
|
||||||
self.DC.SetTextForeground(val["Colour"])
|
|
||||||
|
|
||||||
header_indent = val["Indent"] * self.pwidth
|
header_indent = val["Indent"] * self.pwidth
|
||||||
self.OutTextPageWidth(val["Text"], self.pheader_margin, val["Align"], header_indent, TRUE)
|
text = val["Text"]
|
||||||
|
|
||||||
|
htype = val["Type"]
|
||||||
|
if htype == "Date":
|
||||||
|
addtext = self.GetDate()
|
||||||
|
elif htype == "Date & Time":
|
||||||
|
addtext = self.GetDateTime()
|
||||||
|
else:
|
||||||
|
addtext = ""
|
||||||
|
|
||||||
|
self.OutTextPageWidth(text+addtext, self.pheader_margin, val["Align"], header_indent, TRUE)
|
||||||
|
|
||||||
def PrintFooter(self): # print the header array
|
def PrintFooter(self): # print the header array
|
||||||
if self.draw == FALSE:
|
if self.draw == FALSE:
|
||||||
@@ -423,25 +462,27 @@ class PrintTableDraw(wxScrolledWindow, PrintBase):
|
|||||||
|
|
||||||
footer_pos = self.parent.page_height * self.pheight - self.pfooter_margin + self.vertical_offset
|
footer_pos = self.parent.page_height * self.pheight - self.pfooter_margin + self.vertical_offset
|
||||||
for val in self.parent.footer:
|
for val in self.parent.footer:
|
||||||
f = wxFont(val["Size"], wxSWISS, wxNORMAL, val["Attr"])
|
self.SetPrintFont(val["Font"])
|
||||||
self.DC.SetFont(f)
|
|
||||||
fontname = val["Name"]
|
|
||||||
|
|
||||||
f.SetFaceName(fontname)
|
|
||||||
self.DC.SetTextForeground(val["Colour"])
|
|
||||||
|
|
||||||
footer_indent = val["Indent"] * self.pwidth
|
footer_indent = val["Indent"] * self.pwidth
|
||||||
|
text = val["Text"]
|
||||||
|
|
||||||
ftype = val["Type"]
|
ftype = val["Type"]
|
||||||
if ftype == "Pageof":
|
if ftype == "Pageof":
|
||||||
text = "Page " + str(self.page) + " of " + str(self.total_pages)
|
addtext = "Page " + str(self.page) + " of " + str(self.total_pages)
|
||||||
elif ftype == "Page":
|
elif ftype == "Page":
|
||||||
text = "Page " + str(self.page)
|
addtext = "Page " + str(self.page)
|
||||||
elif ftype == "Num":
|
elif ftype == "Num":
|
||||||
text = str(self.page)
|
addtext = str(self.page)
|
||||||
|
elif ftype == "Date":
|
||||||
|
addtext = self.GetDate()
|
||||||
|
elif ftype == "Date & Time":
|
||||||
|
addtext = self.GetDateTime()
|
||||||
else:
|
else:
|
||||||
text = ""
|
addtext = ""
|
||||||
|
|
||||||
|
self.OutTextPageWidth(text+addtext, footer_pos, val["Align"], footer_indent, TRUE)
|
||||||
|
|
||||||
self.OutTextPageWidth(text, footer_pos, val["Align"], footer_indent, TRUE)
|
|
||||||
|
|
||||||
def LabelColorRow(self, colour):
|
def LabelColorRow(self, colour):
|
||||||
brush = wxBrush(colour, wxSOLID)
|
brush = wxBrush(colour, wxSOLID)
|
||||||
@@ -469,15 +510,13 @@ class PrintTableDraw(wxScrolledWindow, PrintBase):
|
|||||||
col = col + 1
|
col = col + 1
|
||||||
|
|
||||||
def PrintRow(self, row_val, draw = TRUE, align = wxALIGN_LEFT):
|
def PrintRow(self, row_val, draw = TRUE, align = wxALIGN_LEFT):
|
||||||
self.text_font.SetFaceName(self.text_font_name)
|
self.SetPrintFont(self.text_font)
|
||||||
self.DC.SetFont(self.text_font)
|
|
||||||
|
|
||||||
self.pt_space_before = self.text_pt_space_before # set the point spacing
|
self.pt_space_before = self.text_pt_space_before # set the point spacing
|
||||||
self.pt_space_after = self.text_pt_space_after
|
self.pt_space_after = self.text_pt_space_after
|
||||||
|
|
||||||
self.col = 0
|
self.col = 0
|
||||||
max_y = 0
|
max_y = 0
|
||||||
self.DC.SetTextForeground(self.text_font_colour)
|
|
||||||
for vtxt in row_val:
|
for vtxt in row_val:
|
||||||
self.region = self.column[self.col+1] - self.column[self.col]
|
self.region = self.column[self.col+1] - self.column[self.col]
|
||||||
self.indent = self.column[self.col]
|
self.indent = self.column[self.col]
|
||||||
@@ -636,15 +675,8 @@ class PrintTable:
|
|||||||
self.label_colour = wxNamedColour('LIGHT GREY')
|
self.label_colour = wxNamedColour('LIGHT GREY')
|
||||||
|
|
||||||
def SetFonts(self):
|
def SetFonts(self):
|
||||||
self.label_font_size = 12
|
self.label_font = { "Name": self.default_font_name, "Size": 12, "Colour": [0, 0, 0], "Attr": [0, 0, 0] }
|
||||||
self.label_font_attr = wxNORMAL
|
self.text_font = { "Name": self.default_font_name, "Size": 10, "Colour": [0, 0, 0], "Attr": [0, 0, 0] }
|
||||||
self.label_font_name = "Arial"
|
|
||||||
self.label_font_colour = wxNamedColour('BLACK')
|
|
||||||
|
|
||||||
self.text_font_size = 10
|
|
||||||
self.text_font_attr = wxNORMAL
|
|
||||||
self.text_font_name = "Arial"
|
|
||||||
self.text_font_colour = wxNamedColour('BLACK')
|
|
||||||
|
|
||||||
def TextSpacing(self):
|
def TextSpacing(self):
|
||||||
self.label_pt_adj_before = 0 # point adjustment before and after the label text
|
self.label_pt_adj_before = 0 # point adjustment before and after the label text
|
||||||
@@ -667,20 +699,14 @@ class PrintTable:
|
|||||||
|
|
||||||
def SetHeaderValue(self):
|
def SetHeaderValue(self):
|
||||||
self.header_margin = 0.25
|
self.header_margin = 0.25
|
||||||
self.header_font_size = 12
|
self.header_font = { "Name": self.default_font_name, "Size": 11, "Colour": [0, 0, 0], "Attr": [0, 0, 0] }
|
||||||
self.header_font_colour = wxNamedColour('BLACK')
|
|
||||||
self.header_font_attr = wxBOLD
|
|
||||||
self.header_font_name = self.text_font_name
|
|
||||||
self.header_align = wxALIGN_CENTRE
|
self.header_align = wxALIGN_CENTRE
|
||||||
self.header_indent = 0
|
self.header_indent = 0
|
||||||
self.header_type = None
|
self.header_type = "Text"
|
||||||
|
|
||||||
def SetFooterValue(self):
|
def SetFooterValue(self):
|
||||||
self.footer_margin = 0.7
|
self.footer_margin = 0.7
|
||||||
self.footer_font_size = 10
|
self.footer_font = { "Name": self.default_font_name, "Size": 11, "Colour": [0, 0, 0], "Attr": [0, 0, 0] }
|
||||||
self.footer_font_colour = wxNamedColour('BLACK')
|
|
||||||
self.footer_font_attr = wxNORMAL
|
|
||||||
self.footer_font_name = self.text_font_name
|
|
||||||
self.footer_align = wxALIGN_CENTRE
|
self.footer_align = wxALIGN_CENTRE
|
||||||
self.footer_indent = 0
|
self.footer_indent = 0
|
||||||
self.footer_type = "Pageof"
|
self.footer_type = "Pageof"
|
||||||
@@ -714,6 +740,9 @@ class PrintTable:
|
|||||||
self.preview = None
|
self.preview = None
|
||||||
self.page = 0
|
self.page = 0
|
||||||
|
|
||||||
|
self.default_font_name = "Arial"
|
||||||
|
self.default_font = { "Name": self.default_font_name, "Size": 10, "Colour": [0, 0, 0], "Attr": [0, 0, 0] }
|
||||||
|
|
||||||
def SetColAlignment(self, col, align=wxALIGN_LEFT):
|
def SetColAlignment(self, col, align=wxALIGN_LEFT):
|
||||||
self.set_column_align[col] = align
|
self.set_column_align[col] = align
|
||||||
|
|
||||||
@@ -759,23 +788,27 @@ class PrintTable:
|
|||||||
def SetRowLineColour(self, row, colour):
|
def SetRowLineColour(self, row, colour):
|
||||||
self.row_line_colour[row] = colour
|
self.row_line_colour[row] = colour
|
||||||
|
|
||||||
def SetHeader(self, text = "", type = None, name=None, size=None, colour = None, align = None, indent = None, attr=None):
|
def GetColour(self, colour): # returns colours based from wxColour value
|
||||||
|
red = colour.Red()
|
||||||
|
blue = colour.Blue()
|
||||||
|
green = colour.Green()
|
||||||
|
return [red, green, blue ]
|
||||||
|
|
||||||
|
def SetHeader(self, text = "", type = "Text", font=None, align = None, indent = None, colour = None, size = None):
|
||||||
set = { "Text": text }
|
set = { "Text": text }
|
||||||
|
|
||||||
if name == None:
|
if font == None:
|
||||||
set["Name"] = self.header_font_name
|
set["Font"] = copy.copy(self.default_font)
|
||||||
else:
|
else:
|
||||||
set["Name"] = name
|
set["Font"] = font
|
||||||
|
|
||||||
if size == None:
|
if colour != None:
|
||||||
set["Size"] = self.header_font_size
|
setfont = set["Font"]
|
||||||
else:
|
setfont["Colour"] = self.GetColour(colour)
|
||||||
set["Size"] = size
|
|
||||||
|
|
||||||
if colour == None:
|
if size != None:
|
||||||
set["Colour"] = self.header_font_colour
|
setfont = set["Font"]
|
||||||
else:
|
setfont["Size"] = size
|
||||||
set["Colour"] = colour
|
|
||||||
|
|
||||||
if align == None:
|
if align == None:
|
||||||
set["Align"] = self.header_align
|
set["Align"] = self.header_align
|
||||||
@@ -787,11 +820,6 @@ class PrintTable:
|
|||||||
else:
|
else:
|
||||||
set["Indent"] = indent
|
set["Indent"] = indent
|
||||||
|
|
||||||
if attr == None:
|
|
||||||
set["Attr"] = self.header_font_attr
|
|
||||||
else:
|
|
||||||
set["Attr"] = attr
|
|
||||||
|
|
||||||
if type == None:
|
if type == None:
|
||||||
set["Type"] = self.header_type
|
set["Type"] = self.header_type
|
||||||
else:
|
else:
|
||||||
@@ -799,23 +827,21 @@ class PrintTable:
|
|||||||
|
|
||||||
self.header.append(set)
|
self.header.append(set)
|
||||||
|
|
||||||
def SetFooter(self, text = "", type = None, name=None, size=None, colour = None, align = None, indent = None, attr=None):
|
def SetFooter(self, text = "", type = None, font=None, align = None, indent = None, colour = None, size = None):
|
||||||
set = { "Text": text }
|
set = { "Text": text }
|
||||||
|
|
||||||
if name == None:
|
if font == None:
|
||||||
set["Name"] = self.footer_font_name
|
set["Font"] = copy.copy(self.default_font)
|
||||||
else:
|
else:
|
||||||
set["Name"] = name
|
set["Font"] = font
|
||||||
|
|
||||||
if size == None:
|
if colour != None:
|
||||||
set["Size"] = self.footer_font_size
|
setfont = set["Font"]
|
||||||
else:
|
setfont["Colour"] = self.GetColour(colour)
|
||||||
set["Size"] = size
|
|
||||||
|
|
||||||
if colour == None:
|
if size != None:
|
||||||
set["Colour"] = self.footer_font_colour
|
setfont = set["Font"]
|
||||||
else:
|
setfont["Size"] = size
|
||||||
set["Colour"] = colour
|
|
||||||
|
|
||||||
if align == None:
|
if align == None:
|
||||||
set["Align"] = self.footer_align
|
set["Align"] = self.footer_align
|
||||||
@@ -832,11 +858,6 @@ class PrintTable:
|
|||||||
else:
|
else:
|
||||||
set["Type"] = type
|
set["Type"] = type
|
||||||
|
|
||||||
if attr == None:
|
|
||||||
set["Attr"] = self.footer_font_attr
|
|
||||||
else:
|
|
||||||
set["Attr"] = attr
|
|
||||||
|
|
||||||
self.footer.append(set)
|
self.footer.append(set)
|
||||||
|
|
||||||
def Preview(self):
|
def Preview(self):
|
||||||
@@ -857,7 +878,6 @@ class PrintTable:
|
|||||||
frame.SetSize(self.preview_frame_size)
|
frame.SetSize(self.preview_frame_size)
|
||||||
frame.Show(true)
|
frame.Show(true)
|
||||||
|
|
||||||
|
|
||||||
def Print(self):
|
def Print(self):
|
||||||
pdd = wxPrintDialogData()
|
pdd = wxPrintDialogData()
|
||||||
pdd.SetPrintData(self.printData)
|
pdd.SetPrintData(self.printData)
|
||||||
@@ -873,9 +893,6 @@ class PrintTable:
|
|||||||
size = DC.GetSizeTuple()
|
size = DC.GetSizeTuple()
|
||||||
DC.BeginDrawing()
|
DC.BeginDrawing()
|
||||||
|
|
||||||
self.text_font = wxFont(self.text_font_size, wxSWISS, self.text_font_attr, wxNORMAL)
|
|
||||||
self.label_font = wxFont(self.label_font_size, wxSWISS, self.label_font_attr, wxNORMAL)
|
|
||||||
|
|
||||||
table = PrintTableDraw(self, DC, size)
|
table = PrintTableDraw(self, DC, size)
|
||||||
table.data = self.data
|
table.data = self.data
|
||||||
table.set_column = self.set_column
|
table.set_column = self.set_column
|
||||||
|
Reference in New Issue
Block a user