Merge pull request #5593 from PySimpleGUI/Dev-latest

Dev latest
This commit is contained in:
PySimpleGUI 2022-06-11 09:03:26 -04:00 committed by GitHub
commit c076bc71c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 40 deletions

View File

@ -11,7 +11,7 @@
Displays the values dictionary entry for each element
And more!
Copyright 2021 PySimpleGUI
Copyright 2021, 2022 PySimpleGUI
"""
import PySimpleGUI as sg
@ -36,7 +36,7 @@ def make_window(theme):
sg.Image(data=sg.DEFAULT_BASE64_LOADING_GIF, enable_events=True, key='-GIF-IMAGE-'),],
[sg.Checkbox('Checkbox', default=True, k='-CB-')],
[sg.Radio('Radio1', "RadioDemo", default=True, size=(10,1), k='-R1-'), sg.Radio('Radio2', "RadioDemo", default=True, size=(10,1), k='-R2-')],
[sg.Combo(values=('Combo 1', 'Combo 2', 'Combo 3'), default_value='Combo 1', readonly=True, k='-COMBO-'),
[sg.Combo(values=('Combo 1', 'Combo 2', 'Combo 3'), default_value='Combo 1', readonly=False, k='-COMBO-'),
sg.OptionMenu(values=('Option 1', 'Option 2', 'Option 3'), k='-OPTION MENU-'),],
[sg.Spin([i for i in range(1,11)], initial_value=10, k='-SPIN-'), sg.Text('Spin')],
[sg.Multiline('Demo of a Multi-Line Text Element!\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7\nYou get the point.', size=(45,5), expand_x=True, expand_y=True, k='-MLINE-')],
@ -88,9 +88,7 @@ def make_window(theme):
]]
layout[-1].append(sg.Sizegrip())
window = sg.Window('All Elements Demo', layout, right_click_menu=right_click_menu_def, right_click_menu_tearoff=True, grab_anywhere=True, resizable=True, margins=(0,0), use_custom_titlebar=True, finalize=True, keep_on_top=True,
# scaling=2.0,
)
window = sg.Window('All Elements Demo', layout, right_click_menu=right_click_menu_def, right_click_menu_tearoff=True, grab_anywhere=True, resizable=True, margins=(0,0), use_custom_titlebar=True, finalize=True, keep_on_top=True)
window.set_min_size(window.size)
return window
@ -151,7 +149,7 @@ def main():
elif event == 'Edit Me':
sg.execute_editor(__file__)
elif event == 'Versions':
sg.popup(sg.get_versions(), keep_on_top=True)
sg.popup_scrolled(__file__, sg.get_versions(), keep_on_top=True, non_blocking=True)
window.close()
exit(0)

View File

@ -88,8 +88,7 @@ while True:
# sg.Print(event, values)
if event == sg.WIN_CLOSED or event == 'Exit':
break
if event == 'Edit Me':
sg.execute_editor(__file__)
if values['-COMBO-'] != sg.theme():
sg.theme(values['-COMBO-'])
window.close()
@ -99,8 +98,10 @@ while True:
sg.set_options(use_custom_titlebar=use_custom_titlebar)
window.close()
window = make_window()
if event == 'Edit Me':
sg.execute_editor(__file__)
elif event == 'Version':
sg.popup_scrolled(sg.get_versions(), __file__, keep_on_top=True, non_blocking=True)
sg.popup_scrolled(__file__, sg.get_versions(), keep_on_top=True, non_blocking=True)
window.close()

View File

@ -1,22 +1,21 @@
import PySimpleGUI as sg
import random
# Bars drawing in PySimpleGUI
#
# .--.
# | |
# .--.| |.--.
# | || || |
# | || || |
# | || || |
# .--.| || || |
# .--.| || || || |.--.
# | || || || || || |
# | || || || || || |
# .--.| || || || || || |.--.
# | || || || || || || || |.--.
# | || || || || || || || || |
# '--''--''--''--''--''--''--''--''--'
"""
Demo - Using a Graph Element to make Bar Charts
The Graph Element is very versatile. Because you can define your own
coordinate system, it makes producing graphs of many lines (bar, line, etc) very
straightforward.
In this Demo a "bar" is nothing more than a rectangle drawn in a Graph Element (draw_rectangle).
To make things a little more interesting, this is a barchart with that data values
placed as labels atop each bar, another Graph element method (draw_text)
Copyright 2022 PySimpleGUI
"""
BAR_WIDTH = 50 # width of each bar
@ -38,12 +37,13 @@ while True:
graph.erase()
for i in range(7):
graph_value = random.randint(0, GRAPH_SIZE[1])
graph_value = random.randint(0, GRAPH_SIZE[1]-25) # choose an int just short of the max value to give room for the label
graph.draw_rectangle(top_left=(i * BAR_SPACING + EDGE_OFFSET, graph_value),
bottom_right=(i * BAR_SPACING + EDGE_OFFSET + BAR_WIDTH, 0),
fill_color=sg.theme_button_color()[1])
fill_color='green')
# fill_color=sg.theme_button_color()[1])
graph.draw_text(text=graph_value, location=(i*BAR_SPACING+EDGE_OFFSET+25, graph_value+10))
graph.draw_text(text=graph_value, location=(i*BAR_SPACING+EDGE_OFFSET+25, graph_value+10), font='_ 14')
# Normally at the top of the loop, but because we're drawing the graph first, making it at the bottom
event, values = window.read()

View File

@ -39,7 +39,7 @@ def main():
# sg.theme('black')
menu_def = [['&File', ['&Open Ctrl-O', '&Save Ctrl-S', '&Properties', 'E&xit']],
['&Edit', ['Me', 'Special', 'Normal',['Normal1', 'Normal2'] , 'Undo']],
['&Edit', ['Edit Me', 'Special', 'Normal',['Normal1', 'Normal2'] , 'Undo']],
['!Disabled', ['Special', 'Normal',['Normal1', 'Normal2'], 'Undo']],
['&Toolbar', ['---', 'Command &1::Command_Key', 'Command &2', '---', 'Command &3', 'Command &4']],
['&Help', ['&About...']], ]
@ -47,7 +47,7 @@ def main():
layout = [[sg.MenubarCustom(menu_def, pad=(0,0), k='-CUST MENUBAR-')],
[sg.Multiline(size=(70, 20), reroute_cprint=True, write_only=True, no_scrollbar=True, k='-MLINE-')]]
window = sg.Window("Custom Titlebar with Custom (Simulated) Menubar", layout, use_custom_titlebar=True, keep_on_top=True)
window = sg.Window("Custom Titlebar with Custom (Simulated) Menubar", layout, use_custom_titlebar=True, keep_on_top=True, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_VER_EXIT)
# ------ Event Loop ------ #
while True:
@ -66,8 +66,10 @@ def main():
sg.popup('About this program', 'Simulated Menubar to accompany a simulated Titlebar',
'PySimpleGUI Version', sg.get_versions(), grab_anywhere=True, keep_on_top=True)
window.reappear()
elif event == 'Me':
elif event == 'Edit Me':
sg.execute_editor(__file__)
elif event == 'Version':
sg.popup_scrolled(__file__, sg.get_versions(), keep_on_top=True, non_blocking=True)
elif event.startswith('Open'):
filename = sg.popup_get_file('file to open', no_window=True)
print(filename)

View File

@ -51,10 +51,8 @@ def Menubar(menu_def, text_color, background_color, pad=(0, 0)):
def main():
sg.theme('dark green 7')
sg.theme('dark amber')
# sg.theme('dark purple 3')
menu_def = [['&File', ['&Open Ctrl-O', '&Save Ctrl-S', '&Properties', 'E&xit']],
menu_def = [['&File', ['&Open & Ctrl-O', '&Save & Ctrl-S', '&Properties', 'E&xit']],
['&Edit', [['Special', 'Normal',['Normal1', 'Normal2'] ], 'Undo'], ],
['!Disabled', [['Special', 'Normal',['Normal1', 'Normal2'] ], 'Undo'], ],
['&Toolbar', ['---', 'Command &1::Command_Key', 'Command &2', '---', 'Command &3', 'Command &4']],
@ -78,13 +76,13 @@ def main():
layout3 = [[sg.Multiline(size=(70, 20), reroute_stdout=True, reroute_cprint=True, write_only=True)],]
window = sg.Window("Custom Titlebar and Menu", layout, use_custom_titlebar=True, finalize=True)
window = sg.Window("Custom Titlebar and Menu", layout, use_custom_titlebar=True, finalize=True, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_VER_EXIT)
win_loc = window.current_location()
window2 = sg.Window("Traditional Titlebar and Menu", layout2, finalize=True, location=(win_loc[0]-window.size[0]-40, win_loc[1]))
window2 = sg.Window("Traditional Titlebar and Menu", layout2, finalize=True, location=(win_loc[0]-window.size[0]-40, win_loc[1]), right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_VER_EXIT)
window3 = sg.Window("Output Window", layout3, finalize=True, location=(win_loc[0]-window.size[0]//1.5, win_loc[1]+window.size[1]+30), use_custom_titlebar=True)
window3 = sg.Window("Output Window", layout3, finalize=True, location=(int(win_loc[0]-window.size[0]//1.5), int(win_loc[1]+window.size[1]+30)), use_custom_titlebar=True, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_VER_EXIT)
# ------ Event Loop ------ #
@ -97,6 +95,10 @@ def main():
if event in (sg.WIN_CLOSED, 'Exit'):
break
elif event == 'Edit Me':
sg.execute_editor(__file__)
elif event == 'Version':
sg.popup_scrolled(__file__, sg.get_versions(), keep_on_top=True, non_blocking=True)
sg.cprint(f'event = {event}', c='white on red')
sg.cprint(f'values = {values}', c='white on green')

View File

@ -1,6 +1,6 @@
#!/usr/bin/python3
version = __version__ = "4.60.0.38 Unreleased"
version = __version__ = "4.60.0.39 Unreleased"
_change_log = """
Changelog since 4.60.0 released to PyPI on 8-May-2022
@ -96,6 +96,8 @@ _change_log = """
Added exapnd_x and expand_y to all of the "lazy buttons" and Chooser buttons
4.60.0.38
Column element - added horizontal_scroll_only parameter (fingers crossed on this one....)
4.60.0.39
New signature testing
"""
__version__ = version.split()[0] # For PEP 396 and PEP 345
@ -25247,4 +25249,4 @@ if __name__ == '__main__':
exit(0)
main()
exit(0)
def get_signature(): return b'^0A\xe2\x89JK\x91\xed\x9b\xcc&W_\xde\xc5\x82W\xc8\x06\xa1\x0eS\xdbp\x9d\xe4\xbb6\x1f\xdaC\x97\xe7\xe0(|\x89\r\x11@\xaa\x15<\x05\xb0\xd7\x9e \xef\xa1U\x1b\x83\xac\xb4 X\xcb)G\x18\xc0m\xec\xa2F\x98\xe5dc\x14@\xae\xb2\x8b%yJt\xe1\x1e\xa7\x9a\xe0\xd1\x90,\xf9\x89\xe2\x13\xa6\xae\xce\x07Q\x9b\xa2\x80S\x12\xd4\x1c\x8a\x8e\x90\x8c\x18d\xe7n;\xb5\x88\x96XSk\x88j\xefgs`\x08\x06\xa6'
def get_signature(): return b'\x161h\x96\x82w\x10O\x82/g\x9dOb\x02\x12\'\x0f\xec^l;\x18fF\x1f\xcbS3\xc1M\xa2\xcc\xfe\x98Z\xa8\x97\xc8\x88\x10U\x0e\x90HW\x9f\xce\x1a\x90;\xec\n \xe9\x16\xf6\x8drG\n\xc9\x02^\xb1\x86\x8fb\xec\x90\xd6\x1e9\xc5\xc1\t\xfaF\x1c\xe2\x8a\xd9\x9a\xa51\xce^QP.\x0c3\x85\x8fA\xc6+\xe1d\xa2\xac\xd5E\x01\x91\xccH\xff\x9a\xec\xf7h\xbc\xa0\xc7\xd9\xb5\x8a\xde\x1e\x15\xb7\xf1\xb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