def main(): with Display(): with EasyProcess('zenity --question') as p: p.sleep(1) img = grab() rectangles = discover_buttons() print( rectangles ) img = draw_indexed_rect_list(img, rectangles) img = autocrop(img) # display results img.show()
def check_buttons(cmd, expect): with SmartDisplay(visible=VISIBLE) as disp: with EasyProcess(cmd): disp.waitgrab(timeout=TIMEOUT) buttons = discover_buttons() eq_(len(buttons), len(expect), msg='dialog does not have expected buttons %s!=%s' % (buttons,expect)) mouse = PyMouse() print 'buttons:',buttons for v, b in zip(expect, buttons): process = EasyProcess(cmd).start().sleep(1) mouse.click(*b.center) process.wait() eq_(process.stdout, str(v)) #dialog does not return expected value
def click_button_get_return_code(which_button): with EasyProcess('zenity --question') as p: time.sleep(1) rectangles = discover_buttons() PyMouse().click(*rectangles[which_button].center) return p.wait().return_code
def test_zenity(): with SmartDisplay(visible=0) as d: with EasyProcess('zenity --warning') as p: d.waitgrab() ls = discover_buttons() eq_(len(ls), 1)
def test_gmessage(): with SmartDisplay(visible=0) as d: with EasyProcess('gmessage -buttons x,y,z hi') as p: d.waitgrab() ls = discover_buttons() eq_(len(ls), 3)
def main(): with Display(visible=0): with EasyProcess('zenity --question') as p: p.sleep(5) buttons = discover_buttons() print( buttons )