diff --git a/DemoPrograms/Demo_Combo_Filechooser_With_History_And_Clear.py b/DemoPrograms/Demo_Combo_Filechooser_With_History_And_Clear.py index 3ba65023..c954d9e9 100644 --- a/DemoPrograms/Demo_Combo_Filechooser_With_History_And_Clear.py +++ b/DemoPrograms/Demo_Combo_Filechooser_With_History_And_Clear.py @@ -22,7 +22,7 @@ import PySimpleGUI as sg layout = [[sg.Combo(sorted(sg.user_settings_get_entry('-filenames-', [])), default_value=sg.user_settings_get_entry('-last filename-', ''), size=(50, 1), key='-FILENAME-'), sg.FileBrowse(), sg.B('Clear History')], - [sg.Button('Ok'), sg.Button('Cancel')]] + [sg.Button('Ok', bind_return_key=True), sg.Button('Cancel')]] window = sg.Window('Filename Chooser With History', layout) diff --git a/DemoPrograms/Demo_Layout_Vertical_Centered.py b/DemoPrograms/Demo_Layout_Vertical_Centered.py index 9b5141ee..5f8fd974 100644 --- a/DemoPrograms/Demo_Layout_Vertical_Centered.py +++ b/DemoPrograms/Demo_Layout_Vertical_Centered.py @@ -17,7 +17,7 @@ import PySimpleGUI as sg def main(): column_to_be_centered = [ [sg.Text('My Window')], [sg.Input(key='-IN-')], - [sg.Text(size=(12,1), key='-OUT-')], + [sg.Text(size=(30,1), key='-OUT-')], [sg.Button('Go'), sg.Button('Exit')] ] layout = [[sg.Text(key='-EXPAND-', font='ANY 1', pad=(0, 0))], # the thing that expands from top diff --git a/DemoPrograms/Demo_Layout_Vertical_Centered_Using_VPush_Element.py b/DemoPrograms/Demo_Layout_Vertical_Centered_Using_VPush_Element.py new file mode 100644 index 00000000..041a7bf1 --- /dev/null +++ b/DemoPrograms/Demo_Layout_Vertical_Centered_Using_VPush_Element.py @@ -0,0 +1,33 @@ +import PySimpleGUI as sg + +""" + VPush Element + + In version 4.49.0 a new VPush Element was added. + It is not "True Element" but rather a "User Defined Element" because it's a function + that returns elements versus a class based on the Element class. + It's not an important detail in the use of it. + + Use a VPush to "Push" your elements vertically away from it. + * If you put one at the top of your layout, then your layout will be "pushed" to the bottom of the window. + * If you put a VPush at the top and bottom of your layout, then your layout will be centered + + This Demo Program shows the "centered" use case. + + + Copyright 2022 PySimpleGUI +""" + + +layout = [ [sg.VPush()], + [sg.Text('Resize me to see that I am vertically centered')], + [sg.In()], + [sg.In()], + [sg.Button('Go'), sg.Button('Exit'), sg.Cancel(), sg.Ok()], + [sg.VPush(), sg.Sizegrip()] ] # toss a Sizegrip onto the bottom corner to make it easier + + +window = sg.Window('Window Title', layout, resizable=True) + +window.read(close=True) + diff --git a/DemoPrograms/Demo_Make_Windows_Shortcut.pyw b/DemoPrograms/Demo_Make_Windows_Shortcut.pyw index 4b2c4fdc..4b8ea613 100644 --- a/DemoPrograms/Demo_Make_Windows_Shortcut.pyw +++ b/DemoPrograms/Demo_Make_Windows_Shortcut.pyw @@ -1,6 +1,7 @@ import PySimpleGUI as sg from win32com.client import Dispatch import os +import sys """ Demo Program = Make Windows Shortcut diff --git a/DemoPrograms/Demo_User_Settings.py b/DemoPrograms/Demo_User_Settings.py index 9dd42c9d..5b01b41e 100644 --- a/DemoPrograms/Demo_User_Settings.py +++ b/DemoPrograms/Demo_User_Settings.py @@ -36,13 +36,13 @@ def make_window(): :return: (sg.Window) The window that was created """ - sg.theme(sg.user_settings_get_entry('theme', 'DarkBlue2')) # set the theme + sg.theme(sg.user_settings_get_entry('-theme-', 'DarkBlue2')) # set the theme layout = [[sg.Text('Settings Window')], - [sg.Input(sg.user_settings_get_entry('input', ''), k='-IN-')], + [sg.Input(sg.user_settings_get_entry('-input-', ''), k='-IN-')], [sg.Listbox(sg.theme_list(), default_values=[sg.user_settings_get_entry('theme')], size=(15, 10), k='-LISTBOX-')], - [sg.CB('Option 1', sg.user_settings_get_entry('option1', True), k='-CB1-')], - [sg.CB('Option 2', sg.user_settings_get_entry('option2', False), k='-CB2-')], + [sg.CB('Option 1', sg.user_settings_get_entry('-option1-', True), k='-CB1-')], + [sg.CB('Option 2', sg.user_settings_get_entry('-option2-', False), k='-CB2-')], [sg.T('Settings file = ' + sg.user_settings_filename())], [sg.Button('Save'), sg.Button('Exit without saving', k='Exit')]] @@ -64,10 +64,10 @@ def settings_window(): break if event == 'Save': # Save some of the values as user settings - sg.user_settings_set_entry('input', values['-IN-']) - sg.user_settings_set_entry('theme', values['-LISTBOX-'][0]) - sg.user_settings_set_entry('option1', values['-CB1-']) - sg.user_settings_set_entry('option2', values['-CB2-']) + sg.user_settings_set_entry('-input-', values['-IN-']) + sg.user_settings_set_entry('-theme-', values['-LISTBOX-'][0]) + sg.user_settings_set_entry('-option1-', values['-CB1-']) + sg.user_settings_set_entry('-option2-', values['-CB2-']) # if the theme was changed, restart the window if values['-LISTBOX-'][0] != current_theme: @@ -86,17 +86,17 @@ def save_previous_filename_demo(): # Notice that the Input element has a default value given (first parameter) that is read from the user settings layout = [[sg.Text('Enter a filename:')], - [sg.Input(sg.user_settings_get_entry('filename', ''), key='-IN-'), sg.FileBrowse()], + [sg.Input(sg.user_settings_get_entry('-filename-', ''), key='-IN-'), sg.FileBrowse()], [sg.B('Save'), sg.B('Exit Without Saving', key='Exit')]] window = sg.Window('Filename Example', layout) while True: event, values = window.read() - if event in(sg.WINDOW_CLOSED, 'Exit'): + if event in (sg.WINDOW_CLOSED, 'Exit'): break elif event == 'Save': - sg.user_settings_set_entry('filename', values['-IN-']) + sg.user_settings_set_entry('-filename-', values['-IN-']) window.close() diff --git a/DemoPrograms/Demo_pyfiglet.pyw b/DemoPrograms/Demo_pyfiglet.pyw index 6560bf3c..918ba290 100644 --- a/DemoPrograms/Demo_pyfiglet.pyw +++ b/DemoPrograms/Demo_pyfiglet.pyw @@ -107,7 +107,7 @@ def make_window(): [sg.Button('Exit', right_click_menu=sg.MENU_RIGHT_CLICK_DISABLED), sg.T('PySimpleGUI ver ' + sg.version.split(' ')[0] + ' tkinter ver ' + sg.tclversion_detailed + ' Python ver ' + sys.version, font='Default 8', pad=(0,0))],] layout[-1].append(sg.Sizegrip()) - window = sg.Window('psg-figlet', layout, resizable=True, finalize=True, right_click_menu=['_', ['Edit Me', 'Copy', 'Exit']], icon=icon) + window = sg.Window('psgfiglet', layout, resizable=True, finalize=True, right_click_menu=['_', ['Edit Me', 'Copy', 'Exit']], icon=icon) window['-COL R-'].expand(True, True, True) # window['-OUTPUT-'].expand(True, True, False)