# -*- coding: utf-8 -*- import names import squish def TriggerDragAndDrop(Obj=None, topLeftXOffset=150, topLeftYOffset=None): """ Function to enter into drag and drop mode in squish. Arguments: Obj - target object topLeftXOffset - int value for X offset of widget topLeftXOffset - int value for Y offset of widget Return: None """ objRect = object.globalBounds(Obj) x = objRect.x if topLeftXOffset is None: x = objRect.center().x else: x += topLeftXOffset y = objRect.y if topLeftYOffset is None: y = objRect.center().y else: y += topLeftYOffset delta = 10 snoozeTime = 0.01 for i in range(delta): squish.QCursor.setPos(x+i, y) # alternative function -> mouseMove() squish.snooze(snoozeTime) for i in range(delta): squish.QCursor.setPos(x, y+i) squish.snooze(snoozeTime) for i in range(delta): squish.QCursor.setPos(x-i, y) squish.snooze(snoozeTime) for i in range(delta): squish.QCursor.setPos(x, y-i) squish.snooze(snoozeTime) def StartDrag(Obj=None, topLeftXOffset=None, topLeftYOffset=None): """ Function to start a drag on a widget. Arguments: Obj - target object topLeftXOffset - int value for X offset of widget topLeftXOffset - int value for Y offset of widget Return: None """ objRect = object.globalBounds(Obj) if topLeftXOffset is None or topLeftYOffset is None: squish.mousePress(Obj, squish.Qt.LeftButton) else: if topLeftXOffset is None: topLeftXOffset = objRect.center().x if topLeftYOffset is None: topLeftYOffset = objRect.center().y squish.mousePress(Obj, topLeftXOffset, topLeftYOffset, squish.Qt.LeftButton) TriggerDragAndDrop(Obj, topLeftXOffset, topLeftYOffset) def DropOnWidget(Obj=None, topLeftXOffset=None, topLeftYOffset=None): """ Function to Drop on the target widget. Arguments: Obj - target object topLeftXOffset - int value for X offset of widget topLeftXOffset - int value for Y offset of widget Return: None """ TriggerDragAndDrop(Obj, topLeftXOffset, topLeftYOffset) squish.mouseRelease(squish.Qt.LeftButton) def dragAndDropObject(source=None, target=None): """ Drag and drop the source object to target. Arguments: source - Button Object target - Target tab object Return: None """ StartDrag(Obj=source) DropOnWidget(Obj=target) def set_random_slider_weight(value, slider_object): """ Method to drag_slider_position of weight widget Argument: N/A Return: return slider current position """ #weight_combo_box = waitForObject(loc.weightInput) #utility.TapElement(weight_combo_box) #slider_object = waitForObject(self.SliderCurser) squish.mouseDrag(slider_object, 0, 0, value, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) #slider_position = squish.waitForObject(self.__SliderPosition) #cursor_value = object.children(slider_position)[0] #test.log(f"User dragged weight slider into {cursor_value.text}") #return (cursor_value.text) def main(): startApplication("denaliSquish") mouseClick(waitForObject(names.patient_id), 264, 15, Qt.LeftButton) type(waitForObject(names.patient_id), "id") mouseClick(waitForObject(names.confirm_button)) #slider_object = {"container": names. , # "objectName": slider_object_name, # "type": "Slider" } #demo = {"container" : names.o_PreTreatmentCreateStack_PreTreatmentCreate_PreTreatmentCreate, 'gradient':0, 'id':_handler, type:'Rectangle', 'unnamed':1, visible: 'true'}(QQuickRectangle_QML_78) #demo = {"container": names.o_PreTreatmentCreateStack_PreTreatmentCreate_PreTreatmentCreate, "gradient": 0, "id": "_handler", "type": "Rectangle", "unnamed": 1, "visible": True}#(QQuickRectangle_QML_78) """ "bloodFlowRate": [200, 300, 400, 150, 250], "dialysateFlowRate": [150, 250, 300, 450, 500], "duration": [120, 150, 240, 300, 450], "heparinDispensingRate": [0.2, 0.3, 0.6, 0.8, 0.5], "heparinBolusVolume": [0.2, 0.5, 0.8, 1.0, 1.6], "heparinStopTime": [20, 60, 270, 320, 420, 440], "salineBolus": [200], "dialysateTemperature": [35.5, 36.0, 36.5, 37.0, 37.5], "bloodPressureMeasurementInterval": [5, 15, 20, 30, 45, 55], "rinsebackFlowRate": [75, 100, 125], """ slider_object = waitForObject(names.demo) child = object.children(slider_object)[0] child = object.children(child)[0] child = object.children(child)[1] child = object.children(child)[2] child1 = object.children(child)[5] move = object.children(child)[2] set_random_slider_weight(value = 400, slider_object = child) #dragAndDropObject(child1,move) snooze(5)