Skip to content

Commit 5869326

Browse files
committed
Bug fixes
1 parent 5a389fd commit 5869326

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

docs/source/changelog.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,20 @@ Glossary
2424
Releases
2525
---------------------
2626

27+
28+
v1.1.1
29+
================
30+
- Fixed template export on view-only mode, where the template exported wrong type.
31+
- Fixed abstract classes, defined with ``__metaclass__ = ABCMeta``, not being treated as abstract.
32+
33+
2734
v1.1.0
2835
================
2936
- :ref:`Abstract classes` (those that directly inherit :class:`abc.ABC`) are no longer
3037
definable through TkClassWizard.
3138
- :ref:`Polymorphism` support
3239

3340

34-
3541
v1.0.1
3642
=================
3743
- Fixed a bug where the window didn't close and couldn't be closed

tkclasswiz/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Works with Tkinter / TTKBootstrap.
44
"""
55

6-
__version__ = "1.1.0"
6+
__version__ = "1.1.1"
77

88
from .object_frame import *
99
from .annotations import *

tkclasswiz/extensions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Module used to add extensions to add extensions
3-
to TOD.
3+
to TkClassWizard.
44
"""
55
from typing import Callable, TypeVar, Union
66
from inspect import isclass

tkclasswiz/object_frame/frame_base.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import get_args, get_origin, Iterable, Union, Literal, Any, TYPE_CHECKING, TypeVar
22
from abc import ABC
3+
from inspect import isabstract
34
from contextlib import suppress
45

56
from ..convert import *
@@ -157,10 +158,7 @@ def remove_classes(types: list):
157158
r.remove(type_.__wrapped__)
158159

159160
# Abstract classes are classes that don't allow instantiation -> remove the class
160-
# Use the __bases__ instead of issubclass, because ABC is only supposed to denote
161-
# classes abstract if they directly inherit it. In the case of multi-level inheritance
162-
# issubclass would still return True, even though type_ is not a direct subclass ABC.
163-
if ABC in type_.__bases__:
161+
if isabstract(type_):
164162
r.remove(type_)
165163

166164
return r

tkclasswiz/object_frame/frame_struct.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,13 @@ def __init__(
7272
check_parameters: bool = True,
7373
allow_save = True,
7474
additional_values: dict = {},
75+
_annotations_override: dict = None,
7576
):
7677
super().__init__(class_, return_widget, parent, old_data, check_parameters,allow_save)
7778
self._map: Dict[str, Tuple[ComboBoxObjects, Iterable[type]]] = {}
7879
dpi_5 = dpi_scaled(5)
7980

80-
if not (annotations := get_annotations(class_)):
81+
if not (annotations := _annotations_override or get_annotations(class_)):
8182
raise TypeError("This object cannot be edited.")
8283

8384
# Template
@@ -297,15 +298,9 @@ class NewObjectFrameStructView(NewObjectFrameStruct):
297298
get mapped as annotations, which the :class:`NewObjectFrameStruct` knows how to handle.
298299
"""
299300
def __init__(self, class_, *args, **kwargs):
300-
class Viewer:
301-
def __init__(self) -> None:
302-
pass
303-
304-
Viewer.__name__ = class_.__name__
305-
306301
old_data: ObjectInfo = kwargs["old_data"]
307-
Viewer.__init__.__annotations__ = {k: v.class_ if isinstance(v, ObjectInfo) else type(v) for k, v in old_data.data.items()}
308-
super().__init__(Viewer, *args, **kwargs)
302+
annotations = {k: v.class_ if isinstance(v, ObjectInfo) else type(v) for k, v in old_data.data.items()}
303+
super().__init__(class_, *args, **kwargs, _annotations_override=annotations)
309304

310305
@gui_except()
311306
def _edit_selected(self, key: str, combo: ComboBoxObjects):
@@ -322,5 +317,3 @@ def _edit_selected(self, key: str, combo: ComboBoxObjects):
322317
return self.new_object_frame(selection.class_, combo, old_data=selection)
323318
else:
324319
return self.new_object_frame(type(selection), combo, old_data=selection)
325-
326-

0 commit comments

Comments
 (0)