美文网首页
GUI中pack布局管理

GUI中pack布局管理

作者: Chaweys | 来源:发表于2021-01-11 10:38 被阅读0次

    pack 适用于简单的垂直或水平排布,如果需要复杂的布局可以使用 grid 或 place。
    
    #coding=utf-8
    from tkinter import *
    
    root=Tk()
    root.title("pack垂直水平布局")
    root.geometry("500x400+200+200")
    
    
    f1=Frame()
    f1.pack()
    f2=Frame()
    f2.pack()
    
    btntxt=["流行风","中国风","日本风","重金属","轻音乐"]
    
    for i in btntxt:
        Button(f1,text=i).pack(side="left",padx=10)
    
    for i in range(13):
        Label(f2,width=5,height=10,borderwidth=1,relief="solid",bg="white" if i%2==0 else "black").pack(side="left")
    
    
    root.mainloop()
    
    pack布局钢琴界面.png

    相关文章

      网友评论

          本文标题:GUI中pack布局管理

          本文链接:https://www.haomeiwen.com/subject/wwgkaktx.html