Skip to content

Commit 49cc8cd

Browse files
committed
add GroupBoxAndChackBox example
1 parent a3f0712 commit 49cc8cd

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env python3
2+
# -*-coding:utf-8 -*
3+
4+
import tkinter
5+
import tkinter.messagebox
6+
import tkinter.ttk
7+
8+
class Form1(tkinter.Tk):
9+
def __init__(self):
10+
super().__init__()
11+
12+
self.frame = tkinter.ttk.Frame(self)
13+
self.frame.pack(fill = tkinter.BOTH, expand=1)
14+
15+
self.groupBox1 = tkinter.ttk.LabelFrame(self.frame, text="Group 1", height=140, width=135)
16+
self.groupBox1.place(x=10, y=10)
17+
18+
self.checkBoxVar1 = tkinter.BooleanVar()
19+
self.checkBoxVar1.set(False)
20+
21+
self.checkBox1 = tkinter.ttk.Checkbutton(self.groupBox1, text="check 1", variable=self.checkBoxVar1)
22+
self.checkBox1.place(x = 10, y = 10)
23+
24+
self.checkBoxVar2 = tkinter.BooleanVar()
25+
self.checkBoxVar2.set(True)
26+
27+
self.checkBox2 = tkinter.ttk.Checkbutton(self.groupBox1, text="check 2", variable=self.checkBoxVar2)
28+
self.checkBox2.place(x = 10, y = 40)
29+
30+
self.checkBoxVar3 = tkinter.BooleanVar()
31+
self.checkBoxVar3.set(False)
32+
33+
self.checkBox3 = tkinter.ttk.Checkbutton(self.groupBox1, text="check 3", variable=self.checkBoxVar3)
34+
self.checkBox3.place(x = 10, y = 70)
35+
36+
self.groupBox2 = tkinter.ttk.LabelFrame(self.frame, text="Group 2", height=140, width=135)
37+
self.groupBox2.place(x=155, y=10)
38+
39+
self.checkBoxVar4 = tkinter.BooleanVar()
40+
self.checkBoxVar4.set(False)
41+
42+
self.checkBox4 = tkinter.ttk.Checkbutton(self.groupBox2, text="check 4", variable=self.checkBoxVar4)
43+
self.checkBox4.place(x = 10, y = 10)
44+
45+
self.checkBoxVar5 = tkinter.BooleanVar()
46+
self.checkBoxVar5.set(False)
47+
48+
self.checkBox5 = tkinter.ttk.Checkbutton(self.groupBox2, text="check 5", variable=self.checkBoxVar5)
49+
self.checkBox5.place(x = 10, y = 40)
50+
51+
self.checkBoxVar6 = tkinter.BooleanVar()
52+
self.checkBoxVar6.set(True)
53+
54+
self.checkBox6 = tkinter.ttk.Checkbutton(self.groupBox2, text="check 6", variable=self.checkBoxVar6)
55+
self.checkBox6.place(x = 10, y = 70)
56+
57+
self.geometry("300x160+200+100")
58+
self.title("GroupBox and CheckBox example")
59+
60+
def main(self=None):
61+
form = Form1()
62+
form.mainloop()
63+
64+
if __name__ == '__main__':
65+
Form1.main()

0 commit comments

Comments
 (0)