PySimpleGUI/DemoPrograms/Demo_Column_And_Frames.py

54 lines
2.8 KiB
Python
Raw Normal View History

2019-10-03 03:29:07 +00:00
# this one long import has the effect of making the code more compact as there is no 'sg.' prefix required for Elements
import PySimpleGUI as sg
2019-12-24 23:52:47 +00:00
from PySimpleGUI import InputCombo, Combo, Multiline, ML, MLine, Checkbox, CB, Check, Button, B, Btn, ButtonMenu, Canvas, Column, Col, Combo, Frame, Graph, Image, InputText, Input, In, Listbox, LBox, Menu, Multiline, ML, MLine, OptionMenu, Output, Pane, ProgressBar, Radio, Slider, Spin, StatusBar, Tab, TabGroup, Table, Text, Txt, T, Tree, TreeData, VerticalSeparator, Window, Sizer
2019-10-03 03:29:07 +00:00
"""
Demo Columns and Frames
Demonstrates using mixture of Column and Frame elements to create a nice window layout.
A couple of the concepts shown here include:
* Using Columns and Frames with specific sizes on them
* Importing all required classes so that "sg." is not required on any objects. This makes the code more compact and readable
There are 3 columns. Two are side by side at the top and the third is along the bottom
"""
2019-12-24 23:52:47 +00:00
sg.theme('GreenTan')
2019-10-03 03:29:07 +00:00
col2 = Column([[Frame('Accounts:', [[Column([[Listbox(['Account '+str(i) for i in range(1, 16)],
key='-ACCT-LIST-', size=(15, 20)), ]], size=(150, 400))]])]], pad=(0, 0))
2019-10-03 03:29:07 +00:00
col1 = Column([
# Categories frame
[Frame('Categories:', [[Radio('Websites', 'radio1', default=True, key='-WEBSITES-', size=(10, 1)),
Radio('Software', 'radio1', key='-SOFTWARE-', size=(10, 1))]],)],
2019-10-03 03:29:07 +00:00
# Information frame
[Frame('Information:', [[Column([[Text('Account:')],
[Input(key='-ACCOUNT-IN-', size=(19, 1))],
[Text('User Id:')],
[Input(key='-USERID-IN-', size=(19, 1)),
Button('Copy', key='-USERID-')],
[Text('Password:')],
[Input(key='-PW-IN-', size=(19, 1)),
Button('Copy', key='-PASS-')],
[Text('Location:')],
[Input(key='-LOC-IN-', size=(19, 1)),
Button('Copy', key='-LOC')],
[Text('Notes:')],
[Multiline(key='-NOTES-', size=(25, 5))],
], size=(235, 350), pad=(0, 0))]])], ], pad=(0, 0))
col3 = Column([[Frame('Actions:', [[Column([[Button('Save'), Button(
'Clear'), Button('Delete'), ]], size=(450, 45), pad=(0, 0))]])]], pad=(0, 0))
layout = [[col1, col2], [col3]]
2019-10-03 03:29:07 +00:00
window = Window('Passwords', layout)
while True:
event, values = window.read()
print(event, values)
if event is None:
break
2019-10-03 03:29:07 +00:00
window.close()