Skip to content

Commit

Permalink
Fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhozic committed Dec 22, 2023
1 parent 0fbeba0 commit a93368d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
7 changes: 7 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ Glossary
Releases
---------------------

v1.0.1
=================
- Fixed a bug where the window didn't close and couldn't be closed
if an exception was raised when trying to define a class without annotations, and there
were no previously opened frames.


v1.0.0
=================
- Initial release
2 changes: 1 addition & 1 deletion tkclasswiz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Works with Tkinter / TTKBootstrap.
"""

__version__ = "1.0.0"
__version__ = "1.0.1"

from .object_frame import *
from .annotations import *
Expand Down
30 changes: 21 additions & 9 deletions tkclasswiz/object_frame/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def __init__(self, *args, **kwargs):
def closed(self) -> bool:
return self._closed

@gui_except()
def open_object_edit_frame(
self,
class_,
Expand Down Expand Up @@ -104,16 +103,26 @@ def open_object_edit_frame(
allow_save: bool
If False, will open in read-only mode.
"""
if len(self.opened_frames):
prev_frame = self.opened_frames[-1]
else:
prev_frame = None
frame = self._create_and_add_frame(class_, return_widget, old_data, check_parameters, allow_save, kwargs)
if frame is None and not self.opened_frames:
self.destroy()
self._closed = True

@gui_except()
def _create_and_add_frame(
self,
class_: type,
return_widget,
old_data,
check_parameters: bool,
allow_save: bool,
kwargs
):
frame: NewObjectFrameBase
class_origin = get_origin(class_)
if class_origin is None:
class_origin = class_

frame: NewObjectFrameBase
frame_class = self.TYPE_INIT_MAP.get(class_origin, NewObjectFrameStruct)
self.opened_frames.append(
frame := frame_class(
Expand All @@ -126,13 +135,16 @@ def open_object_edit_frame(
**kwargs
)
)

if len(self.opened_frames) > 1:
self.opened_frames[-2].pack_forget()

frame.pack(fill=tk.BOTH, expand=True)
frame.update_window_title()
if prev_frame is not None:
prev_frame.pack_forget()

self.set_default_size_y()

return frame

def close_object_edit_frame(self):
self.opened_frames[-1].close_frame()

Expand Down

0 comments on commit a93368d

Please sign in to comment.