Exemplo n.º 1
0
def eventLoop(args):
    """Starts the UI event loop and get command line parser arguments."""
    app = QApplication(sys.argv)
    for pluginDir in pluginDirs():  # required for svg graphics support
        app.addLibraryPath(pluginDir)
    mw = MainWindow(args=args)
    mw.show()
    return app.exec_()
    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
                                	  }
Exemplo n.º 3
0
 def onVisibilityChange(self, visible):
     if not visible or not self.isFloating():
         return
     # enlarge the floating window
     size = QSize()
     for widget in QApplication.topLevelWidgets():
         size = size.expandedTo(widget.size())
     self.resize(size)
Exemplo n.º 4
0
def renderSVGQt(contents, outfn, size):
    """Has font problems, letter spacing too broad, version number cropped
    (compared to inkscape output).
    Unused, but kept for reference.
    """
    from gui.qt import QtCore, QtSvg, QtGui
    from QtSvg import QSvgRenderer
    from QtCore import QByteArray
    from QtGui import QImage, QPainter, QApplication
    app = QApplication([])
    svg = QSvgRenderer(QByteArray(contents.encode("utf-8")))
    img = QImage(size, size, QImage.Format_ARGB32)
    painter = QPainter(img)
    svg.render(painter)
    painter.end()
    img.save(outfn)
Exemplo n.º 5
0
    def _handle_start_following(self):

        #make sure server is available before sending goal
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        if (not self._client.wait_for_server(rospy.Duration.from_sec(10))):
            QApplication.restoreOverrideCursor()
            msg_box = QMessageBox()
            msg_box.setText("Timeout while looking for path following control server.")
            msg_box.exec_()
            return
        QApplication.restoreOverrideCursor()

        #get path file to load
        filename = QFileDialog.getOpenFileName(self, self.tr('Load Path from File'), '.', self.tr('Path File {.txt} (*.txt)'))
        if filename[0] != '':
            try:
                handle = open(filename[0])
            except IOError as e:
                qWarning(str(e))
                return

        # load path from file
        path_reader=csv.reader(open(filename[0],'rb'),delimiter=';')

        # parse path file and convert to numbers
        temp = [row[0].split() for row in path_reader]
        lines= [[float(num) for num in row] for row in temp]

        # first line of file is radius
        radius = lines[0]
        # remove radius
        del(lines[0])

        now = rospy.Time.now()
        goal = auxos_messages.msg.PlanThenFollowDubinsPathGoal()

        goal.path.header.stamp = now
        goal.path.header.frame_id = self.path_frame_id # TODO: fix this!!!
        for line in lines:
            pose_msg = PoseStamped()
            pose_msg.header.stamp = now
            pose_msg.header.frame_id = goal.path.header.frame_id
            pose_msg.pose.position.x = line[0]
            pose_msg.pose.position.y = line[1]
            quat = qfe(0, 0, psi2theta(line[2]))
            pose_msg.pose.orientation.x = quat[0]
            pose_msg.pose.orientation.y = quat[1]
            pose_msg.pose.orientation.z = quat[2]
            pose_msg.pose.orientation.w = quat[3]
            goal.path.poses.append(pose_msg)

        self._client.send_goal(goal, self._handle_path_complete, self._handle_active, self._handle_feedback)

        print("start following")
Exemplo n.º 6
0
    def on_combo_box_changed(self, text):
        # print('In on_combo_box_changed')
        self.on_clear_button_clicked()
        self.data_plot.tgt_name = self.comboBox.currentText()

        tag = [tg for tg, txt in self.texts.iteritems() if txt == self.comboBox.currentText()][0]
        self.add_topic(self.sub_topics[tag])

        window_title = " ".join(
            [
                "Ground Plane Error Magnitude of Sensor:",
                self.comboBox.currentText(),
                "for Reference:",
                self.data_plot.ref_name,
            ]
        )
        self.setWindowTitle(QApplication.translate("MatPlotWidget", window_title, None, QApplication.UnicodeUTF8))
Exemplo n.º 7
0
 def __init__(self, exception, level='critical', fmt=None):
     QMessageBox.__init__(self, parent=QApplication.activeWindow())
     icon = self._icons.get(level, QMessageBox.NoIcon)
     self.setIcon(icon)
     title = self._titles.get(level, "")
     self.setWindowTitle(title)
     okBtn = self.addButton("ok", QMessageBox.AcceptRole)
     self.setDefaultButton(okBtn)
     if fmt is None:
         fmt = u"<nobr>{e}</nobr>"
     className, methodName = self.classAndMethodName()
     excName, excMsg = type(exception).__name__, str(exception)
     text = u"{3}\n[ {2} in {0}.{1} ]".format(className, methodName,
                                              excName, excMsg)
     self.setText(fmt.format(e=text.replace("\n", "<br />")))
     logfunc = self._logging.get(level, logging.error)
     logfunc(traceback.format_exc())  # log exception traceback
     self.exec_()
Exemplo n.º 8
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();
Exemplo n.º 9
0
def processEventLoop():
    QApplication.processEvents()
Exemplo n.º 10
0
# -*- coding: utf-8 -*-
# gui/bases/settingswidget_test.py

from __future__ import absolute_import  # PEP328
from gui.qt import QtGui
from QtGui import QSpinBox, QDoubleSpinBox, QLineEdit, QApplication
from gui.bases.settingswidget import SettingsWidget
from utils import EPS


class TestSettings(SettingsWidget):
    def setupUi(self, dummy):
        pass


app = QApplication([])
w = TestSettings()


def testIntegerInputBox():
    sp = QSpinBox(w)
    sp.setObjectName("sp")
    sp.setValue(42)
    assert w.get("sp") == 42


def testTextualInputBox():
    le = QLineEdit(w)
    le.setObjectName("le")
    text = "c633296c74bb1e0268cf0df7f2cc50c26589bc3e"
    le.setText(text)
 def closeEvent(self, event):
     QApplication.quit();
     # Bubble event up:
     event.ignore();
 def exit(self):
     QApplication.quit();
            # Does the config dir already exist? If not
            # create it:
            optionsDir = os.path.dirname(self.optionsFilePath);
            if not os.path.isdir(optionsDir):
                os.makedirs(optionsDir, 0777);
            with open(self.optionsFilePath, 'wb') as outFd:
                self.cfgParser.write(outFd);
        except IOError as e:
            self.dialogService.showErrorMsg("Could not save options: %s" % `e`);

        
    def exit(self):
        QApplication.quit();

    def closeEvent(self, event):
        QApplication.quit();
        # Bubble event up:
        event.ignore();


        
if __name__ == '__main__':

    app = QApplication(sys.argv);
    #QApplication.setStyle(QCleanlooksStyle())
    morserChallenge = MorseChallenger();
    app.exec_();
    morserChallenge.exit();
    sys.exit();
    
Exemplo n.º 14
0
        self.audioSlider.setEnabled(False)
        self.previewLayout.addWidget(self.previewWidget)
        self.previewLayout.addWidget(self.audioSlider)

        self.statusLabel = QLabel()
        self.mainLayout.addWidget(self.statusLabel)

        # Audio Feedback Checkbox
        self.audioFeedbackCheckbox = QCheckBox()
        self.audioFeedbackCheckbox.setLayoutDirection(Qt.RightToLeft)
        self.audioFeedbackCheckbox.setIcon(self.headphoneIcon)
        self.audioFeedbackCheckbox.setToolTip("Enable Audio Feedback")
        self.mainLayout.addWidget(self.audioFeedbackCheckbox)

    def setRecordIcon(self):
        self.is_recording = not self.is_recording
        if self.is_recording:
            self.recordButton.setIcon(self.stopIcon)
        else:
            self.recordButton.setIcon(self.recordIcon)


if __name__ == "__main__":
    import sys
    from QtGui import QApplication

    app = QApplication(sys.argv)
    main = RecordingWidget()
    main.show()
    sys.exit(app.exec_())
Exemplo n.º 15
0
 def application(cls):
     if cls._application is None:
         cls._application = QApplication([])
     return cls._application
Exemplo n.º 16
0
 def _matchedWidgets(self, queryType):
     for widget in QApplication.allWidgets():
         if type(widget) is queryType:
             yield widget
from actions.Pr2MoveRightArmAction import Pr2MoveRightArmAction
from pr2_controllers_msgs.msg import *
import pr2_mechanism_msgs.srv._ListControllers
import pr2_mechanism_msgs.srv._LoadController
import pr2_mechanism_msgs.srv._SwitchController
from ProgramQueue import ProgramQueue
from Ps3Subscriber import Ps3Subscriber
import rviz
from sensor_msgs.msg import CompressedImage
from sensor_msgs.msg import Image
from sensor_msgs.msg import JointState
from SimpleFormat import SimpleFormat
import std_srvs.srv._Empty
from trajectory_msgs.msg import *

app = QApplication(sys.argv)

check_collisions = '--no-collision' not in sys.argv
show_point_clouds = '--with-point-clouds' in sys.argv

main_window = QMainWindow()
ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..',
                       'src', 'slider_simple.ui')
loadUi(ui_file, main_window)

# set icons for tabs
icons = {
    0: 'square.png',
    1: 'triangle.png',
    2: 'circle.png',
    3: 'cross.png',
Exemplo n.º 18
0
    def __init__(self):
        super(TBoard, self).__init__();
        
        self.setWindowTitle("TBoard");        
        
        # Find QtCreator's XML file in the PYTHONPATH:
        currDir = os.path.realpath(__file__);
        relPathQtCreatorFile = "tboard_ui/tboard_ui.ui";
        qtCreatorXMLFilePath = Utilities.findFile(relPathQtCreatorFile);
        if qtCreatorXMLFilePath is None:
            raise ValueError("Can't find QtCreator user interface file %s" % relPathQtCreatorFile);
        # Make QtCreator generated UI a child if this instance:
        python_qt_binding.loadUi(qtCreatorXMLFilePath, self);
        self.letterWidgets = [self.ABCWidget, self.DEFWidget, self.GHIWidget, self.JKLWidget,
                              self.MNOWidget, self.PQRWidget, self.STUVWidget, self.WXYZWidget];
                              
        self.createColors();
                              
        # Populate all empty letter board button widgets with
        # GestureButton instances:
        self.populateGestureButtons();
        
        self.preparePixmaps();

	# Increase the width of the word area scrollbar:
	self.wordList.verticalScrollBar().setFixedWidth(WORD_LIST_SCROLLBAR_WIDTH) # pixels

        # Where we accumulate evolving words in encoded form
        # (see symbolToEnc dict in word_collection.py):
        self.encEvolvingWord = ""; 
        self.currButtonUsedForFlick = False;
        self.wordCollection = TelPadEncodedWordCollection();
          
        # Timer to ensure that a crossed-out button doesn't 
        # stay crossed out forever:
        self.crossOutTimer =  QTimer();
        self.crossOutTimer.setSingleShot(True);
        self.crossedOutButtons = [];
        
        # Popup dialog for adding new words to dictionary:
        self.initNewDictWordDialog();
        
        # Gesture buttons all in Dialpad (speed-write mode):
        self.buttonEditMode = ButtonEditMode.DIALPAD;

        # Disable selecting for the remaining-words panel:
	self.wordList.setFocusPolicy(Qt.NoFocus);

        # Mutex for keeping very fast flicking gestures
        # out of each others' hair:
        self.mutex = QMutex();
        
        # The system clipboard for copy:
        self.clipboard = QApplication.clipboard();
        
        # Speak-button not working yet:
        self.speakButton.setDisabled(True);
        
        self.connectWidgets();
        #self.setGeometry(500, 500, 300, 100);
        self.show();
Exemplo n.º 19
0
def tr(s):
    return QApplication.translate(None, s)