From d4533a8c50dcc9de498ef6ef81f9d0c481682c6b Mon Sep 17 00:00:00 2001 From: Hauke Platte Date: Thu, 14 Mar 2024 10:10:11 +0100 Subject: [PATCH] fix(UI-UX): edit screen loads previous value --- UI/profile.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/UI/profile.py b/UI/profile.py index 2b5e120..21d2f9b 100644 --- a/UI/profile.py +++ b/UI/profile.py @@ -9,16 +9,17 @@ class NewProfile(base_frame): def __init__(self, master, *args, **kwargs): super().__init__(master) - self._create_widgets() - self._display_widgets() self.address_toogle = False self.next = kwargs.pop('return_to', Profile) + self.edit = kwargs.pop('edit', False) + self._create_widgets() + self._display_widgets() def _create_widgets(self): self.lblTitle = tk.Label(self, text='Create profile', font=self.master.title_font) self.lblName = tk.Label(self, text='Name') self.etrName = tk.Entry(self) - self.varName = self.etrName.var + self.etrName.val = self.master.player.display_name if self.edit else '' self.btnCreate = tk.Button(self, text='Create profile', command=lambda *args: self._create()) self.btnMenu = tk.Button(self, text='Menu', command=lambda: self.master.show_menu()) @@ -42,7 +43,7 @@ def _display_widgets(self): self.btnMenu.grid(sticky=tk.E+tk.W+tk.N+tk.S, column=9, row=1) def _create(self): - self.master.player = Player(self.varName.get(), 0) + self.master.player = Player(self.etrName.val, 0) self.master.show(self.next) class Profile(base_frame): @@ -63,7 +64,7 @@ def _create_widgets(self): self.lblNameValue = tk.Label(self, text=self.master.player.display_name) self.lblUUDI = tk.Label(self, text='User ID') self.lblUUIDValue = tk.Label(self, text=self.master.player.uuid) - self.btnEdit = tk.Button(self, text='Edit Profile', command=lambda *args: self.master.show(NewProfile, 'edit')) + self.btnEdit = tk.Button(self, text='Edit Profile', command=lambda *args: self.master.show(NewProfile, edit=True)) self.btnDelete = tk.Button(self, text='Delete profile', command=lambda *args: self._delete()) self.btnMenu = tk.Button(self, text='Menu', command=lambda: self.master.show_menu()) @@ -91,4 +92,4 @@ def _display_widgets(self): def _delete(self): self.master.player = None - self.master.show(NewProfile, 'delete') \ No newline at end of file + self.master.show(NewProfile) \ No newline at end of file