Skip to content

Commit b17c19b

Browse files
committed
fix live buttons
1 parent f914f63 commit b17c19b

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

src/daf/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ async def initialize(user_callback: Optional[Union[Callable, Coroutine]] = None,
147147
# Initialize logging
148148
# ------------------------------------------------------------
149149
if logger is None:
150-
logger = logging.LoggerJSON(path=str(Path.home().joinpath("daf/History")))
150+
logger = logging.LoggerJSON()
151151

152152
await logging.initialize(logger)
153153
# ------------------------------------------------------------

src/daf/logging/_logging.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ class LoggerCSV(LoggerBASE):
178178
Parameters
179179
----------------
180180
path: str
181-
Path to the folder where logs will be saved.
181+
Path to the folder where logs will be saved. Defaults to /<user-home>/daf/History
182182
delimiter: str
183-
The delimiter between columns to use.
183+
The delimiter between columns to use. Defaults to ';'
184184
fallback: Optional[LoggerBASE]
185185
The manager to use, in case saving using this manager fails.
186186
@@ -190,7 +190,12 @@ class LoggerCSV(LoggerBASE):
190190
Something went wrong at OS level (insufficient permissions?)
191191
and fallback failed as well.
192192
"""
193-
def __init__(self, path: str, delimiter: str, fallback: Optional[LoggerBASE] = None) -> None:
193+
def __init__(
194+
self,
195+
path: str = str(pathlib.Path.home().joinpath("daf/History")),
196+
delimiter: str = ';',
197+
fallback: Optional[LoggerBASE] = None
198+
) -> None:
194199
self.path = path
195200
self.delimiter = delimiter
196201
super().__init__(fallback)
@@ -261,8 +266,8 @@ class LoggerJSON(LoggerBASE):
261266
262267
Parameters
263268
----------------
264-
path: str
265-
Path to the folder where logs will be saved.
269+
path: Optional[str]
270+
Path to the folder where logs will be saved. Defaults to /<user-home>/daf/History
266271
fallback: Optional[LoggerBASE]
267272
The manager to use, in case saving using this manager fails.
268273
@@ -272,7 +277,11 @@ class LoggerJSON(LoggerBASE):
272277
Something went wrong at OS level (insufficient permissions?)
273278
and fallback failed as well.
274279
"""
275-
def __init__(self, path: str, fallback: Optional[LoggerBASE] = None) -> None:
280+
def __init__(
281+
self,
282+
path: str = str(pathlib.Path.home().joinpath("daf/History")),
283+
fallback: Optional[LoggerBASE] = None
284+
) -> None:
276285
self.path = path
277286
super().__init__(fallback)
278287

src/daf/logging/sql/mgr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def __init__(self,
258258
if fallback is Ellipsis:
259259
# Cannot use None as this can be a legit user value
260260
# and cannot pass directly due to Sphinx issues
261-
fallback = logging.LoggerJSON("History")
261+
fallback = logging.LoggerJSON()
262262

263263
if dialect is None:
264264
dialect = "sqlite"

src/daf_gui/widgets/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
from .object import *
77
from .dpi import *
88
from .async_util import *
9-
from .convert import *
9+
from .convert import *

src/daf_gui/widgets/extra.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ def _callback(*args):
9595

9696
def setup_additional_live_update(w: ttk.Button, frame):
9797
# Don't have a bound object instance
98-
if frame.old_object_info is None or frame.old_object_info.real_object is None:
98+
if (
99+
(oi := frame.old_object_info) is None or
100+
(ro := oi.real_object) is None or
101+
getattr(ro, "parent", False) is None
102+
):
99103
return
100104

101105
def _callback(*args):
@@ -114,7 +118,11 @@ def _callback(*args):
114118

115119
def setup_additional_live_refresh(w: ttk.Button, frame):
116120
# Don't have a bound object instance
117-
if frame.old_object_info is None or frame.old_object_info.real_object is None:
121+
if (
122+
(oi := frame.old_object_info) is None or
123+
(ro := oi.real_object) is None or
124+
getattr(ro, "parent", False) is None
125+
):
118126
return
119127

120128
def _callback(*args):
@@ -146,6 +154,7 @@ def _callback(*args):
146154
if hasattr(item, "update"):
147155
if item not in ADDITIONAL_WIDGETS:
148156
ADDITIONAL_WIDGETS[item] = []
157+
149158
ADDITIONAL_WIDGETS[item].extend([
150159
AdditionalWidget(ttk.Button, setup_additional_live_update, text="Live update"),
151160
AdditionalWidget(ttk.Button, setup_additional_live_refresh, text="Refresh")

0 commit comments

Comments
 (0)