From 2954a935dde8480937293a33938097075031dabd Mon Sep 17 00:00:00 2001 From: Edvard Rejthar Date: Mon, 30 Dec 2024 14:16:05 +0100 Subject: [PATCH] dependency update #5 --- docs/Changelog.md | 3 +++ mininterface/tk_interface/tk_window.py | 7 +++---- mininterface/tk_interface/utils.py | 26 ++++++++++++++------------ pyproject.toml | 11 +++++------ 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 26d1171..5a37f96 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,5 +1,8 @@ # Changelog +## 0.7.2 +* GUI calendar + ## 0.7.1 (2024-11-27) * GUI scrollbars if window is bigger than the screen * [non-interactive][mininterface.Mininterface.__enter__] session support diff --git a/mininterface/tk_interface/tk_window.py b/mininterface/tk_interface/tk_window.py index 4ca62e8..a507680 100644 --- a/mininterface/tk_interface/tk_window.py +++ b/mininterface/tk_interface/tk_window.py @@ -72,17 +72,16 @@ def run_dialog(self, form: TagDict, title: str = "", submit: bool | str = True) self.form = Form(self.frame, name_form="", form_dict=formdict_to_widgetdict(form, self.widgetize), - name_config=submit if isinstance(submit, str) else "Ok", - button=bool(submit) + name_button=submit if isinstance(submit, str) else "Ok", + button_command=self._ok if submit else None ) self.form.pack() # Add radio etc. - replace_widgets(self, self.form.widgets, form) + replace_widgets(self, self.form.fields, form) # Set the submit and exit options if self.form.button: - self.form.button.config(command=self._ok) tip, keysym = ("Enter", "") ToolTip(self.form.button, msg=tip) # NOTE is not destroyed in _clear self._bind_event(keysym, self._ok) diff --git a/mininterface/tk_interface/utils.py b/mininterface/tk_interface/utils.py index 9e987f3..2dbe966 100644 --- a/mininterface/tk_interface/utils.py +++ b/mininterface/tk_interface/utils.py @@ -6,6 +6,8 @@ from autocombobox import AutoCombobox +from tkinter_form.tkinter_form import Form, FieldForm + from ..auxiliary import flatten, flatten_keys from ..experimental import MININTERFACE_CONFIG, FacetCallback, SubmitButton from ..form_dict import TagDict @@ -42,13 +44,12 @@ def get(self): def ready_to_replace(widget: Widget, - name, - tag: "Tag", - variable: Variable) -> tuple[Widget, dict]: + variable: Variable, + field_form: FieldForm) -> tuple[Widget, dict]: if widget.winfo_manager() == 'grid': grid_info = widget.grid_info() widget.grid_forget() - widget.master._Form__vars[name] = variable + field_form.variable = variable return grid_info else: raise ValueError(f"GuiInterface: Cannot tackle the form, unknown winfo_manager {widget.winfo_manager()}.") @@ -87,17 +88,18 @@ def _(*_): def replace_widgets(tk_app: "TkWindow", nested_widgets, form: TagDict): def _fetch(variable): - return ready_to_replace(widget, var_name, tag, variable) + return ready_to_replace(widget, variable, field_form) # NOTE tab order broken, injected to another position # NOTE should the button receive tag or directly # the whole facet (to change the current form)? Specifiable by experimental.FacetCallback. nested_widgets = widgets_to_dict(nested_widgets) - for (var_name, tag), (label1, widget) in zip(flatten_keys(form), flatten(nested_widgets)): + for tag, field_form in zip(flatten(form), flatten(nested_widgets)): tag: Tag - label1: Widget - widget: Widget - variable = widget.master._Form__vars[var_name] + field_form: FieldForm + label1: Widget = field_form.label + widget: Widget = field_form.widget + variable = field_form.variable subwidgets = [] master = widget.master @@ -185,15 +187,15 @@ def create_button(master, _fetch, tag, label1, command=None): return variable, widget2 -def widgets_to_dict(widgets_dict) -> dict: +def widgets_to_dict(widgets_dict) -> dict[str, dict | FieldForm]: """ Convert tkinter_form.widgets to a dict """ result = {} for key, value in widgets_dict.items(): if isinstance(value, dict): result[key] = widgets_to_dict(value) - elif hasattr(value, 'widgets'): + elif isinstance(value, Form): # this is another tkinter_form.Form, recursively parse - result[key] = widgets_to_dict(value.widgets) + result[key] = widgets_to_dict(value.fields) else: # value is a tuple of (Label, Widget (like Entry)) result[key] = value return result diff --git a/pyproject.toml b/pyproject.toml index 41b4a0d..7a39442 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "mininterface" -version = "0.7.1" +version = "0.7.2" description = "A minimal access to GUI, TUI, CLI and config" authors = ["Edvard Rejthar "] license = "GPL-3.0-or-later" @@ -19,17 +19,16 @@ typing_extensions = "*" pyyaml = "*" # Standard requirements autocombobox = "1.4.2" -humanize = "*" # used only in the TkInterface, hence it is not a minimal requirement +humanize = "*" # used only in the TkInterface, hence it is not a minimal requirement textual = "~0.84" tkinter-tooltip = "*" -tkinter_form = "0.1.5.2" +tkinter_form = "0.2.1" tkscrollableframe = "*" -tkcalendar = "*" # TODO put into extras? [tool.poetry.extras] web = ["textual-serve"] -img = ["pillow"] -all = ["textual-serve", "pillow"] +gui = ["pillow", "tkcalendar"] +all = ["textual-serve", "pillow", "tkcalendar"] [tool.poetry.scripts] mininterface = "mininterface.__main__:main"