FreeSimpleGUI

Introduction

Once upon a time there was a package called PySimpleGUI that people liked a lot. The owners decided to re-license it with a proprietary commercial license under a paid subscription. FreeSimpleGUI is the continuation of the LGPL3 licensed version last available. (From FreeSimpleGUI docs)

Install FreeSimpleGUI

pip install FreeSimpleGUI

Links

FreeSimpleGUI (Docs)

FreeSimpleGUI (Home)

FreeSimpleGUI Tips - Demo Programs and Themes (YouTube)

Example

image missing

# code from FreeSimpleGUI Docs import FreeSimpleGUI as sg # ---- Add a touch of color sg.theme('DarkAmber') # ---- All the stuff inside your window. layout = [ [sg.Text('Some text on Row 1')], [sg.Text('Enter something on Row 2'), sg.InputText()], [sg.Button('Ok'), sg.Button('Cancel')] ] # ---- Create the Window window = sg.Window('Window Title', layout) # ---- Event Loop # ---- process "events" and get the "values" of the inputs while True: event, values = window.read() # ---- if user closes window or clicks cancel if event == sg.WIN_CLOSED or event == 'Cancel': break print('You entered ', values[0]) window.close()

Another Example (Enigma Machine simulation GUI)

image missing

# Enigma Machine simple GUI import FreeSimpleGUI as sg plugboard_config = 'plugboard.csv' reflector_config = 'reflector.csv' rotor_config = 'rotors.csv' #font2 = ('Aerial',12) #font4 = ('Aerial',14) font2 = ('Courier New',12) font4 = ('Courier New',14) tsize = 64 abc = ['A','B','C','D','E','F','G','H','I','J','K','L','M', 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] rotors = ['I','II','III','IV','V','VI','VII','VIII'] rotor1 = [ [sg.Combo(rotors,default_value='I', font=font4,key='-RROTOR-'), sg.Combo(abc,default_value='A', font=font4,key='-RPOSITION-',size=(2,1))] ] rotor2 = [ [sg.Combo(rotors,default_value='II', font=font4,key='-MROTOR-'), sg.Combo(abc,default_value='B', font=font4,key='-MPOSITION-',size=(2,1))] ] rotor3 = [ [sg.Combo(rotors,default_value='III', font=font4,key='-LROTOR-'), sg.Combo(abc,default_value='C', font=font4,key='-LPOSITION-',size=(2,1))] ] layout = [ [sg.Button('Q',font=font4), sg.Button('W',font=font4), sg.Button('E',font=font4), sg.Button('R',font=font4), sg.Button('T',font=font4), sg.Button('Y',font=font4), sg.Button('U',font=font4), sg.Button('I',font=font4), sg.Button('O',font=font4), sg.Button('P',font=font4)], [sg.Button('A',font=font4), sg.Button('S',font=font4), sg.Button('D',font=font4), sg.Button('F',font=font4), sg.Button('G',font=font4), sg.Button('H',font=font4), sg.Button('J',font=font4), sg.Button('K',font=font4), sg.Button('L',font=font4)], [sg.Button('Z',font=font4), sg.Button('X',font=font4), sg.Button('C',font=font4), sg.Button('V',font=font4), sg.Button('B',font=font4), sg.Button('N',font=font4), sg.Button('M',font=font4)], [sg.Text(font=font4,text_color='black',key='-IN-', background_color='white',size=(tsize,1))], [sg.Text(font=font4,text_color='black',key='-OUT-', background_color='white',size=(tsize,1))], [sg.Button('Exit',font=font4), sg.Button('Encrypt/Decrypt',font=font4), sg.Button('Reset',font=font4)], [sg.Frame('Left Rotor',rotor3,title_location='n', border_width=2,key='-ROTOR3-'), sg.Frame('Middle Rotor',rotor2,title_location='n', border_width=2,key='-ROTOR2-'), sg.Frame('Right Rotor',rotor1,title_location='n', border_width=2,key='-ROTOR1-')], [sg.Text(rotor_config,font=font2), sg.Text(reflector_config,font=font2), sg.Text(plugboard_config,font=font2)] ] # ---- create the Window win = sg.Window('Enigma Machine',layout,element_justification='c') # ---- Event Loop # ---- process "events" and get the "values" of the inputs while True: event, values = win.read() if event == sg.WIN_CLOSED or event == 'Exit': break win.close()