正如你可以從標題中讀到的,我想在我的螢屏右上角放置一個frame包含 abutton的...我會給你們兩張圖片以供您理解,在第一張圖片中,您會注意到一個藍框,它是background color的frame,其中包括button,我想在右上角位置和第二影像中,你會看到會發生什么,如果我pack()的按鈕...
1 影像: 
2 影像: 
如果你想幫助我,這是你們需要的必要代碼:
from tkinter import *
window = Tk()
# set window title
window.title("Open the Websites")
window.state("zoomed")
# set window background color
window.configure(bg='lightgray')
upFrame = Frame(window, bg='lightgray')
upFrame.grid(row=0, column=0, sticky='nesw')
window.grid_rowconfigure(1, weight = 0)
window.grid_columnconfigure(0, weight = 1)
window.grid_rowconfigure(1, weight = 0)
nw_frame = LabelFrame(upFrame)
nw_frame.pack(anchor='nw')
show_all = Button(nw_frame, text='ΟΛΑ', padx= 10, pady= 10, width= 30)
show_all.pack(side= LEFT)
left_frame = Frame(nw_frame, bg='lightgray')
left_frame.pack(side=LEFT)
midRight_frame = Frame(nw_frame, bg='lightgray')
midRight_frame.pack()
mid_frame = Frame(midRight_frame, bg='lightgray')
mid_frame.pack(side= TOP)
right_frame = Frame(midRight_frame, bg='lightgray')
right_frame.pack(side= BOTTOM)
topleftButton = Button(left_frame, text='<= 20 ΣΤΑΘΕΡΑ', padx= 10, width= 20, activebackground='orange')
topleftButton.pack(side= TOP)
bottomleftButton = Button(left_frame, text='ΣΤΑΘΕΡΑ', padx= 10, width= 20)
bottomleftButton.pack(side= BOTTOM)
topmidButton = Button(mid_frame, text='21 - 100kW', padx= 10, width= 25)
topmidButton.pack(side= LEFT)
bottommidButton = Button(mid_frame, text='> 100kW', padx= 10, width= 20)
bottommidButton.pack(side= RIGHT)
toprightButton = Button(right_frame, text='I-AXIS', padx= 10, width= 25)
toprightButton.pack(side= LEFT)
bottomrightButton = Button(right_frame, text='2-AXIS', padx= 10, width= 20)
bottomrightButton.pack(side= RIGHT)
ne_frame = Frame(upFrame, bg='blue', width= 100, height=10)
ne_frame.pack(anchor= 'ne')
auto_button = Button(ne_frame, text='Αυτ?ματη Λειτουργ?α', pady=10)
auto_button.pack(side= RIGHT)
window.mainloop()
uj5u.com熱心網友回復:
您可以nw_frame在左側和ne_frame右側打包upFrame:
...
nw_frame = LabelFrame(upFrame)
nw_frame.pack(side=LEFT, anchor='nw')
...
ne_frame = Frame(upFrame, bg='blue', width= 100, height=10)
ne_frame.pack(side=RIGHT, anchor='ne')
...
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/398952.html
