reflow get_geometry some, pep8

This commit is contained in:
Eric Blade 2010-10-11 18:22:55 -04:00
parent 284021f207
commit dc215a5d01

View File

@ -49,6 +49,7 @@ from TableWindow import Table_Window
b_width = 3
tb_height = 29
class Table(Table_Window):
def find_table_parameters(self):
@ -56,9 +57,11 @@ class Table(Table_Window):
titles = {}
win32gui.EnumWindows(win_enum_handler, titles)
for hwnd in titles:
if titles[hwnd] == "": continue
if titles[hwnd] == "":
continue
if re.search(self.search_string, titles[hwnd]):
if self.check_bad_words(titles[hwnd]): continue
if self.check_bad_words(titles[hwnd]):
continue
self.window = hwnd
break
@ -75,20 +78,22 @@ class Table(Table_Window):
self.number = hwnd
def get_geometry(self):
if not win32gui.IsWindow(self.number): # window closed
return None
try:
if win32gui.IsWindow(self.number):
(x, y, width, height) = win32gui.GetWindowRect(self.number)
# this apparently returns x = far left side of window, width = far right side of window, y = top of window, height = bottom of window
# so apparently we have to subtract x from "width" to get actual width, and y from "height" to get actual height ?
# it definitely gives slightly different results than the GTK code that does the same thing.
#print "x=", x, "y=", y, "width=", width, "height=", height
width = width - x
height = height - y
return {'x' : int(x) + b_width,
return {
'x' : int(x) + b_width,
'y' : int(y) + tb_height,
'height' : int(height) - y,
'width' : int(width) - x
}
except:
except AttributeError:
return None
def get_window_title(self):
@ -145,5 +150,6 @@ class Table(Table_Window):
# hud.main_window.set_title(real_name)
def win_enum_handler(hwnd, titles):
titles[hwnd] = win32gui.GetWindowText(hwnd)