From the course: Rapid Application Development with Python
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
More on buttons - Python Tutorial
From the course: Rapid Application Development with Python
More on buttons
- [Teacher] Let's take a look at how we might activate and deactivate buttons. I'll add a second button for state change. I'll put this immediately below line seven. I'll call it b_state, and it's a type wx. Button again, self.panel, wx.ID_ANY, and the text on it will be "Disable," and I'll position it at 60, 20. I'll bind it to an event handler, again, of type wx.EVT_BUTTON, and this time it will be self.on_state, and it will bind to self.b_state, our state button. And I'll add an event handler for it. def on_state(self, event). In the event handler, I'll check its current state and switch it. I can do this using the GetLabel method. If self.b_state.GetLabel() is "Disable," it's currently enabled. So the button press needs to disable it and change the text on the button. self.b_test.Disable(). self.b_state.SetLabel(), and we'll set it to "Enable." Otherwise, we'll self.b_test.Enable(), and self.b_state.SetLabel()…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Introducing wxPython2m 13s
-
(Locked)
Class-based skeleton4m 37s
-
(Locked)
Labels and buttons3m 38s
-
(Locked)
More on buttons3m 33s
-
(Locked)
Checkboxes and radio buttons6m 43s
-
(Locked)
Text entry controls4m 36s
-
(Locked)
Use spinners to set values4m 58s
-
(Locked)
Create lists to select from6m 9s
-
(Locked)
Use combo boxes54s
-
(Locked)
Compose a menu bar6m 46s
-
(Locked)
Challenge36s
-
(Locked)
Solution2m 54s
-
-
-
-