程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Try the use of pack() in Python

編輯:Python

Catalog

Python in pack() Method

Python GUI pack Method

Python in pack() Method #Copyright (c)2017, Students of Software College of Northeastern University # All rightsreserved# File name :a.py# do person : Kongyun # Problem description : use pack() Method does not participate in arranging labels # Problem analysis :. The code is as follows :from tkinter import *root=Tk()lbred=Label(root,text=" Red grooved edge ",fg="red",font=(' Microsoft YaHei ',15),width=20,height=2,relief=GROOVE)lbred.pack()lbgreen=Label(root,text=" Green raised ",fg="green",font=(' Microsoft YaHei ',15),width=20,height=2,relief=RAISED)lbgreen.pack()lbblue=Label(root,text=" Blue ridge edge ",fg="blue",font=(' Microsoft YaHei ',15),width=20,height=2,relief=RIDGE)lbblue.pack()lbyellow=Label(root,text=" Yellow sunken ",fg="yellow",font=(' Microsoft YaHei ',15),width=20,height=2,relief=SUNKEN)lbyellow.pack()lbpink=Label(root,text=" Pink flat ",fg="pink",font=(' Microsoft YaHei ',15),width=20,height=2,relief=FLAT)lbpink.pack()root.mainloop()

The operation results are as follows :

notes : attribute relief Rendered for the control 3D Relief style , Yes FLAT( Flat )、RAISED( Protruding )、SUNKEN( Sunken )、GROOVE( Grooved edges ) and RIDGE( Ridge edge )5 Kind of .

Python GUI pack Method from tkinter import *root = Tk()root.title("pack Method ")root.geometry("300x180")print(" Before execution ", root.pack_slaves())ok_label = Label(root, text="OK", font="Times 20 bold", fg="white", bg="blue")ok_label.pack(anchor=S, side=RIGHT, padx=10, pady=10)# root.pack_slaves()[0].forget() # Hide controls ng_label = Label(root, text="NG", font="Times 20 bold", fg="white", bg="red")ng_label.pack(anchor=S, side=RIGHT, pady=10)print(" After execution ", root.pack_slaves())for pack in root.pack_slaves(): print("info", pack.info()) print("size", pack.size())root.mainloop()

The above is personal experience , I hope I can give you a reference , I also hope you can support the software development network .



  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved