Closed KorryKatti closed 6 months ago
i tried putting padx to 0 in an attempt to reduce their distances but to no gain
Hi @KorryKatti,
This was the result of your code in my machine. It didn't give me the same result.
I changed the code to the following. pack
is used display the optionmenu.
frame = ctk.CTkFrame(app)
frame.pack(fill=ctk.BOTH, expand=True, padx=11, pady=10) # Pack the frame to fill the window
# Create the optionmenu widget
optionmenu = ctk.CTkOptionMenu(frame, values=["Home", "Client Update", "Quit"],
command=optionmenu_callback)
optionmenu.pack(expand=True, pady=10, padx=10, side="left")
# Create the library menu widget
libmenu = ctk.CTkOptionMenu(frame, values=["Library", "Apps Update"],
command=libmenu_callback)
libmenu.pack(expand=True, pady=10, padx=10, side="left")
# Create the Commmunity Widget
commenu = ctk.CTkOptionMenu(frame, values=["Community", "Image Board", "Thunder Halls"],
command=commenu_callback)
commenu.pack(expand=True, pady=10, padx=10, side="left")
# Create DevBlogs Widget
devmenu = ctk.CTkOptionMenu(frame,values=["DevBlog", "Changelogs"],
command=devmenu_callback)
devmenu.pack(expand=True, pady=10, padx=10, side="left")
# Create the theme selector
thememenu = ctk.CTkOptionMenu(frame,values=["Default","Orange","Green","Coffee","Violet","Blue","Carrot","Marsh","Metal","Pink","Red","Rose","Sky","Yellow"], command=theme_set)
thememenu.pack(expand=True, pady=10, padx=10, side="left")
Result:
Hope this helps
I have this code ahead of the previous one too
also i can't use pack because it causes this error
File "/usr/lib/python3.11/tkinter/init.py", line 2568, in grid_configure self.tk.call( _tkinter.TclError: cannot use geometry manager grid inside .!ctkframe which already has slaves managed by pack
frame = ctk.CTkFrame(app)
frame.pack(fill=ctk.BOTH, expand=True, padx=11, pady=10) # Pack the frame to fill the window
# Create the optionmenu widget
optionmenu = ctk.CTkOptionMenu(frame, values=["Home", "Client Update", "Quit"],
command=optionmenu_callback)
optionmenu.grid(row=0, column=0, padx=2, pady=0, sticky=ctk.W) # Align to the west (left)
# Create the library menu widget
libmenu = ctk.CTkOptionMenu(frame, values=["Library", "Apps Update"],
command=libmenu_callback)
libmenu.grid(row=0, column=1, padx=0, pady=0, sticky=ctk.W) # Align to the west (left)
# Create the Commmunity Widget
commenu = ctk.CTkOptionMenu(frame, values=["Community", "Image Board", "Thunder Halls"],
command=commenu_callback)
commenu.grid(row=0, column=2, padx=0, pady=0, sticky=ctk.W) # Align to the west (left)
# Create DevBlogs Widget
devmenu = ctk.CTkOptionMenu(frame,values=["Dev Blog", "Changelogs"],
command=devmenu_callback)
devmenu.grid(row=0, column=3, padx=0, pady=0, sticky=ctk.W) # Align to the west (left)
# Create the theme selector
thememenu = ctk.CTkOptionMenu(frame,values=["Default","Orange","Green","Coffee","Violet","Blue","Carrot","Marsh","Metal","Pink","Red","Rose","Sky","Yellow","FlipperZero","hacked"], command=theme_set)
thememenu.grid(row=0, column=4, padx=0, pady=0, sticky=ctk.W) # Align to the west
# Create a scrollable frame inside the existing frame to display contents
scrollable_frame = ctk.CTkScrollableFrame(frame, width=1024, height=576, corner_radius=0, fg_color="transparent")
scrollable_frame.grid(row=2, column=0, columnspan=4, sticky="nsew")
# Add widgets to the scrollable frame
create_labels()
my screens dimensions are 1366x768 btw if it helps
i will try changing the grids in the code to pack changing the grid to pack , is causing the scrollable frame to move towards right and the menus on left , which is not desired
You could change the hierarchy to something like this.
- MainFrame - (pack or grid which is suitable for your app)
- frame - (pack)
- optionmenu - (pack)
- libmenu - (pack)
- commenu - (pack)
- devmenu - (pack)
- thememenu - (pack)
- scrollable_frame - (pack)
Example Code:
mainframe = CTkFrame(master=root)
mainframe.pack_propagate(False)
mainframe.pack(expand=True, fill="both")
frame = CTkFrame(master=mainframe, width=200)
frame.pack(fill="x")
optionmenu = CTkOptionMenu(master=frame, values=['Home', 'Client Update', 'Quit'])
optionmenu.pack(pady=(10, 10), expand=True, side="left")
libmenu = CTkOptionMenu(master=frame, values=["Library", "Apps Update"])
libmenu.pack(pady=(10, 10), expand=True, side="left")
commenu = CTkOptionMenu(master=frame, values=['Community', 'Image Board', 'Thunder Halls'])
commenu.pack(pady=(10, 10), expand=True, side="left")
devmenu = CTkOptionMenu(master=frame, values=["Dev Blogs", "Changelogs"])
devmenu.pack(pady=(10, 10), expand=True, side="left")
thememenu = CTkOptionMenu(master=frame, values=["Default","Orange","Green","Coffee","Violet","Blue","Carrot","Marsh","Metal","Pink","Red","Rose","Sky","Yellow","FlipperZero","hacked"])
thememenu.pack(pady=(10, 10), expand=True, side="left")
scrollable_frame = CTkScrollableFrame(master=mainframe, corner_radius=0, fg_color="transparent")
scrollable_frame.pack(expand=True, fill="both")
Hope This Helps
Thanks it works now , also just in case , if i decide to add any widget in the future i will be using pack instead of grid right ?
Thanks it works now , also just in case , if i decide to add any widget in the future i will be using pack instead of grid right ?
If you used pack for mainframe
then you can only use pack for other widgets with the same parent as that of the mainframe. If you used grid for mainframe
then you can only use grid for other widgets with the same parent as that of the mainframe. But you can use pack
or grid
inside scrollable_frame
alright thanks , have a nice day
The option menu at the right most is cut off from the display even at full screen , how do i fix it
relevant part of the code
the menu i am talking about is the thememenu