From bf872d088293ff6dc860d271cc02808f1217b034 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Thu, 21 Apr 2022 12:42:56 -0400 Subject: [PATCH 1/3] Changed how custom titlebar and menubar are generated --- DemoPrograms/Demo_All_Elements_Simple.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/DemoPrograms/Demo_All_Elements_Simple.py b/DemoPrograms/Demo_All_Elements_Simple.py index aeea3a62..bd9c7a0b 100644 --- a/DemoPrograms/Demo_All_Elements_Simple.py +++ b/DemoPrograms/Demo_All_Elements_Simple.py @@ -14,12 +14,19 @@ def make_window(theme=None): NAME_SIZE = 23 + def name(name): dots = NAME_SIZE-len(name)-2 return sg.Text(name + ' ' + '•'*dots, size=(NAME_SIZE,1), justification='r',pad=(0,0), font='Courier 10') sg.theme(theme) + # NOTE that we're using our own LOCAL Menu element + if use_custom_titlebar: + Menu = sg.MenubarCustom + else: + Menu = sg.Menu + treedata = sg.TreeData() treedata.Insert("", '_A_', 'Tree Item 1', [1234], ) @@ -59,8 +66,9 @@ def make_window(theme=None): [name('StatusBar'), sg.StatusBar('StatusBar')], [name('Sizegrip'), sg.Sizegrip()] ] - layout = [[sg.MenubarCustom([['File', ['Exit']], ['Edit', ['Edit Me', ]]], k='-CUST MENUBAR-',p=0)] if use_custom_titlebar else [sg.Menu([['File', ['Exit']], ['Edit', ['Edit Me', ]]], k='-CUST MENUBAR-',p=0)], - [sg.Checkbox('Use Custom Titlebar & Menubar', use_custom_titlebar, enable_events=True, k='-USE CUSTOM TITLEBAR-')], + # Note - LOCAL Menu element is used (see about for how that's defined) + layout = [[Menu([['File', ['Exit']], ['Edit', ['Edit Me', ]]], k='-CUST MENUBAR-',p=0)], + [sg.Checkbox('Use Custom Titlebar & Menubar', sg.theme_use_custom_titlebar(), enable_events=True, k='-USE CUSTOM TITLEBAR-')], [sg.T('PySimpleGUI Elements - Use Combo to Change Themes', font='_ 18', justification='c', expand_x=True)], [sg.Col(layout_l), sg.Col(layout_r)]] @@ -76,6 +84,7 @@ window = make_window() while True: event, values = window.read() + sg.Print(event, values) if event == sg.WIN_CLOSED or event == 'Exit': break if event == 'Edit Me': From 40567418db095c485776284c1d0055fb61625660 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Thu, 21 Apr 2022 12:43:41 -0400 Subject: [PATCH 2/3] Made initial window loop much shorter. Correctly handle closing initial window, add commented out line showing how to make transparent window if on windows, added copyright --- DemoPrograms/Demo_Animated_GIFs.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/DemoPrograms/Demo_Animated_GIFs.py b/DemoPrograms/Demo_Animated_GIFs.py index 89d544b6..741cd1dc 100644 --- a/DemoPrograms/Demo_Animated_GIFs.py +++ b/DemoPrograms/Demo_Animated_GIFs.py @@ -11,6 +11,8 @@ import PySimpleGUI as sg The first image that uses popup_animated will stop after a few seconds on its own. The remaining images are shown 1 at a time. To move on to the next image, click the current image. If you want to exit before reaching the final image, right click the image and choose 'exit' + + Copyright 2022 PySimpleGUI """ # ---------------------------- Base 64 GIFs ---------------------------- @@ -29,18 +31,20 @@ bar_striped = b'R0lGODlhoAAUAIAAAAQCBP7+/iH/C05FVFNDQVBFMi4wAwEAAAAh+QQJCQABACwA gifs = [ring_blue, red_dots_ring, ring_black_dots, ring_gray_segments, ring_lines, blue_dots, red_dots_ring, bar_striped, line_boxes, line_bubbles] # first show how to use popup_animated using built-in GIF image -for i in range(100000): - sg.popup_animated(sg.DEFAULT_BASE64_LOADING_GIF, message='Right Click To Exit GIF Windows That Follow\nLeft click to move to next one', no_titlebar=False, time_between_frames=100, text_color='black', background_color='white') +for i in range(1000): + if not sg.popup_animated(sg.DEFAULT_BASE64_LOADING_GIF, message='Right Click To Exit GIF Windows That Follow\nLeft click to move to next one', no_titlebar=False, time_between_frames=100, text_color='black', background_color='white'): + break sg.popup_animated(None) # close all Animated Popups # Next demo is to show how to create custom windows with animations -layout = [[sg.Image(data=gifs[0], enable_events=True, background_color='white', key='-IMAGE-', right_click_menu=['UNUSED', ['Exit']])],] +layout = [[sg.Image(data=gifs[0], enable_events=True, background_color='white', key='-IMAGE-', right_click_menu=['UNUSED', ['Exit']], pad=0)],] window = sg.Window('My new window', layout, no_titlebar=True, grab_anywhere=True, keep_on_top=True, background_color='white', + # transparent_color='white' if sg.running_windows() else None, alpha_channel=.8, margins=(0,0)) From ee7179fb3abd1561d5edf1d5449fd51ea0153e12 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Thu, 21 Apr 2022 12:44:36 -0400 Subject: [PATCH 3/3] Added some text, added use of Debug Window to display values since may be running from the Demo Browser where prints are not shown --- DemoPrograms/Demo_Spin_Element_Wraps_Around.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/DemoPrograms/Demo_Spin_Element_Wraps_Around.py b/DemoPrograms/Demo_Spin_Element_Wraps_Around.py index 53d8216e..5b1c3936 100644 --- a/DemoPrograms/Demo_Spin_Element_Wraps_Around.py +++ b/DemoPrograms/Demo_Spin_Element_Wraps_Around.py @@ -10,16 +10,17 @@ import PySimpleGUI as sg This Spin element will wrap around going in either direction. When getting to the end then it will go back to the beginning. - Copyright 2021 PySimpleGUI + Copyright 2022 PySimpleGUI """ lower, upper = 0, 10 data = [i for i in range(lower - 1, upper + 2)] -layout = [[sg.Spin(data, initial_value=lower, readonly=True, size=3, enable_events=True, key='-SPIN-')]] +layout = [[sg.Text('This Spin element wraps around in both directions')], + [sg.Spin(data, initial_value=lower, readonly=True, size=3, enable_events=True, key='-SPIN-')]] -window = sg.Window('Title', layout, font='_ 18') +window = sg.Window('Wrapping Spin Element', layout, font='_ 18', keep_on_top=True) while True: @@ -27,7 +28,7 @@ while True: if event == sg.WIN_CLOSED: break - + # code to make the Spin do the wrap around. Do this prior to using the Spin's value in your code if event == '-SPIN-': value = values['-SPIN-'] @@ -38,6 +39,6 @@ while True: window['-SPIN-'].update(value=lower) values['-SPIN-'] = lower # Change the values dictionary too so it'll be correct if used - print(values['-SPIN-']) + sg.Print('Spin Value:', values['-SPIN-'], relative_location=(-400, 0)) window.close() \ No newline at end of file