Tkinter Toplevel

   Tkinter Toplevel:顶层部件的工作,直接由窗口管理器管理的窗口。他们不必在它们上面的父widget
 
顶层部件的工作,直接由窗口管理器管理的窗口。他们不必在它们上面的父widget.

你的应用程序可以使用任意数量的顶层窗口.

语法:

这里是一个简单的语法来创建这个widget:

w = Toplevel ( option, ... )

参数:

  • options: 下面是这个小工具最常用的选项列表。这些选项可以作为键 - 值对以逗号分隔.

OptionDescription
bgThe background color of the window.
bdBorder width in pixels; default is 0.
cursorThe cursor that appears when the mouse is in this window.
class_Normally, text selected within a text widget is exported to be the selection in the window manager. Set exportselection=0 if you don't want that behavior.
fontThe default font for text inserted into the widget.
fgThe color used for text (and bitmaps) within the widget. You can change the color for tagged regions; this option is just the default.
heightWindow height.
reliefNormally, a top-level window will have no 3-d borders around it. To get a shaded border, set the bd option larger that its default value of zero, and set the relief option to one of the constants.
widthThe desired width of the window.

方法:

量表的对象有这些方法:

Methods & Description
deiconify()
Displays the window, after using either the iconify or the withdraw methods.
frame()
Returns a system-specific window identifier.
group(window)
Adds the window to the window group administered by the given window.
iconify()
Turns the window into an icon, without destroying it.
protocol(name, function)
Registers a function as a callback which will be called for the given protocol.
iconify()
Turns the window into an icon, without destroying it.
state()
Returns the current state of the window. Possible values are normal, iconic, withdrawn, and icon.
transient([master])
Turns the window into a temporary(transient) window for the given master, or to the window's parent, when no argument is given.
withdraw()
Removes the window from the screen, without destroying it.
maxsize(width, height)
Defines the maximum size for this window.
minsize(width, height)
Defines the minimum size for this window.
positionfrom(who)
Defines the position controller.
resizable(width, height)
Defines the resize flags, which control whether the window can be resized.
sizefrom(who)
Defines the size controller.
title(string)
Defines the window title.

例子:

自行尝试下面的例子:

from Tkinter import *

root = Tk()
top = Toplevel()

top.mainloop()

这将产生以下结果:

 

转载于:https://www.cnblogs.com/tkinter/p/5628832.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值