2018-09-27 20:24:09 +00:00
|
|
|
#!/usr/bin/env python
|
2019-10-23 20:10:03 +00:00
|
|
|
'''
|
|
|
|
Example of (almost) all widgets, that you can use in PySimpleGUI.
|
|
|
|
'''
|
2018-08-18 21:22:38 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
import PySimpleGUI as sg
|
|
|
|
|
2020-05-07 10:22:59 +00:00
|
|
|
|
|
|
|
sg.theme('Dark Red')
|
2019-12-24 23:52:47 +00:00
|
|
|
# sg.set_options(text_color='black', background_color='#A6B2BE', text_element_background_color='#A6B2BE')
|
2018-09-21 03:44:47 +00:00
|
|
|
# ------ Menu Definition ------ #
|
2018-09-29 17:48:48 +00:00
|
|
|
menu_def = [['&File', ['&Open', '&Save', 'E&xit', 'Properties']],
|
|
|
|
['&Edit', ['Paste', ['Special', 'Normal', ], 'Undo'], ],
|
|
|
|
['&Help', '&About...'], ]
|
2018-09-21 03:44:47 +00:00
|
|
|
|
|
|
|
# ------ Column Definition ------ #
|
2019-12-24 23:52:47 +00:00
|
|
|
column1 = [[sg.Text('Column 1', justification='center', size=(10, 1))],
|
2019-10-23 20:10:03 +00:00
|
|
|
[sg.Spin(values=('Spin Box 1', '2', '3'),
|
|
|
|
initial_value='Spin Box 1')],
|
2020-05-07 10:22:59 +00:00
|
|
|
[sg.Spin(values=['Spin Box 1', '2', '3'],
|
2019-10-23 20:10:03 +00:00
|
|
|
initial_value='Spin Box 2')],
|
2018-09-10 22:42:05 +00:00
|
|
|
[sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 3')]]
|
|
|
|
|
|
|
|
layout = [
|
2018-09-21 03:44:47 +00:00
|
|
|
[sg.Menu(menu_def, tearoff=True)],
|
2019-10-23 20:10:03 +00:00
|
|
|
[sg.Text('(Almost) All widgets in one Window!', size=(
|
|
|
|
30, 1), justification='center', font=("Helvetica", 25), relief=sg.RELIEF_RIDGE)],
|
2018-09-10 22:42:05 +00:00
|
|
|
[sg.Text('Here is some text.... and a place to enter text')],
|
|
|
|
[sg.InputText('This is my text')],
|
2018-09-19 13:36:17 +00:00
|
|
|
[sg.Frame(layout=[
|
2019-10-23 20:10:03 +00:00
|
|
|
[sg.CBox('Checkbox', size=(10, 1)),
|
|
|
|
sg.CBox('My second checkbox!', default=True)],
|
|
|
|
[sg.Radio('My first Radio! ', "RADIO1", default=True, size=(10, 1)),
|
2019-12-24 23:52:47 +00:00
|
|
|
sg.Radio('My second Radio!', "RADIO1")]], title='Options', relief=sg.RELIEF_SUNKEN, tooltip='Use these to set flags')],
|
2019-10-23 20:10:03 +00:00
|
|
|
[sg.MLine(default_text='This is the default Text should you decide not to type anything', size=(35, 3)),
|
|
|
|
sg.MLine(default_text='A second multi-line', size=(35, 3))],
|
2019-12-24 23:52:47 +00:00
|
|
|
[sg.Combo(('Combobox 1', 'Combobox 2'),default_value='Combobox 1', size=(20, 1)),
|
2018-09-10 22:42:05 +00:00
|
|
|
sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85)],
|
2019-10-23 20:10:03 +00:00
|
|
|
[sg.OptionMenu(('Menu Option 1', 'Menu Option 2', 'Menu Option 3'))],
|
2018-09-10 22:42:05 +00:00
|
|
|
[sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3)),
|
2019-10-23 20:10:03 +00:00
|
|
|
sg.Frame('Labelled Group', [[
|
|
|
|
sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25, tick_interval=25),
|
|
|
|
sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75),
|
|
|
|
sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10),
|
2019-12-24 23:52:47 +00:00
|
|
|
sg.Col(column1)]])
|
2019-10-23 20:10:03 +00:00
|
|
|
],
|
2018-09-10 22:42:05 +00:00
|
|
|
[sg.Text('_' * 80)],
|
|
|
|
[sg.Text('Choose A Folder', size=(35, 1))],
|
2019-10-23 20:10:03 +00:00
|
|
|
[sg.Text('Your Folder', size=(15, 1), justification='right'),
|
2018-09-10 22:42:05 +00:00
|
|
|
sg.InputText('Default Folder'), sg.FolderBrowse()],
|
2018-10-15 20:07:23 +00:00
|
|
|
[sg.Submit(tooltip='Click to submit this form'), sg.Cancel()]]
|
2018-09-10 22:42:05 +00:00
|
|
|
|
2020-05-07 10:22:59 +00:00
|
|
|
window = sg.Window('Everything bagel', layout)
|
2018-09-21 03:44:47 +00:00
|
|
|
|
2020-05-07 10:22:59 +00:00
|
|
|
event, values = window.read(close=True)
|
2019-10-23 20:10:03 +00:00
|
|
|
sg.popup('Title',
|
2018-09-24 22:01:00 +00:00
|
|
|
'The results of the window.',
|
2018-10-15 20:07:23 +00:00
|
|
|
'The button clicked was "{}"'.format(event),
|
2018-09-21 03:44:47 +00:00
|
|
|
'The values are', values)
|