Python Tkinter Toplevel - Javatpoint
Python Tkinter Toplevel - Javatpoint
Tkinter Toplevel
The Toplevel widget is used to create and display the toplevel windows which are directly managed by the window
manager. The toplevel widget may or may not have the parent window on the top of them.
The toplevel widget is used when a python application needs to represent some extra information, pop-up, or the
group of widgets on the new window.
The toplevel windows have the title bars, borders, and other window decorations.
Syntax
w = Toplevel(options)
SN Options Description
3 cursor The mouse pointer is changed to the cursor type set to the arrow, dot, etc. when the mouse is
in the window.
4 class_ The text selected in the text widget is exported to be selected to the window manager. We can
set this to 0 to make this behavior false.
5 font The font type of the text inserted into the widget.
⇧ 9SCROLL
width
TO TOPIt represents the width of the window,
https://www.javatpoint.com/python-tkinter-toplevel 2/6
10/24/22, 6:37 AM Python Tkinter Toplevel - Javatpoint
Methods
The methods associated with the Toplevel widget is given in the following list.
SN Method Description
5 protocol(name, It is used to mention a function which will be called for the specific protocol.
function)
6 state() It is used to get the current state of the window. Possible values are normal, iconic,
withdrawn, and icon.
Example
from tkinter import *
root = Tk()
root.geometry("200x200")
def open():
top = Toplevel(root)
top.mainloop()
⇧ SCROLL TO TOP
https://www.javatpoint.com/python-tkinter-toplevel 3/6
10/24/22, 6:37 AM Python Tkinter Toplevel - Javatpoint
btn = Button(root, text = "open", command = open)
btn.place(x=75,y=50)
root.mainloop()
Output:
← Prev
Next →
Sponsored
[Gallery] Plugs Have These Two Holes, Here's
Why
xfreehub
For Videos Join Our Youtube Channel: Join Now
Feedback
⇧ SCROLL TO TOP
Splunk SPSS Swagger Transact-SQL Tumblr
https://www.javatpoint.com/python-tkinter-toplevel 4/6