def build(self, tk, parent): self.box1 = CheckBox(tk, checked=True) self.box2 = CheckBox(tk) self.box1.click = self.click_handler self.box2.click = self.click_handler parent.append(self.box1) parent.append(self.box2)
def build(self, tk, parent): parent.setLayout(VBox()) box1 = CheckBox(tk, text="Option 1") box2 = CheckBox(tk, checked=True, text="Option 2") box3 = CheckBox(tk, text="Option 3") box4 = CheckBox(tk, text="Option 4") parent.append(box1) parent.append(box2) parent.append(box3) parent.append(box4) box4.checked = True selection = StaticText(tk) parent.append(selection) def handle_click(e): selection.text = ", ".join(b.text for b in (box1, box2, box3, box4) if b.checked) box1.click = box2.click = box3.click = box4.click = handle_click handle_click(None)
def build(self, tk, parent): button = Button(tk, "Click me!") t1 = StaticText(tk, 'Enabled:') c1 = CheckBox(tk) t2 = StaticText(tk, 'Visible:') c2 = CheckBox(tk, checked=True) def toggle_state(x): button.enabled = not button.enabled c1.click = toggle_state def toggle_visibility(x): button.visible = c2.checked c2.click = toggle_visibility button.enabled = False parent.append(button) parent.append(t1) parent.append(c1) parent.append(t2) parent.append(c2)