diff --git a/config.json b/config.json index 41c876f6a..88a233ead 100644 --- a/config.json +++ b/config.json @@ -32,6 +32,11 @@ "ui_autoSetFormat": true, + "tk.progressbar.color.fill": "blue", + "tk.progressbar.color.background": "gray", + "tk.progressbar.color.text": "yellow", + "tk.progressbar.font": "Sans", + "reverse_matchWord": true, "reverse_showRel": "Percent", "reverse_saveStep": 1000, diff --git a/doc/config.rst b/doc/config.rst index a603bfc3e..bc1a838f3 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -1,79 +1,87 @@ Configuration Parameters ------------------------ -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| Name | Command Flags | Type | Default | Comment | -+==============================+===============================+=======+===============+=============================================================================+ -| ``log_time`` | | ``--log-time`` | bool | ``false`` | Show date and time in logs | -| | | ``--no-log-time`` | | | | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``cleanup`` | | ``--cleanup`` | bool | ``true`` | Cleanup cache or temporary files after conversion | -| | | ``--no-cleanup`` | | | | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``auto_sqlite`` | | bool | ``true`` | Auto-enable ``--sqlite`` to limit RAM usage when direct | -| | | | | mode is not possible. Can override with ``--no-sqlite`` | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``enable_alts`` | | ``--alts`` | bool | ``true`` | Enable alternates | -| | | ``--no-alts`` | | | | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``skip_resources`` | ``--skip-resources`` | bool | ``false`` | Skip resources (images, audio, css, etc) | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``save_info_json`` | ``--info`` | bool | ``false`` | Save .info file alongside output file(s) | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``lower`` | | ``--lower`` | bool | ``false`` | Lowercase word(s) | -| | | ``--no-lower`` | | | | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``utf8_check`` | | ``--utf8-check`` | bool | ``false`` | Fix Unicode in word(s) and definition | -| | | ``--no-utf8-check`` | | | | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``rtl`` | ``--rtl`` | bool | ``false`` | Make definition right-to-left | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``remove_html`` | ``--remove-html`` | str | ``""`` | Remove given comma-separated HTML tags (not their contents) from definition | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``remove_html_all`` | ``--remove-html-all`` | bool | ``false`` | Remove all HTML tags (not their contents) from definition | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``normalize_html`` | ``--normalize-html`` | bool | ``false`` | Normalize HTML tags in definition (WIP) | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``skip_duplicate_headword`` | ``--skip-duplicate-headword`` | bool | ``false`` | Skip entries with a duplicate headword | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``trim_arabic_diacritics`` | ``--trim-arabic-diacritics`` | bool | ``false`` | Trim Arabic diacritics from headword | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``unescape_word_links`` | ``--unescape-word-links`` | bool | ``false`` | Unescape Word Links | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``color.enable.cmd.unix`` | ``--no-color`` | bool | ``true`` | Enable colors in Linux/Unix command line | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``color.enable.cmd.windows`` | ``--no-color`` | bool | ``false`` | Enable colors in Windows command line | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``color.cmd.critical`` | | int | ``196`` | | Color code for critical errors in command line | -| | | | |image0| | | See `term-colors.md <./term-colors.md/>`_ | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``color.cmd.error`` | | int | ``1`` | | Color code for errors in command line | -| | | | |image1| | | See `term-colors.md <./term-colors.md/>`_ | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``color.cmd.warning`` | | int | ``208`` | | Color code for warnings in command line | -| | | | |image2| | | See `term-colors.md <./term-colors.md/>`_ | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``cmdi.prompt.indent.str`` | | str | ``">"`` | | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``cmdi.prompt.indent.color`` | | int | ``2`` | | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``cmdi.prompt.msg.color`` | | int | ``-1`` | | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``cmdi.msg.color`` | | int | ``-1`` | | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``ui_autoSetFormat`` | | bool | ``true`` | | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``reverse_matchWord`` | | bool | ``true`` | | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``reverse_showRel`` | | str | ``"Percent"`` | | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``reverse_saveStep`` | | int | ``1000`` | | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``reverse_minRel`` | | float | ``0.3`` | | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``reverse_maxNum`` | | int | ``-1`` | | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ -| ``reverse_includeDefs`` | | bool | ``false`` | | -+------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| Name | Command Flags | Type | Default | Comment | ++=====================================+===============================+=======+===============+=============================================================================+ +| ``log_time`` | | ``--log-time`` | bool | ``false`` | Show date and time in logs | +| | | ``--no-log-time`` | | | | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``cleanup`` | | ``--cleanup`` | bool | ``true`` | Cleanup cache or temporary files after conversion | +| | | ``--no-cleanup`` | | | | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``auto_sqlite`` | | bool | ``true`` | Auto-enable ``--sqlite`` to limit RAM usage when direct | +| | | | | mode is not possible. Can override with ``--no-sqlite`` | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``enable_alts`` | | ``--alts`` | bool | ``true`` | Enable alternates | +| | | ``--no-alts`` | | | | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``skip_resources`` | ``--skip-resources`` | bool | ``false`` | Skip resources (images, audio, css, etc) | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``save_info_json`` | ``--info`` | bool | ``false`` | Save .info file alongside output file(s) | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``lower`` | | ``--lower`` | bool | ``false`` | Lowercase word(s) | +| | | ``--no-lower`` | | | | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``utf8_check`` | | ``--utf8-check`` | bool | ``false`` | Fix Unicode in word(s) and definition | +| | | ``--no-utf8-check`` | | | | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``rtl`` | ``--rtl`` | bool | ``false`` | Make definition right-to-left | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``remove_html`` | ``--remove-html`` | str | ``""`` | Remove given comma-separated HTML tags (not their contents) from definition | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``remove_html_all`` | ``--remove-html-all`` | bool | ``false`` | Remove all HTML tags (not their contents) from definition | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``normalize_html`` | ``--normalize-html`` | bool | ``false`` | Normalize HTML tags in definition (WIP) | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``skip_duplicate_headword`` | ``--skip-duplicate-headword`` | bool | ``false`` | Skip entries with a duplicate headword | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``trim_arabic_diacritics`` | ``--trim-arabic-diacritics`` | bool | ``false`` | Trim Arabic diacritics from headword | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``unescape_word_links`` | ``--unescape-word-links`` | bool | ``false`` | Unescape Word Links | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``color.enable.cmd.unix`` | ``--no-color`` | bool | ``true`` | Enable colors in Linux/Unix command line | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``color.enable.cmd.windows`` | ``--no-color`` | bool | ``false`` | Enable colors in Windows command line | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``color.cmd.critical`` | | int | ``196`` | | Color code for critical errors in command line | +| | | | |image0| | | See `term-colors.md <./term-colors.md/>`_ | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``color.cmd.error`` | | int | ``1`` | | Color code for errors in command line | +| | | | |image1| | | See `term-colors.md <./term-colors.md/>`_ | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``color.cmd.warning`` | | int | ``208`` | | Color code for warnings in command line | +| | | | |image2| | | See `term-colors.md <./term-colors.md/>`_ | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``cmdi.prompt.indent.str`` | | str | ``">"`` | | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``cmdi.prompt.indent.color`` | | int | ``2`` | | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``cmdi.prompt.msg.color`` | | int | ``-1`` | | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``cmdi.msg.color`` | | int | ``-1`` | | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``ui_autoSetFormat`` | | bool | ``true`` | | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``tk.progressbar.color.fill`` | | str | ``"blue"`` | Tkinter: progressbar fill color | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``tk.progressbar.color.background`` | | str | ``"gray"`` | Tkinter: progressbar background color | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``tk.progressbar.color.text`` | | str | ``"yellow"`` | Tkinter: progressbar text color | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``tk.progressbar.font`` | | str | ``"Sans"`` | Tkinter: progressbar text font. Example: "Sans", "Sans 15" | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``reverse_matchWord`` | | bool | ``true`` | | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``reverse_showRel`` | | str | ``"Percent"`` | | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``reverse_saveStep`` | | int | ``1000`` | | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``reverse_minRel`` | | float | ``0.3`` | | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``reverse_maxNum`` | | int | ``-1`` | | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ +| ``reverse_includeDefs`` | | bool | ``false`` | | ++-------------------------------------+-------------------------------+-------+---------------+-----------------------------------------------------------------------------+ Configuration Files ------------------- diff --git a/pyglossary/ui/base.py b/pyglossary/ui/base.py index 22439c6e7..7200b41c8 100644 --- a/pyglossary/ui/base.py +++ b/pyglossary/ui/base.py @@ -149,7 +149,26 @@ class UIBase: "cmdi.prompt.indent.color": IntOption(hasFlag=False), "cmdi.prompt.msg.color": IntOption(hasFlag=False), "cmdi.msg.color": IntOption(hasFlag=False), + # general GUI options "ui_autoSetFormat": BoolOption(hasFlag=False), + # Tkinter + "tk.progressbar.color.fill": StrOption( + hasFlag=False, + comment="Tkinter: progressbar fill color", + ), + "tk.progressbar.color.background": StrOption( + hasFlag=False, + comment="Tkinter: progressbar background color", + ), + "tk.progressbar.color.text": StrOption( + hasFlag=False, + comment="Tkinter: progressbar text color", + ), + "tk.progressbar.font": StrOption( + hasFlag=False, + comment='Tkinter: progressbar text font. Example: "Sans", "Sans 15"', + ), + # Reverse "reverse_matchWord": BoolOption(hasFlag=False), "reverse_showRel": StrOption(hasFlag=False), "reverse_saveStep": IntOption(hasFlag=False), diff --git a/pyglossary/ui/ui_tk.py b/pyglossary/ui/ui_tk.py index eb613d4a7..173efb4bd 100644 --- a/pyglossary/ui/ui_tk.py +++ b/pyglossary/ui/ui_tk.py @@ -188,25 +188,19 @@ def CallWrapper__call__(self, *args): class ProgressBar(ttk.Frame): - - """ - Comes from John Grayson's book "Python and Tkinter programming" - Edited by Saeed Rasooli. - """ - def __init__( # noqa: PLR0913 self, - rootWin=None, - min_=0, - max_=100, - width=100, - height=18, - appearance="sunken", - fillColor="blue", - background="gray", - labelColor="yellow", - labelFont="Verdana", - value=0, + rootWin, + min_: float, + max_: float, + width: int, + height: int, + appearance: str, # "sunken" + fillColor: str, + background: str, + labelColor: str, + labelFont: str, + value: float = 0, ) -> None: self.min = min_ self.max = max_ @@ -1197,7 +1191,7 @@ def __init__( # _________________________________________________________________ # - statusBarframe = ttk.Frame(self) + statusBarframe = self.statusBarframe = ttk.Frame(self) clearB = newButton( statusBarframe, text="Clear", @@ -1231,20 +1225,6 @@ def __init__( combo.pack(side="left") self.verbosityCombo = comboVar comboVar.set(log.getVerbosity()) - ##### - pbar = ProgressBar(statusBarframe, width=700, height=28) - pbar.pack(side="left", fill="x", expand=True, padx=10) - self.pbar = pbar - statusBarframe.pack(fill="x") - self.progressTitle = "" - # _________________________________________________________________ # - - centerWindow(rootWin) - # show the window - if os.sep == "\\": # Windows - rootWin.attributes("-alpha", 1.0) - else: # Linux - rootWin.deiconify() def textSelectAll(self, tktext) -> None: tktext.tag_add(tk.SEL, "1.0", tk.END) @@ -1468,6 +1448,7 @@ def run( # noqa: PLR0913 convertOptions: dict[str, Any] | None = None, glossarySetAttrs: dict[str, Any] | None = None, ) -> None: + config = config or {} self.config = config if inputFilename: @@ -1491,6 +1472,31 @@ def run( # noqa: PLR0913 if reverse: log.error("Tkinter interface does not support Reverse feature") + pbar = ProgressBar( + self.statusBarframe, + min_=0, + max_=100, + width=700, + height=28, + appearance="sunken", + fillColor=config.get("tk.progressbar.color.fill", "blue"), + background=config.get("tk.progressbar.color.background", "gray"), + labelColor=config.get("tk.progressbar.color.text", "yellow"), + labelFont=config.get("tk.progressbar.font", "Sans"), + ) + pbar.pack(side="left", fill="x", expand=True, padx=10) + self.pbar = pbar + self.statusBarframe.pack(fill="x") + self.progressTitle = "" + # _________________________________________________________________ # + + centerWindow(self.rootWin) + # show the window + if os.sep == "\\": # Windows + self.rootWin.attributes("-alpha", 1.0) + else: # Linux + self.rootWin.deiconify() + # must be before setting self.readOptions and self.writeOptions self.anyEntryChanged()