TomSchimansky / CustomTkinter

A modern and customizable python UI-library based on Tkinter
MIT License
11.56k stars 1.08k forks source link

CTKOptionMenu display issue #2531

Open Macdrap opened 3 months ago

Macdrap commented 3 months ago

Hi,

I have spotted an issue with using CTKOptionMenu and the .place() method.

Please see the attached picture, but basically when I hover over the CTKOptionMenu the text background covers part of the button for any reason.

I've also attached my code. Using the .pack() method does get rid of the issue though.

Screenshot (68)

` class ModifyUserView: """Modify user view"""

def __init__(self, window, main_frame, controller):
    """
        :param window:
        :param main_frame:
        :param controller:
    """
    self.main_frame = main_frame
    self.controller = controller
    self.window = window
    self.title_label = ctk.CTkLabel(self.main_frame, text='Modify User', text_color=config.psl_purple_color,
                                    font=('Arial', 40))
    self.modify_user_label = ctk.CTkLabel(self.main_frame, text='Select user to modify:',
                                          text_color='white')
    self.select_user_to_modify_menu = ctk.CTkOptionMenu(self.main_frame, values=sorted(  ## CHECK ALL THE CTKOPTION MENU THEY DONT DISPLAY PROPERLY
        [user.username for user in session.query(User).all()]),
                                                        button_color=config.psl_blue_color,
                                                        button_hover_color=config.psl_purple_color,
                                                        dropdown_fg_color=config.psl_blue_color,
                                                        dropdown_hover_color=config.psl_purple_color,
                                                        dropdown_text_color='white',
                                                        fg_color=config.psl_blue_color, anchor='center', dynamic_resizing=True)
    self.username_label = ctk.CTkLabel(self.main_frame, text='Username', text_color='white')
    self.username_input = ctk.CTkEntry(self.main_frame, placeholder_text='Username')
    self.password_label = ctk.CTkLabel(self.main_frame, text='Password', text_color='white')
    self.password_input = ctk.CTkEntry(self.main_frame, placeholder_text='Password', show='*')
    self.re_password_label = ctk.CTkLabel(self.main_frame, text='Password', text_color='white')
    self.re_password_input = ctk.CTkEntry(self.main_frame, placeholder_text='Re-type your password', show='*')
    self.first_name_label = ctk.CTkLabel(self.main_frame, text='First Name', text_color='white')
    self.first_name_input = ctk.CTkEntry(self.main_frame, placeholder_text='First Name')
    self.last_name_label = ctk.CTkLabel(self.main_frame, text='Last Name', text_color='white')
    self.last_name_input = ctk.CTkEntry(self.main_frame, placeholder_text='Last Name')
    self.user_group_label = ctk.CTkLabel(self.main_frame, text='User Group', text_color='white')
    self.user_group_input = ctk.CTkOptionMenu(self.main_frame, values=[group.value for group in UserGroup],
                                              #SOURCE OF ISSUE FROM PYTEST
                                              button_color=config.psl_blue_color,
                                              button_hover_color=config.psl_purple_color,
                                              dropdown_fg_color=config.psl_blue_color,
                                              dropdown_hover_color=config.psl_purple_color,
                                              dropdown_text_color='white', dynamic_resizing=True,
                                              fg_color=config.psl_blue_color)
    self.modify_user_button = ctk.CTkButton(self.main_frame, text='Modify User', text_color='white',
                                         fg_color=config.psl_blue_color, hover_color=config.psl_purple_color)

def display(self):
    """Display the modify user view"""
    hide_widgets_in_frame(self.main_frame)
    self.select_user_to_modify_menu.configure(values=sorted([user.username for user in session.query(User).all()]))
    self.title_label.place(anchor='center', relwidth=.2, relheight=.1, relx=.5, rely=.1)
    self.modify_user_label.place(anchor='center', relwidth=.2, relheight=.05, relx=.5, rely=.2)
    self.select_user_to_modify_menu.place(anchor='center',relwidth=.2, relheight=.05, relx=.5, rely=.25)
    self.username_label.place(anchor='center', relwidth=.5, relheight=.05, relx=.5, rely=.3)
    self.username_input.place(anchor='center', relwidth=.2, relheight=.05, relx=.5, rely=.35)
    self.username_input.delete(0,len(self.username_input.get()))
    self.username_input.insert(0,[user.username for user in session.query(User).all()][0])
    self.password_label.place(anchor='center', relwidth=.2, relheight=.05, relx=.5, rely=.4)
    self.password_input.place(anchor='center', relwidth=.2, relheight=.05, relx=.5, rely=.45)
    self.password_input.delete(0, len(self.password_input.get()))
    self.password_input.insert(0, [user.password for user in session.query(User).all()][0])
    self.re_password_label.place(anchor='center', relwidth=.2, relheight=.05, relx=.5, rely=.5)
    self.re_password_input.place(anchor='center', relwidth=.2, relheight=.05, relx=.5, rely=.55)
    self.re_password_input.delete(0, len(self.re_password_input.get()))
    self.re_password_input.insert(0, [user.password for user in session.query(User).all()][0])
    self.first_name_label.place(anchor='center', relwidth=.2, relheight=.05, relx=.5, rely=.6)
    self.first_name_input.place(anchor='center', relwidth=.2, relheight=.05, relx=.5, rely=.65)
    self.first_name_input.delete(0, len(self.first_name_input.get()))
    self.first_name_input.insert(0, [user.first_name for user in session.query(User).all()][0])
    self.last_name_label.place(anchor='center', relwidth=.2, relheight=.05, relx=.5, rely=.7)
    self.last_name_input.place(anchor='center', relwidth=.2, relheight=.05, relx=.5, rely=.75)
    self.last_name_input.delete(0, len(self.last_name_input.get()))
    self.last_name_input.insert(0, [user.last_name for user in session.query(User).all()][0])
    self.user_group_label.place(anchor='center', relwidth=.2, relheight=.05, relx=.5, rely=.8)
    self.user_group_input.place(anchor='center', relwidth=.2, relheight=.05, relx=.5, rely=.85)
    self.user_group_input.set([user.user_group for user in session.query(User).all()][0].value)
    self.modify_user_button.place(anchor='center', relwidth=.2, relheight=.05, relx=.5, rely=.95)

`

Akascape commented 3 months ago

@Macdrap Try changing the corner_radius of the option menu widget