|
import tkinter
# from Tkinter import *
class MyApp(tkinter.Frame):
def __init__(self, master=None):
tkinter.Frame.__init__(self, master)
self.pack()
self.setGUI()
def setGUI(self):
self.group = tkinter.LabelFrame(self, text="Noten")
self.group.pack(fill="both", expand="yes")
self.chk1= tkinter.Checkbutton(self)
self.chk1["text"] = "Eins"
self.chk1.pack()
self.chk2= tkinter.Checkbutton(self)
self.chk2["text"] = "Zwei"
self.chk2.pack()
self.chk3= tkinter.Checkbutton(self)
self.chk3["text"] = "Drei"
self.chk3.pack()
self.chkProperty1 = tkinter.BooleanVar()
self.chkProperty1.set(True)
self.chk1["variable"] = self.chkProperty1
self.chkProperty2 = tkinter.BooleanVar()
self.chkProperty2.set(False)
self.chk2["variable"] = self.chkProperty2
self.chkProperty3 = tkinter.BooleanVar()
self.chkProperty3.set(False)
self.chk3["variable"] = self.chkProperty3
self.bnOk = tkinter.Button(self)
self.bnOk["text"] = "Abbruch"
self.bnOk["command"] = self.quit
self.bnOk.pack(side="right")
self.bnTest = tkinter.Button(self)
self.bnTest["text"] = "Test Checkbox"
self.bnTest["command"] = self.onTestChk
self.bnTest.pack(side="right")
def onTestChk(self):
print( str(self.chkProperty1.get()) )
print( str(self.chkProperty2.get()) )
print( str(self.chkProperty3.get()) )
root = tkinter.Tk()
root.title("CheckBox")
root.geometry("250x150")
app = MyApp(root)
app.mainloop()
|
|