Skip to 0 minutes and 1 second Here is another example of how updates are used in a program, this time to represent buttons on an interface. To create the buttons, we create two objects of the class pushbutton named button one, and button two.
Skip to 0 minutes and 17 seconds Each button is an object in the program sense, and you can see that the buttons are each shown as a rectangle, giving us a visual representation of the button object.
Example: using objects to create a GUI
Here is another example to show how objects are used in a program – this time to represent buttons on an interface. This is just a demonstration of the principle - there is no need to type this code yourself as it requires you to install some extra software to get it working.
To create the buttons, we create two objects of the class
button1 = PushButton(app, text="Button 1", command=do_stuff) button2 = PushButton(app, text="Button 2", command=do_other_stuff)
Each button is now an object in the programming sense, and you can see that each button is shown as a rectangle, giving us a visual representation of the button object.
If you’re having trouble seeing the code in the video, make sure you are watching in HD and click the ‘Fullscreen’ button at the bottom right-hand side of the video.
© CC BY-SA 4.0