Photo Consolidation Project – User Interface Libraries

A very bare user interface showing only one button

We need a user interface where the user can enter the root folder that needs to be searched for photos. In time we can add features to it. But for now it needs to allow you to choose a folder, and have a button to launch the process.

Acronyms

In this page I use two acronyms:

  • UI: User Interface
  • GUI: Graphical User Interface.

tkinter

ChatGPT gave me sample code using tkinter. I don’t know whether to blame ChatGPT or tkinter, but the code it gave me is not my cup of tea. There is far too much fiddling around with rows and columns. This functionality might be useful for making a calculator which has a lot of buttons, but for my user interface, I’m going to investigate some other libraries.

The code to show a very basic user interface in tkinter

All that code produces this rather bleak user interface:

The user interface produced by the code above

Alternatives

I headed off to LogRocket who compares the different GUI libraries. Unsurprisingly it suggests that ktinter is not all that beautiful looking.

It says that PyQt5 has a steep learning curve. I’m trying to make a presentable user interface. I don’t want to spend time learning a complicated UI library.

PySide6 needs a commercial license. I’m not going to go that route for a hobby application.

Kivy doesn’t offer a native-looking user interface. That would not go down well on a mac. I think we’ll give this one a miss as well.

wxPython

A quick browse led me to Mouse Us Python. I think that is what it is called. The code in their example looks a lot more readable to me. I’ll see what I can knock up with that.

Head off to Wikipedia to find out more about wxPython. It looks like it is current, cross-platform and has a really cute logo. Pasted their sample code into VS Code and of course it doesn’t run. Everything other than ktinker needs to be installed. NB: on other systems you may have to use the full word python, or python3 instead of py.

py -m pip install wxpython

Python Spot shows you through the basics of using this library to create a simple user interface. Its sample code shows an empty user interface. Each wx program needs to have one .App() object. The window is created by instantiating a Frame. NB this is Python Spot’s code, not mine. It is outdated. Their course is in Python2.

import wx

app = wx.App()
frame = wx.Frame(None, -1, 'win.py')
frame.SetDimensions(0,0,640,480)
frame.Show()
app.MainLoop()

I asked ChatGPT for code to set up the UI, and the code it gave me is even more horrible to read than the ktinker code above. I think ChatGPT and I will now part our ways, for this project at least. I will be using Mouse us Python.

Leave a Reply

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