def initLabelFrame(self, labels): # We init the frame: if self.labelFrame is not None: self.labelFrame.destroy() self.labelIds = [] self.labelEntries = [] self.labelFrame = Frame(self) self.labelFrame.grid(row=self.labelFrameRow, column=11, sticky="nsew") self.labelFrame.columnconfigure(0, weight=1) # We init the row counter: i = 0 # We make the head message: self.labelFrame.rowconfigure(i, weight=1) title = Message(self.labelFrame, text="Labels", **self.headMessagesOption) title.grid(row=i, column=0, sticky='nsew', pady=10) i += 1 # For each label: for id, label in labels.items(): try: # We make the message: currentMessage = None if label["type"] != LABEL_TYPE.checkbutton or dictContains( label, "shorttitle"): currentMessage = Message( self.labelFrame, text=label["title"], width=self.messageWidth, font=self.messageFont ) # bg="white", foreground="black" # According to the label type: if not dictContains( label, "type") or label["type"] == LABEL_TYPE.scale: # We make the entry: currentEntry = Scale\ ( self.labelFrame, from_=label["from"] if dictContains(label, "from") else 0.0, to=label["to"] if dictContains(label, "to") else 1.0, orient=HORIZONTAL, resolution=label["resolution"] if dictContains(label, "resolution") else 0.05, ) currentEntry.set(label["default"] if dictContains( label, "default") else 0.5) # We save the entry: self.labelEntries.append(currentEntry) elif label["type"] == LABEL_TYPE.checkbutton: var = BooleanVar() currentEntry = Checkbutton\ ( self.labelFrame, text=label["shorttitle"] if dictContains(label, "shorttitle") else label["title"], variable=var, ) if dictContains(label, "default") and label["default"]: currentEntry.select() # We save the entry: self.labelEntries.append(var) elif label["type"] == LABEL_TYPE.radiobutton: vals = [] etiqs = [] for k, v in label["options"].items(): vals.append(k) etiqs.append(v) var = IntVar() var.set(vals[1]) currentEntry = [] for i in range(len(vals)): currentEtiq = etiqs[i] currentVal = vals[i] c = Radiobutton\ ( self.labelFrame, text=currentEtiq, variable=var, value=currentVal, ) currentEntry.append(c) if dictContains( label, "default") and label["default"] == currentVal: c.select() self.labelEntries.append(var) # We save the id: self.labelIds.append(id) # We grid the message: if currentMessage is not None: self.labelFrame.rowconfigure(i, weight=1) currentMessage.grid(row=i, column=0, sticky="nsew") i += 1 # We grid the entry: self.labelFrame.rowconfigure(i, weight=1) if isinstance(currentEntry, list): for c in currentEntry: c.grid(row=i, column=0, sticky="nsw") i += 1 else: currentEntry.grid(row=i, column=0, sticky="nsew") i += 1 # We make a separator: self.labelFrame.rowconfigure(i, weight=1) sep = Separator(self.labelFrame, orient=HORIZONTAL) sep.grid(row=i, column=0, sticky='nsew', pady=10) i += 1 except Exception as e: logException(e, self)