Added more contribs from Lorne White, and updated some of the existing ones.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11553 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2001-09-04 04:17:38 +00:00
parent ddcb3d8378
commit 53fe40bac2
12 changed files with 1506 additions and 65 deletions

View File

@@ -35,7 +35,7 @@ Updated wxColumnSorterMixin to also be able to place sort icons on the
column headers, and updated the wxListCtrl demo to show it off by column headers, and updated the wxListCtrl demo to show it off by
using wxColumnSorterMixin. using wxColumnSorterMixin.
Added wxGenBitmapTextButton contrib from Lorne White. Added wxGenBitmapTextButton, TablePrint, etc. contribs from Lorne White.

View File

@@ -20,7 +20,7 @@ include demo/bmp_source/*.ico
include demo/bmp_source/*.gif include demo/bmp_source/*.gif
include demo/bmp_source/*.png include demo/bmp_source/*.png
include demo/bmp_source/*.jpg include demo/bmp_source/*.jpg
include demo/README.txt include demo/*.txt
include demo/*.xml include demo/*.xml
include demo/data/*.png include demo/data/*.png
include demo/data/*.htm include demo/data/*.htm

View File

@@ -187,8 +187,37 @@ class SimpleGrid(wxGrid): ##, wxGridAutoEditMixin):
class TestFrame(wxFrame): class TestFrame(wxFrame):
def __init__(self, parent, log): def __init__(self, parent, log):
wxFrame.__init__(self, parent, -1, "Simple Grid Demo", size=(640,480)) wxFrame.__init__(self, parent, -1, "Simple Grid Demo", size=(640,480))
grid = SimpleGrid(self, log) self.grid = grid = SimpleGrid(self, log)
self.mainmenu = wxMenuBar()
menu = wxMenu()
mID = NewId()
menu.Append(mID, 'Preview Grid', 'Print Displayed Grid')
EVT_MENU(self, mID, self.OnPreviewGrid)
self.mainmenu.Append(menu, '&Print')
self.SetMenuBar(self.mainmenu)
def OnPreviewGrid(self, event):
from wxPython.lib.printout import PrintGrid
grid = self.grid
total_col = 4 # not all columns to be used for printing
total_row = 4
format = [1, 1.5, 2.5, 4, 5, 7] # column spacing
# class to print and preview
prt = PrintGrid(self, grid, format, total_col, total_row )
prt.SetAttributes() # get the colour and text attributes
table = prt.GetTable() # the table print control class
table.SetHeader("Simple Grid Test Header")
table.SetFooter()
prt.Preview() # preview the table
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------

View File

@@ -26,10 +26,10 @@ _treeList = [
'PyCrust', 'PyCrust',
'VirtualListCtrl', 'VirtualListCtrl',
'wxListCtrl', 'wxListCtrl',
'TablePrint',
]), ]),
('Windows', ['wxFrame', 'wxDialog', 'wxMiniFrame', ('Windows', ['wxFrame', 'wxDialog', 'wxMiniFrame',
'',
'wxGrid', 'wxSashWindow', 'wxGrid', 'wxSashWindow',
'wxScrolledWindow', 'wxSplitterWindow', 'wxScrolledWindow', 'wxSplitterWindow',
'wxStatusBar', 'wxNotebook', 'wxStatusBar', 'wxNotebook',
@@ -64,7 +64,7 @@ _treeList = [
'wxCalendar', 'wxMVCTree', 'wxVTKRenderWindow', 'wxCalendar', 'wxMVCTree', 'wxVTKRenderWindow',
'FileBrowseButton', 'GenericButtons', 'wxEditor', 'FileBrowseButton', 'GenericButtons', 'wxEditor',
'ColourSelect', 'ImageBrowser', 'ColourSelect', 'ImageBrowser',
'infoframe', 'ColourDB', 'PyCrust', 'infoframe', 'ColourDB', 'PyCrust', 'TablePrint',
]), ]),
('Cool Contribs', ['pyTree', 'hangman', 'SlashDot', 'XMLtreeview']), ('Cool Contribs', ['pyTree', 'hangman', 'SlashDot', 'XMLtreeview']),

207
wxPython/demo/TablePrint.py Normal file
View File

@@ -0,0 +1,207 @@
from wxPython.wx import *
from wxPython.lib.printout import PrintTable
import os
#---------------------------------------------------------------------------
buttonDefs = {
814 : ('PreviewWide', 'Preview print of a wide table'),
815 : ('PreviewNarrow', 'Preview print of a narrow table with color highlights'),
818 : ('OnPreviewMatrix', 'Preview print of a narrow column grid without a table header'),
817 : ('PreviewLine', 'Preview print to demonstrate the use of line breaks'),
819 : ('PrintWide', 'Direct print (no preview) of a wide table'),
}
class TablePanel(wxPanel):
def __init__(self, parent, log, frame):
wxPanel.__init__(self, parent, -1)
self.log = log
self.frame = frame
box = wxBoxSizer(wxVERTICAL)
box.Add(20, 30)
keys = buttonDefs.keys()
keys.sort()
for k in keys:
text = buttonDefs[k][1]
btn = wxButton(self, k, text)
box.Add(btn, 0, wxALIGN_CENTER|wxALL, 15)
EVT_BUTTON(self, k, self.OnButton)
self.SetAutoLayout(true)
self.SetSizer(box)
def OnButton(self, evt):
funct = buttonDefs[evt.GetId()][0]
code = 'self.' + funct + '()'
eval(code)
def ReadData(self):
test_file = "TestTable.txt"
print "**** ", os.getcwd()
file = open(test_file,'r',1)
i = 0
data = []
while 1:
text = file.readline()
text = string.strip(text)
if not text:
break
list_val = string.splitfields(text,'\t')
data.append(list_val)
file.close()
self.header = data[0]
self.data = data[1:]
def PreviewWide(self):
self.ReadData()
prt = PrintTable(self.frame)
prt.data = self.data
prt.left_margin = 0.5
prt.set_column = [1.0, 1.0, 1.0, 1.5, 1.0, 3.0]
prt.label = self.header
prt.SetLandscape()
prt.SetColumnLineSize(2, 3)
prt.SetColumnLineColour(3, wxNamedColour('RED'))
prt.SetRowLineSize(1, 3)
prt.SetRowLineColour(5, wxNamedColour('RED'))
prt.SetHeader("wxWindows Applications")
prt.SetFooter()
prt.Preview()
def PreviewNarrow(self):
self.ReadData()
new_data = []
for val in self.data:
new_data.append([val[0], val[1], val[2], val[4], val[5]])
val = self.header
new_header = [val[0], val[1], val[2], val[4], val[5]]
prt = PrintTable(self.frame)
prt.data = new_data
prt.set_column = [ 1, 1, 1, 1, 2]
prt.label = new_header
prt.SetColAlignment(1, wxALIGN_CENTRE)
prt.SetColBackgroundColour(0, wxNamedColour('RED'))
prt.SetColTextColour(0, wxNamedColour('WHITE'))
prt.SetCellColour(4, 0, wxNamedColour('LIGHT BLUE'))
prt.SetCellColour(4, 1, wxNamedColour('LIGHT BLUE'))
prt.SetCellColour(17, 1, wxNamedColour('LIGHT BLUE'))
prt.SetColBackgroundColour(2, wxNamedColour('LIGHT BLUE'))
prt.SetCellText(4, 2, wxNamedColour('RED'))
prt.SetColTextColour(3, wxNamedColour('RED'))
prt.label_font_colour = wxNamedColour('WHITE')
prt.SetHeader("wxWindows Applications", colour = wxNamedColour('RED'))
prt.SetHeader("Date", align=wxALIGN_RIGHT, indent = -2, colour = wxNamedColour('BLUE'))
prt.SetFooter("Page No", colour = wxNamedColour('RED'), type ="Num")
prt.Preview()
def OnPreviewMatrix(self):
total_col = 45
total_row = 10
hsize = 0.2
vsize = 0.2
data = []
startx = 1.0
columns = []
for val in range(total_col):
columns.append(hsize)
prt = PrintTable(self.frame)
for row in range(total_row):
value = []
for col in range(total_col):
value.append(str(col))
data.append(value)
for col in range(total_col):
prt.SetColAlignment(col, wxALIGN_CENTRE)
prt.SetLandscape()
prt.text_font_size = 8
prt.cell_left_margin = 0
prt.data = data
prt.set_column = columns
prt.SetHeader("Test of Small Grid Size")
prt.Preview()
def PreviewLine(self):
prt = PrintTable(self.frame)
prt.label = ["Header 1", "Header 2", "Header 3"]
prt.set_column = []
prt.data = [["Row 1", "1", "2"], ["Row 2", "3", "4\nNew Line to see if it also can wrap around the cell region properly\nAnother new line"]]
prt.SetFooter()
prt.Preview()
def PrintWide(self):
self.ReadData()
prt = PrintTable(self.frame)
prt.data = self.data
prt.left_margin = 0.5
prt.set_columns = [ 1, 1, 1, 1, 2, 1, 3 ]
prt.label = self.header
prt.SetLandscape()
prt.Print()
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TablePanel(nb, log, frame)
return win
#---------------------------------------------------------------------------
import os
import wxPython.lib.printout
overview = """\
<html><body>
<h2>Table Printing</h2>
This demo shows various ways of using the <b><i>new
</i></b> PrintOut class. To understand the class you need to examine the demo examples
and the library <a href="%s">printout.py</a> module classes.
<p>
The initial class primarily contains a Table preview/printing class. There is alot of flexibility
in manipulating the placement, sizing, colours, alignment of the table text and cell background colors.
There are also a number of options for printing Header and Footer information on the page.
<p>
There is also a class to extract the parameters from a wxGrid and easily recreate a Table printout.
<p>
The data is printed from a list object containing the column and row values. The label or table header
can be defined and will be repeated for all pages.
<p>
The correct "Total Page" does get calculated and used in the print out Footer.
<p>
There is still problems with the print framework to properly get the total pages in the preview unless
the program knows it before trying to parse through the available pages. This will be fixed
when the framework allows for it.
""" % os.path.join(os.path.dirname(wxPython.lib.printout.__file__), "printout.py")

View File

@@ -0,0 +1,38 @@
Name Type Platform Location Availability Description
WebReuser Development Windows 95, Windows NT, HPUX 9.05 and 10.2, Solaris 2.4 and 2.5 http://www.stablesoft.com Evaluation WebReuser is a re-use tool from Hitachi Europe Limited. WebReuser is a tool that simplifies software reuse. Its ability to track, schematize and search documents makes it the ideal way to understand C++ code. These features also make WebReuser an ideal tool to classify any Web resource. WebReuser can even be used for more general documentation management tasks.
MacAnova Development Windows, Motif, Mac http://www.stat.umn.edu/~gary/macanova/macanova.home.html Free A large statistical application from the School of Statistics, University of Minnesota. It is based on a modified version of wxWindows 1.65.
Hardy Development Win 3.1, WIN32, Motif (Sun only) http://www.aiai.ed.ac.uk/~hardy/ Freeware for personal and academic use A hypertext-based diagramming and knowledge-based system development tool, with NASA's CLIPS built-in. It is a superset of wxCLIPS.
wxCLIPS Development Win 3.1, WIN32, Motif, XView http://web.ukonline.co.uk/julian.smart/wxclips Freeware A GUI development environment for CLIPS applications.
wxPython Development wxWindows 2 for the new version http://alldunn.com/wxPython/ Freeware Python/wxWindows combination by Robin Dunn and Harri Pasanen. Python is an elegant object-oriented, interpreted language that runs on many platforms.
MrEd Development Win 3.1, WIN32, Motif, XView http://www.cs.rice.edu/CS/PLT/packages/mred/ Freeware MrEd is a combined editor and Scheme development environment by Matthew Flatt.
WXLisp Development Win 3.1, WIN32, Motif, XView http://www.cadlab.de/~lipuser/wxlisp/wxlisp.html Freeware A combination of wxWindows and XLisp.
Scriptum Development Motif http://www.isoft.com.ar/eng/products/system/scriptum.html Freeware Graphical editor with visual highlighting, navigation/browsing, undo, class browser for C++ and Java, source code management, file locking, remote editing using ftp, configurable.
WipeOut Development XView/Linux http://www.softwarebuero.de/wipeout-eng.html Giftware WipeOut is an integrated development environment for C++ projects, available for Linux/XView. The authors are working on versions for SunOS/Solaris. Source is available for porting to other platforms.
OPL Development Win 3.1, WIN32, Motif, XView http://www.ozemail.com.au/~adavison/ Freeware Object Prolog is a portable implementation of Prolog by Andrew Davison, with object-oriented extensions, entirely written in C++. In the initial version, a binding to wxWindows is available. In the revamped version, this binding has not been written yet.
Dataplore Graphics and sound Windows, other? http://www.datan.de/dataplore Commercial Data visualisation tool, from Datan
VCG Tool Graphics and sound Win 3.1, WIN32, Motif, XView http://www.cs.uni-sb.de:80/RW/users/sander/html/gsvcg1.html Freeware A graph layout tool similar to GraphPlace, but with extensions. Very nice indeed!
Y.E.S. Graphics and sound Win 3.1, WIN32, XView (Linux) ftp://ftp.musik.uni-essen.de/pub/EsAC/program/ Shareware Monophonic notation program.
JAZZ Graphics and sound XView (Linux) http://rokke.aug.hiagder.no/per/jazz.html Freeware A MIDI sequencer for Linux.
ISP Graphics and sound Win 3.1, WIN32, Motif, XView ftp://www.remstar.com/pub/wxwin/contrib/isp-100/ Freeware Image and sound player educational tool.
ClockWorks Graphics and sound Win 3.1, WIN32, Motif, XView http://web.ukonline.co.uk/Members/julian.smart/freesoft.html#clockworks Freeware A configurable analogue clock, with a collection of 'fine art' faces. By Julian Smart.
M Miscellaneous Windows 95, Windows NT, Linux http://www.phy.hw.ac.uk/~karsten/M/index.html GPL M is a cross-platform e-mail application. It will be available for X11/Unix and Windows platforms, supporting a wide range of e-mail transfer protocols as well as including full MIME support. M's wealth of features and ease of use make it one of the most powerful MUAs available, providing a consistent and intuitive interface across all platforms.
Boolean Miscellaneous Windows 95, Windows NT, Solaris http://www.xs4all.nl/~kholwerd/bool.html Freeware A GDSII CAD file format viewer, and program to perform boolean operations on sets of 2D polygons. By Klaas Holwerda.
TimeMan Miscellaneous wxGTK, Unix http://www.bgif.no/neureka/TimeMan/ Freeware A time manager, written using wxGTK
Forty Thieves Miscellaneous Motif, Windows apps/forty/forty.htm Freeware A fiendish patience game, by Chris Breeze. A nice demo of what's possible with wxWindows.
Lean Integration Platform Miscellaneous Windows NT, various flavours of UNIX http://www.c-lab.de/~lipuser/lip To be decided LIP is a workflow-oriented tool integration system which uses wxLisp (and thus wxWindows) as an implementation basis. Lisp combined with the wxWindows bindings make up the compatible extension language platform of the system.
wxWeb Miscellaneous Win 3.1, WIN32, Motif ftp://www.remstar.com/pub/wxwin/contrib/wxweb Freeware Andrew Davison's Web browser, with SimSock portable socket library and wxHtml canvas. Includes an http server for UNIX and Windows.
SANTIS Miscellaneous Win 3.1, Windows 95, Linux, Solaris OpenLook and Motif, Silicon Graphics http://www.physiology.rwth-aachen.de/bs/santis/ Free for non-commercial use SANTIS is a software tool designed for the analysis of signals and time series data of any kind, in particular for scientific purposes. It was developed at the Laboratory of Biomedical Systems Analysis, Institute of Physiology at the University of Aachen, Germany.
Xbaies Miscellaneous Win 3.1, WIN32, Motif, XView xbaies.htm Freeware A shell for building Bayesian network models, by Robert Cowell.
wxTinyBB Miscellaneous Win 3.1, WIN32, Motif, XView ftp://www.remstar.com/pub/wxwin/contrib/wxtinybb Freeware/commercial A tiny blackboard shell demo showing an embedded (commercial) Prolog engine. Demo written by Arvindra Sehmi. A good example of a nice interface using wxWindows.
Gambit Miscellaneous Win 3.1, WIN32, Motif, XView http://www.hss.caltech.edu/~gambit/Gambit.html Freeware A large wxWindows application with source, and features such as a table control with printing.
Tex2RTF Miscellaneous Win 3.1, WIN32, Motif, XView http://web.ukonline.co.uk/julian.smart/tex2rtf Freeware Converts subset of LaTeX syntax to WinHelp, wordprocessor RTF, HTML, and wxHelp. As used for wxWindows documentation.
wxPoem Miscellaneous Win 3.1, WIN32, Motif, XView none.htm Freeware A poetry display program for wxWindows. Included as a sample in the wxWindows distribution.
Sonar tracking software Miscellaneous See Web site http://www.desertstar.com Demonstration Miscellaneous sonar tracking software from Desert Star Systems, who use wxWindows for all their Windows-based software.
Name Research software Platform Location Availability Description
DisCo Research software N/A http://www.cs.tut.fi/laitos/DisCo/tool.fm.html N/A A tool for specification of reactive systems.
CAFE Research software N/A cafe.htm N/A Cellular Analysis of Fire and Extinction
CODA Research software See Web site http://www.ozemail.com.au/~mbedward/coda/coda.html See Web site CODA assists in the design of networks of nature reserves or protected areas. It has been used for major reserve planning studies, as a teaching resource and for research into conservation planning methods.<2E>
EGRESS Research software N/A http://www.aiai.ed.ac.uk/~jimd/Egress2/projInfo_contents.html N/A An evacuation decision model.
ACT Research software N/A none.htm N/A A general process and tracker and automator being built at NASA.
Rectangular nesting program Research software N/A http://www.elec-eng.leeds.ac.uk/een5mpd/research.html N/A Optimized layout of rectangles on a page.
Finite element post processor Research software N/A http://www.ime.auc.dk/afd3/odessy/manuals/index.htm N/A Finite element postprocessor, produced at Aalborg University in Denmark by John Rasmussen and Erik Lund.

View File

@@ -29,7 +29,7 @@ day_abbr = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', ]
def leapdays(y1, y2): def leapdays(y1, y2):
return (y2+3)/4 - (y1+3)/4 return (y2+3)/4 - (y1+3)/4
# Return 1 for leap years, 0 for non-leap years # Return 1 for leap years, 0 for non-leap years
def isleap(year): def isleap(year):
return year % 4 == 0 and (year % 100 <> 0 or year % 400 == 0) return year % 4 == 0 and (year % 100 <> 0 or year % 400 == 0)
@@ -40,7 +40,7 @@ def FillDate(val):
s = '0' + s s = '0' + s
return s return s
def julianDay(year, month, day): def julianDay(year, month, day):
b = 0L b = 0L
year, month, day = long(year), long(month), long(day) year, month, day = long(year), long(month), long(day)
@@ -62,7 +62,7 @@ def julianDay(year, month, day):
b = 2L - year/100L + year/400L b = 2L - year/100L + year/400L
return (1461L*year - yearCorr)/4L + 306001L*(month + 1L)/10000L + day + 1720994L + b return (1461L*year - yearCorr)/4L + 306001L*(month + 1L)/10000L + day + 1720994L + b
def TodayDay(): def TodayDay():
date = time.localtime(time.time()) date = time.localtime(time.time())
year = date[0] year = date[0]
@@ -109,14 +109,14 @@ def daysPerMonth(month, year):
return ndays return ndays
class now: class now:
def __init__(self): def __init__(self):
self.date = time.localtime(time.time()) self.date = time.localtime(time.time())
self.year = self.date[0] self.year = self.date[0]
self.month = self.date[1] self.month = self.date[1]
self.day = self.date[2] self.day = self.date[2]
class Date: class Date:
def __init__(self, year, month, day): def __init__(self, year, month, day):
self.julian = julianDay(year, month, day) self.julian = julianDay(year, month, day)
self.month = month self.month = month
self.year = year self.year = year

View File

@@ -366,7 +366,6 @@ class wxGenBitmapButton(wxGenButton):
return -1, -1, false return -1, -1, false
return self.bmpLabel.GetWidth()+2, self.bmpLabel.GetHeight()+2, false return self.bmpLabel.GetWidth()+2, self.bmpLabel.GetHeight()+2, false
def DrawLabel(self, dc, width, height, dw=0, dy=0): def DrawLabel(self, dc, width, height, dw=0, dy=0):
bmp = self.bmpLabel bmp = self.bmpLabel
if self.bmpDisabled and not self.IsEnabled(): if self.bmpDisabled and not self.IsEnabled():
@@ -384,6 +383,7 @@ class wxGenBitmapButton(wxGenButton):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
class wxGenBitmapTextButton(wxGenBitmapButton): # generic bitmapped button with Text Label class wxGenBitmapTextButton(wxGenBitmapButton): # generic bitmapped button with Text Label
def __init__(self, parent, ID, bitmap, label, def __init__(self, parent, ID, bitmap, label,
pos = wxDefaultPosition, size = wxDefaultSize, pos = wxDefaultPosition, size = wxDefaultSize,
@@ -443,8 +443,10 @@ class wxGenBitmapTextButton(wxGenBitmapButton): # generic bitmapped button w
dc.DrawText(label, pos_x + dw+bw, (height-th)/2+dy) # draw the text dc.DrawText(label, pos_x + dw+bw, (height-th)/2+dy) # draw the text
#---------------------------------------------------------------------- #----------------------------------------------------------------------
class __ToggleMixin: class __ToggleMixin:
def SetToggle(self, flag): def SetToggle(self, flag):
self.up = not flag self.up = not flag
@@ -490,6 +492,7 @@ class wxGenBitmapToggleButton(__ToggleMixin, wxGenBitmapButton):
class wxGenBitmapTextToggleButton(__ToggleMixin, wxGenBitmapTextButton): class wxGenBitmapTextToggleButton(__ToggleMixin, wxGenBitmapTextButton):
pass pass
#---------------------------------------------------------------------- #----------------------------------------------------------------------

View File

@@ -5,8 +5,8 @@
# Author: Lorne White (email: lorne.white@telusplanet.net) # Author: Lorne White (email: lorne.white@telusplanet.net)
# #
# Created: # Created:
# Version 0.85 # Version 0.90
# Date: June 20, 2001 # Date: July 19, 2001
# Licence: wxWindows license # Licence: wxWindows license
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@@ -18,7 +18,7 @@ import string, time
CalDays = [6, 0, 1, 2, 3, 4, 5] CalDays = [6, 0, 1, 2, 3, 4, 5]
AbrWeekday = {6:"Sun", 0:"Mon", 1:"Tue", 2:"Wed", 3:"Thu", 4:"Fri", 5:"Sat"} AbrWeekday = {6:"Sun", 0:"Mon", 1:"Tue", 2:"Wed", 3:"Thu", 4:"Fri", 5:"Sat"}
_MIDSIZE = 160 _MIDSIZE = 180
BusCalDays = [0, 1, 2, 3, 4, 5, 6] BusCalDays = [0, 1, 2, 3, 4, 5, 6]
@@ -44,6 +44,19 @@ class CalDraw:
self.DefParms() self.DefParms()
def DefParms(self): def DefParms(self):
self.num_auto = TRUE # auto scale of the cal number day size
self.num_size = 12 # default size of calendar if no auto size
self.max_num_size = 12 # maximum size for calendar number
self.num_align_horz = wxALIGN_CENTRE # alignment of numbers
self.num_align_vert = wxALIGN_CENTRE
self.num_indent_horz = 0 # points indent from position, used to offset if not centered
self.num_indent_vert = 0
self.week_auto = TRUE # auto scale of week font text
self.week_size = 10
self.max_week_size = 12
self.grid_color = 'BLACK' # grid and selection colors self.grid_color = 'BLACK' # grid and selection colors
self.back_color = 'WHITE' self.back_color = 'WHITE'
self.sel_color = 'RED' self.sel_color = 'RED'
@@ -227,20 +240,29 @@ class CalDraw:
self.DC.DrawText(year, self.cx_st + adjust, self.cy_st + th) self.DC.DrawText(year, self.cx_st + adjust, self.cy_st + th)
def DrawWeek(self): # draw the week days def DrawWeek(self): # draw the week days
sizef = 8 width = self.gridx[1]-self.gridx[0]
if self.sizeh < _MIDSIZE: height = self.gridy[1] - self.gridy[0]
sizef = 7 rect_w = self.gridx[7]-self.gridx[0]
f = wxFont(10, self.font, wxNORMAL, self.bold) # initial font setting
if self.week_auto == TRUE:
test_size = self.max_week_size # max size
test_day = ' Sun '
while test_size > 2:
f.SetPointSize(test_size)
self.DC.SetFont(f)
tw,th = self.DC.GetTextExtent(test_day)
if tw < width and th < height:
break
test_size = test_size - 1
else:
f.SetPointSize(self.week_size) # set fixed size
self.DC.SetFont(f)
f = wxFont(sizef, self.font, wxNORMAL, self.bold)
self.DC.SetFont(f)
self.DC.SetTextForeground(wxNamedColour(self.week_font_color)) self.DC.SetTextForeground(wxNamedColour(self.week_font_color))
cnt_x = 0 cnt_x = 0
cnt_y = 0 cnt_y = 0
width = self.gridx[1]-self.gridx[0]
height = self.gridy[1] - self.gridy[0]
rect_w = self.gridx[7]-self.gridx[0]
brush = wxBrush(wxNamedColour(self.week_color), wxSOLID) brush = wxBrush(wxNamedColour(self.week_color), wxSOLID)
self.DC.SetBrush(brush) self.DC.SetBrush(brush)
@@ -265,12 +287,22 @@ class CalDraw:
self.DC.DrawText(day, x+diffx, y+diffy) self.DC.DrawText(day, x+diffx, y+diffy)
cnt_x = cnt_x + 1 cnt_x = cnt_x + 1
def DrawNum(self): # draw the day numbers def DrawNum(self): # draw the day numbers
sizef = 10 f = wxFont(10, self.font, wxNORMAL, self.bold) # initial font setting
if self.sizeh < _MIDSIZE: if self.num_auto == TRUE:
sizef = 8 test_size = self.max_num_size # max size
f = wxFont(sizef, self.font, wxNORMAL, self.bold) test_day = ' 99 '
while test_size > 2:
f.SetPointSize(test_size)
self.DC.SetFont(f)
tw,th = self.DC.GetTextExtent(test_day)
if tw < self.dl_w and th < self.dl_h:
sizef = test_size
break
test_size = test_size - 1
else:
f.SetPointSize(self.num_size) # set fixed size
self.DC.SetFont(f)
cnt_x = 0 cnt_x = 0
cnt_y = 1 cnt_y = 1
@@ -287,7 +319,26 @@ class CalDraw:
self.DC.SetTextForeground(wxNamedColour(num_color)) self.DC.SetTextForeground(wxNamedColour(num_color))
self.DC.SetFont(f) self.DC.SetFont(f)
self.DC.DrawText(val, x+5, y+5) tw,th = self.DC.GetTextExtent(val)
if self.num_align_horz == wxALIGN_CENTRE:
adj_h = (self.dl_w - tw)/2
elif self.num_align_horz == wxALIGN_RIGHT:
adj_h = self.dl_w - tw
else:
adj_h = 0 # left alignment
adj_h = adj_h + self.num_indent_horz
if self.num_align_vert == wxALIGN_CENTRE:
adj_v = (self.dl_h - th)/2
elif self.num_align_horz == wxALIGN_RIGHT:
adj_v = self.dl_h - th
else:
adj_v = 0 # left alignment
adj_v = adj_v + self.num_indent_vert
self.DC.DrawText(val, x+adj_h, y+adj_v)
if cnt_x < 6: if cnt_x < 6:
cnt_x = cnt_x + 1 cnt_x = cnt_x + 1
else: else:
@@ -425,6 +476,8 @@ class wxCalendar(wxWindow):
def OnLeftEvent(self, event): def OnLeftEvent(self, event):
self.click = 'LEFT' self.click = 'LEFT'
self.shiftkey = event.ShiftDown()
self.ctrlkey = event.ControlDown()
self.ProcessClick(event) self.ProcessClick(event)
def OnLeftDEvent(self, event): def OnLeftDEvent(self, event):
@@ -524,6 +577,8 @@ class wxCalendar(wxWindow):
else: else:
evt = wxPyCommandEvent(2100, self.GetId()) evt = wxPyCommandEvent(2100, self.GetId())
evt.click, evt.day, evt.month, evt.year = self.click, self.day, self.month, self.year evt.click, evt.day, evt.month, evt.year = self.click, self.day, self.month, self.year
evt.shiftkey = self.shiftkey
evt.ctrlkey = self.ctrlkey
self.GetEventHandler().ProcessEvent(evt) self.GetEventHandler().ProcessEvent(evt)
self.set_day = self.day self.set_day = self.day

View File

@@ -17,30 +17,37 @@ from wxPython.wx import *
# GetColour method to get the selected colour # GetColour method to get the selected colour
class ColourSelect(wxButton): class ColourSelect(wxButton):
def __init__(self, parent, id, bcolour=(0, 0, 0), pos=wxDefaultPosition, size=wxDefaultSize): def __init__(self, parent, position = wxPoint(20, 20), bcolour = [0, 0, 0], size = wxSize(20, 20)):
wxButton.__init__(self, parent, id, "", pos=pos, size=size) self.win = parent
EVT_BUTTON(parent, self.GetId(), self.OnClick)
self.SetForegroundColour(wxWHITE)
self.SetColour(bcolour)
mID = NewId()
self.b = b = wxButton(parent, mID, "", position, size)
EVT_BUTTON(parent, mID, self.OnClick)
def SetColour(self, bcolour):
self.set_colour_val = set_colour = wxColor(bcolour[0], bcolour[1], bcolour[2]) self.set_colour_val = set_colour = wxColor(bcolour[0], bcolour[1], bcolour[2])
self.SetBackgroundColour(set_colour) b.SetBackgroundColour(set_colour)
b.SetForegroundColour(wxWHITE)
self.set_colour = bcolour self.set_colour = bcolour
def SetColour(self, bcolour):
self.b.SetBackgroundColour(bcolour)
def GetColour(self): def GetColour(self):
return self.set_colour return self.set_colour
def OnClick(self, event): def OnClick(self, event):
data = wxColourData() data = wxColourData()
data.SetChooseFull(true) data.SetChooseFull(true)
data.SetColour(self.set_colour_val) data.SetColour(self.set_colour_val)
dlg = wxColourDialog(self.GetParent(), data) dlg = wxColourDialog(self.win, data)
if dlg.ShowModal() == wxID_OK: if dlg.ShowModal() == wxID_OK:
data = dlg.GetColourData() data = dlg.GetColourData()
self.SetColour(data.GetColour().Get()) self.set_colour = set = data.GetColour().Get()
self.set_colour_val = bcolour = wxColour(set[0],set[1],set[2])
self.b.SetBackgroundColour(bcolour)
dlg.Destroy() dlg.Destroy()

View File

@@ -5,8 +5,8 @@
# #
# Author: Lorne White # Author: Lorne White
# #
# Version: 0.6 # Version: 0.9
# Date: March 27, 2001 # Date: August 15, 2001
# Licence: wxWindows license # Licence: wxWindows license
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@@ -17,6 +17,9 @@ dir_path = os.getcwd()
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
def ConvertBMP(file_nm): def ConvertBMP(file_nm):
if file_nm is None:
return None
fl_fld = os.path.splitext(file_nm) fl_fld = os.path.splitext(file_nm)
ext = fl_fld[1] ext = fl_fld[1]
ext = string.lower(ext[1:]) ext = string.lower(ext[1:])
@@ -33,27 +36,62 @@ def ConvertBMP(file_nm):
return image return image
class ImageView: def GetSize(file_nm): # for scaling image values
def __init__(self, iparent, ipos, isize): image = ConvertBMP(file_nm)
self.win = iparent bmp = image.ConvertToBitmap()
self.ImagePanel = wxPanel(size = isize, parent = iparent, id = -1, name = 'backgroundPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN, pos= ipos) size = bmp.GetWidth(), bmp.GetHeight()
self.clear = wxColour(255, 255, 255) return size
self.ImagePanel.SetBackgroundColour(self.clear) # clear the panel
self.image_sizex = isize.width class ImageView(wxWindow):
self.image_sizey = isize.height def __init__(self, parent, id=-1, pos=wxDefaultPosition, size=wxDefaultSize):
self.image_posx = ipos.x wxWindow.__init__(self, parent, id, pos, size)
self.image_posy = ipos.y self.win = parent
self.image = None
self.back_color = 'WHITE'
self.border_color = 'BLACK'
self.image_sizex = size.width
self.image_sizey = size.height
self.image_posx = pos.x
self.image_posy = pos.y
EVT_PAINT(self, self.OnPaint)
wxInitAllImageHandlers() wxInitAllImageHandlers()
def OnPaint(self, event):
dc = wxPaintDC(self)
self.DrawImage(dc)
def DrawImage(self, dc):
dc.BeginDrawing()
self.DrawImage(dc)
dc.EndDrawing()
def SetValue(self, file_nm): # display the selected file in the panel def SetValue(self, file_nm): # display the selected file in the panel
image = ConvertBMP(file_nm).ConvertToBitmap() image = ConvertBMP(file_nm)
if image is None: self.image = image
self.Refresh()
def DrawBorder(self, dc):
brush = wxBrush(wxNamedColour(self.back_color), wxSOLID)
dc.SetBrush(brush)
dc.SetPen(wxPen(wxNamedColour(self.border_color), 1))
dc.DrawRectangle(0, 0, self.image_sizex, self.image_sizey)
def DrawImage(self, dc):
try:
image = self.image
except:
return return
iwidth = image.GetWidth() # dimensions of image file self.DrawBorder(dc)
iheight = image.GetHeight() if image is None:
return
bmp = image.ConvertToBitmap()
iwidth = bmp.GetWidth() # dimensions of image file
iheight = bmp.GetHeight()
diffx = (self.image_sizex - iwidth)/2 # center calc diffx = (self.image_sizex - iwidth)/2 # center calc
if iwidth >= self.image_sizex -10: # if image width fits in window adjust if iwidth >= self.image_sizex -10: # if image width fits in window adjust
@@ -64,13 +102,12 @@ class ImageView:
if iheight >= self.image_sizey - 10: # if image height fits in window adjust if iheight >= self.image_sizey - 10: # if image height fits in window adjust
diffy = 5 diffy = 5
iheight = self.image_sizey - 10 iheight = self.image_sizey - 10
self.ClearPanel()
wxStaticBitmap(self.win, -1, image, wxPoint(self.image_posx+diffx, self.image_posy+diffy), wxSize(iwidth, iheight ))
def ClearPanel(self): # clear the image panel image.Rescale(iwidth, iheight) # rescale to fit the window
self.ImagePanel.SetBackgroundColour(self.clear) image.ConvertToBitmap()
self.ImagePanel.Refresh() bmp = image.ConvertToBitmap()
dc.DrawBitmap(bmp, diffx, diffy) # draw the image to window
class ImageDialog(wxDialog): class ImageDialog(wxDialog):
def __init__(self, parent, set_dir = None): def __init__(self, parent, set_dir = None):
@@ -128,7 +165,7 @@ class ImageDialog(wxDialog):
self.sel_type = wxComboBox(self, mID, self.set_type, wxPoint(image_posx , self.type_posy), wxSize(150, -1), self.fl_types, wxCB_DROPDOWN) self.sel_type = wxComboBox(self, mID, self.set_type, wxPoint(image_posx , self.type_posy), wxSize(150, -1), self.fl_types, wxCB_DROPDOWN)
EVT_COMBOBOX(self, mID, self.OnSetType) EVT_COMBOBOX(self, mID, self.OnSetType)
self.image_view = ImageView(self, wxPoint(image_posx, image_posy), wxSize(image_sizex, image_sizey)) self.image_view = ImageView(self, pos=wxPoint(image_posx, image_posy), size=wxSize(image_sizex, image_sizey))
self.y_pos = self.y_pos + height + 20 self.y_pos = self.y_pos + height + 20
@@ -177,7 +214,6 @@ class ImageDialog(wxDialog):
dlg.Destroy() dlg.Destroy()
def ResetFiles(self): # refresh the display with files and initial image def ResetFiles(self): # refresh the display with files and initial image
self.image_view.ClearPanel()
self.DisplayDir() self.DisplayDir()
self.GetFiles() self.GetFiles()
self.tb.Set(self.fl_list) self.tb.Set(self.fl_list)
@@ -185,10 +221,13 @@ class ImageDialog(wxDialog):
self.tb.SetSelection(0) self.tb.SetSelection(0)
self.SetListValue(0) self.SetListValue(0)
except: except:
pass self.image_view.SetValue(None)
def GetFile(self): def GetFile(self):
return self.set_file return self.set_file
def GetDirectory(self):
return self.set_dir
def OnCancel(self, event): def OnCancel(self, event):
self.result = None self.result = None

File diff suppressed because it is too large Load Diff