kann mit jemand einen Tipp geben, warum im unten stehenden Code die Funktion 'WingetByTitle', ausgeführt im Main thread, ein Ergebnis liefert, die selbe Funktion in GUIclass (Thread-1), Button command=WingetByTitle, jedoch loopt?
Danke fürs Lesen
Wolf
Code: Alles auswählen
import win32gui, threading
from Tkinter import Tk, Button
################################################################################
class GUIclass(threading.Thread):
def __init__(self):
self.root = Tk()
self.root.geometry('300x70')
self.root.title('*** ShowWindows ***')
Button(self.root, command=WingetByTitle, text='ShowWindows').pack()
threading.Thread.__init__(self)
def run(self):
self.root.mainloop()
################################################################################
def WingetByTitle(title='PyDev'):
topWindows = []
print("WingetByTitle '%s'" %(title))
win32gui.EnumWindows(winEnumHandler, topWindows)
for e in topWindows:
print("e=%s %s" %(e[0], e[1]))
if (title in e[1]):
print("found: handle=%s, title=%s\n" %(e[0], e[1]))
return
return
#-------------------------------------------------------------------------------
def winEnumHandler(hwnd, resultList):
t = win32gui.GetWindowText(hwnd)
if (t):
resultList.append((hwnd, t))
return(hwnd)
return(None)
################################################################################
WingetByTitle(title='PyDev') # liefert Ergebnis
GUI = GUIclass()
GUI.start()
################################################################################