def draw_a_line(context): current_window = context.app.get_current_window() slide = current_window.child(name='PageShape: Slide 1', roleName='shape') (x,y) = slide.position (a,b) = slide.size drag((x+a/4,y+b/4),(x+a*3/4,y+b*3/4))
def test_drag(self): self.runDemo('Tool Palette') focus.window('Tool Palette') src_position = focus.window.node.child("gtk-caps-lock-warning").position dst_position = focus.window.node.child("Passive DnD Mode").position dst_position = (dst_position[0] + 50, dst_position[1] + 50) drag(src_position, dst_position)
def test_drag(self): self.runDemo('Tool Palette') win = self.app.window('Tool Palette') src = win.findChildren(lambda x: x.roleName == 'push button' and x.showing)[0] dst = win.child(roleName='viewport') drag((src.position[0] + src.size[0] / 2, src.position[1] + src.size[1] / 2), (dst.position[0] + dst.size[0] / 2, dst.position[1] + dst.size[1] / 2))
def do_action_on_source_to_dest_via_drag_and_drop(context, action, source, dest): if action not in ['Copy', 'Move']: raise RuntimeError("Unknown action: %s" % action) pane = context.app.instance.findChildren(lambda x: x.roleName == 'scroll pane')[-1] source_item = pane.child(source) dest_item = pane.child(dest) source_center = (source_item.position[0] + source_item.size[0]/2, source_item.position[1] + source_item.size[1]/2) dest_center = (dest_item.position[0] + dest_item.size[0]/2, dest_item.position[1] + dest_item.size[1]/2) drag(source_center, dest_center, button=2) context.app.instance.menuItem('%s Here' % action).click() sleep(0.1)