zoukankan      html  css  js  c++  java
  • Tkinter Toplevel

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

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

    语法:

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

    w = Toplevel ( option, ... )
    

    参数:

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

    OptionDescription
    bg The background color of the window.
    bd Border width in pixels; default is 0.
    cursor The 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.
    font The default font for text inserted into the widget.
    fg The color used for text (and bitmaps) within the widget. You can change the color for tagged regions; this option is just the default.
    height Window height.
    relief Normally, 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.
    width The 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()
    

    这将产生以下结果:

  • 相关阅读:
    二进制求和
    删除排序数组中的重复项--leetcode算法题
    vue render
    数字实现千分位分隔符
    用nodejs实现向文件的固定位置插入内容
    工作中用到的正则表达式
    组件toast(类似于element-ui的message组件)的实现
    用svg实现一个环形进度条
    批量删除当前文件夹下面的.svn文件夹
    windows下的包管理器scoop
  • 原文地址:https://www.cnblogs.com/shiyongge/p/10288840.html
Copyright © 2011-2022 走看看