Button

3 minutes
Share the link to this page
Copied
  Completed
The Button widget is a standard Tkinter widget used to implement various kinds of buttons. Buttons can contain text or images, and you can associate a Python function or method with each button. When the button is pressed, Tkinter automatically calls that function or method.

Transcript

Hello, in this video we are going to show you how to basically put a button into our window. Because if we right now, since you know simple window, we want to spice it up a bit. What we're going to do is use the message box module is part of the teaching library and we're going to actually pop up a message box, click the button. So we're going to import yes or no. From the from that last point, I'm going to define a method and we'll call it pop up function takes no parameters and if you wanted to, that's fine. You can extend the accordingly for this message.

And this is going to equal a message box dot show info. And in here for the title of the method box pop up by top and then the message in the message box on a message as an extra task, you know, once we're done with this, I want you to extend this even more, maybe even get user input, put it, put it in from the console, we'll wait till the tutorial where we have some for a more of a user input widget. And you know, do something maybe have multiple buttons button if you press one, it provides one message into the public function on the other one function and that parameter here, so really exciting stuff. Now we're going to create the button over here equal to click into window and go to info click me. So text the blade in the button when they click me and entice the Use up command in basically what is you know cord when you click that button widget x equals 25 and 100.

So this is the coordinates that I'm placing in the quarter start on the top left, so positive in the x axis goes to the right, negative goes left, positive in the y axis goes down positive or negative y axis goes up. So pretty simple stuff. Now should be ready to run. Nara Click me, and that pops up. And that's it. Simple as that.

So that's it for this video. Log said extended have more buttons, maybe have one button that actually doesn't pop anything up, but if you press it, it adds some number to an existing variable and click the pop up button. The variable is displayed in there. Thanks for watching, and I look forward to seeing you in the next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.