0% found this document useful (0 votes)
102 views

Python Tkinter Toplevel - Javatpoint

The Toplevel widget in Tkinter is used to create and display additional windows that are managed by the window manager. Toplevel windows have title bars, borders, and other window decorations and can be used to represent extra information or groups of widgets in new windows. Options for Toplevel windows include background color, border size, cursor, font, foreground color, height, relief, and width. Methods associated with Toplevel include deiconify(), frame(), group(), iconify(), protocol(), state(), transient(), withdraw(), maxsize(), minsize(), positionfrom(), resizable(), sizefrom(), and title(). An example shows creating a Toplevel window when a button is clicked.

Uploaded by

Daksha2k22 Mes
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views

Python Tkinter Toplevel - Javatpoint

The Toplevel widget in Tkinter is used to create and display additional windows that are managed by the window manager. Toplevel windows have title bars, borders, and other window decorations and can be used to represent extra information or groups of widgets in new windows. Options for Toplevel windows include background color, border size, cursor, font, foreground color, height, relief, and width. Methods associated with Toplevel include deiconify(), frame(), group(), iconify(), protocol(), state(), transient(), withdraw(), maxsize(), minsize(), positionfrom(), resizable(), sizefrom(), and title(). An example shows creating a Toplevel window when a button is clicked.

Uploaded by

Daksha2k22 Mes
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

10/24/22, 6:37 AM 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.

The syntax to use the Toplevel widget is given below.

Syntax

w = Toplevel(options)   

A List of possible options is given below.

SN Options Description

1 bg It represents the background color of the window.

2 bd It represents the border size of the window.

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.

6 fg The foreground color of the widget.

7 height It represents the height of the window.

8 relief It represents the type of the window.

⇧ 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

1 deiconify() This method is used to display the window.

2 frame() It is used to show a system dependent window identifier.

3 group(window) It is used to add this window to the specified window group.

4 iconify() It is used to convert the toplevel window into an icon.

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.

7 transient([master]) It is used to convert this window to a transient window (temporary).

8 withdraw() It is used to delete the window but doesn't destroy it.

9 maxsize(width, It is used to declare the maximum size for the window.


height)

10 minsize(width, It is used to declare the minimum size for the window.


height)

11 positionfrom(who) It is used to define the position controller.

12 resizable(width, It is used to control whether the window can be resizable or not.


height)

13 sizefrom(who) It is used to define the size controller.

14 title(string) It is used to define the title for the window.

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

Send your Feedback to [email protected]

Help Others, Please Share

Learn Latest Tutorials

⇧ SCROLL TO TOP
Splunk SPSS Swagger Transact-SQL Tumblr
https://www.javatpoint.com/python-tkinter-toplevel 4/6

You might also like