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

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

  • 相关阅读:
    入门菜鸟
    FZU 1202
    XMU 1246
    Codeforces 294E Shaass the Great 树形dp
    Codeforces 773D Perishable Roads 最短路 (看题解)
    Codeforces 814E An unavoidable detour for home dp
    Codeforces 567E President and Roads 最短路 + tarjan求桥
    Codeforces 567F Mausoleum dp
    Codeforces 908G New Year and Original Order 数位dp
    Codeforces 813D Two Melodies dp
  • 原文地址:https://www.cnblogs.com/DaBing0806/p/4939442.html
Copyright © 2011-2022 走看看