X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/49875c533ba56fd78c26fc9862ec3e84c66dfb74..b9ac87bc5cbe46227195e32c44e25831f8206e3c:/wxPython/demo/wxCalendar.py diff --git a/wxPython/demo/wxCalendar.py b/wxPython/demo/wxCalendar.py index 05bfe10e94..5c14011608 100644 --- a/wxPython/demo/wxCalendar.py +++ b/wxPython/demo/wxCalendar.py @@ -4,7 +4,7 @@ # # Author: Lorne White (email: lwhite1@planet.eon.net) # -# Version 0.9 +# Version 0.9 # Date: Feb 26, 2001 # Licence: wxWindows license #---------------------------------------------------------------------------- @@ -12,8 +12,8 @@ from wxPython.wx import * from wxPython.lib.calendar import wxCalendar, Month, PrtCalDraw, CalenDlg +import images import os -dir_path = os.getcwd() # highlighted days in month @@ -62,7 +62,10 @@ class TestPanel(wxPanel): monthlist = GetMonthList() mID = NewId() - self.date = wxComboBox(self, mID, Month[start_month], wxPoint(100, 20), wxSize(90, -1), monthlist, wxCB_DROPDOWN) + self.date = wxComboBox(self, mID, "", + wxPoint(100, 20), wxSize(90, -1), + monthlist, wxCB_DROPDOWN) + self.date.SetSelection(start_month-1) EVT_COMBOBOX(self, mID, self.EvtComboBox) # set start month and year @@ -72,7 +75,7 @@ class TestPanel(wxPanel): # set attributes of calendar - self.calend.hide_title = TRUE + self.calend.hide_title = True self.calend.HideGrid() self.calend.SetWeekColor('WHITE', 'BLACK') @@ -88,7 +91,7 @@ class TestPanel(wxPanel): mID = NewId() self.scroll = wxScrollBar(self, mID, wxPoint(100, 240), wxSize(200, 20), wxSB_HORIZONTAL) - self.scroll.SetScrollbar(start_month-1, 1, 12, 1, TRUE) + self.scroll.SetScrollbar(start_month-1, 1, 12, 1, True) EVT_COMMAND_SCROLL(self, mID, self.Scroll) # spin control for year selection @@ -107,7 +110,7 @@ class TestPanel(wxPanel): wxStaticText(self, -1, "Test Calendar Dialog", wxPoint(350, 50), wxSize(150, -1)) mID = NewId() - bmp = wxBitmap('bitmaps/Calend.bmp', wxBITMAP_TYPE_BMP) + bmp = images.getCalendarBitmap() self.but = wxBitmapButton(self, mID, bmp, wxPoint(380, 80))#, wxSize(30, 30)) EVT_BUTTON(self, mID, self.TestDlg) @@ -116,14 +119,12 @@ class TestPanel(wxPanel): wxStaticText(self, -1, "Test Calendar Window", wxPoint(350, 150), wxSize(150, -1)) mID = NewId() - bmp = wxBitmap('bitmaps/Calend.bmp', wxBITMAP_TYPE_BMP) self.but = wxBitmapButton(self, mID, bmp, wxPoint(380, 180))#, wxSize(30, 30)) EVT_BUTTON(self, mID, self.TestFrame) wxStaticText(self, -1, "Test Calendar Print", wxPoint(350, 250), wxSize(150, -1)) mID = NewId() - bmp = wxBitmap('bitmaps/Calend.bmp', wxBITMAP_TYPE_BMP) self.but = wxBitmapButton(self, mID, bmp, wxPoint(380, 280))#, wxSize(30, 30)) EVT_BUTTON(self, mID, self.OnPreview) @@ -146,8 +147,8 @@ class TestPanel(wxPanel): def TestFrame(self, event): frame = CalendFrame(self, -1, "Test Calendar", self.log) - frame.Show(true) - return true + frame.Show(True) + return True # calendar print preview @@ -170,7 +171,7 @@ class TestPanel(wxPanel): name = event.GetString() self.log.WriteText('EvtComboBox: %s\n' % name) monthval = self.date.FindString(name) - self.scroll.SetScrollbar(monthval, 1, 12, 1, TRUE) + self.scroll.SetScrollbar(monthval, 1, 12, 1, True) self.calend.SetMonth(monthval+1) self.ResetDisplay() @@ -231,7 +232,8 @@ class TestPanel(wxPanel): class CalendFrame(wxFrame): def __init__(self, parent, id, title, log): - wxFrame.__init__(self, parent, id, title, wxPyDefaultPosition, wxSize(400, 400)) + wxFrame.__init__(self, parent, id, title, size=wxSize(400, 400), + style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE) EVT_CLOSE(self, self.OnCloseWindow) self.log = log @@ -316,26 +318,24 @@ class CalendFrame(wxFrame): def MakeToolMenu(self): tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER) - bmp_path = 'bitmaps/' - mID = NewId() - SetToolPath(self, tb, mID, bmp_path + 'DbDec.bmp', 'Dec Year') + SetToolPath(self, tb, mID, images.getDbDecBitmap(), 'Dec Year') EVT_TOOL(self, mID, self.OnDecYear) mID = NewId() - SetToolPath(self, tb, mID, bmp_path + 'Dec.bmp', 'Dec Month') + SetToolPath(self, tb, mID, images.getDecBitmap(), 'Dec Month') EVT_TOOL(self, mID, self.OnDecMonth) mID = NewId() - SetToolPath(self, tb, mID, bmp_path + 'Pt.bmp', 'Current Month') + SetToolPath(self, tb, mID, images.getPtBitmap(), 'Current Month') EVT_TOOL(self, mID, self.OnCurrent) mID = NewId() - SetToolPath(self, tb, mID, bmp_path + 'Inc.bmp', 'Inc Month') + SetToolPath(self, tb, mID, images.getIncBitmap(), 'Inc Month') EVT_TOOL(self, mID, self.OnIncMonth) mID = NewId() - SetToolPath(self, tb, mID, bmp_path + 'DbInc.bmp', 'Inc Year') + SetToolPath(self, tb, mID, images.getDbIncBitmap(), 'Inc Year') EVT_TOOL(self, mID, self.OnIncYear) tb.Realize() @@ -366,8 +366,8 @@ class PrintCalend: self.sel_lst = [] # highlighted selected days self.size = None - self.hide_title = FALSE - self.hide_grid = FALSE + self.hide_title = False + self.hide_grid = False self.set_day = None def SetParms(self): @@ -416,14 +416,14 @@ class PrintCalend: frame.Initialize() frame.SetPosition(self.frame.GetPosition()) frame.SetSize(self.frame.GetSize()) - frame.Show(true) + frame.Show(True) def Print(self): pdd = wxPrintDialogData() pdd.SetPrintData(self.printData) printer = wxPrinter(pdd) printout = SetPrintout(self) - frame = wxFrame(NULL, -1, "Test") + frame = wxFrame(None, -1, "Test") if not printer.Print(frame, printout): wxMessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wxOK) else: @@ -438,7 +438,7 @@ class PrintCalend: if self.preview is None: cal.SetPSize(size[0]/self.pagew, size[1]/self.pageh) - cal.SetPreview(FALSE) + cal.SetPreview(False) else: if self.preview == 1: @@ -454,7 +454,7 @@ class PrintCalend: cal.grid_color = self.grid_color cal.high_color = self.high_color cal.back_color = self.back_color - cal.outer_border = FALSE + cal.outer_border = False cal.font = self.font cal.bold = self.bold @@ -518,9 +518,7 @@ class PrintCalend: self.ptheight = height def SetToolPath(self, tb, id, bmp, title): - global dir_path - tb.AddSimpleTool(id, wxBitmap(os.path.join(dir_path, bmp), wxBITMAP_TYPE_BMP), - title, title) + tb.AddSimpleTool(id, bmp, title, title) class SetPrintout(wxPrintout): def __init__(self, canvas): @@ -536,9 +534,9 @@ class SetPrintout(wxPrintout): def HasPage(self, page): if page <= self.end_pg: - return true + return True else: - return false + return False def GetPageInfo(self): self.end_pg = self.canvas.GetTotalPages() @@ -596,14 +594,14 @@ class SetPrintout(wxPrintout): self.canvas.SetPageSize(self.psizew, self.psizeh) self.canvas.DoDrawing(dc) - return true + return True class MyApp(wxApp): def OnInit(self): - frame = CalendFrame(NULL, -1, "Test Calendar") - frame.Show(true) + frame = CalendFrame(None, -1, "Test Calendar") + frame.Show(True) self.SetTopWindow(frame) - return true + return True #---------------------------------------------------------------------------