Custom calendar :: refresh problem

Patrick J. Anderson pat.j.anderson at gmail.com
Sat Nov 3 18:45:56 PDT 2007


On Sat, 03 Nov 2007 16:30:46 -0700, Robin Dunn wrote:

> Patrick J. Anderson wrote:
>> I'm trying to build a custom planner and being new to wxPython and
>> desktop programming in general, I'm still learning how to do things.
>> 
>> Below is a little test I wrote. Its a frame with a splitter window. On
>> the left there is a calendar control which I use to change dates and on
>> the right, I have a notebook with 3 pages: 'Day', 'Week', 'Month',
>> which correspond to the date selected in the calendar on the left.
>> 
>> I have created the daily, weekly and monthly views of the planner with
>> a wx.FlexGridSizer and mostly wx.Panels.
>> 
>> I decided to recreate the properties and layout of each notebook page.
>> I'm not sure if this is the right approach to building such widgets, as
>> for example the CalendarCtrl is drawn on the screen and not combined
>> from individual panels, but this is just a prototype.
>> 
>> However, as you may notice if you run it, I notice that the notebook
>> pages flicker and quite often I see a small panel in the top left
>> corner, which I believed shows when I loop through the days to create
>> the display.
>> 
>> Any way this could be avoided and the transition made smoother?
> 
> It looks like you are creating a new set of widgets when you change
> dates.  You really don't want to do that, you'll eventually run out of
> resources.  Instead just change the values displayed by the existing
> widgets.  Also you may want to rethink how you are creating a separate
> panel for every rectangle in the planners.  It would probably be better
> to just have a single panel and draw the rectangles and the text
> yourself in the panel's EVT_PAINT handler.

Thanks, Robin. I noticed that my prototype had some issues, due to my 
rather fresh and less-informed approach. I'll look into drawing on the 
panel. If you'd have a minute, would you point me in the right direction 
as far as the resources I could useful in creating a new calendar grid?





More information about the wxpython-users mailing list