Skip to content

Commit

Permalink
fix(UI-UX): edit screen loads previous value
Browse files Browse the repository at this point in the history
  • Loading branch information
HOOK-Hawkins committed Mar 14, 2024
1 parent 124f287 commit d4533a8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions UI/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -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):
Expand All @@ -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())

Expand Down Expand Up @@ -91,4 +92,4 @@ def _display_widgets(self):

def _delete(self):
self.master.player = None
self.master.show(NewProfile, 'delete')
self.master.show(NewProfile)

0 comments on commit d4533a8

Please sign in to comment.