MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / main

Function main

DemoPrograms/Demo_Window_Background_Image.py:40–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38
39
40def main():
41
42 background_layout = [ title_bar('This is the titlebar', sg.theme_text_color(), sg.theme_background_color()),
43 [sg.Image(data=background_image)]]
44 window_background = sg.Window('Background', background_layout, no_titlebar=True, finalize=True, margins=(0, 0), element_padding=(0,0), right_click_menu=[[''], ['Exit',]])
45
46 window_background['-C-'].expand(True, False, False) # expand the titlebar's rightmost column so that it resizes correctly
47
48
49 # ------ Column Definition ------ #
50 column1 = [[sg.Text('Column 1', justification='center', size=(10, 1))],
51 [sg.Spin(values=('Spin Box 1', 'Spin Box 2', 'Spin Box 3'),
52 initial_value='Spin Box 1')],
53 [sg.Spin(values=['Spin Box 1', '2', '3'],
54 initial_value='Spin Box 2')],
55 [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 3')]]
56
57 layout = [
58 [sg.Text('Window + Background Image\nWith tkinter', size=(30, 2), justification='center', font=("Helvetica", 25), relief=sg.RELIEF_RIDGE)],
59 [sg.Text('Here is some text.... and a place to enter text')],
60 [sg.InputText('This is my text')],
61 [sg.Frame(layout=[
62 [sg.CBox('Checkbox', size=(10, 1)),
63 sg.CBox('My second checkbox!', default=True)],
64 [sg.Radio('My first Radio! ', "RADIO1", default=True, size=(10, 1)),
65 sg.Radio('My second Radio!', "RADIO1")]], title='Options', relief=sg.RELIEF_SUNKEN, tooltip='Use these to set flags')],
66 [sg.MLine(default_text='This is the default Text should you decide not to type anything', size=(35, 3)),
67 sg.MLine(default_text='A second multi-line', size=(35, 3))],
68 [sg.Combo(('Combobox 1', 'Combobox 2'),default_value='Combobox 1', size=(20, 1)),
69 sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85)],
70 [sg.OptionMenu(('Menu Option 1', 'Menu Option 2', 'Menu Option 3'))],
71 [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3)),
72 sg.Frame('Labelled Group', [[
73 sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25, tick_interval=25),
74 sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75),
75 sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10),
76 sg.Col(column1)]])
77 ],
78 [sg.Text('_' * 80)],
79 [sg.Text('Choose A Folder', size=(35, 1))],
80 [sg.Text('Your Folder', size=(15, 1), justification='right'),
81 sg.InputText('Default Folder'), sg.FolderBrowse()],
82 [sg.Submit(tooltip='Click to submit this form'), sg.Cancel()],
83 [sg.Text('Right Click To Exit', size=(30, 1), justification='center', font=("Helvetica", 25), relief=sg.RELIEF_SUNKEN)], ]
84
85 top_window = sg.Window('Everything bagel', layout, finalize=True, keep_on_top=True, grab_anywhere=False, transparent_color=sg.theme_background_color(), no_titlebar=True)
86
87 # window_background.send_to_back()
88 # top_window.bring_to_front()
89
90 while True:
91 window, event, values = sg.read_all_windows()
92 print(event, values)
93 if event is None or event == 'Cancel' or event == 'Exit':
94 print(f'closing window = {window.Title}')
95 break
96
97 top_window.close()

Callers 1

Calls 3

closeMethod · 0.95
expandMethod · 0.80
title_barFunction · 0.70

Tested by

no test coverage detected