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

    这将产生以下结果:

  • 相关阅读:
    PHP_SELF、 SCRIPT_NAME、 REQUEST_URI 区别
    用canvas画弧形进度条
    sass/scss 和 less的区别
    vue-router 知识点记录
    vue-cli中全局组件的注册使用
    传统项目转前端工程化——路由跳转时出现浏览器锁死和白屏【该死的同步ajax】
    亲身实践 yui-compressor压缩js和css
    vue-webpack 做出来的项目部署到服务器上,点开是空白页(我这里把项目发布到git上)
    git相关
    对象中的方法积累
  • 原文地址:https://www.cnblogs.com/shiyongge/p/10288840.html
Copyright © 2011-2022 走看看