Adding a TimeCtrl Widget to wxGlade

The program I’m working on (ErgMate) requires entry of hours/mins/seconds durations. I just defined input as total number of seconds for the initial prototypes, but the time has come to make it more usable. I was able to create the bridge code necessary to add the wx.lib.masked.TimeCtrl to the wxGlade widget palette by following examples from Alberto Griggio .

The normal TimeCtrl can bind to an external scroll button. The package also includes a new control called TimeSpin. It is based on Andrea Gavana’s FloatSpin control, and provides both a TimeCtrl and scroll button in one control. TimeSpin does not accept the format nor the scrollBar parameters, otherwise it should be a drop-in replacement for TimeCtrl. Let me know if I missed something important in the interface.

There is (at least!) one minor problem with TimeSpin: It seems to report too large a width – its bounding box is actually wider than the displayed control. I’d appreciate anyone with more knowledge of wxPython than I looking into it and sending a patch. For now it’s good enough to get started using.

Both time widgets are added to wxGlade by untarring the time_spin_and_control distribution from within your .wxglade directory. The included README contains more details.

Edit:
1.1 – fixed codegen problem w/value
1.2 – fixed loading problem when presetting a value
1.3 – added workaround for bug in timectrl when using min/max/limited settings

This entry was posted in Python, wxPython. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *