Create a text entry box Get the value of an entry box
All posts by
Button
Create a button Respond to a button press Up Down Left Right buttons example
Label
Display a label Setting properties Update label text Multi line Just use the \n newline character.You’ll need to set anchor and justify if you want the text aligned left (defaults to center). Align anchor – Values n, ne, e, se, s, sw, w, nw, or center. For example, nw means display the information such that […]
Image
Show image object Update an image Image is blank When you add an image object to a Tkinter widget, you must keep your own reference to the image object. If you don’t, the image won’t always show up. This is because the Tkinter/Tk interface doesn’t handle references to Image objects properly; the Tk widget will […]
Use tkinter without mainloop
Typically tkinter is used with its own main loop that takes over the main thread. You need to run your app code off its callbacks or in a different thread. But you can also call tkinter to update from your own main loop without it taking over the thread. ap_gui.py
Threads for background processes
Tkinter is not thread safe, it needs to run on your applications main thread. However when you call root.mainloop() your application won’t do anything more until the GUI window gets closed. To do background tasks you create a new thread (or threads) to do them.
.1 Installing Visual Studio Code
Setup for VS Code Python programming Install Python for Windows Reboot windows (so the correct environmental variables are picked up for python by VS code – we found was needed after adding / updating Python to a new version). In VS Code, add the “Python extension for Visual Studio Code”, just named “Python”. Ensure VS Code […]
.2 Making VS Code work the way we like
VS Code Options Our general settings for VS Code – see here Python programming specific settings Use CTRL+SHIFT+P and then enter “Open User Settings (JSON)” to open the raw json file. Check it has the following: File > Preferences > Settings “editor.trimAutoWhitespace”: false – stops VSCode auto removing indent of blank lines
count()
Get total number of records
HTTP GET
Simple GET request Get Byte array of response (e.g. raw byte array of a returned file)