Python 3 Programming Tutorial - Tkinter event handling

preview_player
Показать описание
In this tutorial, we cover tkinter event handling. In this scenario, we are adding a quit event to our quit button. In basically every circumstance, we're going to want to have our buttons actually do something or perform an action. This is called an event, and we can write code to handle events. In tkinter, this is as simple as adding a command, which we'll make into a function. Even though this function is a basic 1-line function that simply calls another function, we can see how we can later create more complex functions for our events.

Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Рекомендации по теме
Комментарии
Автор

Great tutorial!
I have been searching around the internet for a good tkinter tutorial for a long time!
Thanks!

roiegal
Автор

Thank you, pretty cool tutorial!
Thanks! Awesome python functionality :)

timkane
Автор

Thank you for these films :D you are very helping me

lesnyczadzior
Автор

You can also use the build-in function. self.frame.quit().

EkanV
Автор

All your videos are amazing sir :D Thank you for sharing your knowledge ^_^

joanedelima
Автор

why do you use self in the argument when defining functions? why do you use self. before calling functions?

love your shows. thanks.

DavidARayMusic
Автор

that was so great thank you alot,
i have a question what should i do if i want to execute another python3 script by pressing the button, so to choose the file and execute it for me ?

tinablack
Автор

found out where the bug was. Yours is: root.geometry("400x300"). Mine was: root.geometry("400X300"). Phew! Also thank you for explaining why we can reference a function before it even exists. That's the same question I had from the last tutorial.

TXfoxie
Автор

Hey sentdex, i have a question: what functions should i use/ make as a command for a button when i want it to show a peice of text on an entry, later i want another button to evaluate the text on the entry and do something with it (using the eval() ) function, thans for your nice videos!! btw i have a suggestion for a video: i knwo that ttk makes your buttons etc look better but is there a possibility to make your own styles such a steam or the google chrome installer? if yes i would be cool if you made a video about it. (but i dont mind if you dont, you already make ausome videos)

EvdeKsp
Автор

could you do a video on range? thanks!

silverrick
Автор

in the function client_exit(self), to avoid Python alerting that your program is still running and whether to kill it, try:

root.destroy()
sys.exit()

instead of:

exit()

oldaccount
Автор

is 'master' needed in the title attribute for init_window() because it gets displayed on the Frame (one level up from init_window())?

alv
Автор

Can you add 2 commands or press more that one button

anamicgaming
Автор

u did
 command = self.client_exit 
my question is: isnt client_exit a function? shouldnt we write? 
command = self.client_exit()
but when i write it in this way the button doesnt work. why is that?

aminimohammad
Автор

If i have a function bind to a botton and one definition that makes something, can I then know what variable it came frome? Like that that click came from lets say botton1

andree.johnsson
Автор

What does the into fiction do in in the window program?

tahmeedmuhtasim
Автор

In your tutorial explains well the function "frame.bind"?
Please i whant undestand how to manage tkinter and i think undestand last step.
Thanks for reading this comment.

paololobello
Автор

I have a question. Imagine I have a label and a button, and when I press the button I want to call a function and concatenate the text from the label with the one from the button.how do i do it??can I Access the label from a function?

bernardosolanorodriguez
Автор

Hi, I have a question that I have been trying to answer for myself for a couple of weeks now regarding event binding. What I would like to do is to press either "Return" button or the mouse left button to run, in this instance a search function. I have been able to do this with a Listbox but can not do it with a button - can you please help me as at 64 my little gray cells don't seem to be firing at the appropriate times.?

Clive
Автор

Hi. I would need help to design a button such that, whenever I click the button it runs an entire script which I have written. The script or codes import some datas and does some merge n lookups and finally gives the output in Excel. So ideally on one click of the button I have everything ready

biswadiproychowdhury