

- #PUREBASIC IMAGE TYPES FOR BUTTON IMAGE GADGET HOW TO#
- #PUREBASIC IMAGE TYPES FOR BUTTON IMAGE GADGET INSTALL#
This is the key name you defined earlier for the Input Element. You check for the Exit event, which occurs when you close the application. You read() the window object for events and values. This is how you create the event loop in PySimpleGUI. The last piece of code to cover are these lines: while True: Any Element you need to access later should also be given a name, which is the key argument. You disable the Input Element to make it read-only and prevent typing into it - each keypress would be an individual Event, and your loop is not prepared for that. To enable events for an Element, you set the enable_events argument to True - this will submit an Event whenever the Element changes.

These 11 lines of code define how your Elements are laid out. Window = sg.Window("Image Viewer", elements) Now you're ready to learn about the main() function: def main(): You import PySimpleGUI and the modules you need from PIL, and set file_types to the file selection choices for the Browse button in the form, which will default to JPEG. Let's break it down into a couple of smaller pieces: # image_viewer.py If event = "Exit" or event = sg.WIN_CLOSED: Window = sg.Window("Image Viewer", layout) Then add this code to the file: # image_viewer.py To see how, create a new file and name it image_viewer.py. PySimpleGUI lets you create a simple image viewer in less than 50 lines. Now that you have your dependencies installed, you can create a brand new application! Creating an Image Viewer
#PUREBASIC IMAGE TYPES FOR BUTTON IMAGE GADGET INSTALL#
You will also need Pillow because Tkinter only supports GIF and PGM/PPM image types.įortunately, you can install both of these packages easily with pip: python3 -m pip install PySimpleGUI Pillow You need to install PySimpleGUI as it is not included with Python. You will be using the regular version of PySimpleGUI, which wraps Tkinter, rather than its wxPython or PyQt variants.
#PUREBASIC IMAGE TYPES FOR BUTTON IMAGE GADGET HOW TO#
In this tutorial, you will learn how to use PySimpleGUI to create a simple Image Viewer. PySimpleGUI makes creating applications easy.
