SetFocus for Input and Multiline. Fix for closing Debug Print window with X
This commit is contained in:
parent
bd32345218
commit
39a0b8e8a5
|
@ -515,6 +515,13 @@ class InputText(Element):
|
||||||
def Get(self):
|
def Get(self):
|
||||||
return self.TKStringVar.get()
|
return self.TKStringVar.get()
|
||||||
|
|
||||||
|
|
||||||
|
def SetFocus(self):
|
||||||
|
try:
|
||||||
|
self.TKEntry.focus_set()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
super().__del__()
|
super().__del__()
|
||||||
|
|
||||||
|
@ -983,6 +990,13 @@ class Multiline(Element):
|
||||||
def Get(self):
|
def Get(self):
|
||||||
return self.TKText.get(1.0, tk.END)
|
return self.TKText.get(1.0, tk.END)
|
||||||
|
|
||||||
|
|
||||||
|
def SetFocus(self):
|
||||||
|
try:
|
||||||
|
self.TKText.focus_set()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
super().__del__()
|
super().__del__()
|
||||||
|
|
||||||
|
@ -3175,10 +3189,7 @@ class Window:
|
||||||
for row in self.Rows:
|
for row in self.Rows:
|
||||||
for element in row:
|
for element in row:
|
||||||
element.__del__()
|
element.__del__()
|
||||||
# try:
|
|
||||||
# del(self.TKroot)
|
|
||||||
# except:
|
|
||||||
# pass
|
|
||||||
|
|
||||||
|
|
||||||
FlexForm = Window
|
FlexForm = Window
|
||||||
|
@ -5073,22 +5084,31 @@ class DebugWin():
|
||||||
[DummyButton('Quit')]
|
[DummyButton('Quit')]
|
||||||
]
|
]
|
||||||
self.window.AddRows(self.layout)
|
self.window.AddRows(self.layout)
|
||||||
self.window.Show(non_blocking=True) # Show a ;non-blocking form, returns immediately
|
self.window.Read(timeout=0) # Show a non-blocking form, returns immediately
|
||||||
return
|
return
|
||||||
|
|
||||||
def Print(self, *args, end=None, sep=None):
|
def Print(self, *args, end=None, sep=None):
|
||||||
sepchar = sep if sep is not None else ' '
|
sepchar = sep if sep is not None else ' '
|
||||||
endchar = end if end is not None else '\n'
|
endchar = end if end is not None else '\n'
|
||||||
|
|
||||||
|
if self.window is None: # if window was destroyed already, just print
|
||||||
|
print(*args, sep=sepchar, end=endchar)
|
||||||
|
return
|
||||||
|
|
||||||
event, values = self.window.Read(timeout=0)
|
event, values = self.window.Read(timeout=0)
|
||||||
if event == 'Quit' or event is None:
|
if event == 'Quit' or event is None:
|
||||||
self.Close()
|
self.Close()
|
||||||
print(*args, sep=sepchar, end=endchar)
|
print(*args, sep=sepchar, end=endchar)
|
||||||
|
# Add extra check to see if the window was closed... if closed by X sometimes am not told
|
||||||
|
try:
|
||||||
|
state = self.window.TKroot.state()
|
||||||
|
except:
|
||||||
|
self.Close()
|
||||||
|
|
||||||
def Close(self):
|
def Close(self):
|
||||||
self.window.Close()
|
self.window.Close()
|
||||||
self.window.__del__()
|
self.window.__del__()
|
||||||
|
self.window = None
|
||||||
|
|
||||||
def PrintClose():
|
def PrintClose():
|
||||||
EasyPrintClose()
|
EasyPrintClose()
|
||||||
|
@ -5104,20 +5124,12 @@ def EasyPrint(*args, size=(None, None), end=None, sep=None, location=(None, None
|
||||||
Print = EasyPrint
|
Print = EasyPrint
|
||||||
eprint = EasyPrint
|
eprint = EasyPrint
|
||||||
|
|
||||||
def EasyPrintold(*args, size=(None, None), end=None, sep=None):
|
|
||||||
if 'easy_print_data' not in EasyPrint.__dict__: # use a function property to save DebugWin object (static variable)
|
|
||||||
EasyPrint.easy_print_data = DebugWin(size=size)
|
|
||||||
if EasyPrint.easy_print_data is None:
|
|
||||||
EasyPrint.easy_print_data = DebugWin(size=size)
|
|
||||||
EasyPrint.easy_print_data.Print(*args, end=end, sep=sep)
|
|
||||||
|
|
||||||
|
|
||||||
def EasyPrintClose():
|
def EasyPrintClose():
|
||||||
if 'easy_print_data' in EasyPrint.__dict__:
|
global _easy_print_data
|
||||||
if EasyPrint.easy_print_data is not None:
|
if _easy_print_data is not None:
|
||||||
EasyPrint.easy_print_data._Close()
|
_easy_print_data.Close()
|
||||||
EasyPrint.easy_print_data = None
|
_easy_print_data = None
|
||||||
# del EasyPrint.easy_print_data
|
|
||||||
|
|
||||||
|
|
||||||
# ======================== Scrolled Text Box =====#
|
# ======================== Scrolled Text Box =====#
|
||||||
|
|
Loading…
Reference in New Issue