Skip to content

Commit 5db54e8

Browse files
committed
Some small improvements
1 parent 0cfbb0f commit 5db54e8

File tree

3 files changed

+48
-6
lines changed

3 files changed

+48
-6
lines changed

custom_ui.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def update(self):
3939
self.input_unchecked = "#404040"
4040
self.input_hover = "#808080"
4141
self.input_press = "#afafaf"
42+
self.scrollbar_arrow = "#606060"
43+
self.scrollbar_arrow_disabled = "#bfbfbf"
44+
self.scrollbar_thumb = "#cdcdcd"
4245
self.accent = winaccent.accent_dark
4346
self.accent_hover = winaccent._utils.blend_colors(self.accent, self.bg, 90)
4447
self.accent_press = winaccent._utils.blend_colors(self.accent, self.bg, 80)
@@ -76,6 +79,9 @@ def update(self):
7679
self.input_unchecked = "#404040"
7780
self.input_hover = "#4f4f4f"
7881
self.input_press = "#5f5f5f"
82+
self.scrollbar_arrow = "#676767"
83+
self.scrollbar_arrow_disabled = "#404040"
84+
self.scrollbar_thumb = "#4d4d4d"
7985
self.accent = winaccent.accent_light
8086
self.accent_hover = winaccent._utils.blend_colors(self.accent, self.bg, 80)
8187
self.accent_press = winaccent._utils.blend_colors(self.accent, self.bg, 60)
@@ -572,6 +578,16 @@ def update_colors(self):
572578
self.radio.config()
573579

574580

581+
class ScrolledTextTtkScrollbar(ScrolledText):
582+
def __init__(self, master, **kwargs):
583+
super().__init__(master, **kwargs)
584+
585+
self.vbar.destroy()
586+
self.vbar = ttk.Scrollbar(self.frame, command = self.yview)
587+
self.vbar.pack(side = "right", fill = "y")
588+
self.configure(yscrollcommand = self.vbar.set)
589+
590+
575591
class App(tk.Tk):
576592
def set_theme(self):
577593
pywinstyles.apply_style(self, "light" if colors.light_theme else "dark")
@@ -586,12 +602,34 @@ def set_theme(self):
586602
style.configure("StatusBar.TFrame", background = colors.bg_status_bar)
587603
style.configure("StatusBar.TLabel", background = colors.bg_status_bar, foreground = colors.fg)
588604
style.configure("Description.TLabel", foreground = colors.fg_desc)
605+
606+
self.style.configure(
607+
"Vertical.TScrollbar", background = colors.bg, troughcolor = colors.bg,
608+
bordercolor = colors.bg, relief = "solid", padding = (2, 3, 1, 2)
609+
)
610+
611+
self.style.map(
612+
"Vertical.TScrollbar",
613+
arrowcolor = [("disabled", colors.scrollbar_arrow_disabled), ("", colors.scrollbar_arrow)],
614+
lightcolor = [("disabled", colors.bg), ("", colors.scrollbar_thumb)],
615+
darkcolor = [("disabled", colors.bg), ("", colors.scrollbar_thumb)],
616+
fieldbackground = [("disabled", colors.bg), ("", colors.scrollbar_thumb)],
617+
)
618+
589619
self.configure(background = colors.bg)
590620

591621
def __init__(self, *args, **kwargs):
592622
super().__init__(*args, **kwargs)
593623
self.withdraw()
594624

625+
self.style = ttk.Style()
626+
self.style.element_create("Custom.Vertical.Scrollbar.trough", "from", "clam")
627+
self.style.element_create("Custom.Vertical.Scrollbar.uparrow", "from", "alt")
628+
self.style.element_create("Custom.Vertical.Scrollbar.downarrow", "from", "alt")
629+
self.style.element_create("Custom.Vertical.Scrollbar.thumb", "from", "clam", "field")
630+
631+
self.style.layout("Vertical.TScrollbar", [("Button.padding", {"sticky": "ns", "children": [("Custom.Vertical.Scrollbar.trough", {"sticky": "ns", "children": [("Custom.Vertical.Scrollbar.uparrow", {"side": "top", "sticky": "nswe"}), ("Custom.Vertical.Scrollbar.downarrow", {"side": "bottom", "sticky": "nswe"}), ("Custom.Vertical.Scrollbar.thumb", {"expand": "1", "sticky": "nswe"})]})]})])
632+
595633
self.iconbitmap(default = preferences.internal + "icons\\icon.ico")
596634
self.update()
597635
self.set_theme()

dialogs/about.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import tkinter as tk, strings, custom_ui, webbrowser
22
from tkinter import ttk
3-
from tkinter.scrolledtext import ScrolledText
43
import strings._info
54
from utils import preferences
65
from dialogs import app_license
@@ -17,8 +16,12 @@ def show_hide_licenses():
1716
global arrow, show_os_licenses
1817
show_os_licenses = not show_os_licenses
1918

20-
if show_os_licenses: licenses.pack(pady = preferences.get_scaled_value(16))
21-
else: licenses.forget()
19+
if show_os_licenses:
20+
licenses_header.pack(after = links, pady = (preferences.get_scaled_value(16), preferences.get_scaled_value(8)), anchor = "w")
21+
licenses.pack(after = licenses_header, pady = preferences.get_scaled_value(8))
22+
else:
23+
licenses_header.forget()
24+
licenses.forget()
2225

2326
show_licenses.configure(image = custom_ui.icons.arrow_up if show_os_licenses else custom_ui.icons.arrow_down)
2427

@@ -55,7 +58,9 @@ def show_hide_licenses():
5558

5659
custom_ui.Button(buttons, text = strings.lang.ok, command = window.destroy, default = "active").pack(side = "right")
5760

58-
licenses = ScrolledText(window, width = 80, height = 20, wrap = "word", background = custom_ui.colors.entry_bg,
61+
licenses_header = ttk.Label(window, text = strings.lang.open_source_licenses, font = ("Segoe UI Semibold", 14))
62+
63+
licenses = custom_ui.ScrolledTextTtkScrollbar(window, width = 80, height = 20, wrap = "word", background = custom_ui.colors.entry_bg,
5964
foreground = custom_ui.colors.fg, selectbackground = custom_ui.colors.entry_select,
6065
selectforeground = "#ffffff", highlightthickness = 1, relief = "solid",
6166
highlightbackground = custom_ui.colors.entry_bd,

dialogs/app_license.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import tkinter as tk, strings, custom_ui
22
from tkinter import ttk
3-
from tkinter.scrolledtext import ScrolledText
43
from utils import preferences
54

65
def show(window):
@@ -14,7 +13,7 @@ def show(window):
1413
ttk.Label(header, text = "\ueb95 ", font = ("Segoe UI", 17), padding = (0, 5, 0, 0)).pack(side = "left")
1514
ttk.Label(header, width = 25, text = strings.lang.license, font = ("Segoe UI Semibold", 17)).pack(side = "left")
1615

17-
license_text = ScrolledText(window, width = 80, height = 22, wrap = "word", background = custom_ui.colors.entry_bg,
16+
license_text = custom_ui.ScrolledTextTtkScrollbar(window, width = 80, height = 22, wrap = "word", background = custom_ui.colors.entry_bg,
1817
foreground = custom_ui.colors.fg, selectbackground = custom_ui.colors.entry_select,
1918
selectforeground = "#ffffff", highlightthickness = 1, relief = "solid",
2019
highlightbackground = custom_ui.colors.entry_bd, border = 0,

0 commit comments

Comments
 (0)