Python provides a variety of GUI (Graphic User Interface) such as PyQt, Tkinter, Kivy and soon. Among them, tkinter is the most commonly used GUI module in Python since it is simple and easy to learn and implement as well. The word Tkinter comes from the tk interface. The tkinter module is available in Python standard library.
Note: For more information, refer to Python GUI – tkinter
For Ubuntu, you have to install tkinter module by writing following command:
sudo apt-get install python-tk
When a Tkinter program runs, it runs a mainloop (an infinite loop) which is responsible for running a GUI program. At a time only one instance of mainloop can be active, so in order to open a new window we have to use a widget, Toplevel.
A Toplevel widget works pretty much like a Frame, but it opens in a separate top-level window, such windows have all the properties that a main window (root/master window) should have.
To open a new window with a button, we will use events.
Example 2: This will be a class based approach, in this we will create a class which will derive Toplevel widget class and will behave like a toplevel. This method will be useful when you want to add some other properties to an existing Toplevel widget class.
Every object of this class will be a Toplevel widget. We will also use bind() method to register click event.
- PyQt5 – How to open window in maximized format?
- PyQtGraph – Getting Window Flags of Plot Window
- PyQtGraph – Setting Window Flag to Plot Window
- Python - Create window button in GTK+ 3
- wxPython - Get size of Radio Button Window
- Python script to open a Google Map location on clipboard
- Python PIL | Image.open() method
- Python | sympy.sets.open() method
- Python | os.open() method
- Open a File in Python
- How to open and close a file in Python
- Python - Convert Tick-by-Tick data into OHLC (Open-High-Low-Close) Data
- Open computer drives like C, D or E using Python
- Zip function in Python to change to a new character set
- Python | Return new list on element insertion
- Add a new column in Pandas Data Frame Using a Dictionary
- Python | Add new keys to a dictionary
- Adding new column to existing DataFrame in Pandas
- Create a new column in Pandas DataFrame based on the existing columns
- Python PIL | Image.new() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.