Skip to content

Commit

Permalink
dependency update #5
Browse files Browse the repository at this point in the history
  • Loading branch information
e3rd committed Dec 30, 2024
1 parent 9b8e83d commit 2954a93
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
3 changes: 3 additions & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 3 additions & 4 deletions mininterface/tk_interface/tk_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", "<Return>")
ToolTip(self.form.button, msg=tip) # NOTE is not destroyed in _clear
self._bind_event(keysym, self._ok)
Expand Down
26 changes: 14 additions & 12 deletions mininterface/tk_interface/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()}.")
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
11 changes: 5 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"]
license = "GPL-3.0-or-later"
Expand All @@ -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"
Expand Down

0 comments on commit 2954a93

Please sign in to comment.