Categories
Development

oci-bucket-gui in Python

Do you think I was able to stick to my initial idea of developing in Electron? Did I power through no matter what? Haha: no.

Here I am, switching languages again – this time it’s Python. It’s impressive how little code you need to create a mock GUI using GTK+ and GTK Builder with Glade visual editor.

It’s literally this much:

import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk


class Handler:
    def onDestroy(self, *args):
        Gtk.main_quit()

    def on_btnSetup_clicked(self, button):
        print("Setup button clicked")

    def on_btnConnect_clicked(self, button):
        print("Connect button clicked")


builder = Gtk.Builder()
builder.add_from_file("MyGUI.glade")
builder.connect_signals(Handler())

window = builder.get_object("window1")
window.show_all()

Gtk.main()

The only other piece of code is a .glade file – an XML containing description of all the widgets, their layouts and signals (call backs).

Sure, it does nothing but it’s already looking great:

In the Glade editor, most of the layout is done visually like in the olden Visual Basic 6 days!

The most complex part is understanding how Glade layouts work – how containers and widgets interact and how sizes and positions are negotiated, but once understood it’s easy enough to get going and develop fast. So far I’m impressed.

I’ve done this on my old computer running Ubuntu, next step – testing it on Windows.

Keep hacking (•̀ᴗ•́)و ̑̑

Leave a Reply