Added new force parameter to all SetFocus calls. Removed calls to WM_DESTROY due to memory leak

This commit is contained in:
MikeTheWatchGuy 2019-06-19 08:30:04 -04:00
parent 6c3da863d3
commit 9cce12e8c2
1 changed files with 33 additions and 13 deletions

View File

@ -704,10 +704,13 @@ class InputText(Element):
text = ''
return text
def SetFocus(self):
def SetFocus(self, force=False):
""" """
try:
self.TKEntry.focus_set()
if force:
self.TKEntry.focus_force()
else:
self.TKEntry.focus_set()
except:
pass
@ -1023,10 +1026,13 @@ class Listbox(Element):
""" """
return self.Values
def SetFocus(self):
def SetFocus(self, force=False):
""" """
try:
self.TKListbox.focus_set()
if force:
self.TKListbox.focus_force()
else:
self.TKListbox.focus_set()
except:
pass
@ -1405,13 +1411,17 @@ class Multiline(Element):
""" """
return self.TKText.get(1.0, tk.END)
def SetFocus(self):
def SetFocus(self, force=False):
""" """
try:
self.TKText.focus_set()
if force:
self.TKText.focus_force()
else:
self.TKText.focus_set()
except:
pass
def __del__(self):
""" """
super().__del__()
@ -2082,13 +2092,17 @@ class Button(Element):
""" """
return self.ButtonText
def SetFocus(self):
def SetFocus(self, force=False):
""" """
try:
self.TKButton.focus_set()
if force:
self.TKButton.focus_force()
else:
self.TKButton.focus_set()
except:
pass
def Click(self):
"""Generates a click of the button as if the user clicked the button
:return:
@ -2881,10 +2895,16 @@ class Graph(Element):
if self.ParentForm.CurrentlyRunningMainloop:
self.ParentForm.TKroot.quit() # kick out of loop if read was called
def SetFocus(self):
def SetFocus(self, force=False):
""" """
self._TKCanvas2.focus_set()
# self._TKCanvas2.focus_force()
try:
if force:
self._TKCanvas2.focus_force()
else:
self._TKCanvas2.focus_set()
except:
pass
def __del__(self):
""" """
@ -4852,8 +4872,8 @@ class Window:
self.TKAfterID = self.TKroot.after(timeout, self._TimeoutAlarmCallback)
self.CurrentlyRunningMainloop = True
# print(f'In main {self.Title} {self.TKroot}')
self.TKroot.protocol("WM_DESTROY_WINDOW", self.OnClosingCallback)
self.TKroot.protocol("WM_DELETE_WINDOW", self.OnClosingCallback)
# self.TKroot.protocol("WM_DESTROY_WINDOW", self.OnClosingCallback)
# self.TKroot.protocol("WM_DELETE_WINDOW", self.OnClosingCallback)
self.TKroot.mainloop()
# print('Out main')
self.CurrentlyRunningMainloop = False