-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.py
More file actions
186 lines (143 loc) · 7.07 KB
/
example.py
File metadata and controls
186 lines (143 loc) · 7.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# coding: utf-8
import azure_dark
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
azure_dark.apply_theme(root)
root.title('Azure')
window_height = 530
window_width = 800
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x_cordinate = int((screen_width/2) - (window_width/2))
y_cordinate = int((screen_height/2) - (window_height/2))
root.geometry("{}x{}+{}+{}".format(window_width, window_height, x_cordinate, y_cordinate))
options = ['', 'OptionMenu', 'Value 1', 'Value 2']
a = tk.BooleanVar()
b = tk.BooleanVar(value=True)
c = tk.BooleanVar()
d = tk.IntVar(value=2)
e = tk.StringVar(value=options[1])
f = tk.BooleanVar()
g = tk.IntVar(value=75)
h = tk.BooleanVar(value=1)
frame1 = ttk.LabelFrame(root, text='Checkbuttons', width=210, height=200)
frame1.place(x=20, y=12)
check1 = ttk.Checkbutton(frame1, text='Unchecked', variable=a)
check1.place(x=20, y=20)
check2 = ttk.Checkbutton(frame1, text='Checked', variable=b)
check2.place(x=20, y=60)
check3 = ttk.Checkbutton(frame1, text='Third state', variable=c)
check3.state(['alternate'])
check3.place(x=20, y=100)
check4 = ttk.Checkbutton(frame1, text='Disabled', state='disabled')
check4.place(x=20, y=140)
frame2 = ttk.LabelFrame(root, text='Radiobuttons', width=210, height=160)
frame2.place(x=20, y=252)
radio1 = ttk.Radiobutton(frame2, text='Deselected', variable=d, value=1)
radio1.place(x=20, y=20)
radio2 = ttk.Radiobutton(frame2, text='Selected', variable=d, value=2)
radio2.place(x=20, y=60)
radio3 = ttk.Radiobutton(frame2, text='Disabled', state='disabled')
radio3.place(x=20, y=100)
entry = ttk.Entry(root)
entry.place(x=250, y=20)
entry.insert(0, 'Entry')
spin = ttk.Spinbox(root, from_=0, to=100, increment=0.1)
spin.place(x=250, y=70)
spin.insert(0, 'Spinbox')
combo1 = ttk.Combobox(root, value=['Combobox', 'Editable item 1', 'Editable item 2'])
combo1.current(0)
combo1.place(x=250, y=120)
combo2 = ttk.Combobox(root, state='readonly', value=['Readonly combobox', 'Item 1', 'Item 2'])
combo2.current(0)
combo2.place(x=250, y=170)
menu = tk.Menu(root, tearoff=0)
menu.add_command(label='Menu item 1')
menu.add_command(label='Menu item 2')
menu.add_separator()
menu.add_command(label='Menu item 3')
menu.add_command(label='Menu item 4')
menubtn = ttk.Menubutton(root, text='Menubutton', menu=menu, direction='below')
menubtn.place(x=250, y=220)
menubtn = ttk.OptionMenu(root, e, *options)
menubtn.place(x=250, y=270)
def callback(): print('Button callback')
button = ttk.Button(root, text='Button', command=callback)
button.place(x=250, y=320)
accentbutton = ttk.Button(root, text='Accent button', style='Accentbutton', command=callback)
accentbutton.place(x=250, y=370)
toggle = ttk.Checkbutton(root, text='Toggle button', style='Togglebutton', variable=f)
toggle.place(x=250, y=420)
scale = ttk.Scale(root, to=100, variable=g)
scale.place(x=80, y=430)
g2 = tk.IntVar()
g.trace_add([ 'write', 'unset', ], lambda *args: g2.set(100 - g.get()))
g.set(g.get()) # init g2
progress = ttk.Progressbar(root, variable=g2, mode='determinate')
progress.place(x=80, y=480)
switch = ttk.Checkbutton(root, text='Toggle switch', style='Switch', variable=h)
switch.place(x=250, y=470)
sep1 = ttk.Separator()
sep1.place(x=20, y=235, width=210)
notebook = ttk.Notebook(root)
notebookTab1 = ttk.Frame(notebook, width=335, height=150)
notebook.add(notebookTab1, text='Tab 1')
notebookTab2 = ttk.Frame(notebook, width=335, height=150)
notebook.add(notebookTab2, text='Tab 2')
notebookTab3 = ttk.Frame(notebook, width=335, height=150)
notebook.add(notebookTab3, text='Tab 3')
notebook.place(x=420, y=330)
#inside tab1
ttk.Scale(notebookTab1, from_=100, to=0, variable=g, orient=tk.VERTICAL).pack(side=tk.LEFT)
ttk.Progressbar(notebookTab1, variable=g, mode='determinate', orient=tk.VERTICAL).pack(side=tk.LEFT)
treeFrame = ttk.Frame(root)
treeFrame.place(x=420, y=20)
treeScroll = ttk.Scrollbar(treeFrame)
treeScroll.pack(side='right', fill='y')
treeview = ttk.Treeview(treeFrame, selectmode="extended", yscrollcommand=treeScroll.set, columns=(1, 2), height=12)
treeview.pack()
treeScroll.config(command=treeview.yview)
treeview.column("#0", width=120)
treeview.column(1, anchor='w', width=100)
treeview.column(2, anchor='w', width=100)
treeview.heading("#0", text="Treeview", anchor='center')
treeview.heading(1, text="Column 1", anchor='center')
treeview.heading(2, text="Column 2", anchor='center')
treeview.insert(parent='', index='end', iid=1, text="Parent", values=("Item 1", "Value 1"))
treeview.item(1, open=True)
treeview.insert(parent=1, index='end', iid=2, text="Child", values=("Subitem 1.1", "Value 1.1"))
treeview.insert(parent=1, index='end', iid=3, text="Child", values=("Subitem 1.2", "Value 1.2"))
treeview.insert(parent=1, index='end', iid=4, text="Child", values=("Subitem 1.3", "Value 1.3"))
treeview.insert(parent=1, index='end', iid=5, text="Child", values=("Subitem 1.4", "Value 1.4"))
treeview.insert(parent='', index='end', iid=6, text="Parent", values=("Item 2", "Value 2"))
treeview.item(6, open=True)
treeview.insert(parent=6, index='end', iid=13, text="Child", values=("Subitem 2.1", "Value 2.1"))
treeview.insert(parent=6, index='end', iid=7, text="Sub-parent", values=("Subitem 2.2", "Value 2.2"))
treeview.item(7, open=True)
treeview.insert(parent=7, index='end', iid=8, text="Child", values=("Subitem 2.2.1", "Value 2.2.1"))
treeview.insert(parent=7, index='end', iid=9, text="Child", values=("Subitem 2.2.2", "Value 2.2.2"))
treeview.selection_set(9)
treeview.insert(parent=7, index='end', iid=10, text="Child", values=("Subitem 2.2.3", "Value 2.2.3"))
treeview.insert(parent=6, index='end', iid=11, text="Child", values=("Subitem 2.3", "Value 2.3"))
treeview.insert(parent=6, index='end', iid=12, text="Child", values=("Subitem 2.4", "Value 2.4"))
treeview.insert(parent='', index='end', iid=14, text="Parent", values=("Item 3", "Value 3"))
treeview.item(14, open=True)
treeview.insert(parent=14, index='end', iid=15, text="Child", values=("Subitem 3.1", "Value 3.1"))
treeview.insert(parent=14, index='end', iid=16, text="Child", values=("Subitem 3.2", "Value 3.2"))
treeview.insert(parent=14, index='end', iid=17, text="Child", values=("Subitem 3.3", "Value 3.3"))
treeview.insert(parent=14, index='end', iid=18, text="Child", values=("Subitem 3.4", "Value 3.4"))
treeview.insert(parent='', index='end', iid=19, text="Parent", values=("Item 4", "Value 4"))
treeview.item(19, open=True)
treeview.insert(parent=19, index='end', iid=20, text="Child", values=("Subitem 4.1", "Value 4.1"))
treeview.insert(parent=19, index='end', iid=21, text="Sub-parent", values=("Subitem 4.2", "Value 4.2"))
treeview.item(21, open=True)
treeview.insert(parent=21, index='end', iid=22, text="Child", values=("Subitem 4.2.1", "Value 4.2.1"))
treeview.insert(parent=21, index='end', iid=23, text="Child", values=("Subitem 4.2.2", "Value 4.2.2"))
treeview.insert(parent=21, index='end', iid=24, text="Child", values=("Subitem 4.2.3", "Value 4.2.3"))
treeview.insert(parent=19, index='end', iid=25, text="Child", values=("Subitem 4.3", "Value 4.3"))
#last widget is over others
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
ttk.Sizegrip(root).grid(sticky=tk.SE)
root.mainloop()