Python GUI Programming Frame Layout

"" "Today when you learn to see the code for the interface of a piano, he is using Frame layout area division.

My understanding is that Frame layout is a top-down vertical layout, so it needs to be up and down for

Layout management operations. "" "

# Code:

# coding=utf-8

from tkinter import *


root = Tk()
root.geometry("520x220+200+100")

f1 = Frame(root)
f1.pack()
f2 = Frame(root)
f2.pack()

btnText = ("流行风", "中国风", "日本风", "金属风", "轻音乐")

for txt in btnText:
Button(f1, text=txt).pack(side="left", padx="10")

for i in range(1, 12):
Label(f2, width=5, height=10, borderwidth=1, relief="solid",
bg="black" if i % 2 ==0 else "white").pack(side="left", padx=2)


root.mainloop()

# 运行结果

 

 

# Code analysis:

Frame frame # f1 and f2 are the first call will be provided on the panel with root 

# They will root is divided into two regions, followed by the definition of a Ganso and

After traversing Set # Button. f2 but also so he set up a Label.

 

# Beginner Python if insufficient exhibitions

# Blog know today can send the screenshot above

Guess you like

Origin www.cnblogs.com/walxt/p/11528058.html