reflow get_geometry some, pep8
This commit is contained in:
parent
284021f207
commit
dc215a5d01
|
@ -49,6 +49,7 @@ from TableWindow import Table_Window
|
||||||
b_width = 3
|
b_width = 3
|
||||||
tb_height = 29
|
tb_height = 29
|
||||||
|
|
||||||
|
|
||||||
class Table(Table_Window):
|
class Table(Table_Window):
|
||||||
|
|
||||||
def find_table_parameters(self):
|
def find_table_parameters(self):
|
||||||
|
@ -56,39 +57,43 @@ class Table(Table_Window):
|
||||||
titles = {}
|
titles = {}
|
||||||
win32gui.EnumWindows(win_enum_handler, titles)
|
win32gui.EnumWindows(win_enum_handler, titles)
|
||||||
for hwnd in titles:
|
for hwnd in titles:
|
||||||
if titles[hwnd] == "": continue
|
if titles[hwnd] == "":
|
||||||
|
continue
|
||||||
if re.search(self.search_string, titles[hwnd]):
|
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
|
self.window = hwnd
|
||||||
break
|
break
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if self.window == None:
|
if self.window == None:
|
||||||
log.error( "Window %s not found. Skipping." % self.search_string )
|
log.error("Window %s not found. Skipping." % self.search_string)
|
||||||
return None
|
return None
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
log.error(_("self.window doesn't exist? why?"))
|
log.error(_("self.window doesn't exist? why?"))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
self.title = titles[hwnd]
|
self.title = titles[hwnd]
|
||||||
self.hud = None
|
self.hud = None
|
||||||
self.number = hwnd
|
self.number = hwnd
|
||||||
|
|
||||||
def get_geometry(self):
|
def get_geometry(self):
|
||||||
if not win32gui.IsWindow(self.number): # window closed
|
|
||||||
return None
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
(x, y, width, height) = win32gui.GetWindowRect(self.number)
|
if win32gui.IsWindow(self.number):
|
||||||
#print "x=",x,"y=",y,"width=",width,"height=",height
|
(x, y, width, height) = win32gui.GetWindowRect(self.number)
|
||||||
width = width - x
|
# this apparently returns x = far left side of window, width = far right side of window, y = top of window, height = bottom of window
|
||||||
height = height - y
|
# so apparently we have to subtract x from "width" to get actual width, and y from "height" to get actual height ?
|
||||||
return {'x' : int(x) + b_width,
|
# 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,
|
||||||
'y' : int(y) + tb_height,
|
'y' : int(y) + tb_height,
|
||||||
'height' : int(height) - y,
|
'height' : int(height) - y,
|
||||||
'width' : int(width) - x
|
'width' : int(width) - x
|
||||||
}
|
}
|
||||||
except:
|
except AttributeError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_window_title(self):
|
def get_window_title(self):
|
||||||
|
@ -145,5 +150,6 @@ class Table(Table_Window):
|
||||||
|
|
||||||
# hud.main_window.set_title(real_name)
|
# hud.main_window.set_title(real_name)
|
||||||
|
|
||||||
|
|
||||||
def win_enum_handler(hwnd, titles):
|
def win_enum_handler(hwnd, titles):
|
||||||
titles[hwnd] = win32gui.GetWindowText(hwnd)
|
titles[hwnd] = win32gui.GetWindowText(hwnd)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user