Skip to content

Commit

Permalink
Added JSON theme
Browse files Browse the repository at this point in the history
  • Loading branch information
ElSaico committed May 27, 2024
1 parent d18a8d4 commit a40a10e
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 5 deletions.
14 changes: 11 additions & 3 deletions EDMarketConnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ def already_running_popup():

handle_edmc_callback_or_foregrounding()

if locked == JournalLockResult.ALREADY_LOCKED:
if False:
#if locked == JournalLockResult.ALREADY_LOCKED:

Check failure on line 354 in EDMarketConnector.py

View workflow job for this annotation

GitHub Actions / push_checks

E115 expected an indented block (comment)

Check failure on line 354 in EDMarketConnector.py

View workflow job for this annotation

GitHub Actions / push_checks

E265 block comment should start with '# '
# There's a copy already running.

logger.info("An EDMarketConnector.exe process was already running, exiting.")
Expand Down Expand Up @@ -399,6 +400,7 @@ def already_running_popup():
# isort: on


import json
import tkinter as tk
import tkinter.filedialog
import tkinter.font
Expand Down Expand Up @@ -462,6 +464,11 @@ def open_window(systray: 'SysTrayIcon') -> None:
self.systray.start()

plug.load_plugins(master)
self.style = ttk.Style()
with open('themes/dark.json') as f:
dark = json.load(f)
self.style.theme_create('dark', 'default', dark)
self.style.theme_use('dark')

if sys.platform == 'win32':
self.w.wm_iconbitmap(default='EDMarketConnector.ico')
Expand Down Expand Up @@ -523,7 +530,7 @@ def open_window(systray: 'SysTrayIcon') -> None:
plugin_no = 0
for plugin in plug.PLUGINS:
# Per plugin separator
plugin_sep = ttk.Separator(frame, name=f"plugin_hr_{plugin_no + 1}")
plugin_sep = ttk.Frame(frame, name=f"plugin_hr_{plugin_no + 1}", style='Sep.TFrame')
# Per plugin frame, for it to use as its parent for own widgets
plugin_frame = ttk.Frame(
frame,
Expand Down Expand Up @@ -564,6 +571,7 @@ def open_window(systray: 'SysTrayIcon') -> None:
frame,
name='themed_update_button',
width=28,
anchor=tk.CENTER,
state=tk.DISABLED
)

Expand Down Expand Up @@ -681,7 +689,7 @@ def open_window(systray: 'SysTrayIcon') -> None:
lambda e: self.help_menu.tk_popup(e.widget.winfo_rootx(),
e.widget.winfo_rooty()
+ e.widget.winfo_height()))
ttk.Separator(self.theme_menubar).grid(columnspan=5, padx=self.PADX, sticky=tk.EW)
ttk.Frame(self.theme_menubar, style='Sep.TFrame').grid(columnspan=5, padx=self.PADX, sticky=tk.EW)
theme.register(self.theme_minimize) # images aren't automatically registered
theme.register(self.theme_close)
self.blank_menubar = ttk.Frame(frame, name="blank_menubar")
Expand Down
55 changes: 55 additions & 0 deletions themes/dark.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"TFrame": {
"configure": {
"background": "grey4",
"highlightbackground": "#aa5500"
}
},
"Sep.TFrame": {
"configure": {
"background": "#ff8000",
"padding": 2
}
},
"TLabel": {
"configure": {
"background": "grey4",
"foreground": "#ff8000",
"padding": 1
},
"map": {
"background": [
["active", "#ff8000"]
],
"foreground": [
["active", "grey4"],
["disabled", "#aa5500"]
]
}
},
"Hyperlink.TLabel": {
"configure": {
"foreground": "white"
}
},
"TButton": {
"configure": {
"background": "grey4",
"foreground": "#ff8000",
"relief": "raised",
"padding": 2
},
"map": {
"background": [
["pressed", "#ff8000"]
],
"foreground": [
["pressed", "grey4"],
["disabled", "#aa5500"]
],
"relief": [
["pressed", "sunken"]
]
}
}
}
7 changes: 5 additions & 2 deletions ttkHyperlinkLabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@ def __init__(self, master: ttk.Frame | tk.Frame | None = None, **kw: Any) -> Non
"""
self.font_u: tk_font.Font
self.font_n = None
self.style = 'Hyperlink.TLabel'
self.url = kw.pop('url', None)
self.popup_copy = kw.pop('popup_copy', False)
self.underline = kw.pop('underline', None) # override ttk.Label's underline
self.foreground = kw.get('foreground', 'blue')
self.foreground = kw.get('foreground', ttk.Style().lookup(
'Hyperlink.TLabel', 'foreground'))
# ttk.Label doesn't support disabledforeground option
self.disabledforeground = kw.pop('disabledforeground', ttk.Style().lookup(
'TLabel', 'foreground', ('disabled',))) # ttk.Label doesn't support disabledforeground option
'Hyperlink.TLabel', 'foreground', ('disabled',)))
ttk.Label.__init__(self, master, **kw)

self.bind('<Button-1>', self._click)
Expand Down

0 comments on commit a40a10e

Please sign in to comment.