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()
    

    这将产生以下结果:

  • 相关阅读:
    003 Leaflet 第三个demo 地图上的面积测量
    002 Leaflet 第二个demo 地图上的矩形拉框选择
    001 Leaflet 第一个demo 加载天地图
    This关键字,打印花瓣的数量
    Myeclipse8.5 添加Tomcat7
    WGS84经纬度 与 web 墨卡托相互转化 工具类
    java list集合去重复
    response 下载文件
    jquery实现可拖拽的div
    linux 前端环境搭建
  • 原文地址:https://www.cnblogs.com/shiyongge/p/10288840.html
Copyright © 2011-2022 走看看