2018-11-10 22:26:59 +00:00
|
|
|
import PySimpleGUIQt as sg
|
2018-11-18 01:05:37 +00:00
|
|
|
from random import randint
|
2018-11-10 22:26:59 +00:00
|
|
|
|
2018-11-18 01:05:37 +00:00
|
|
|
def main():
|
|
|
|
sg.ChangeLookAndFeel('GreenTan')
|
2018-11-24 22:52:31 +00:00
|
|
|
# sg.SetOptions(element_padding=(0,0))
|
2018-11-18 01:05:37 +00:00
|
|
|
# ------ Menu Definition ------ #
|
|
|
|
menu_def = [['&File', ['&Open', '&Save', '&Properties', 'E&xit']],
|
|
|
|
['&Edit', ['&Paste', ['Special', 'Normal', ], 'Undo'], ],
|
|
|
|
['&Toolbar', ['Command &1', 'Command &2', 'Command &3', 'Command &4']],
|
|
|
|
['&Help', '&About...'], ]
|
|
|
|
|
|
|
|
treedata = sg.TreeData()
|
|
|
|
|
|
|
|
treedata.Insert("", '_A_', 'Tree Item 1', [1,2,3], )
|
|
|
|
treedata.Insert("", '_B_', 'B', [4,5,6], )
|
|
|
|
treedata.Insert("_A_", '_A1_', 'Sub Item 1', ['can','be','anything'],)
|
|
|
|
treedata.Insert("", '_C_', 'C', [], )
|
|
|
|
treedata.Insert("_C_", '_C1_', 'C1', ['or'], )
|
|
|
|
treedata.Insert("_A_", '_A2_', 'Sub Item 2', [None, None])
|
|
|
|
treedata.Insert("_A1_", '_A3_', 'A30', ['getting deep'])
|
|
|
|
treedata.Insert("_C_", '_C2_', 'C2', ['nothing', 'at', 'all'])
|
|
|
|
|
|
|
|
for i in range(100):
|
|
|
|
treedata.Insert('_C_', i, i, [])
|
|
|
|
|
|
|
|
|
|
|
|
frame1 = [
|
2018-11-24 22:52:31 +00:00
|
|
|
[sg.Input('Input Text', size=(250,35)), sg.Stretch()],
|
|
|
|
[sg.Multiline(size=(250,75),default_text='Multiline Input'),
|
|
|
|
sg.MultilineOutput(size=(250,75),default_text='Multiline Output')],
|
2018-11-18 01:05:37 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
frame2 = [
|
2018-11-24 22:52:31 +00:00
|
|
|
[sg.Listbox(['Listbox 1','Listbox 2','Listbox 3'], size=(200,85))],
|
|
|
|
[sg.Combo(['Combo item 1','Combo item 2','Combo item 3'], size=(200,35))],
|
|
|
|
[sg.Spin([1,2,3], size=(40,30))],
|
2018-11-18 01:05:37 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
frame3 = [
|
2018-11-24 22:52:31 +00:00
|
|
|
[sg.Checkbox('Checkbox1', True),sg.Checkbox('Checkbox1')],
|
|
|
|
[sg.Radio('Radio Button1', 1), sg.Radio('Radio Button2', 1, default=True), sg.Stretch()],
|
2018-11-18 01:05:37 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
frame4 = [
|
2018-11-24 22:52:31 +00:00
|
|
|
[sg.Slider(range=(0,100), orientation='v', size=(3, 30), default_value=40), sg.Dial(range=(0,100),tick_interval=50, size=(150,150), default_value=40), sg.Stretch()],
|
2018-11-18 01:05:37 +00:00
|
|
|
]
|
|
|
|
matrix = [[str(x*y) for x in range(4)] for y in range(3)]
|
|
|
|
|
|
|
|
frame5 = [
|
2018-11-24 22:52:31 +00:00
|
|
|
[sg.Table(values=matrix, max_col_width=25,
|
|
|
|
auto_size_columns=True, display_row_numbers=True, change_submits=False, bind_return_key=True, justification='right', num_rows=8, alternating_row_color='lightblue', key='_table_', text_color='black'),
|
|
|
|
sg.Tree(data=treedata, headings=['col1', 'col2', 'col3'],change_submits=True, auto_size_columns=True, num_rows=10, col0_width=10, key='_TREE_', show_expanded=True, size=(200,150)), sg.Stretch()],
|
2018-11-18 01:05:37 +00:00
|
|
|
]
|
|
|
|
|
2018-11-24 22:52:31 +00:00
|
|
|
graph_elem = sg.Graph((880,150), (0,0), (600,300), key='+GRAPH+')
|
2018-11-18 01:05:37 +00:00
|
|
|
|
|
|
|
frame6 = [
|
2018-11-24 22:52:31 +00:00
|
|
|
[graph_elem, sg.Stretch()],
|
2018-11-18 01:05:37 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
tab1 = sg.Tab('Graph Number 1',frame6)
|
|
|
|
tab2 = sg.Tab('Graph Number 2',[[]])
|
|
|
|
|
|
|
|
layout = [
|
2018-11-24 22:52:31 +00:00
|
|
|
[sg.Menu(menu_def)],
|
|
|
|
[sg.Image(data_base64=logo),sg.Frame('Input Text Group', frame1, title_color='red'), sg.Stretch()],
|
|
|
|
[sg.Frame('Multiple Choice Group', frame2, title_color='green'),
|
|
|
|
sg.Frame('Binary Choice Group', frame3, title_color='purple'),
|
|
|
|
sg.Frame('Variable Choice Group', frame4, title_color='blue'),sg.Stretch()],
|
|
|
|
[sg.Frame('Structured Data Group', frame5, title_color='red'), ],
|
|
|
|
# [sg.Frame('Graphing Group', frame6)],
|
|
|
|
[sg.TabGroup([[tab1,tab2]])],
|
|
|
|
[sg.ProgressBar(max_value=600, start_value=400, size=(600,25), key='+PROGRESS+'), sg.Stretch(),
|
|
|
|
sg.ButtonMenu('&Menu', ['Menu', ['&Pause Graph', 'Menu item']], key='_MENU_'),
|
|
|
|
sg.Button('Button'), sg.Button('Exit')],
|
2018-11-18 01:05:37 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
window = sg.Window('Window Title',
|
2018-11-24 22:52:31 +00:00
|
|
|
font=('Helvetica', 13),
|
|
|
|
default_button_element_size=(100,30),
|
|
|
|
auto_size_buttons=False,
|
|
|
|
default_element_size=(200,22)
|
|
|
|
).Layout(layout).Finalize()
|
2018-11-18 01:05:37 +00:00
|
|
|
graph_elem.DrawCircle((200,200), 50, 'blue')
|
|
|
|
i=0
|
2018-11-24 22:52:31 +00:00
|
|
|
graph_paused = False
|
2018-11-18 01:05:37 +00:00
|
|
|
while True: # Event Loop
|
|
|
|
# sg.TimerStart()
|
|
|
|
event, values = window.Read(timeout=0)
|
2018-11-24 22:52:31 +00:00
|
|
|
if event is None or event == 'Exit' :
|
2018-11-18 01:05:37 +00:00
|
|
|
break
|
2018-11-24 22:52:31 +00:00
|
|
|
if event == 'Button':
|
|
|
|
print(event, values)
|
|
|
|
if values['_MENU_'] == 'Pause Graph':
|
|
|
|
graph_paused = not graph_paused
|
|
|
|
if not graph_paused:
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
if i < 600:
|
|
|
|
graph_elem.DrawLine((i,0),(i,randint(0,300)), width=1, color='#{:06x}'.format(randint(0,0xffffff)))
|
|
|
|
else:
|
|
|
|
graph_elem.Move(-1,0)
|
|
|
|
graph_elem.DrawLine((i,0),(i,randint(0,300)), width=1, color='#{:06x}'.format(randint(0,0xffffff)))
|
|
|
|
|
|
|
|
window.FindElement('+PROGRESS+').UpdateBar(i%600)
|
|
|
|
|
2018-11-18 01:05:37 +00:00
|
|
|
# sg.TimerStop()
|
|
|
|
window.Close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logo = b'iVBORw0KGgoAAAANSUhEUgAAAMgAAACVCAYAAAAdSLW3AAAACXBIWXMAABcRAAAXEQHKJvM/AAAenklEQVR42u2deXxM1/vHn3OXWTOTTPZVhAgRUWIPvhS11q50UYoqqpYudPm2uv9ain6rlG5o0UYtLVW6WVpC1S4RW0hkTyQzk9mXu/z+yGIymUlSJaF93l73ZXKXMzfnnM99zvOc554QURQBQRDPUFgFCIICQRAUCIKgQBAEBYIgKBAEQYEgCAoEQVAgCIICQRAEBYIgKBAEQYEgCAoEQVAgCIICQRAUCIKgQBAEBYIgKBAEQVAgCIICQRAUCIKgQBAEBYIgKBAEQYEgCAoEQVAgCIKgQBAEBYIgKBAEQYEgCAoEQVAgCIICQRAUCIKgQBAEBYIgCAoEQVAgCIICQRAUCII0NQxWQePg5AU6p6S8WX6pISRArTDEhvtflrK0s8EFiE4anEUBAAwPbLAWCC1iraJA7npK9ObArQczpm47dH6m3myLEkWRIkBEtUJaMLZ3/MrH7uuwwkcusXktgDcroCxlGmi3PwO8MRIIEYH2zQV1nxTwu38DyOMuABCs6NsEEUV8EN0ujl8q6PT6xt/W5pUaEsFzLxb7tI/e8Nbkfk/6yCXmWkc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