Digital Solutions

Lesson: GUI__moreFormsAndColours


Example 1: PySimpleGUI/PSG_colours.py:
import PySimpleGUI as PSG PSG.SetOptions( background_color = "salmon", text_element_background_color = "plum", text_color = "white" ) LAYOUT = [ [PSG.Text("Some Text Here")] ] FORM = PSG.FlexForm("") FORM.Layout(LAYOUT) button, value = FORM.Read()
Example 2: PySimpleGUI/multiple_forms.py:
import PySimpleGUI as PSG PRIMARY_LAYOUT = [ [PSG.ReadFormButton("CLOSE PRIMARY")], [PSG.ReadFormButton("OPEN SECONDARY")] ] SECONDARY_LAYOUT = [ [PSG.ReadFormButton("SAVE AND CLOSE SECONDARY")] ] PRIMARY = PSG.FlexForm("") PRIMARY.Layout(PRIMARY_LAYOUT) while True: button, value = PRIMARY.Read() if button == "OPEN SECONDARY": SECONDARY = PSG.FlexForm("") button, value = SECONDARY.LayoutAndRead(SECONDARY_LAYOUT) #----------------------------------------- #GET WHATEVER YOU NEED FROM SECONDARY HERE #----------------------------------------- SECONDARY.CloseNonBlockingForm() if button == "CLOSE PRIMARY": PRIMARY.CloseNonBlockingForm() break
Example 3: PySimpleGUI/multiple_forms_example.py:
import PySimpleGUI as PSG PRIMARY_LAYOUT = [ [PSG.ReadFormButton("CLOSE PRIMARY")], [PSG.ReadFormButton("OPEN SECONDARY")] ] SECONDARY_LAYOUT = [ [PSG.InputText("Gday Mate", key="Hi")], [PSG.ReadFormButton("SAVE AND CLOSE SECONDARY")] ] PRIMARY = PSG.FlexForm("") PRIMARY.Layout(PRIMARY_LAYOUT) while True: button, value = PRIMARY.Read() if button == "OPEN SECONDARY": SECONDARY = PSG.FlexForm("") button, value = SECONDARY.LayoutAndRead(SECONDARY_LAYOUT) print(value["Hi"]) SECONDARY.CloseNonBlockingForm() if button == "CLOSE PRIMARY": PRIMARY.CloseNonBlockingForm() break