Tkinter which button pressed




















My apologies for not noticing that before I posted that comment. Just one last question. After I determine which button was pressed, I have a text box above the original two buttons for the number that is being converted to be typed.

Below it, I want to delete the previous two buttons were there, and instead have one button there for the user to click on to convert the number. How would I do this? Dan - This link will show you how to remove the buttons from view: stackoverflow. An object-oriented way to do this is to just pass the button clicked to the OnButtonClick method: def OnButtonClick self, button : do stuff with button passed OnButtonClick button. These anonymous functions, created with the lambda keyword can be created when connecting the buttons by filling in the command option: self.

OnButtonClick "b1" self. OnButtonClick "b2" self. Use a different callback for each button. This solves the problem but it's highly inconvenient when OnButton1Click and OnButton2Click are supposed to be the same function. Use an Entry where you can set and get the string in the text field with a local method from Object Entry. Christopher Hoffman Christopher Hoffman 7 7 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook.

Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Explaining the semiconductor shortage, and how it might end.

Does ES6 make JavaScript frameworks obsolete? Featured on Meta. Now live: A fully responsive profile. However, the text can span multiple lines. On top of that, you can make one of the characters underline to mark a keyboard shortcut. To invoke a function or a method of a class automatically when the button is clicked, you assign its command option to the function or method.

This is called the command binding in Tkinter. The default state of a button is normal. In the normal state, the button will respond to the mouse events and keyboard presses by invoking the callback function assigned to its command option. The button can also have the disabled state. The biography of the man himself cannot be written. You have to sweat over it and bug it to death. You can't do it by pushing buttons and watching a TV screen. You can help with your donation: The need for donations Social Media python-course on social media: Facebook: python-course.

If you are interested in an instructor-led classroom training, you may have a look at the international Python courses by Bernd Klein. If you are looking for classes in Germany, you can check the Python courses by Bernd Klein at Bodenseo. Training will not substantially help matters.



0コメント

  • 1000 / 1000