我想知道如何根據視窗大小自動調整以下漸變框架的大小。
from tkinter import *
class InventorySystem:
def __init__(self, root):
self.root = root
self.root.title("Inventory System")
self.root.geometry("1366x768")
j = 0
colors = ["#007F5F", "#2B9348", "#55A630", "#80B918", "#AACC00", "#BFD200",
"#D4D700", "#DDDF00", "#EEEF20", "#FFFF3F"]
for color in colors:
Frame(self.root, width = 1366 / len(colors), height = 768,
bg = color).place(x = j, y = 0)
j = j 1366 / len(colors)
if __name__ == "__main__":
root = Tk()
application = InventorySystem(root)
root.mainloop()
uj5u.com熱心網友回復:
您可以使用相關選項的.place():
# relative width of each frame
# 1.0 means same width of parent
relw = 1 / len(colors)
for j, color in enumerate(colors):
Frame(self.root, bg=color).place(relx=j*relw, y=0, relwidth=relw, relheight=1)
詳情請參考官方檔案
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/312904.html
上一篇:當導航欄被點擊時影像幻燈片會消失
下一篇:Blazor-Serversidenav/sidebarforIdentity/Account/Manage看起來像NavMenu.razor
