In this Page we are going to learn how can we add a Working quit button in tkinter main window also known as root window.
In other words we are going to demonstrate how to close a tkinter window.
This blog also targets on How you can tkinter and python on Android.
About Tkinter
Tkinter gives us the way in through which we can build a GUI in Python.It can be said as Python interface to the Tk GUI toolkit,which comes with Python.Tkinter is the standard library in Python. When Python and Tkinter are combined then they provide a fast and easy way to create GUI applications. Tkinter provides a powerful object-oriented interface to the Tk GUI toolkit.
Basic steps to start your tkinter-python program are:-
Import Tkintermodule.
Create main window of GUI generally known as Root window.
Add widgets you want.
Enter the main event loop using root.mainloop() to take action against each operation defined by you.
Widgets
Tkinter provides user to create different objects in their window which are known as Widgets.Example of such Widgets are;buttons, labels and textboxes used in a GUI application.
Button
The Button widget is used to add button in a Tkinter Window.These buttons can display text on them or images to convey its function to the user. You can give a command by defining a function and adding to the widget using the appropriate code. A button Widget can be customized in easy way by adjusting the size,borders,color,font,Relief structure.etc.
Relief style that we are going to use:-
Generally "raised" relief style is used for buttons,as it provides the exact 3-D effect for a button .In this project we have also used the same relief style.If you don't know about relief styles of widgets The following link may help you out.
The above code is used for making a window(GUI) of a basic login screen.
It have a Quit button in the south(down) part of the window which is the Main topic of this blog.The quit button uses command of root.destroy() to trigger the exit function.
root.destroy()
This is used to close all the windows which are displayed along with the root window.Refer the code for better understanding.
About Youtube series
All the execution of the above code was done on Android device.The playlist is based on MAKING GUI ON ANDROID Device.
For more information Visit Our Youtube channel.
For Tutorial Watch My YouTube Video:-
"Hope it helped" Have anything in mind? Let me know in the comment section👇
Thanks