Web Analytics Made Easy - Statcounter

Simple form

It's sometimes useful to exlore what it would take to duplicate a GUI written in tkinter, especially when a nicely written article accompanies the code.

This GUI code duplicates a portion of the tkinter code posted on this page: https://www.devmedia.com.br/tkinter-interfaces-graficas-em-python/33956

It performs performs the logic for only the "Inserir" button.

To add the code for the remaining buttons, add elif statements onto the bottom of the if statement in the event loop. At the moment, buttons that are not handled in the event loop causes a "Not yet implemlented" message to be shown.

On a Windows machine, the window this code produces looks like this:

snag-0487.jpg

PySimpleGUI is a package that provides an interface to GUI Frameworks that uses constructs familiar to Python programmers of all experience levels. With PySimpleGUI you can run your source code on tkinter, Qt, WxPython and in a browser... on Windows, Mac and Linux

One of the "neat tricks" that PySimpleGUI has is the ability to run on multiple GUI platforms with a minimal amount of changes to your code. Often it is just 1 line of code to change.

You can't do this on Trinket, in your browser because Trinket only supports tkinter.

For the example code above, running on a Windows machine, the import statement at the top was changed to use a version of PySimpleGUI that runs on Qt, WxPython and in the browser (using Remi). Note that the windows produced are not perfect and may need a font size or other change to make it look better, but the several character change using PySimpleGUI is tiny compared to what it would take to port tkinter code to Qt.

Changed the import to run on PySide2 (Qt)

import PySimpleGUIQt as sg

The code then created this window running on Qt

snag-0488.jpg

Changed the import to run on WxPython

import PySimpleGUIWx as sg

The code then created this window running on WxPython

snag-0489.jpg

Changed the import to run in a browser:

import PySimpleGUIWeb as sg

The code then created this window running in a chrome window

snag-0490.jpg