dimanche 8 mars 2020

Unable to create any widgets in label frame in a class [duplicate]

This error has me stumped, since I have never seen this behavior. I see a widget being created on the main window, instead of the label frame. Here is my code:

class createActivity(Toplevel):
    def __init__(self):


        Toplevel.__init__(self)
        self.configure(background="#eff0f1")
        self.geometry('700x700')
        self.resizable(0,0)
        self.wm_iconbitmap(os.getcwd()+'/Activity.ico')
        self.title("Create Activity")
        Toplevel.grab_set(self)

        findDeptQuery="SELECT [Department] FROM AllDepartments"
        findRoomQuery = "SELECT [Room] FROM AllRooms"

        allDepartments=cur.execute(findDeptQuery).fetchall()
        deptList=[]
        allRooms = cur.execute(findRoomQuery).fetchall()
        roomList = []

        '''
        Setting up Front End

        '''
        for item in allRooms:
            roomList.append(item[0])

        for item in allDepartments:
            deptList.append(item[0])

        self.deptLabel = ttk.Label(self,text="Department: ").grid(row=0,column=0,padx=10,pady=10)
        self.deptDropdown = ttk.Combobox(self,state='readonly',values=deptList)
        if len(deptList)!=0:
            self.deptDropdown.current(0)
        self.deptDropdown.grid(row=0,column=1,pady=10)
        self.activityLabel = ttk.Label(self,text="Activity: ").grid(row=0,column=2,padx=10,pady=10)
        self.activityDropdown = ttk.Combobox(self)
        self.activityDropdown.grid(row=0,column=3,pady=10)
        self.activityDesc = ttk.Entry(self,width=25)
        self.activityDesc.grid(row=0,column=4,padx=10,pady=10)
        self.activityDesc.insert(0,"Description")
        self.frameOfFields = ttk.LabelFrame(self,text="Select the fields required for this activity",width=680,height=600).grid(row=2,column=0,columnspan=5)

####################### SOURCE OF ERROR#########################        
        self.checkButtonOrder = ttk.Checkbutton(self.frameOfFields,text="Order#").grid(row=0,column=0)

Checkbox on Main Window

Why is that checkbox not on the labelframe, but on the main window?

Thank you!




Aucun commentaire:

Enregistrer un commentaire