fixed dropdown_menu_fallback.py for Linux

This commit is contained in:
TomSchimansky
2022-06-14 18:31:10 -04:00
parent a86dbd4d07
commit 20e16969f2
3 changed files with 25 additions and 9 deletions

View File

@ -76,13 +76,14 @@ class DropdownMenu(tkinter.Toplevel):
elif sys.platform.startswith("win"): elif sys.platform.startswith("win"):
self.overrideredirect(True) # remove title-bar self.overrideredirect(True) # remove title-bar
self.configure(bg="#010302") #self.configure(bg="#010302")
self.wm_attributes("-transparentcolor", "#010302") #self.wm_attributes("-transparent", "#010302")
self.focus()
self.focus() self.focus()
self.frame = customtkinter.CTkFrame(self, self.frame = customtkinter.CTkFrame(self,
border_width=0, border_width=0,
width=self.width, width=self.width,
corner_radius=self.corner_radius, corner_radius=0,
fg_color=self.fg_color, fg_color=self.fg_color,
overwrite_preferred_drawing_method="circle_shapes") overwrite_preferred_drawing_method="circle_shapes")
else: # Linux else: # Linux

View File

@ -1,8 +1,6 @@
import tkinter import tkinter
import sys import sys
import copy import copy
from distutils.version import StrictVersion as Version
import platform
from typing import Union from typing import Union
from ..theme_manager import ThemeManager from ..theme_manager import ThemeManager
@ -51,6 +49,17 @@ class DropdownMenuFallback(tkinter.Menu):
font=self.apply_font_scaling(self.text_font), font=self.apply_font_scaling(self.text_font),
cursor="hand2") cursor="hand2")
else:
self.configure(tearoff=False,
relief="flat",
activebackground=ThemeManager.single_color(self.button_hover_color, self._appearance_mode),
borderwidth=0,
activeborderwidth=0,
bg=ThemeManager.single_color(self.fg_color, self._appearance_mode),
fg=ThemeManager.single_color(self.text_color, self._appearance_mode),
activeforeground=ThemeManager.single_color(self.text_color, self._appearance_mode),
font=self.apply_font_scaling(self.text_font))
self.values = values self.values = values
self.command = command self.command = command
@ -58,12 +67,14 @@ class DropdownMenuFallback(tkinter.Menu):
def add_menu_commands(self): def add_menu_commands(self):
for value in self.values: for value in self.values:
self.add_command(label=value.ljust(self.min_character_width), command=lambda v=value: self.button_callback(v), compound="left") self.add_command(label=value.ljust(self.min_character_width),
command=lambda v=value: self.button_callback(v),
compound="left")
def open(self, x: Union[int, float], y: Union[int, float]): def open(self, x: Union[int, float], y: Union[int, float]):
if sys.platform == "darwin": if sys.platform == "darwin":
y += self.apply_widget_scaling(8) y += self.apply_widget_scaling(8)
elif sys.platform.startswith("win"): else:
y += self.apply_widget_scaling(3) y += self.apply_widget_scaling(3)
self.post(int(x), int(y)) self.post(int(x), int(y))
@ -113,8 +124,10 @@ class DropdownMenuFallback(tkinter.Menu):
self._widget_scaling = new_widget_scaling self._widget_scaling = new_widget_scaling
self._spacing_scaling = new_spacing_scaling self._spacing_scaling = new_spacing_scaling
self.configure(font=self.apply_font_scaling(self.text_font), self.configure(font=self.apply_font_scaling(self.text_font))
activeborderwidth=self.apply_widget_scaling(4),)
if sys.platform.startswith("win"):
self.configure(activeborderwidth=self.apply_widget_scaling(4))
def set_appearance_mode(self, mode_string): def set_appearance_mode(self, mode_string):
if mode_string.lower() == "dark": if mode_string.lower() == "dark":

View File

@ -1,6 +1,8 @@
import tkinter import tkinter
import customtkinter import customtkinter
customtkinter.set_widget_scaling(2)
customtkinter.set_appearance_mode("dark") # Modes: "System" (standard), "Dark", "Light" customtkinter.set_appearance_mode("dark") # Modes: "System" (standard), "Dark", "Light"
customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue" customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"