commit
228db6be75
|
@ -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':
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
|
@ -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()
|
Loading…
Reference in New Issue