user interface - Checkbox not showing up python -
i making gui control robot.
this code far:
from tkinter import * #importing tkinter class application(frame): #making frame def __init__(self, master=none): frame.__init__(self, master) self.master.title("vinny's myro controller version 0.1") #setting name of program/window self.master.geometry("550x365+300+300") #window dimensions self.master.rowconfigure(0, weight=2) #how space rows take self.master.columnconfigure(0, weight=1) #how space columns take ''' \/ bottom buttons \/ ''' self.master.button1 = button(master, text = "take picture") #bottom button supposed take pic. self.master.button1.grid(row=6, column=0, sticky=w+e) self.master.button2 = button(master, text = "honk horn") #bottom button supposed honk horn. self.master.button2.grid(row=6, column=1, sticky=w+e) self.master.button3 = button(master, text = "get sensor data") #bottom button supposed data sensors. self.master.button3.grid(row=6, column=2, sticky=w+e) ''' /\ bottom buttons /\ ''' ''' \/ left red frame contains arrows move robot \/ ''' self.frame1 = frame(master, bg="red") #background color self.frame1.grid(row = 0, column = 0, rowspan = 1, columnspan = 1, sticky = w+e+n+s, padx=10, pady=10) self.frame1.forward = button(self.frame1, text = "forward", width=30, height=3) #forward button self.frame1.forward.place(x=63, y=75) #button position self.frame1.right = button(self.frame1, text = "right", width=12, height=3) #right button self.frame1.right.place(x=189, y=131) #button position self.frame1.backward = button(self.frame1, text = "backward", width=30, height=3) #backward button self.frame1.backward.place(x=63, y=187) #button position self.frame1.left = button(self.frame1, text = "left", width=12, height=3) #left button self.frame1.left.place(x=63, y=131) #button position ''' /\ left red frame contains arrows move robot /\ ''' self.frame2 = frame(master, bg="green") self.frame2.grid(row = 0, column = 1, rowspan = 3, columnspan = 3, sticky = w+e+n+s, padx=10, pady=10) self.frame2.button5 = button(self.frame2, text = "test") self.frame2.button5.grid(row=6, column=2) self.frame2.light = booleanvar() self.frame2.chk1 = checkbutton(self, text = "lights", variable = self.frame2.light, command = 1+1) self.frame2.chk1.grid(row = 0, column = 3, padx=10, pady = 10) root = tk() app = application(master=root) app.mainloop()
note piece of code:
self.frame2.light = booleanvar() self.frame2.chk1 = checkbutton(self, text = "lights", variable = self.frame2.light, command = 1+1) self.frame2.chk1.grid(row = 0, column = 3, padx=10, pady = 10)
somehow, can place button inside frame, not checkbox. need checkbox in order data robot's sensors.
i've tried using grid , place.
could me?
screenshot:
thanks
the problem creating checkbutton child of self
rather child of self.frame2
. change checkbutton be:
self.frame2.chk1 = checkbutton(self.frame2, ...)
Comments
Post a Comment