在我的tkinter應用程式中,我想制作一個框架,它將在其他部件的頂部,不占用任何空間(像html位置固定)。
框架必須包含小工具,如果框架不可能,標簽或按鈕也可以。
我不知道如何做,所以還沒有嘗試任何東西。請幫助!
uj5u.com熱心網友回復:
這里有一個place管理器的演示。
代碼中的注釋解釋了行為。
import tkinter as tk
root = tk.Tk()
root.geometry("868x131")
button = tk.Button(root, text = "A Button")
button.place(x = 2, y = 2)
Frame = tk.LabelFrame(root, text = "A LabelFrame using place", bg="cyan")
# Frame using place with x, y, width, height in absolute coordinates250, y = 20, width = 600, height = 70)
ButtonInFrame = tk.Button(Frame, text = "A Button IN LabelFrame", bg="白色")
# Note: place x,y is referenced to the container (Frame)
# 注意:place只使用x,y并允許Button決定寬度和高度。
ButtonInFrame.place(x = 2, y = 2)
Label = tk.Label(root, text = "A Label on LabelFrame")
有多行
的文本。", bg="淺綠色")
# Label sits on top of buttonFrame and Frame。
# 注意place只使用x,y,并允許Label決定寬度和高度。
Label.place(x = 330, y = 60)
root.mainloop()
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/333034.html
標籤:
