As you can read from the tittle I want to position a frame
that includes a button
on the right top corner of my screen... I will let you guys two image for your unterstanding, in the first image you will notice a blue frame that is the background color
of the frame
that includes the button
that I want to position on the right top corner and in the second image you will see what happens if I pack()
the button...
Here's the neccessary code that you guys need if you want to help me out:
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()
CodePudding user response:
You can pack nw_frame
at the left side and ne_frame
at the right side inside 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')
...