Archive for the ‘python’ Category

LeMMA 0.8 alpha release

LeMMA 0.8 is now available as an alpha version. A more ‘contemporary’ look-and-feel has been adopted for this version. I’ve also added various usability improvements (e.g. keyboard navigation using arrow keys), and some attempts at supporting the Mac platform better. A new .ini-like configuration file format is used, using the built-in Python config file parsing library, replacing the previous Pickled file format.

If there are any Mac python programmers using this, I’m interested in learning what’s the proper way to package a Mac python application, and any other advice you can give me.

Here’s a screenshot of the new GUI:

Get it from the usual place.


Read Full Post »

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 »

Minor enhancement: I finally added an install script for Linux users, and support the saving of settings in ~/.lemma, so you can finally install it into /usr or /usr/local. And along with that, a simple Debian package. I use checkinstall to generate it. I can’t seem to specify Python as a pre-requisite using checkinstall, but the package installs and removes just fine. Go get it now.

Read Full Post »

LeMMA 0.7 is out

One year after my last LeMMA release, here’s version 0.7. It’s a little embarrassing actually, because the last version contained some stupid bugs, especially on the Windows platform, and it was out there for one full year. So version 0.7 is largely a bug fix and “bulletproofing” (I added debug mode and codes for error handling) release. I did squeeze in some minor enhancements though.

Lately I got a couple of emails from folks who got the impression that LeMMA can open any MMA file, in particular the ones that are bundled with MMA. Sorry to disappoint, but that’s not what LeMMA is. LeMMA is meant to just provide an easy way to generate chord progressions. I’m also not certain that it is feasible, or even possible, to create a full-fledged GUI interface to MMA.

Anyway, I hope this release works for all of you, and thanks for the interest!

Read Full Post »

chordcalc.py 0.3

A number of changes for chordcalc 0.3, plus one stupid bug fixed:

  • New: AUTO_REDUCE filter option. If no fingerings can be found, try to progressively omit 5th, omit root, and omit 3rd until fingerings are found. This is useful for instruments with fewer strings playing larger chords.
  • New: NO_OPEN filter option. Reject fingerings with open strings.
  • Fixed: filter options not passed in since version 0.1.
  • Added spaces between strings in fingering, to cater for fingerings with 10th fret and above.
  • Added display of chord structure beside the chord name
  • Added descriptive help text for filter options
  • Restructured core functions to be independent of NOTES, TUNINGS, CHORDTYPE dictionaries (no change to command-line interface)

Read Full Post »

chordcalc.py 0.2

Updated version 0.2 of chordcalc.py available. Changes below:

  • Corrections for some chord definitions
  • Minor changes to error messages
  • Default span values for various instruments
  • Options –position and –span now issue warning and set to default values instead of exiting
  • Option -v now just prints the version and exits. All other options are ignored.
  • Fixed bug with chord name parsing
  • No longer exits when invalid chords are encountered. Proceed to next chord if available.
  • Display the chord notes for each fingering.
  • Chord notes are also displayed for each chord type for –help-chords.

Read Full Post »

chordcalc.py – initial release

I finally wrote that program to generate chord fingerings for any fretted instrument. It’s written in Python and meant to be run at the command-line. It’s quite a pleasure writing this in Python – I was surprised to finish writing the core algorithm in just one morning.

Why another chord generation program when there are so many of them on the web already? Well, a variety of reasons: there doesn’t seem to one in Python yet, I want a command-line version (it’s more efficient in some ways), and I want to be able to fine-tune the algorithms. I can slap on a GUI later. Python’s list manipulation capabilities means that I can support instruments of any number of strings, and in any tuning.

I wrote it on my Ubuntu box, but it should work for any platform that Python runs on. It’s written in Python 2.5. I’m still unsure about moving on to Python 3.0.

Interested folks can download the initial release here: chordcalc.py

Let me know if you find any errors e.g. in the chord definitions.

Read Full Post »

Older Posts »