From eb37de359477c092098660cb0fe439c5f9797746 Mon Sep 17 00:00:00 2001 From: eblade Date: Wed, 10 Jun 2009 13:47:07 -0400 Subject: [PATCH] fix get_geometry to use the correct parameters to IsWindow and GetWindowRect (too much error trapping will create pitfalls), use main_window.window instead of window_foreign_new() to get gdkhandle for gtkwindow, remove process enumeration in topify() for windows --- pyfpdb/WinTables.py | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/pyfpdb/WinTables.py b/pyfpdb/WinTables.py index cb449a52..d8f138eb 100644 --- a/pyfpdb/WinTables.py +++ b/pyfpdb/WinTables.py @@ -79,12 +79,11 @@ class Table(Table_Window): self.gdkhandle = gtk.gdk.window_foreign_new(long(self.window)) def get_geometry(self): - - if not win32gui.IsWindow(self.window): # window closed + if not win32gui.IsWindow(self.number): # window closed return None try: - (x, y, width, height) = win32gui.GetWindowRect(hwnd) + (x, y, width, height) = win32gui.GetWindowRect(self.number) width = width - x height = height - y return {'x' : int(x) + b_width, @@ -121,31 +120,32 @@ class Table(Table_Window): def topify(self, hud): """Set the specified gtk window to stayontop in MS Windows.""" - def windowEnumerationHandler(hwnd, resultList): - '''Callback for win32gui.EnumWindows() to generate list of window handles.''' - resultList.append((hwnd, win32gui.GetWindowText(hwnd))) - - unique_name = 'unique name for finding this window' - real_name = hud.main_window.get_title() - hud.main_window.set_title(unique_name) - tl_windows = [] - win32gui.EnumWindows(windowEnumerationHandler, tl_windows) - - for w in tl_windows: - if w[1] == unique_name: +# def windowEnumerationHandler(hwnd, resultList): +# '''Callback for win32gui.EnumWindows() to generate list of window handles.''' +# resultList.append((hwnd, win32gui.GetWindowText(hwnd))) +# +# unique_name = 'unique name for finding this window' +# real_name = hud.main_window.get_title() +# hud.main_window.set_title(unique_name) +# tl_windows = [] +# win32gui.EnumWindows(windowEnumerationHandler, tl_windows) +# +# for w in tl_windows: +# if w[1] == unique_name: # hud.main_window.gdkhandle = gtk.gdk.window_foreign_new(w[0]) -# hud.main_window.gdkhandle.set_transient_for(self.gdkhandle) - rect = self.gdkhandle.get_frame_extents() - (innerx, innery) = self.gdkhandle.get_origin() - b_width = rect.x - innerx - tb_height = rect.y - innery + hud.main_window.gdkhandle = hud.main_window.window + hud.main_window.gdkhandle.set_transient_for(self.gdkhandle) + rect = self.gdkhandle.get_frame_extents() + (innerx, innery) = self.gdkhandle.get_origin() + b_width = rect.x - innerx + tb_height = rect.y - innery # # style = win32gui.GetWindowLong(self.number, win32con.GWL_EXSTYLE) # style |= win32con.WS_CLIPCHILDREN # win32gui.SetWindowLong(self.number, win32con.GWL_EXSTYLE, style) - break +# break - hud.main_window.set_title(real_name) +# hud.main_window.set_title(real_name) def win_enum_handler(hwnd, titles): titles[hwnd] = win32gui.GetWindowText(hwnd)