Skip to content

Commit a93368d

Browse files
committed
Fixed bug
1 parent 0fbeba0 commit a93368d

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

docs/source/changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ Glossary
2424
Releases
2525
---------------------
2626

27+
v1.0.1
28+
=================
29+
- Fixed a bug where the window didn't close and couldn't be closed
30+
if an exception was raised when trying to define a class without annotations, and there
31+
were no previously opened frames.
32+
33+
2734
v1.0.0
2835
=================
2936
- Initial release

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.0.0"
6+
__version__ = "1.0.1"
77

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

tkclasswiz/object_frame/window.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ def __init__(self, *args, **kwargs):
7676
def closed(self) -> bool:
7777
return self._closed
7878

79-
@gui_except()
8079
def open_object_edit_frame(
8180
self,
8281
class_,
@@ -104,16 +103,26 @@ def open_object_edit_frame(
104103
allow_save: bool
105104
If False, will open in read-only mode.
106105
"""
107-
if len(self.opened_frames):
108-
prev_frame = self.opened_frames[-1]
109-
else:
110-
prev_frame = None
106+
frame = self._create_and_add_frame(class_, return_widget, old_data, check_parameters, allow_save, kwargs)
107+
if frame is None and not self.opened_frames:
108+
self.destroy()
109+
self._closed = True
111110

111+
@gui_except()
112+
def _create_and_add_frame(
113+
self,
114+
class_: type,
115+
return_widget,
116+
old_data,
117+
check_parameters: bool,
118+
allow_save: bool,
119+
kwargs
120+
):
121+
frame: NewObjectFrameBase
112122
class_origin = get_origin(class_)
113123
if class_origin is None:
114124
class_origin = class_
115125

116-
frame: NewObjectFrameBase
117126
frame_class = self.TYPE_INIT_MAP.get(class_origin, NewObjectFrameStruct)
118127
self.opened_frames.append(
119128
frame := frame_class(
@@ -126,13 +135,16 @@ def open_object_edit_frame(
126135
**kwargs
127136
)
128137
)
138+
139+
if len(self.opened_frames) > 1:
140+
self.opened_frames[-2].pack_forget()
141+
129142
frame.pack(fill=tk.BOTH, expand=True)
130143
frame.update_window_title()
131-
if prev_frame is not None:
132-
prev_frame.pack_forget()
133-
134144
self.set_default_size_y()
135145

146+
return frame
147+
136148
def close_object_edit_frame(self):
137149
self.opened_frames[-1].close_frame()
138150

0 commit comments

Comments
 (0)