Getting more Demo Programs synced up. New demo for VPush too
This commit is contained in:
parent
409846bd3f
commit
1eb653d910
|
@ -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')],
|
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)
|
window = sg.Window('Filename Chooser With History', layout)
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ import PySimpleGUI as sg
|
||||||
def main():
|
def main():
|
||||||
column_to_be_centered = [ [sg.Text('My Window')],
|
column_to_be_centered = [ [sg.Text('My Window')],
|
||||||
[sg.Input(key='-IN-')],
|
[sg.Input(key='-IN-')],
|
||||||
[sg.Text(size=(12,1), key='-OUT-')],
|
[sg.Text(size=(30,1), key='-OUT-')],
|
||||||
[sg.Button('Go'), sg.Button('Exit')] ]
|
[sg.Button('Go'), sg.Button('Exit')] ]
|
||||||
|
|
||||||
layout = [[sg.Text(key='-EXPAND-', font='ANY 1', pad=(0, 0))], # the thing that expands from top
|
layout = [[sg.Text(key='-EXPAND-', font='ANY 1', pad=(0, 0))], # the thing that expands from top
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
from win32com.client import Dispatch
|
from win32com.client import Dispatch
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Demo Program = Make Windows Shortcut
|
Demo Program = Make Windows Shortcut
|
||||||
|
|
|
@ -36,13 +36,13 @@ def make_window():
|
||||||
:return: (sg.Window) The window that was created
|
: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')],
|
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.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 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 2', sg.user_settings_get_entry('-option2-', False), k='-CB2-')],
|
||||||
[sg.T('Settings file = ' + sg.user_settings_filename())],
|
[sg.T('Settings file = ' + sg.user_settings_filename())],
|
||||||
[sg.Button('Save'), sg.Button('Exit without saving', k='Exit')]]
|
[sg.Button('Save'), sg.Button('Exit without saving', k='Exit')]]
|
||||||
|
|
||||||
|
@ -64,10 +64,10 @@ def settings_window():
|
||||||
break
|
break
|
||||||
if event == 'Save':
|
if event == 'Save':
|
||||||
# Save some of the values as user settings
|
# Save some of the values as user settings
|
||||||
sg.user_settings_set_entry('input', values['-IN-'])
|
sg.user_settings_set_entry('-input-', values['-IN-'])
|
||||||
sg.user_settings_set_entry('theme', values['-LISTBOX-'][0])
|
sg.user_settings_set_entry('-theme-', values['-LISTBOX-'][0])
|
||||||
sg.user_settings_set_entry('option1', values['-CB1-'])
|
sg.user_settings_set_entry('-option1-', values['-CB1-'])
|
||||||
sg.user_settings_set_entry('option2', values['-CB2-'])
|
sg.user_settings_set_entry('-option2-', values['-CB2-'])
|
||||||
|
|
||||||
# if the theme was changed, restart the window
|
# if the theme was changed, restart the window
|
||||||
if values['-LISTBOX-'][0] != current_theme:
|
if values['-LISTBOX-'][0] != current_theme:
|
||||||
|
@ -86,7 +86,7 @@ def save_previous_filename_demo():
|
||||||
|
|
||||||
# Notice that the Input element has a default value given (first parameter) that is read from the user settings
|
# 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:')],
|
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')]]
|
[sg.B('Save'), sg.B('Exit Without Saving', key='Exit')]]
|
||||||
|
|
||||||
window = sg.Window('Filename Example', layout)
|
window = sg.Window('Filename Example', layout)
|
||||||
|
@ -96,7 +96,7 @@ def save_previous_filename_demo():
|
||||||
if event in (sg.WINDOW_CLOSED, 'Exit'):
|
if event in (sg.WINDOW_CLOSED, 'Exit'):
|
||||||
break
|
break
|
||||||
elif event == 'Save':
|
elif event == 'Save':
|
||||||
sg.user_settings_set_entry('filename', values['-IN-'])
|
sg.user_settings_set_entry('-filename-', values['-IN-'])
|
||||||
|
|
||||||
window.close()
|
window.close()
|
||||||
|
|
||||||
|
|
|
@ -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))],]
|
[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())
|
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['-COL R-'].expand(True, True, True)
|
||||||
# window['-OUTPUT-'].expand(True, True, False)
|
# window['-OUTPUT-'].expand(True, True, False)
|
||||||
|
|
Loading…
Reference in New Issue