Posts Tagged ‘Ubuntu’

I’ve been working on enhancing the user interface of my LeMMA app, which is written in Python/Tkinter. This discusses some of my thoughts while researching the current state of the art with regards to using Tkinter.

Why did I choose Tkinter when there are other widget libraries that looks better and works natively? My decision was mainly based on the ease of installation by users, i.e. no installation required. Because Tkinter comes standard with Python on almost all platforms (except on Ubuntu where you must explicitly install the python-tk package). I don’t want my users to have to install any third-party widget libraries. Users should be able to simply unzip and run the app immediately.

(For the record, I’ve used PyGtk and like it, but I still haven’t found an easy way to install GTK on Windows, other than installing other GTK apps like GIMP or pidgin…)

However, Tkinter suffers from the following issues:

  • Dated look and feel: Surprisingly, despite Python’s widespread use in the major Linux distros, Tkinter looks ugliest on Linux. For Gnome-based distros, it appears that the PyGtk bridge is a more popular choice for GUI Python apps.
  • Lack of good documentation: Yes, there is the Tk documentation, but what is mentioned there is not necessarily available in Python. And some options don’t work for some widgets/platforms. For certain platforms, e.g. Mac you have to resort to direct Tk calls to get certain behavior, and even then not everything described works. You can find some good resources at NMT and effbot.org, but they are not complete. It’s no wonder that we often refer to it as Tk ‘folklore’.

And some platform-specific problems I discovered are:

  • On Linux, the menu in the OptionMenu widget won’t display if it is taller than screen height. The menubutton+menu approach works, but it doesn’t scroll so it is still not useable. Mac and Windows implementations use native menus that can scroll.
  • Mac doesn’t support flat relief buttons (well, I use them in LeMMA, so they looked really bad).
  • Tix is currently broken at least on Ubuntu due to version mismatch in packaging (Ubuntu python is compiled with Tk 8.5, i.e. ttk support). Ok, this is not really a valid problem, but no Tix-love until Ubuntu fixes its repositories. What? You mean there isn’t any Python Tix apps that people are complaining are broken in Ubuntu…?

The next-generation Tkinter is ttk (Tiled Tk), which is able to use native widgets in Mac and Windows, however:

  • It is NOT a drop-in replacement for Tk. Current apps won’t be automagically beautified. You will need to explicitly import the ttk module.
  • It’s not just a simple import statement. Only a subset of widget options are supported in ttk, and the style options were removed. Styling in ttk has a different approach. Perhaps this is a better way, but it means that old Tkinter programs wanting a fresh coat of paint need to be re-coded.
  • Even if a simple import works, all subclassed Tk widgets will NOT get the benefit of ttk, so no third-party widget extensions, or you will get a weird ‘mashup’ of different widget look-and-feel.
  • On the plus side, assuming the documentation at the TkDocs website is accurate, the standard extended widgets will be styled eventually in future Python releases (version 2.7?). That’s not the case yet for the current Tkinter/Tk8.5 implementations as far as I know.
  • Widgets on Linux will look somewhat better, but it’s still ugly, partly because there is no one standard native widget engine, unlike Mac and Windows. Hopefully, at least GTK and Qt can be supported in future, as they are what’s used in most modern Linux distros today. I don’t think the built-in theming support in ttk is the correct way ahead (I’m still looking for instructions on how to design and install new themes for use in Tkinter).

We are finally seeing the beginning of real cross-platform GUI development with Tkinter, using native widgets, but there are still quite a few raw edges. For now I’ll use the following approach:

  • Current: Use the Tk 8.4 widgets set, and write my own pure Tk widgets extensions, avoiding the use of all third-party Tk extensions.
  • Near-future: Re-code my app to auto-detect the availability of ttk and continue to work with and without it. A command-line option to force either selection is also recommended, in case ttk doesn’t work for some users.
  • (Far?) future: When ttk is finally mature, stable and widespread, to Use only ttk widgets.

Another consideration is the eventual migration of your app to Python 3. That might be good time to make a clean break between 2.x + Tk8.4 apps and 3.x + Tk8.5/Ttk apps.

Of course, if you just want to write new Python apps for the future and don’t care about the current installed base, by all means go ahead and write in Python 3 (which is already supported in Python 2.6) and ttk. We need good apps to encourage people to switch anyway. 🙂


Read Full Post »

Ubuntu 9.04 is out!

I just upgraded to Ubuntu 9.04 on my laptop and netbook. The upgrade experience was quite smooth, but I’m expecting the bugs to start appearing. So far, I’ve found that gnome system monitor is crashing for some reason. I don’t feel very ‘jaunty’ yet.

I also tried installing the real-time kernel on the netbook but it failed to boot. Disappointing, as the real-time kernel has not been working for me since 8.10.

Update 1 May 09: Looks like the major issue with Jaunty is the graphics. EXA is supposed to be a new and better way to do graphics than XAA, but for me the performance is much worse (especially in Flash, which is already bad enough under Linux). On my old Dell D600 (ATI Radeon Mobility 9000) I had to set AccelMethod back to XAA. On my Asus 1000HE (Intel 945GME) setting XAA doesn’t work – I’m still studying the options. The new audio mixer also has some quirks. The only plus side for me is that on the Asus 1000HE touchpad edge scrolling is now enabled, but all in all I think Jaunty is pretty much a flop. No point getting faster boot if the system lags after booting.

Read Full Post »

After installing Ubuntu on my Asus 1000HE, I decided to repartition the hard disk, so I backed up everything using fsarchiver and restore everything after I was done.

I found that the UUID for the swap partition has changed from the repartitioning so I edited /etc/fstab to mount the new swap partition. Then I discovered that my Ubuntu boot splash refused to stay in graphical mode. It will always drop to text at the “resume image” step. What to do? Google for the solution!

Turns out that this step in the boot process is looking for the swap partition at the old UUID.

There are two ways to fix this:

METHOD 1: Recreate the swap partition with the old UUID. Revert the /etc/fstab entry as well.

METHOD 2: Update /etc/initramfs-tools/conf.d/resume to reflect the new swap UUID, then run ‘sudo update-initramfs -u’ to update the initramfs image.

And voila, graphical boot all the way to the login screen!

Read Full Post »

Playing midi with audacious & AMidi plugin

I use the audacious player with AMidi plugin for playing midi files (and most audio files). There are two choices of backends – Timidity and Fluidsynth. I used to use the Timidity backend but found that lately the playback keeps skipping with my soundfonts, so I switched to the Fluidsynth backend and it’s much better now.

Read Full Post »

Upgraded to Ubuntu 8.10

I upgraded to Ubuntu 8.10 from 8.04 last night, and it went pretty smoothly. Glad to see Gimp 2.6 made it, but too bad OpenOffice 3 didn’t. I had to remove the OpenOffice 2.4 forced on me during the upgrade and reinstall the menus for OpenOffice 3.

I did find a problem with gedit’s file browser plug-in though. Apparently it only works with the official icon sets. All my other custom icon sets (e.g. the Mac4Lin ones) will make gedit go into an infinite loop. First time I’ve an icon set hang an app…I decided to remove the file browser plug-in.

Another problem I found is that audacious no longer opens the files on double clicking. I tested it at the command-line and it appears to be a bug with this build, not the file manager.

Read Full Post »

Ubuntu 8.04

Upgraded my Ubuntu to 8.04 today. This time it went pretty smoothly, compared to when I went from 7.04 to 7.10. Other than a problem with Gnome not loading because of a problem gdm theme (I was using a customised theme, had to switched to one of the stock ones), nothing else seems to be broken (yet). Ubuntu 8.04 comes with Firefox 3 Beta 5, so far so good, except that most of my add-ons and themes are not working – hope that they get updated to Firefox 3 soon.

Read Full Post »

Fixed my Ubuntu! (I think)

Dunno what exactly I did, but after reinstalling packages, tweaking config files, and replacing some config with the default 7.10 versions (which I skipped during the update), I seem to have got my suspend problem fixed in the Ubuntu 7.10 kernel. It works only in the generic kernel though, not sure why it’s not working still in the realtime kernel. I’ll have to test my audio recording apps again for latency.

Read Full Post »

Older Posts »