zoukankan      html  css  js  c++  java
  • python的图形化界面

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    #! /usr/bin/env python
    #coding=utf-8
    from Tkinter import *
     
    class LabelDemo( Frame ):
       """Demonstrate Labels"""
     
       def __init__( self ):
          """Create three Labels and pack them"""
     
          Frame.__init__( self )   # initializes Frame instance
     
          # frame fills all available space
          self.pack( expand = YES, fill = BOTH )
          self.master.title( "Labels" )
     
          self.Label1 = Label( self, text = "Label with text" )
     
          # resize frame to accommodate Label
          self.Label1.pack()
     
          self.Label2 = Label( self,
             text = "Labels with text and a bitmap" )
     
          # insert Label against left side of frame
          self.Label2.pack( side = LEFT )
     
          # using default bitmap image as label
          self.Label3 = Label( self, bitmap = "warning" )
          self.Label3.pack( side = LEFT )
     
    def main():
       LabelDemo().mainloop()  # starts event loop
     
    if __name__ == "__main__":
       main()

     注意一下,添加组件的时候,下面这一行代码还是不能少的,笔者也是刚刚接触,说错了大家别喷。

    self.pack()

      如果取消这一行的话,其他的组件不能显示。

  • 相关阅读:
    获取字符串的MD5值
    将对象XML序列化为XML文件/反序列化XML文件为对象
    C#通过反射获得对象所有属性和值
    Jquery.Validate使用
    JS删除确认框
    生成验证码
    文件备份方法
    Log日志类
    Ext.NET 基础学习笔记08 (FormPanel)
    Tibco EMS Message trace
  • 原文地址:https://www.cnblogs.com/DaBing0806/p/4939442.html
Copyright © 2011-2022 走看看