Skip to content

Commit

Permalink
Merge pull request #2201 from HullSeals/enhancement/2186/macos-refine…
Browse files Browse the repository at this point in the history
…ment

[2186] Refine macOS to preserve ContextMenu
  • Loading branch information
Rixxan authored Apr 20, 2024
2 parents 74fc774 + fa091e9 commit 6732515
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 31 deletions.
3 changes: 1 addition & 2 deletions docs/examples/click_counter/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import logging
import tkinter as tk
from tkinter import ttk

import myNotebook as nb # noqa: N813
from config import appname, config
Expand Down Expand Up @@ -65,7 +64,7 @@ def setup_preferences(self, parent: nb.Notebook, cmdr: str, is_beta: bool) -> nb

# setup our config in a "Click Count: number"
nb.Label(frame, text='Click Count').grid(row=current_row)
ttk.Entry(frame, textvariable=self.click_count).grid(row=current_row, column=1)
nb.EntryMenu(frame, textvariable=self.click_count).grid(row=current_row, column=1)
current_row += 1 # Always increment our row counter, makes for far easier tkinter design.
return frame

Expand Down
21 changes: 10 additions & 11 deletions myNotebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, master: ttk.Frame | None = None, **kw):


class Frame(ttk.Frame):
"""Custom t(t)k.Frame class to fix some display issues."""
"""Custom ttk.Frame class to fix some display issues."""

def __init__(self, master: ttk.Notebook | None = None, **kw):
if sys.platform == 'win32':
Expand Down Expand Up @@ -121,42 +121,41 @@ def paste(self) -> None:


class Entry(EntryMenu):
"""Custom t(t)k.Entry class to fix some display issues."""
"""Custom ttk.Entry class to fix some display issues."""

# DEPRECATED: Migrate to ttk.Entry or EntryMenu. Will remove in 5.12 or later.
# DEPRECATED: Migrate to EntryMenu. Will remove in 5.12 or later.
def __init__(self, master: ttk.Frame | None = None, **kw):
EntryMenu.__init__(self, master, **kw)


class Button(ttk.Button): # type: ignore
"""Custom t(t)k.Button class to fix some display issues."""
class Button(ttk.Button):
"""Custom ttk.Button class to fix some display issues."""

# DEPRECATED: Migrate to ttk.Button. Will remove in 5.12 or later.
def __init__(self, master: ttk.Frame | None = None, **kw):
if sys.platform == 'win32':
ttk.Button.__init__(self, master, style='nb.TButton', **kw)
else:
ttk.Button.__init__(self, master, **kw)


class ColoredButton(tk.Button): # type: ignore
"""Custom t(t)k.ColoredButton class to fix some display issues."""
class ColoredButton(tk.Button):
"""Custom tk.Button class to fix some display issues."""

# DEPRECATED: Migrate to tk.Button. Will remove in 5.12 or later.
def __init__(self, master: ttk.Frame | None = None, **kw):
tk.Button.__init__(self, master, **kw)


class Checkbutton(ttk.Checkbutton):
"""Custom t(t)k.Checkbutton class to fix some display issues."""
"""Custom ttk.Checkbutton class to fix some display issues."""

def __init__(self, master=None, **kw):
def __init__(self, master: ttk.Frame | None = None, **kw):
style = 'nb.TCheckbutton' if sys.platform == 'win32' else None
super().__init__(master, style=style, **kw) # type: ignore


class Radiobutton(ttk.Radiobutton):
"""Custom t(t)k.Radiobutton class to fix some display issues."""
"""Custom ttk.Radiobutton class to fix some display issues."""

def __init__(self, master: ttk.Frame | None = None, **kw):
style = 'nb.TRadiobutton' if sys.platform == 'win32' else None
Expand Down
15 changes: 7 additions & 8 deletions plugins/coriolis.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,24 @@ def plugin_prefs(parent: ttk.Notebook, cmdr: str | None, is_beta: bool) -> nb.Fr

# LANG: Settings>Coriolis: Label for 'NOT alpha/beta game version' URL
nb.Label(conf_frame, text=_('Normal URL')).grid(sticky=tk.W, row=cur_row, column=0, padx=PADX, pady=PADY)
ttk.Entry(conf_frame,
textvariable=coriolis_config.normal_textvar).grid(
nb.EntryMenu(conf_frame, textvariable=coriolis_config.normal_textvar).grid(
sticky=tk.EW, row=cur_row, column=1, padx=PADX, pady=BOXY
)
# LANG: Generic 'Reset' button label
ttk.Button(conf_frame, text=_("Reset"),
command=lambda: coriolis_config.normal_textvar.set(value=DEFAULT_NORMAL_URL)).grid(
nb.Button(conf_frame, text=_("Reset"),
command=lambda: coriolis_config.normal_textvar.set(value=DEFAULT_NORMAL_URL)).grid(
sticky=tk.W, row=cur_row, column=2, padx=PADX, pady=0
)
cur_row += 1

# LANG: Settings>Coriolis: Label for 'alpha/beta game version' URL
nb.Label(conf_frame, text=_('Beta URL')).grid(sticky=tk.W, row=cur_row, column=0, padx=PADX, pady=PADY)
ttk.Entry(conf_frame, textvariable=coriolis_config.beta_textvar).grid(
sticky=tk.EW, row=cur_row, column=1, padx=PADX, pady=BOXY
nb.EntryMenu(conf_frame, textvariable=coriolis_config.beta_textvar).grid(
sticky=tk.EW, row=cur_row, column=1, padx=PADX, pady=BOXY
)
# LANG: Generic 'Reset' button label
ttk.Button(conf_frame, text=_('Reset'),
command=lambda: coriolis_config.beta_textvar.set(value=DEFAULT_BETA_URL)).grid(
nb.Button(conf_frame, text=_('Reset'),
command=lambda: coriolis_config.beta_textvar.set(value=DEFAULT_BETA_URL)).grid(
sticky=tk.W, row=cur_row, column=2, padx=PADX, pady=0
)
cur_row += 1
Expand Down
8 changes: 4 additions & 4 deletions plugins/edsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ def __init__(self):
self.cmdr_text: nb.Label | None = None

self.user_label: nb.Label | None = None
self.user: ttk.Entry | None = None
self.user: nb.EntryMenu | None = None

self.apikey_label: nb.Label | None = None
self.apikey: ttk.Entry | None = None
self.apikey: nb.EntryMenu | None = None


this = This()
Expand Down Expand Up @@ -345,14 +345,14 @@ def plugin_prefs(parent: ttk.Notebook, cmdr: str | None, is_beta: bool) -> nb.Fr
# LANG: EDSM Commander name label in EDSM settings
this.user_label = nb.Label(frame, text=_('Commander Name'))
this.user_label.grid(row=cur_row, padx=PADX, pady=PADY, sticky=tk.W)
this.user = ttk.Entry(frame)
this.user = nb.EntryMenu(frame)
this.user.grid(row=cur_row, column=1, padx=PADX, pady=BOXY, sticky=tk.EW)

cur_row += 1
# LANG: EDSM API key label
this.apikey_label = nb.Label(frame, text=_('API Key'))
this.apikey_label.grid(row=cur_row, padx=PADX, pady=PADY, sticky=tk.W)
this.apikey = ttk.Entry(frame, show="*", width=50)
this.apikey = nb.EntryMenu(frame, show="*", width=50)
this.apikey.grid(row=cur_row, column=1, padx=PADX, pady=BOXY, sticky=tk.EW)
cur_row += 1

Expand Down
4 changes: 2 additions & 2 deletions plugins/inara.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def __init__(self):
self.log: 'tk.IntVar'
self.log_button: nb.Checkbutton
self.label: HyperlinkLabel
self.apikey: ttk.Entry
self.apikey: nb.EntryMenu
self.apikey_label: tk.Label

self.events: dict[Credentials, Deque[Event]] = defaultdict(deque)
Expand Down Expand Up @@ -292,7 +292,7 @@ def plugin_prefs(parent: ttk.Notebook, cmdr: str, is_beta: bool) -> nb.Frame:
# LANG: Inara API key label
this.apikey_label = nb.Label(frame, text=_('API Key')) # Inara setting
this.apikey_label.grid(row=cur_row, padx=PADX, pady=PADY, sticky=tk.W)
this.apikey = ttk.Entry(frame, show="*", width=50)
this.apikey = nb.EntryMenu(frame, show="*", width=50)
this.apikey.grid(row=cur_row, column=1, padx=PADX, pady=BOXY, sticky=tk.EW)
cur_row += 1

Expand Down
2 changes: 0 additions & 2 deletions prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,6 @@ def __setup_output_tab(self, root_notebook: ttk.Notebook) -> None:
)
self.outbutton.grid(column=1, padx=self.PADX, pady=self.PADY, sticky=tk.EW, row=row.get())

nb.Frame(output_frame).grid(row=row.get()) # type: ignore # bottom spacer # TODO: does nothing?

# LANG: Label for 'Output' Settings/Preferences tab
root_notebook.add(output_frame, text=_('Output')) # Tab heading in settings

Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
certifi==2024.2.2
requests==2.31.0
pillow==10.2.0
pillow==10.3.0
# requests depends on this now ?
charset-normalizer==2.1.1
charset-normalizer==3.3.2

watchdog==3.0.0
# Commented out because this doesn't package well with py2exe
Expand Down

0 comments on commit 6732515

Please sign in to comment.