コード例 #1
0
    def __init__(self, parent=None):
        # Enforce singleton op for this class. 
        # We could simply return, if we detect
        # a second instantiation here, but it seems
        # better to clarify the correct operation: 
        if PythonScriptDialog.ui is not None:
            raise RuntimeError("Can only have single instance of PythonScriptDialog. Use getInstance() factory method.");
        
        super(PythonScriptDialog, self).__init__(parent);
        self.dialogService = DialogService();
        self.recentDirSavedTo = os.getenv("HOME", "/tmp");
            
        self.initUI();
        # Move this window to the center of the screen,
        # else it always pops up far away:
        self.move(QApplication.desktop().screen().rect().center() - self.rect().center())

        # Dict that maps Puppet function names to methods in this class
        # that produce respective translation to Python script:
        self.TRANSLATION_METHOD_MAP = {
                                	   'head' : self.headToPython,
                                	   'rarm' : self.rarmToPython,
                                	   'larm' : self.larmToPython,
                                	   'lgrip': self.lgripToPython,
                                	   'rgrip': self.rgripToPython,
                                	   'speak': self.speakToPython,
                                	   'look_at_face' : self.lookAtFaceToPython,
                                	   'torso': self.torsoToPython
                                	  }
コード例 #2
0
    def __init__(self, parent=None):
        
        # Enforce singleton op for this class. 
        # We could simply return, if we detect
        # a second instantiation here, but it seems
        # better to clarify the correct operation: 
        if AccessibleSlider.ui is not None:
            raise RuntimeError("Can only have single instance of AccessibleSlider. Use getInstance() factory method.");
        
        # For accessibility: keep sliders on top:
        super(AccessibleSlider, self).__init__(parent, QtCore.Qt.WindowStaysOnTopHint);
        self.dialogService = DialogService();

        # Set of slider/dial that were changed between
        # transmission blackouts:
        self.sliderDialSet = set();

        self.initUI();
        # Move this window to the center of the screen,
        # else it always pops up far away:
        self.move(QApplication.desktop().screen().rect().center() - self.rect().center())
        
        self.joyMsg = Joy();
        # One axis for each slider and each dial (the factor of 2):
        self.joyMsg.axes = [ 0 ] * AccessibleSlider.NUM_SLIDER_BOARD_CHANNELS * 2;
        # Buttons: 18 channel buttons + 4 tape recorder buttons + 1 scene button:
        self.joyMsg.buttons = [ 0 ] * 25
        mode = None

        rospy.init_node('accessibleSliders')
        self.pub = rospy.Publisher('joy', Joy, latch=True)
        rospy.Subscriber('/joy', Joy, self.joyCallback)
        
        # Timer for checking on stacked up slider events:
        #self._timer = None;
        #self._timer = rospy.Timer(TX_BLACKOUT_DURATION, self.serviceDialSliderActions, oneshot=True);
        #self._timer = rospy.Timer(TX_BLACKOUT_DURATION, self.serviceDialSliderActions);
        self._timer = threading.Timer(TX_BLACKOUT_DURATION, self.serviceDialSliderActions);
        self._timer.start();
        
        self.show();