Archive for February, 2008

February 13, 2008: 7:21 am: kpdPython, wxPython

I added a workaround for a problem with timectrl.

You’ll want to upgrade to the 1.4 version of the time_spin_and_control distribution if you use limited, min, max, or value parameters in Glade when specifying the control.

Edit – 3/8 – updated to version 1.4

February 11, 2008: 7:17 am: kpdPython, wxPython

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

February 5, 2008: 5:43 am: kpdPython

The February Cleveland Area Python Users Group Meeting was held last night. The guys at BitBacker opened their doors and supplied pizza. It was the best meeting in awhile – 3 talks!

Christian Wyglendowski kicked things off with an overview of SimpleParse. He’s used it in applications from an ini file parser to a parser for an online survey processing language. It looks easy to use. Some time ago I wrote a parser for generating Python code from FLTK’s Fluid GUI builder data files using Spark. A great library, but SimpleParse might have been so much easier – it depends if I could have created or found a grammar for the fluid file format.

Matt Wilson spoke on IPython. I’ve been using IPython for some time and realized I wasn’t making full use of it. Until his talk I didn’t realize how much of IPython I was missing (“You only use 10% of your Ipython’s capabilities….”). Never knew it would assign results to _## where ## is the history line number. That alone will save a lot of time. Matt’s Ipython talk notes are online at his website.

Matt also gave a short talk on Twill. Twill is a domain-specific language used to test websites and web applications. The most interesting part of Twill is its extensibility. He demonstrated how one can add automatic checks as Twill encounters each page in your application – checks for tables-within-tables for example. Matt’s notes contain more information.

These talks gave us a lot to take home and think about.

February 2, 2008: 8:18 am: kpdwxPython

This morning I started getting the following exception when generating code from wxGlade:


<pre>
Traceback (most recent call last):
  File "c:\temp\wxGlade\application.py", line 394, in generate_code
    class_names=class_names)
  File "c:\temp\wxGlade\xml_parse.py", line 503, in __init__
   .
   .
   .
  File "c:\temp\wxGlade\xml_parse.py", line 593, in endElement
    self.code_writer.add_class(obj)
  File "c:\temp\wxGlade\codegen\py_codegen.py", line 640, in add_class
    indentation = prev_src.spaces[code_obj.klass]
KeyError: 'FancyListControl'
</pre>

There was only one mention of a similar problem on the wxGlade mailing list. The solution posted there was to start a new project – not really an option at this stage of development.

So after a little digging, I found a different solution.

The item causing the problem is a fancy subclass of ListControl defined in another module. I had placed a wx.Panel in the sizer slot, and had then changed the class to my fancy ListControl. Is the problem now obvious? This fancy list control is not equivalent to a wx.Panel from wxGlade’s perspective. Removing the panel and instead adding a ListControl with my fancy control as the class name fixed everything up.

So, in summary, use the closest matching wxGlade class (ListControl instead of Panel) when using your own classes.

Doh.