Archive for wxpython

wxPython on Linux (GTK) Annoyances

It is very fashionable to gripe about Windows short comings and brag that Linux solutions are always better, more bug-free, etc. I have come to the opposite conclusion in the case of wxPython and Windows/Linux development. Programming on Windows just works. Linux (or more accurately the GTK platform on Linux) is very frustrating because of the quirky behavior in a surprisingly wide variety of cases.

  • the File Browse Button widget (wx.lib.filebrowsebutton) had a bug that appears on GTK (but not Windows). If the value of the associated text control points to a directory or file that does not exist, clicking on the Browse button causes an assertion error. More info (and the fix) is here, summarized below:
    • This is the same error as discussed in
      http://trac.wxwidgets.org/ticket/4749 for 2.8.7.1 (I am using 2.8.9.1)
      but apparently the fix didn't carry over or fix this particular case.

      "Simple fix is to add a line that blanks out the file part when the
      directory is not found." is what it says but my 2.8.9.1 source for
      filebrowsebutton.py doesn't actually blank out the file part.

      adding:
      current = ''

      in the else clause around line 161 fixed it.

      else:
      directory = self.startDirectory
      current = ''
      dlg = wx.FileDialog(self, self.dialogTitle, directory, current,self.fileMask, self.fileMode)

  • Default fonts are sometimes (but not always!) larger than the encapsulating control. Pull down menus especially suffer from this on GTK, and I have to write special case code to check whether the program is being run under GTK, and size the fonts smaller so they are not clipped by the control. Very annoying!
  • StaticBitmap on GTK does not behave as on Windows, with the latter version being more feature full. There is a work around, by using a wx.lib.statbmp.GenStaticBitmap, but this leads to a performance hit, so I need to special case this as well for GTK.
  • More to come as I struggle with cross-platform programming.

Comments off