示例#1
0
    def __init__(self,
                 caption,
                 default_value=None,
                 caption_size=None,
                 text_size=None):
        QWidget.__init__(self)

        self.description = QLabel(caption)
        self.description.setWordWrap(True)
        if caption_size:
            self.description.setMaximumWidth(caption_size)

        self.line_edit = QLineEdit()
        if default_value:
            self.line_edit.setText(default_value)
        if text_size:
            self.line_edit.setMaximumWidth(text_size)

        hbox = QHBoxLayout()
        hbox.addWidget(self.description)
        hbox.addSpacing(10)
        hbox.addWidget(self.line_edit)
        if text_size:
            hbox.addStretch(1)
        hbox.setMargin(0)
        self.setLayout(hbox)
        self.setContentsMargins(0, 0, 0, 0)
示例#2
0
    def _align(widget, checkbox=None):

        l = QHBoxLayout()

        if checkbox is not None:
            checkbox.setMaximumWidth(23)
            l.addWidget(checkbox, 0)
        else:
            l.addSpacing(25)

        l.addStretch(0.5)
        if widget is not None:
            widget.setMinimumWidth(180)
            widget.setMaximumWidth(180)
            l.addWidget(widget)
        else:
            l.addSpacing(180)

        l.setContentsMargins(0, 0, 0, 0)
        l.addStretch(1)

        w = QWidget()
        w.setContentsMargins(0, 2, 0, 2)
        w.setLayout(l)
        return w
示例#3
0
文件: demo.py 项目: WUHAN5827/Try
 def __init__(self):
     super(PyGui, self).__init__()
     self.setObjectName('PyGui')
     self.pub = rospy.Publisher("pyqt_topic", String, queue_size=10)
     rospy.init_node('pyqt_gui')
     self.current_value = 0
     my_layout = QHBoxLayout()
     my_btn = QPushButton()
     my_btn.setText("Publisher")
     my_btn.setFixedWidth(130)
     my_btn.clicked.connect(self.publish_topic)
     my_layout.addWidget(my_btn)
     my_layout.addSpacing(50)
     self.my_label = QLabel()
     self.my_label.setFixedWidth(140)
     self.my_label.setText("num: " + str(0))
     self.my_label.setEnabled(False)
     my_layout.addWidget(self.my_label)
     my_slider = QSlider()
     my_slider.setMinimum(0)
     my_slider.setMaximum(99)
     my_slider.setOrientation(Qt.Horizontal)
     my_slider.valueChanged.connect(self.changeValue)
     my_vlay = QVBoxLayout()
     my_vlay.addWidget(my_slider)
     layout = QVBoxLayout()
     layout.addLayout(my_layout)
     layout.addLayout(my_vlay)
     self.setLayout(layout)
示例#4
0
文件: tabs.py 项目: koll00/Gui_SM
 def set_corner_widgets(self, corner_widgets):
     """
     Set tabs corner widgets
     corner_widgets: dictionary of (corner, widgets)
     corner: Qt.TopLeftCorner or Qt.TopRightCorner
     widgets: list of widgets (may contains integers to add spacings)
     """
     assert isinstance(corner_widgets, dict)
     assert all(key in (Qt.TopLeftCorner, Qt.TopRightCorner)
                for key in corner_widgets)
     self.corner_widgets.update(corner_widgets)
     for corner, widgets in self.corner_widgets.iteritems():
         cwidget = QWidget()
         cwidget.hide()
         prev_widget = self.cornerWidget(corner)
         if prev_widget:
             prev_widget.close()
         self.setCornerWidget(cwidget, corner)
         clayout = QHBoxLayout()
         clayout.setContentsMargins(0, 0, 0, 0)
         for widget in widgets:
             if isinstance(widget, int):
                 clayout.addSpacing(widget)
             else:
                 clayout.addWidget(widget)
         cwidget.setLayout(clayout)
         cwidget.show()
示例#5
0
    def __init__(self):
        QWidget.__init__(self)

        layout = QHBoxLayout()
        layout.addSpacing(10)

        workflow_model = WorkflowsModel()

        # workflow_model.observable().attach(WorkflowsModel.CURRENT_CHOICE_CHANGED_EVENT, self.showWorkflow)
        workflow_combo = ComboChoice(workflow_model, "Select Workflow", "run/workflow")
        layout.addWidget(QLabel(workflow_combo.getLabel()), 0, Qt.AlignVCenter)
        layout.addWidget(workflow_combo, 0, Qt.AlignVCenter)

        # simulation_mode_layout.addStretch()
        layout.addSpacing(20)

        self.run_button = QToolButton()
        self.run_button.setIconSize(QSize(32, 32))
        self.run_button.setText("Start Workflow")
        self.run_button.setIcon(util.resourceIcon("ide/gear_in_play"))
        self.run_button.clicked.connect(self.startWorkflow)
        self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)

        layout.addWidget(self.run_button)
        layout.addStretch(1)

        self.setLayout(layout)

        self.__running_workflow_dialog = None

        self.workflowSucceeded.connect(self.workflowFinished)
        self.workflowFailed.connect(self.workflowFinishedWithFail)
示例#6
0
    def __init__(self, caption, values, default_value, caption_size=None, expand_combo=False):
        QWidget.__init__(self)

        self.values = values

        description = QLabel(caption)
        description.setWordWrap(True)
        if caption_size:
            description.setMaximumWidth(caption_size)

        self.combo = QComboBox()
        for item in values:
            self.combo.addItem(item, item)

        for i in range(0, len(values)):
            if values[i] == default_value:
                self.combo.setCurrentIndex(i)
                break

        hbox = QHBoxLayout()
        hbox.addWidget(description)
        hbox.addSpacing(10)
        if expand_combo:
            hbox.addWidget(self.combo, 1)
        else:
            hbox.addWidget(self.combo)
        hbox.setMargin(0)
        self.setLayout(hbox)
        self.setContentsMargins(0, 0, 0, 0)
示例#7
0
 def create_scedit(self, text, option, default=NoDefault, tip=None,
                   without_layout=False):
     label = QLabel(text)
     clayout = ColorLayout(QColor(Qt.black), self)
     clayout.lineedit.setMaximumWidth(80)
     if tip is not None:
         clayout.setToolTip(tip)
     cb_bold = QCheckBox()
     cb_bold.setIcon(get_icon("bold.png"))
     cb_bold.setToolTip(_("Bold"))
     cb_italic = QCheckBox()
     cb_italic.setIcon(get_icon("italic.png"))
     cb_italic.setToolTip(_("Italic"))
     self.scedits[(clayout, cb_bold, cb_italic)] = (option, default)
     if without_layout:
         return label, clayout, cb_bold, cb_italic
     layout = QHBoxLayout()
     layout.addWidget(label)
     layout.addLayout(clayout)
     layout.addSpacing(10)
     layout.addWidget(cb_bold)
     layout.addWidget(cb_italic)
     layout.addStretch(1)
     layout.setContentsMargins(0, 0, 0, 0)
     widget = QWidget(self)
     widget.setLayout(layout)
     return widget
示例#8
0
    def __init__(self,
                 caption,
                 values,
                 default_value,
                 caption_size=None,
                 expand_combo=False):
        QWidget.__init__(self)

        self.values = values

        description = QLabel(caption)
        description.setWordWrap(True)
        if caption_size:
            description.setMaximumWidth(caption_size)

        self.combo = QComboBox()
        for item in values:
            self.combo.addItem(item, item)

        for i in range(0, len(values)):
            if values[i] == default_value:
                self.combo.setCurrentIndex(i)
                break

        hbox = QHBoxLayout()
        hbox.addWidget(description)
        hbox.addSpacing(10)
        if expand_combo:
            hbox.addWidget(self.combo, 1)
        else:
            hbox.addWidget(self.combo)
        hbox.setMargin(0)
        self.setLayout(hbox)
        self.setContentsMargins(0, 0, 0, 0)
示例#9
0
    def __init__(self, isLightTheme):
        QDialog.__init__(self)

        self.mode = None

        # Set the title and icon
        self.setWindowTitle("Cryptully")
        self.setWindowIcon(QIcon(utils.getAbsoluteResourcePath('images/' + ('light' if isLightTheme else 'dark') + '/icon.png')))

        clientButton = QModeButton("Connect to friend", utils.getAbsoluteResourcePath('images/client.png'), lambda: self.modeSelected(constants.MODE_CLIENT), 150, self)
        serverButton = QModeButton("Wait for connection", utils.getAbsoluteResourcePath('images/server.png'), lambda: self.modeSelected(constants.MODE_SERVER), 150, self)

        helpLink = QLinkLabel("Confused? Read the docs.", "https://cryptully.readthedocs.org/en/latest/", self)

        # Center the buttons horizontally
        hbox = QHBoxLayout()
        hbox.addStretch(1)
        hbox.addWidget(clientButton)
        hbox.addSpacing(45)
        hbox.addWidget(serverButton)
        hbox.addStretch(1)

        # Add the help link to the bottom left corner
        vbox = QVBoxLayout()
        vbox.addLayout(hbox)
        vbox.addWidget(helpLink)

        self.setLayout(vbox)

        qtUtils.resizeWindow(self, 500, 200)
        qtUtils.centerWindow(self)
示例#10
0
    def __init__(self, buttonText, imagePath, buttonCallback, imageSize, parent=None):
        QWidget.__init__(self, parent)

        icon = QLabel(self)
        icon.setPixmap(QPixmap(imagePath).scaled(imageSize, imageSize))

        button = QPushButton(buttonText)
        button.clicked.connect(buttonCallback)

        vbox = QVBoxLayout()
        vbox.addStretch(1)
        vbox.addWidget(icon, alignment=Qt.AlignHCenter)
        vbox.addSpacing(20)
        vbox.addWidget(button)
        vbox.addStretch(1)

        # Add some horizontal padding
        hbox = QHBoxLayout()
        hbox.addSpacing(10)
        hbox.addLayout(vbox)
        hbox.addSpacing(10)

        groupBox = QGroupBox()
        groupBox.setLayout(hbox)

        hbox = QHBoxLayout()
        hbox.addStretch(1)
        hbox.addWidget(groupBox)
        hbox.addStretch(1)

        self.setLayout(hbox)
示例#11
0
    def __init__(self, parent):
        QtGui.QMainWindow.__init__(self, parent)
        SkinHelper().setStyle(self, ':/qss/titlebar_style.qss')
        self.setFixedHeight(30)

        self.mPIconLabel = QLabel()
        self.mPTitleLabel = QLabel()
        self.mPMinimizeBtn = QPushButton()
        self.mPMaximizeBtn = QPushButton()
        self.mPCloseBtn = QPushButton()

        self.mPIconLabel.setFixedSize(20, 20)
        # !!必须要设置这一项,表示大小随内容缩放,配合等宽高setFixedSize,控件随图片按照等比缩放内容
        self.mPIconLabel.setScaledContents(True)
        self.mPTitleLabel.setSizePolicy(QSizePolicy.Expanding,
                                        QSizePolicy.Fixed)
        self.mPTitleLabel.setFont(QtFontUtil().getFont(u'微软雅黑', 14, True))

        self.mPMinimizeBtn.setFixedSize(20, 20)
        self.mPMaximizeBtn.setFixedSize(20, 20)
        self.mPCloseBtn.setFixedSize(20, 20)

        self.mPTitleLabel.setObjectName(u'titleLabel')
        self.mPMinimizeBtn.setObjectName(u'minimizeBtn')
        self.mPMaximizeBtn.setObjectName(u'maximizeBtn')
        self.mPCloseBtn.setObjectName(u'closeBtn')

        # self.mPMinimizeBtn.setPixmap(QtGui.QPixmap(':/darkqss/dark_img/close-hover.png'))
        # self.mPMaximizeBtn.setPixmap(QtGui.QPixmap(':/darkqss/dark_img/close-pressed.png'))
        # self.mPCloseBtn.setPixmap(QtGui.QPixmap(':/darkqss/dark_img/close.png'))
        # !!必须要设置这一项,表示大小随内容缩放,配合等宽高setFixedSize,控件随图片按照等比缩放内容
        # self.mPMinimizeBtn.setScaledContents(True)
        # self.mPMaximizeBtn.setScaledContents(True)
        # self.mPCloseBtn.setScaledContents(True)

        hBoxLayout = QHBoxLayout()
        hBoxLayout.addWidget(self.mPIconLabel)
        hBoxLayout.addSpacing(5)
        hBoxLayout.addWidget(self.mPTitleLabel)
        hBoxLayout.addWidget(self.mPMinimizeBtn)
        hBoxLayout.addWidget(self.mPMaximizeBtn)
        hBoxLayout.addWidget(self.mPCloseBtn)
        # 控件之间的间距
        hBoxLayout.addSpacing(0)
        # 控件与窗体之间的间距
        hBoxLayout.setContentsMargins(5, 0, 5, 0)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        # 这里使用的信号槽方式有3种,以后可以参考下,理一下思路。这里都是实验ok的。
        self.connect(self.mPMinimizeBtn, QtCore.SIGNAL('clicked()'),
                     self.parent(), QtCore.SLOT('showMinimized()'))
        self.connect(self.mPMaximizeBtn, QtCore.SIGNAL('clicked()'),
                     self.maximizeBtnClick)
        self.connect(self.mPCloseBtn, QtCore.SIGNAL('clicked()'), QtGui.qApp,
                     QtCore.SLOT('quit()'))
        self.widget = QtGui.QWidget()
        self.widget.setMouseTracking(True)
        self.widget.setLayout(hBoxLayout)
        self.setCentralWidget(self.widget)
示例#12
0
    def __init__(self, nick, question, parent=None):
        QDialog.__init__(self, parent)

        self.clickedButton = constants.BUTTON_CANCEL

        # Set the title and icon
        self.setWindowTitle("Authenticate %s" % nick)
        self.setWindowIcon(QIcon(qtUtils.getAbsoluteImagePath('icon.png')))

        smpQuestionLabel = QLabel("Question: <b>%s</b>" % question, self)

        smpAnswerLabel = QLabel("Answer (case sensitive):", self)
        self.smpAnswerInput = QLineEdit(self)

        okayButton = QPushButton(QIcon.fromTheme('dialog-ok'), "OK", self)
        cancelButton = QPushButton(QIcon.fromTheme('dialog-cancel'), "Cancel",
                                   self)

        keyIcon = QLabel(self)
        keyIcon.setPixmap(
            QPixmap(
                qtUtils.getAbsoluteImagePath('fingerprint.png')).scaledToWidth(
                    60, Qt.SmoothTransformation))

        helpLabel = QLabel(
            "%s has requested to authenticate your conversation by asking you a\n"
            "question only you should know the answer to. Enter your answer below\n"
            "to authenticate your conversation.\n\n"
            "You may wish to ask your buddy a question as well." % nick)

        okayButton.clicked.connect(
            lambda: self.buttonClicked(constants.BUTTON_OKAY))
        cancelButton.clicked.connect(
            lambda: self.buttonClicked(constants.BUTTON_CANCEL))

        helpLayout = QHBoxLayout()
        helpLayout.addStretch(1)
        helpLayout.addWidget(keyIcon)
        helpLayout.addSpacing(15)
        helpLayout.addWidget(helpLabel)
        helpLayout.addStretch(1)

        # Float the buttons to the right
        buttons = QHBoxLayout()
        buttons.addStretch(1)
        buttons.addWidget(okayButton)
        buttons.addWidget(cancelButton)

        vbox = QVBoxLayout()
        vbox.addLayout(helpLayout)
        vbox.addWidget(QLine())
        vbox.addWidget(smpQuestionLabel)
        vbox.addWidget(smpAnswerLabel)
        vbox.addWidget(self.smpAnswerInput)
        vbox.addLayout(buttons)

        self.setLayout(vbox)
 def _initLayout(self):
     layout = QVBoxLayout(self)
     layout.setContentsMargins(5, 5, 5, 5)
     layout.setSpacing(0)
     
     nameLayout = QHBoxLayout()
     nameLayout.setContentsMargins(0, 0, 0, 0)
     
     self._fileIconLabel = QLabel(self)
     nameLayout.addWidget(self._fileIconLabel, 0, Qt.AlignLeft)
     
     self._nameLabel = QLabel(self)
     nameLayout.addSpacing(5)
     nameLayout.addWidget(self._nameLabel, 1, Qt.AlignLeft)
     
     layout.addLayout(nameLayout)
     
     progressWidget = QWidget(self)
     progressLayout = QHBoxLayout(progressWidget)
     progressLayout.setSpacing(5)
     progressLayout.setContentsMargins(0, 0, 0, 0)
     
     iconLabel = QLabel(progressWidget)
     if self._down:
         picFile = get_settings().get_resource("images", "down.png")
     else:
         picFile = get_settings().get_resource("images", "up.png")
     iconLabel.setPixmap(QPixmap(picFile))
     iconLabel.setFixedSize(15,15)
     progressLayout.addWidget(iconLabel, 0, Qt.AlignBottom)
     
     self._progress = QProgressBar(progressWidget)
     self._progress.setMinimum(0)
     self._progress.setMaximum(100)
     if getPlatform() == PLATFORM_MAC:
         self._progress.setAttribute(Qt.WA_MacMiniSize)
         self._progress.setMaximumHeight(16)
     progressLayout.addWidget(self._progress, 1)
     
     self._button = QPushButton(progressWidget)
     self._button.clicked.connect(self._buttonClicked)
     progressLayout.addSpacing(5)
     progressLayout.addWidget(self._button, 0, Qt.AlignCenter)
     
     layout.addWidget(progressWidget, 0, Qt.AlignBottom)
     
     self._statusLabel = QLabel(self)
     if getPlatform() == PLATFORM_MAC:
         self._statusLabel.setAttribute(Qt.WA_MacSmallSize)
     layout.addWidget(self._statusLabel)
     
     self.setObjectName(u"__transfer_widget")
     self.setFrameShape(QFrame.StyledPanel)
     self.setStyleSheet("QFrame#__transfer_widget{border-width: 1px; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-color:palette(mid)}");
         
     self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)
 def __init__(self, hintInfo="", parent = None):
     InfoHintDialog.__init__(self, hintInfo, parent)
     self.setStyleSheet("font-size : 16px")
     
     language = StoreInfoParser.instance().getLanguage()
     m_pTranslator = QTranslator()
     exePath = "./"
     if language == "chinese":
         QmName = "zh_CN.qm"
     else:
         QmName = "en_US.qm"
         
     if(m_pTranslator.load(QmName, exePath)):
         QCoreApplication.instance().installTranslator(m_pTranslator)
     
     self.setTitle(self.tr("Super Administrator"))
     
     self.passwordLabel = QLabel(self.tr("Root Password"))
     self.passwordLineEdit = QLineEdit()
     self.passwordLineEdit.setContextMenuPolicy(Qt.NoContextMenu)
     self.passwordLineEdit.setEchoMode(QLineEdit.Password)
     self.passwordLineEdit.setFocus(True)
     
     self.ensureBtn = QPushButton(self.tr("OK"))
     self.cancelBtn = QPushButton(self.tr("Cancel"))
     self.ensureBtn.setStyleSheet("background: rgb(7,87,198); color: white; width: 70px; height: 20px;font-size : 16px;")
     self.cancelBtn.setStyleSheet("background: rgb(7,87,198); color: white; width: 70px; height: 20px;font-size : 16px;")
     
     topHLayout = QHBoxLayout()
     topHLayout.addStretch()
     topHLayout.addWidget(self.passwordLabel)
     topHLayout.addSpacing(5)
     topHLayout.addWidget(self.passwordLineEdit)
     topHLayout.addStretch()
     
     bottomHLayout = QHBoxLayout()
     bottomHLayout.addStretch()
     bottomHLayout.addWidget(self.ensureBtn)
     bottomHLayout.addSpacing(10)
     bottomHLayout.addWidget(self.cancelBtn)
     bottomHLayout.addStretch()
     
     mainVLayout = QVBoxLayout()
     mainVLayout.addStretch()
     mainVLayout.addLayout(topHLayout)
     mainVLayout.addStretch()
     mainVLayout.addLayout(bottomHLayout)
     
     self.setLayout(mainVLayout)
     
     self.okBtn.hide()
     
     self.connect(self.ensureBtn, SIGNAL("clicked()"),self.slotCheckPassWord)
     self.connect(self.cancelBtn, SIGNAL("clicked()"),self.slotCancel)
     self.connect(self.okBtn, SIGNAL("clicked()"),self.slotOk)
示例#15
0
    def __init__(self):
        super(PyGui, self).__init__()
        self.setObjectName('PyGui')
        # self.pub = rospy.Publisher("pyqt_topic", String, queue_size=10)
        self.init_pose_pub_ = rospy.Publisher("/robotis/base/ini_pose",
                                              String,
                                              queue_size=10)

        rospy.init_node('pyqt_gui')
        self.current_value = 0

        # Create Horizontal Layout
        my_hlay = QHBoxLayout()
        # Create Vertical Layout
        my_vlay = QVBoxLayout()

        # Init Button
        init_btn = QPushButton()
        init_btn.setText("Init Pose")
        init_btn.setFixedWidth(130)
        init_btn.clicked.connect(self.publish_init_topic)
        # Add Horizontal Layout
        my_hlay.addWidget(init_btn)
        my_hlay.addSpacing(50)

        # self.my_label = QLabel()
        # self.my_label.setFixedWidth(140)
        # self.my_label.setText("num: " + str(0))
        # self.my_label.setEnabled(False)
        # # Add Horizontal Layout
        # my_hlay.addWidget(self.my_label)

        # # Slider
        # my_slider = QSlider()
        # my_slider.setMinimum(0)
        # my_slider.setMaximum(200)
        # my_slider.setOrientation(Qt.Horizontal)
        # my_slider.valueChanged.connect(self.changeValue)
        # # Add Vertical Layout
        # my_vlay.addWidget(my_slider)

        # Torque Off Button
        reset_btn = QPushButton()
        reset_btn.setText("Torque OFF")
        reset_btn.setFixedWidth(130)
        # reset_btn.clicked.connect(self.publish_topic)
        # Add Horizontal Layout
        my_hlay.addWidget(reset_btn)

        # Display Layout
        layout = QVBoxLayout()
        layout.addLayout(my_hlay)
        layout.addLayout(my_vlay)

        self.setLayout(layout)
示例#16
0
    def __init__(self, finders, iface, parent=None):
        self.iface = iface
        self.mapCanvas = iface.mapCanvas()
        self.rubber = QgsRubberBand(self.mapCanvas)
        self.rubber.setColor(QColor(255, 255, 50, 200))
        self.rubber.setIcon(self.rubber.ICON_CIRCLE)
        self.rubber.setIconSize(15)
        self.rubber.setWidth(4)
        self.rubber.setBrushStyle(Qt.NoBrush)

        QComboBox.__init__(self, parent)
        self.setEditable(True)
        self.setInsertPolicy(QComboBox.InsertAtTop)
        self.setMinimumHeight(27)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)

        self.insertSeparator(0)
        self.lineEdit().returnPressed.connect(self.search)

        self.resultView = QTreeView()
        self.resultView.setHeaderHidden(True)
        self.resultView.setMinimumHeight(300)
        self.resultView.activated.connect(self.itemActivated)
        self.resultView.pressed.connect(self.itemPressed)
        self.setView(self.resultView)

        self.resultModel = ResultModel(self)
        self.setModel(self.resultModel)

        self.finders = finders
        for finder in self.finders.values():
            finder.resultFound.connect(self.resultFound)
            finder.limitReached.connect(self.limitReached)
            finder.finished.connect(self.finished)

        self.clearButton = QPushButton(self)
        self.clearButton.setIcon(
            QIcon(":/plugins/quickfinder/icons/draft.svg"))
        self.clearButton.setText('')
        self.clearButton.setFlat(True)
        self.clearButton.setCursor(QCursor(Qt.ArrowCursor))
        self.clearButton.setStyleSheet('border: 0px; padding: 0px;')
        self.clearButton.clicked.connect(self.clear)

        layout = QHBoxLayout(self)
        self.setLayout(layout)
        layout.addStretch()
        layout.addWidget(self.clearButton)
        layout.addSpacing(20)

        buttonSize = self.clearButton.sizeHint()
        # frameWidth = self.lineEdit().style().pixelMetric(QtGui.QStyle.PM_DefaultFrameWidth)
        padding = buttonSize.width()  # + frameWidth + 1
        self.lineEdit().setStyleSheet('QLineEdit {padding-right: %dpx; }' %
                                      padding)
示例#17
0
    def __init__(self, finders, iface, parent=None):
        self.iface = iface
        self.mapCanvas = iface.mapCanvas()
        self.rubber = QgsRubberBand(self.mapCanvas)
        self.rubber.setColor(QColor(255, 255, 50, 200))
        self.rubber.setIcon(self.rubber.ICON_CIRCLE)
        self.rubber.setIconSize(15)
        self.rubber.setWidth(4)
        self.rubber.setBrushStyle(Qt.NoBrush)

        QComboBox.__init__(self, parent)
        self.setEditable(True)
        self.setInsertPolicy(QComboBox.InsertAtTop)
        self.setMinimumHeight(27)
        self.setSizePolicy(QSizePolicy.Expanding,
                           QSizePolicy.Fixed)

        self.insertSeparator(0)
        self.lineEdit().returnPressed.connect(self.search)

        self.resultView = QTreeView()
        self.resultView.setHeaderHidden(True)
        self.resultView.setMinimumHeight(300)
        self.resultView.activated.connect(self.itemActivated)
        self.resultView.pressed.connect(self.itemPressed)
        self.setView(self.resultView)

        self.resultModel = ResultModel(self)
        self.setModel(self.resultModel)

        self.finders = finders
        for finder in self.finders.values():
            finder.resultFound.connect(self.resultFound)
            finder.limitReached.connect(self.limitReached)
            finder.finished.connect(self.finished)

        self.clearButton = QPushButton(self)
        self.clearButton.setIcon(QIcon(":/plugins/quickfinder/icons/draft.svg"))
        self.clearButton.setText('')
        self.clearButton.setFlat(True)
        self.clearButton.setCursor(QCursor(Qt.ArrowCursor))
        self.clearButton.setStyleSheet('border: 0px; padding: 0px;')
        self.clearButton.clicked.connect(self.clear)

        layout = QHBoxLayout(self)
        self.setLayout(layout)
        layout.addStretch()
        layout.addWidget(self.clearButton)
        layout.addSpacing(20)

        buttonSize = self.clearButton.sizeHint()
        # frameWidth = self.lineEdit().style().pixelMetric(QtGui.QStyle.PM_DefaultFrameWidth)
        padding = buttonSize.width()  # + frameWidth + 1
        self.lineEdit().setStyleSheet('QLineEdit {padding-right: %dpx; }' % padding)
示例#18
0
文件: pqMsgs.py 项目: jlg234bob/PPQT
    def __init__(self, parent=None):
        super(QWidget, self).__init__(parent)
        # Create the four widgets:

        # 1, the line number widget
        self.lnum = QLineEdit()
        self.lnum.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        # allow up to 5 digits, and ensure only digits can be entered.
        val = QIntValidator()
        val.setRange(1,99999) # Line numbers start at 1
        self.lnum.setValidator(val)
        self.setWidth(self.lnum, 6)
        # connect the lnum ReturnPressed signal to our slot for that
        self.connect(self.lnum, SIGNAL("returnPressed()"), self.moveLine)

        # 2, the column number display
        self.cnum = QLabel()
        self.cnum.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        self.setWidth(self.cnum, 3)

        # 3, the png field. Scan image filenames are not always numeric!
        self.image = QLineEdit()
        self.image.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        self.setWidth(self.image, 6)
        #val = QIntValidator()
        #val.setRange(1,9999) # png numbers start at 1
        #self.image.setValidator(val)
        # Connect the image ReturnPressed signal to our slot for that
        self.connect(self.image, SIGNAL("returnPressed()"), self.movePng)

        # 4, the folio display
        self.folio = QLabel()
        self.folio.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        self.setWidth(self.folio, 12)

        # Make a layout frame and lay the four things out in it with captions
        # Line [      ] Column (  )    Image [      ] Folio (   )

        hb = QHBoxLayout()
        hb.addWidget(self.makeCaption(u"Line"))
        hb.addWidget(self.lnum)
        hb.addWidget(self.makeCaption(u"Column"))
        hb.addWidget(self.cnum)

        hb.addSpacing(5) # Qt doc doesn't say what the units are!

        hb.addWidget(self.makeCaption(u"Image"))
        hb.addWidget(self.image)
        hb.addWidget(self.makeCaption(u"Folio"))
        hb.addWidget(self.folio)

        hb.addStretch() # add stretch on the right to make things compact left
        self.setLayout(hb) # make it our layout
示例#19
0
    def __init__(self):
        QWidget.__init__(self)

        layout = QVBoxLayout()

        self._simulation_mode_combo = QComboBox()
        addHelpToWidget(self._simulation_mode_combo, "run/simulation_mode")

        self._simulation_mode_combo.currentIndexChanged.connect(
            self.toggleSimulationMode)

        simulation_mode_layout = QHBoxLayout()
        simulation_mode_layout.addSpacing(10)
        simulation_mode_layout.addWidget(QLabel("Simulation mode:"), 0,
                                         Qt.AlignVCenter)
        simulation_mode_layout.addWidget(self._simulation_mode_combo, 0,
                                         Qt.AlignVCenter)

        simulation_mode_layout.addSpacing(20)

        self.run_button = QToolButton()
        self.run_button.setIconSize(QSize(32, 32))
        self.run_button.setText("Start Simulation")
        self.run_button.setIcon(resourceIcon("ide/gear_in_play"))
        self.run_button.clicked.connect(self.runSimulation)
        self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        addHelpToWidget(self.run_button, "run/start_simulation")

        simulation_mode_layout.addWidget(self.run_button)
        simulation_mode_layout.addStretch(1)

        layout.addSpacing(5)
        layout.addLayout(simulation_mode_layout)
        layout.addSpacing(10)

        self._simulation_stack = QStackedWidget()
        self._simulation_stack.setLineWidth(1)
        self._simulation_stack.setFrameStyle(QFrame.StyledPanel)

        layout.addWidget(self._simulation_stack)

        self._simulation_widgets = OrderedDict()
        """ :type: OrderedDict[BaseRunModel,SimulationConfigPanel]"""

        self.addSimulationConfigPanel(SingleTestRunPanel())
        self.addSimulationConfigPanel(EnsembleExperimentPanel())
        self.addSimulationConfigPanel(EnsembleSmootherPanel())
        self.addSimulationConfigPanel(
            IteratedEnsembleSmootherPanel(advanced_option=True))
        self.addSimulationConfigPanel(MultipleDataAssimilationPanel())

        self.setLayout(layout)
示例#20
0
    def createImageView2DHud(self, axis, value, backgroundColor,
                             foregroundColor):
        self.axis = axis
        self.backgroundColor = backgroundColor
        self.foregroundColor = foregroundColor
        self.labelsWidth = 20
        self.labelsheight = 20

        self.layout.addSpacing(4)

        self.axisLabel = self.createAxisLabel()
        self.sliceSelector = SpinBoxImageView(self.parent(),
                                              backgroundColor,
                                              foregroundColor,
                                              value,
                                              self.labelsheight, 12)

        self.buttons['slice'] = self.sliceSelector

        # Add left-hand items into a sub-layout so we can draw a frame
        # around them
        leftHudLayout = QHBoxLayout()
        leftHudLayout.setContentsMargins(0,0,0,0)
        leftHudLayout.setSpacing(0)
        leftHudLayout.addWidget( self.axisLabel )
        leftHudLayout.addSpacing(1)
        leftHudLayout.addLayout(self.sliceSelector)

        leftHudFrame = QFrame()
        leftHudFrame.setLayout( leftHudLayout )
        setupFrameStyle( leftHudFrame )

        self.layout.addWidget( leftHudFrame )

        self.layout.addSpacing(12)

        for name, handler in [('rotate-left', self.on_rotLeftButton),
                              ('swap-axes', self.on_swapAxesButton),
                              ('rotate-right', self.on_rotRightButton)]:
            self._add_button(name, handler)

        self.layout.addStretch()

        for name, handler in [('undock', self.on_dockButton),
                              ('maximize', self.on_maxButton)]:
            self._add_button(name, handler)

        # some other classes access these members directly.
        self.sliceSelector = self.buttons['slice']
        self.dockButton = self.buttons['undock']
        self.maxButton = self.buttons['maximize']
  def initLayout(self):
      self.terminalTypeGroupbox = QGroupBox(u'终端类型')
      
      self.cDesktopRadioBtn = QRadioButton(u'桌面虚拟化')
      self.cTerminalRadioBtn = QRadioButton(u'终端虚拟化')
      
      self.settingBtn = QPushButton(u"设置")
      self.settingBtn.setStyleSheet("background: rgb(7,87,198); color: white; width: 90px; height: 30px;font-size : 16px;")
      
      topVLayout = QVBoxLayout()
      topVLayout.setSpacing(10)
      topVLayout.setMargin(10)
      
      topVLayout.addSpacing(30)
      topVLayout.addWidget(self.cDesktopRadioBtn)
      topVLayout.addSpacing(20)
      topVLayout.addWidget(self.cTerminalRadioBtn)
      topVLayout.addSpacing(50)
      
      topHLayout = QHBoxLayout()
      topHLayout.setSpacing(10)
      topHLayout.setMargin(10)
      
      topHLayout.addSpacing(40)
      topHLayout.addLayout(topVLayout)
      topHLayout.addSpacing(160)
 
      self.terminalTypeGroupbox.setLayout(topHLayout)
      
      bottomHLayout = QHBoxLayout()
      bottomHLayout.addStretch()
      bottomHLayout.addWidget(self.settingBtn)
      bottomHLayout.addStretch()
      
      #布局调整
      vLayout = QVBoxLayout()
      vLayout.addStretch()
      vLayout.addWidget(self.terminalTypeGroupbox)
      vLayout.addSpacing(80)
      vLayout.addStretch()
      
      topMainLayout = QHBoxLayout()
      topMainLayout.addStretch()
      topMainLayout.addLayout(vLayout)
      topMainLayout.addStretch()
      
      mainHLayout = QVBoxLayout()
      mainHLayout.addLayout(topMainLayout)
      mainHLayout.addLayout(bottomHLayout)
      
      self.setLayout(mainHLayout)
示例#22
0
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)
        self.clickedButton = constants.BUTTON_CANCEL

        # Set the title and icon
        self.setWindowTitle("Authenticate Buddy")
        self.setWindowIcon(QIcon(qtUtils.getAbsoluteImagePath('icon.png')))

        smpQuestionLabel = QLabel("Question:", self)
        self.smpQuestionInput = QLineEdit(self)

        smpAnswerLabel = QLabel("Answer (case sensitive):", self)
        self.smpAnswerInput = QLineEdit(self)

        okayButton = QPushButton(QIcon.fromTheme('dialog-ok'), "OK", self)
        cancelButton = QPushButton(QIcon.fromTheme('dialog-cancel'), "Cancel", self)

        keyIcon = QLabel(self)
        keyIcon.setPixmap(QPixmap(qtUtils.getAbsoluteImagePath('fingerprint.png')).scaledToWidth(50, Qt.SmoothTransformation))

        helpLabel = QLabel("In order to ensure that no one is listening in on your conversation\n"
                           "it's best to verify the identity of your buddy by entering a question\n"
                           "that only your buddy knows the answer to.")

        okayButton.clicked.connect(lambda: self.buttonClicked(constants.BUTTON_OKAY))
        cancelButton.clicked.connect(lambda: self.buttonClicked(constants.BUTTON_CANCEL))

        helpLayout = QHBoxLayout()
        helpLayout.addStretch(1)
        helpLayout.addWidget(keyIcon)
        helpLayout.addSpacing(15)
        helpLayout.addWidget(helpLabel)
        helpLayout.addStretch(1)

        # Float the buttons to the right
        buttons = QHBoxLayout()
        buttons.addStretch(1)
        buttons.addWidget(okayButton)
        buttons.addWidget(cancelButton)

        vbox = QVBoxLayout()
        vbox.addLayout(helpLayout)
        vbox.addWidget(QLine())
        vbox.addWidget(smpQuestionLabel)
        vbox.addWidget(self.smpQuestionInput)
        vbox.addWidget(smpAnswerLabel)
        vbox.addWidget(self.smpAnswerInput)
        vbox.addLayout(buttons)

        self.setLayout(vbox)
    def __init__(self, nick, question, parent=None):
        QDialog.__init__(self, parent)

        self.clickedButton = constants.BUTTON_CANCEL

        # Set the title and icon
        self.setWindowTitle("Authenticate %s" % nick)
        self.setWindowIcon(QIcon(qtUtils.getAbsoluteImagePath('icon.png')))

        smpQuestionLabel = QLabel("Question: <b>%s</b>" % question, self)

        smpAnswerLabel = QLabel("Answer (case sensitive):", self)
        self.smpAnswerInput = QLineEdit(self)

        okayButton = QPushButton(QIcon.fromTheme('dialog-ok'), "OK", self)
        cancelButton = QPushButton(QIcon.fromTheme('dialog-cancel'), "Cancel", self)

        keyIcon = QLabel(self)
        keyIcon.setPixmap(QPixmap(qtUtils.getAbsoluteImagePath('fingerprint.png')).scaledToWidth(60, Qt.SmoothTransformation))

        helpLabel = QLabel("%s has requested to authenticate your conversation by asking you a\n"
                           "question only you should know the answer to. Enter your answer below\n"
                           "to authenticate your conversation.\n\n"
                           "You may wish to ask your buddy a question as well." % nick)

        okayButton.clicked.connect(lambda: self.buttonClicked(constants.BUTTON_OKAY))
        cancelButton.clicked.connect(lambda: self.buttonClicked(constants.BUTTON_CANCEL))

        helpLayout = QHBoxLayout()
        helpLayout.addStretch(1)
        helpLayout.addWidget(keyIcon)
        helpLayout.addSpacing(15)
        helpLayout.addWidget(helpLabel)
        helpLayout.addStretch(1)

        # Float the buttons to the right
        buttons = QHBoxLayout()
        buttons.addStretch(1)
        buttons.addWidget(okayButton)
        buttons.addWidget(cancelButton)

        vbox = QVBoxLayout()
        vbox.addLayout(helpLayout)
        vbox.addWidget(QLine())
        vbox.addWidget(smpQuestionLabel)
        vbox.addWidget(smpAnswerLabel)
        vbox.addWidget(self.smpAnswerInput)
        vbox.addLayout(buttons)

        self.setLayout(vbox)
示例#24
0
    def __init__(self,
                 image,
                 imageWidth,
                 connectClickedSlot,
                 nick='',
                 parent=None):
        QWidget.__init__(self, parent)

        self.connectClickedSlot = connectClickedSlot

        # Image
        self.image = QLabel(self)
        self.image.setPixmap(
            QPixmap(qtUtils.getAbsoluteImagePath(image)).scaledToWidth(
                imageWidth, Qt.SmoothTransformation))

        # Nick field
        self.nickLabel = QLabel("Nickname:", self)
        self.nickEdit = QLineEdit(nick, self)
        self.nickEdit.setMaxLength(constants.NICK_MAX_LEN)
        self.nickEdit.returnPressed.connect(self.__connectClicked)
        self.nickEdit.setFocus()

        # Connect button
        self.connectButton = QPushButton("Connect", self)
        self.connectButton.resize(self.connectButton.sizeHint())
        self.connectButton.setAutoDefault(False)
        self.connectButton.clicked.connect(self.__connectClicked)

        hbox = QHBoxLayout()
        hbox.addStretch(1)
        hbox.addWidget(self.nickLabel)
        hbox.addWidget(self.nickEdit)
        hbox.addStretch(1)

        vbox = QVBoxLayout()
        vbox.addStretch(1)
        vbox.addLayout(hbox)
        vbox.addWidget(self.connectButton)
        vbox.addStretch(1)

        hbox = QHBoxLayout()
        hbox.addStretch(1)
        hbox.addWidget(self.image)
        hbox.addSpacing(10)
        hbox.addLayout(vbox)
        hbox.addStretch(1)

        self.setLayout(hbox)
示例#25
0
    def createColorsGroupBox(self):
        self.targetComboBox = QComboBox()
        self.targetComboBox.addItem(self.settings['highlightKey'])
        self.targetComboBox.addItem(self.settings['extractKey'])
        self.targetComboBox.addItems(self.settings['quickKeys'].keys())
        self.targetComboBox.currentIndexChanged.connect(
            self.updateHighlightingTab)

        targetLayout = QHBoxLayout()
        targetLayout.addWidget(self.targetComboBox)
        targetLayout.addStretch()

        colors = self.getColorList()

        self.bgColorComboBox = QComboBox()
        self.bgColorComboBox.addItems(colors)
        setComboBoxItem(self.bgColorComboBox,
                        self.settings['highlightBgColor'])
        self.bgColorComboBox.currentIndexChanged.connect(
            self.updateColorPreview)

        self.textColorComboBox = QComboBox()
        self.textColorComboBox.addItems(colors)
        setComboBoxItem(self.textColorComboBox,
                        self.settings['highlightTextColor'])
        self.textColorComboBox.currentIndexChanged.connect(
            self.updateColorPreview)

        bgColorLabel = QLabel('Background')
        bgColorLayout = QHBoxLayout()
        bgColorLayout.addWidget(bgColorLabel)
        bgColorLayout.addSpacing(10)
        bgColorLayout.addWidget(self.bgColorComboBox)

        textColorLabel = QLabel('Text')
        textColorLayout = QHBoxLayout()
        textColorLayout.addWidget(textColorLabel)
        textColorLayout.addSpacing(10)
        textColorLayout.addWidget(self.textColorComboBox)

        layout = QVBoxLayout()
        layout.addLayout(bgColorLayout)
        layout.addLayout(textColorLayout)
        layout.addStretch()

        groupBox = QGroupBox('Colors')
        groupBox.setLayout(layout)

        return groupBox
 def __init__(self, app, parent = None):
     super(ResolutionSettingWidget,self).__init__(parent)
     self.setStyleSheet("font-size : 16px;")
     self.app = app
     CDLL("libjson-c.so", mode=RTLD_GLOBAL)
     self.jytcapi = cdll.LoadLibrary('../lib/libjytcapi.so')
     self.jytcapi.jyinittcapi()
     self.resolutionLabel = QLabel(self.tr("Resolution setting"))
     
     self.resolutionCombox = QComboBox()
     self.resolutionCombox.setFixedSize(300, 30)
     
     self.saveBtn = QPushButton(self.tr("Save"))
     self.saveBtn.setStyleSheet("background: rgb(7,87,198); color: white; width: 90px; height: 30px;font-size : 16px;")
   
     gridLayout = QGridLayout()
     gridLayout.setSpacing(15)
     gridLayout.setMargin(10)
     gridLayout.addWidget(self.resolutionLabel, 0, 0, 1, 1)
     gridLayout.addWidget(self.resolutionCombox, 0, 1, 1, 1)
     
     topLayout = QHBoxLayout()
     topLayout.addStretch()
     topLayout.addSpacing(50)
     topLayout.addLayout(gridLayout)
     topLayout.addStretch(1)
     
     bottomHLayout = QHBoxLayout()
     bottomHLayout.addStretch()
     bottomHLayout.addWidget(self.saveBtn)
     bottomHLayout.addStretch()
     
     vLayout = QVBoxLayout()
     vLayout.addStretch()
     vLayout.addSpacing(50)
     vLayout.addLayout(topLayout)
     vLayout.addStretch(2)
     vLayout.addSpacing(10)
     vLayout.addLayout(bottomHLayout)
     
     self.setLayout(vLayout)
     
     self.updateResolutionCombox()
     
     self.timer = QTimer()
     self.timer.setSingleShot(True)
     self.connect(self.timer,SIGNAL("timeout()"),self.resetScreenResolution);
     
     self.connect(self.saveBtn, SIGNAL("clicked()"),self.slotSave)
示例#27
0
    def __init__(self):
        QWidget.__init__(self)

        layout = QVBoxLayout()

        self._simulation_mode_combo = QComboBox()
        addHelpToWidget(self._simulation_mode_combo, "run/simulation_mode")

        self._simulation_mode_combo.currentIndexChanged.connect(self.toggleSimulationMode)

        simulation_mode_layout = QHBoxLayout()
        simulation_mode_layout.addSpacing(10)
        simulation_mode_layout.addWidget(QLabel("Simulation mode:"), 0, Qt.AlignVCenter)
        simulation_mode_layout.addWidget(self._simulation_mode_combo, 0, Qt.AlignVCenter)

        simulation_mode_layout.addSpacing(20)

        self.run_button = QToolButton()
        self.run_button.setIconSize(QSize(32, 32))
        self.run_button.setText("Start Simulation")
        self.run_button.setIcon(resourceIcon("ide/gear_in_play"))
        self.run_button.clicked.connect(self.runSimulation)
        self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        addHelpToWidget(self.run_button, "run/start_simulation")

        simulation_mode_layout.addWidget(self.run_button)
        simulation_mode_layout.addStretch(1)

        layout.addSpacing(5)
        layout.addLayout(simulation_mode_layout)
        layout.addSpacing(10)

        self._simulation_stack = QStackedWidget()
        self._simulation_stack.setLineWidth(1)
        self._simulation_stack.setFrameStyle(QFrame.StyledPanel)

        layout.addWidget(self._simulation_stack)

        self._simulation_widgets = OrderedDict()
        """ :type: OrderedDict[BaseRunModel,SimulationConfigPanel]"""

        self.addSimulationConfigPanel(SingleTestRunPanel())
        self.addSimulationConfigPanel(EnsembleExperimentPanel())
        self.addSimulationConfigPanel(EnsembleSmootherPanel())
        self.addSimulationConfigPanel(IteratedEnsembleSmootherPanel())
        self.addSimulationConfigPanel(MultipleDataAssimilationPanel())

        self.setLayout(layout)
示例#28
0
    def __init__(self):
        QWidget.__init__(self)

        layout = QVBoxLayout()

        simulation_mode_layout = QHBoxLayout()
        simulation_mode_layout.addSpacing(10)
        simulation_mode_model = SimulationModeModel()
        simulation_mode_model.observable().attach(
            SimulationModeModel.CURRENT_CHOICE_CHANGED_EVENT, self.toggleSimulationMode
        )
        simulation_mode_combo = ComboChoice(simulation_mode_model, "Simulation mode", "run/simulation_mode")
        simulation_mode_layout.addWidget(QLabel(simulation_mode_combo.getLabel()), 0, Qt.AlignVCenter)
        simulation_mode_layout.addWidget(simulation_mode_combo, 0, Qt.AlignVCenter)

        # simulation_mode_layout.addStretch()
        simulation_mode_layout.addSpacing(20)

        self.run_button = QToolButton()
        self.run_button.setIconSize(QSize(32, 32))
        self.run_button.setText("Start Simulation")
        self.run_button.setIcon(util.resourceIcon("ide/gear_in_play"))
        self.run_button.clicked.connect(self.runSimulation)
        self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        HelpedWidget.addHelpToWidget(self.run_button, "run/start_simulation")

        simulation_mode_layout.addWidget(self.run_button)
        simulation_mode_layout.addStretch(1)

        layout.addSpacing(5)
        layout.addLayout(simulation_mode_layout)
        layout.addSpacing(10)

        self.simulation_stack = QStackedWidget()
        self.simulation_stack.setLineWidth(1)
        self.simulation_stack.setFrameStyle(QFrame.StyledPanel)

        layout.addWidget(self.simulation_stack)

        self.simulation_widgets = {}

        self.addSimulationConfigPanel(EnsembleExperimentPanel())
        self.addSimulationConfigPanel(SensitivityStudyPanel())
        self.addSimulationConfigPanel(EnsembleSmootherPanel())
        self.addSimulationConfigPanel(IteratedEnsembleSmootherPanel())

        self.setLayout(layout)
示例#29
0
    def createImageView2DHud(self, axis, value, backgroundColor, foregroundColor):
        self.axis = axis
        self.backgroundColor = backgroundColor
        self.foregroundColor = foregroundColor
        self.labelsWidth = 20
        self.labelsheight = 20 
        
        self.layout.addSpacing(4)

        self.axisLabel = self.createAxisLabel()
        self.sliceSelector = SpinBoxImageView(backgroundColor, foregroundColor, value, self.labelsheight, 12)

        # Add left-hand items into a sub-layout so we can draw a frame around them
        leftHudLayout = QHBoxLayout()
        leftHudLayout.setContentsMargins(0,0,0,0)
        leftHudLayout.setSpacing(0)
        leftHudLayout.addWidget( self.axisLabel )
        leftHudLayout.addSpacing(1)
        leftHudLayout.addLayout(self.sliceSelector)

        def setupFrameStyle( frame ):
            # Use this function to add a consistent frame style to all HUD elements
            frame.setFrameShape( QFrame.Box )
            frame.setFrameShadow( QFrame.Raised )
            frame.setLineWidth( 2 )
        
        leftHudFrame = QFrame()
        leftHudFrame.setLayout( leftHudLayout )
        setupFrameStyle( leftHudFrame )
        
        self.layout.addWidget( leftHudFrame )
        self.layout.addStretch()
        
        self.dockButton = LabelButtons(backgroundColor, foregroundColor, self.labelsWidth, self.labelsheight)
        self.dockButton.clicked.connect(self.on_dockButton)
        self.dockButton.setUndockIcon()
        setupFrameStyle( self.dockButton )
        self.layout.addWidget(self.dockButton)
        self.layout.addSpacing(4)
        
        self.maxButton = LabelButtons(backgroundColor, foregroundColor, self.labelsWidth, self.labelsheight)
        self.maxButton.clicked.connect(self.on_maxButton)
        self.maxButton.setMaximizeIcon()
        setupFrameStyle( self.maxButton )
        self.layout.addWidget(self.maxButton)
        self.layout.addSpacing(4)
示例#30
0
    def __init__(self, parent, text="", isLightTheme=True, onCloseSlot=None, showIP=False):
        QDialog.__init__(self, parent)
        self.onCloseSignal.connect(onCloseSlot)

        # Create connecting image
        connMov = QMovie(utils.getAbsoluteResourcePath('images/' + ('light' if isLightTheme else 'dark') + '/waiting.gif'))
        connMov.start()
        self.connImg = QLabel(self)
        self.connImg.setMovie(connMov)

        # Create connecting and IP address labels
        self.connLabel = QLabel(text, self)
        if showIP:
            self.ipLabel = QLabel(self.ipLabelPrefix + "Getting IP address...", self)
            self.ipHelpLabel = QLabel("Your friend should enter the IP address above as the host to connect to.\n"
                                      "Make sure that port " + str(constants.DEFAULT_PORT) + " is forwarded to "
                                      "this computer. See the help\nfor more info.", self)


        hbox = QHBoxLayout()
        hbox.addStretch(1)
        hbox.addWidget(self.connImg)
        hbox.addSpacing(10)
        hbox.addWidget(self.connLabel)
        hbox.addStretch(1)

        vbox = QVBoxLayout()
        vbox.addStretch(1)
        vbox.addLayout(hbox)

        if showIP:
            vbox.addSpacing(10)
            vbox.addWidget(QLine())
            vbox.addSpacing(10)
            vbox.addWidget(self.ipLabel)
            vbox.addSpacing(10)
            vbox.addWidget(self.ipHelpLabel)

        vbox.addStretch(1)

        self.setLayout(vbox)

        if showIP:
            # Start the thread to get the IP address and update the IP label when finished
            self.ipThread = qtThreads.GetIPAddressThread(self.__setIPAddress, self.__getIPAddressFailure)
            self.ipThread.start()
示例#31
0
    def __init__(self):
        QWidget.__init__(self)

        layout = QVBoxLayout()

        simulation_mode_layout = QHBoxLayout()
        simulation_mode_layout.addSpacing(10)
        simulation_mode_model = SimulationModeModel()
        simulation_mode_model.observable().attach(SimulationModeModel.CURRENT_CHOICE_CHANGED_EVENT, self.toggleSimulationMode)
        simulation_mode_combo = ComboChoice(simulation_mode_model, "Simulation mode", "run/simulation_mode")
        simulation_mode_layout.addWidget(QLabel(simulation_mode_combo.getLabel()), 0, Qt.AlignVCenter)
        simulation_mode_layout.addWidget(simulation_mode_combo, 0, Qt.AlignVCenter)

        # simulation_mode_layout.addStretch()
        simulation_mode_layout.addSpacing(20)

        self.run_button = QToolButton()
        self.run_button.setIconSize(QSize(32, 32))
        self.run_button.setText("Start Simulation")
        self.run_button.setIcon(util.resourceIcon("ide/gear_in_play"))
        self.run_button.clicked.connect(self.runSimulation)
        self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        HelpedWidget.addHelpToWidget(self.run_button, "run/start_simulation")

        simulation_mode_layout.addWidget(self.run_button)
        simulation_mode_layout.addStretch(1)

        layout.addSpacing(5)
        layout.addLayout(simulation_mode_layout)
        layout.addSpacing(10)

        self.simulation_stack = QStackedWidget()
        self.simulation_stack.setLineWidth(1)
        self.simulation_stack.setFrameStyle(QFrame.StyledPanel)

        layout.addWidget(self.simulation_stack)

        self.simulation_widgets = {}

        self.addSimulationConfigPanel(EnsembleExperimentPanel())
        self.addSimulationConfigPanel(EnsembleSmootherPanel())
        self.addSimulationConfigPanel(MultipleDataAssimilationPanel())
        self.addSimulationConfigPanel(IteratedEnsembleSmootherPanel())

        self.setLayout(layout)
示例#32
0
    def __init__(self, caption, button_text, caption_size=None):
        QWidget.__init__(self)

        self.description = QLabel(caption)
        self.description.setWordWrap(True)
        if caption_size:
            self.description.setMaximumWidth(caption_size)

        self.button = QPushButton(i18n.get(button_text))
        self.button.clicked.connect(self.__on_click)

        hbox = QHBoxLayout()
        hbox.addWidget(self.description, 1)
        hbox.addSpacing(10)
        hbox.addWidget(self.button)
        hbox.setMargin(0)
        self.setLayout(hbox)
        self.setContentsMargins(0, 0, 0, 0)
示例#33
0
    def __init__(self, caption, button_text, caption_size=None):
        QWidget.__init__(self)

        self.description = QLabel(caption)
        self.description.setWordWrap(True)
        if caption_size:
            self.description.setMaximumWidth(caption_size)

        self.button = QPushButton(i18n.get(button_text))
        self.button.clicked.connect(self.__on_click)

        hbox = QHBoxLayout()
        hbox.addWidget(self.description, 1)
        hbox.addSpacing(10)
        hbox.addWidget(self.button)
        hbox.setMargin(0)
        self.setLayout(hbox)
        self.setContentsMargins(0, 0, 0, 0)
 def __init__(self, app, parent = None):
     super(LanguageSettingWidget,self).__init__(parent)
     self.setStyleSheet("font-size : 16px")
     self.app = app
     self.languageLabel = QLabel(self.tr("Language setting"))
     
     languageList = [self.tr("中文简体"),"English"]
     
     self.languageCombox = QComboBox()
     self.languageCombox.addItems(languageList)
     self.languageCombox.setFixedSize(300, 30)
     
     self.saveBtn = QPushButton(self.tr("Save"))
     self.connect(self.saveBtn, SIGNAL("clicked()"),self.slotSave)
     self.saveBtn.setStyleSheet("background: rgb(7,87,198); color: white; width: 90px; height: 30px;font-size : 16px;")
   
     gridLayout = QGridLayout()
     gridLayout.setSpacing(15)
     gridLayout.setMargin(10)
     gridLayout.addWidget(self.languageLabel, 0, 0, 1, 1)
     gridLayout.addWidget(self.languageCombox, 0, 1, 1, 1)
     
     topLayout = QHBoxLayout()
     topLayout.addStretch()
     topLayout.addSpacing(50)
     topLayout.addLayout(gridLayout)
     topLayout.addStretch(1)
     
     bottomHLayout = QHBoxLayout()
     bottomHLayout.addStretch()
     bottomHLayout.addWidget(self.saveBtn)
     bottomHLayout.addStretch()
     
     vLayout = QVBoxLayout()
     vLayout.addStretch()
     vLayout.addSpacing(50)
     vLayout.addLayout(topLayout)
     vLayout.addStretch(2)
     vLayout.addSpacing(10)
     vLayout.addLayout(bottomHLayout)
     
     self.setLayout(vLayout)
     
     self.updateLanguageCombox()
示例#35
0
    def __init__(self, parent, text=""):
        QDialog.__init__(self, parent)

        # Create waiting image
        waitingImage = QMovie(qtUtils.getAbsoluteImagePath('waiting.gif'))
        waitingImage.start()
        waitingImageLabel = QLabel(self)
        waitingImageLabel.setMovie(waitingImage)

        waitingLabel = QLabel(text, self)

        hbox = QHBoxLayout()
        hbox.addStretch(1)
        hbox.addWidget(waitingImageLabel)
        hbox.addSpacing(10)
        hbox.addWidget(waitingLabel)
        hbox.addStretch(1)

        self.setLayout(hbox)
示例#36
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        # Create connecting image
        self.connectingGif = QMovie(
            qtUtils.getAbsoluteImagePath('waiting.gif'))
        self.connectingGif.start()
        self.connetingImageLabel = QLabel(self)
        self.connetingImageLabel.setMovie(self.connectingGif)
        self.connectingLabel = QLabel(self)

        hbox = QHBoxLayout()
        hbox.addStretch(1)
        hbox.addWidget(self.connetingImageLabel, alignment=Qt.AlignCenter)
        hbox.addSpacing(10)
        hbox.addWidget(self.connectingLabel, alignment=Qt.AlignCenter)
        hbox.addStretch(1)

        self.setLayout(hbox)
示例#37
0
    def __init__(self, parent, text=""):
        QDialog.__init__(self, parent)

        # Create waiting image
        waitingImage = QMovie(qtUtils.getAbsoluteImagePath('waiting.gif'))
        waitingImage.start()
        waitingImageLabel = QLabel(self)
        waitingImageLabel.setMovie(waitingImage)

        waitingLabel = QLabel(text, self)

        hbox = QHBoxLayout()
        hbox.addStretch(1)
        hbox.addWidget(waitingImageLabel)
        hbox.addSpacing(10)
        hbox.addWidget(waitingLabel)
        hbox.addStretch(1)

        self.setLayout(hbox)
    def __init__(self, image, imageWidth, connectClickedSlot, nick='', parent=None):
        QWidget.__init__(self, parent)

        self.connectClickedSlot = connectClickedSlot

        # Image
        self.image = QLabel(self)
        self.image.setPixmap(QPixmap(qtUtils.getAbsoluteImagePath(image)).scaledToWidth(imageWidth, Qt.SmoothTransformation))

        # Nick field
        self.nickLabel = QLabel("Nickname:", self)
        self.nickEdit = QLineEdit(nick, self)
        self.nickEdit.setMaxLength(constants.NICK_MAX_LEN)
        self.nickEdit.returnPressed.connect(self.__connectClicked)
        self.nickEdit.setFocus()

        # Connect button
        self.connectButton = QPushButton("Connect", self)
        self.connectButton.resize(self.connectButton.sizeHint())
        self.connectButton.setAutoDefault(False)
        self.connectButton.clicked.connect(self.__connectClicked)

        hbox = QHBoxLayout()
        hbox.addStretch(1)
        hbox.addWidget(self.nickLabel)
        hbox.addWidget(self.nickEdit)
        hbox.addStretch(1)

        vbox = QVBoxLayout()
        vbox.addStretch(1)
        vbox.addLayout(hbox)
        vbox.addWidget(self.connectButton)
        vbox.addStretch(1)

        hbox = QHBoxLayout()
        hbox.addStretch(1)
        hbox.addWidget(self.image)
        hbox.addSpacing(10)
        hbox.addLayout(vbox)
        hbox.addStretch(1)

        self.setLayout(hbox)
示例#39
0
 def keyRow(self,keys,lspace,rspace):
     global SPOLICY
     grid = QGridLayout()
     for j in range(len(keys)) : # keys in numeric order left to right
         grid.setColumnStretch(j,0) # all columns equal stretch
         key = keys[j]
         if key != ' ' :
             grid.addWidget(self.key_objects[key], 0, j)
         else :
             ql = QLabel(' ')
             ql.setSizePolicy(SPOLICY)
             ql.setMinimumSize(QSize(20,20))
             grid.addWidget(ql,0,j)
     hbox = QHBoxLayout()
     if lspace : # if stagger-right, stick in space on left
         hbox.addSpacing(lspace)
     hbox.addLayout(grid) # put the keys in the middle
     if rspace : # if stagger-left, stick in space on the right
         hbox.addSpacing(rspace)
     return hbox
示例#40
0
 def keyRow(self, keys, lspace, rspace):
     global SPOLICY
     grid = QGridLayout()
     for j in range(len(keys)):  # keys in numeric order left to right
         grid.setColumnStretch(j, 0)  # all columns equal stretch
         key = keys[j]
         if key != ' ':
             grid.addWidget(self.key_objects[key], 0, j)
         else:
             ql = QLabel(' ')
             ql.setSizePolicy(SPOLICY)
             ql.setMinimumSize(QSize(20, 20))
             grid.addWidget(ql, 0, j)
     hbox = QHBoxLayout()
     if lspace:  # if stagger-right, stick in space on left
         hbox.addSpacing(lspace)
     hbox.addLayout(grid)  # put the keys in the middle
     if rspace:  # if stagger-left, stick in space on the right
         hbox.addSpacing(rspace)
     return hbox
示例#41
0
    def initUI(self):

        # Adding input part
        vbox = QVBoxLayout()
        topLabel = QLabel(self.tr("Choose a file to load"))
        topLabel.setWordWrap(True)
        vbox.addWidget(topLabel)
        vbox.addSpacing(20)

        # Add first horizontal box
        self.buttonbrowse = QPushButton("Browse")
        self.buttonbrowse.clicked.connect(self.handlebuttonbrowse)
        self.inputfilename = ''
        self.inputfile = QLabel(self.inputfilename)
        self.inputfile.setWordWrap(True)
        hbox1 = QHBoxLayout()
        hbox1.addWidget(self.buttonbrowse)
        hbox1.addWidget(self.inputfile)
        hbox1.addStretch()
        vbox.addLayout(hbox1)

        vbox.addSpacing(10)

        # Adding output part
        bottomLabel = QLabel(self.tr("Select an output format"))
        bottomLabel.setWordWrap(True)
        vbox.addWidget(bottomLabel)
        vbox.addWidget(bottomLabel)

        # Add second horizontal box
        self.rbuttonxls = QRadioButton(self.tr("xls"))
        self.rbuttoncsv = QRadioButton(self.tr("csv"))
        hbox2 = QHBoxLayout()
        hbox2.addWidget(self.rbuttonxls)
        hbox2.addSpacing(50)
        hbox2.addWidget(self.rbuttoncsv)
        hbox2.addStretch()
        vbox.addLayout(hbox2)
        vbox.addStretch()

        self.setLayout(vbox)
示例#42
0
 def addWidgets(self):
     layout = QVBoxLayout()
     layout.setSpacing(0)
     self.setLayout(layout)
     header = QFrame(self)
     header.setObjectName('header')
     hbox = QHBoxLayout()
     hbox.addSpacing(10)
     hbox.setContentsMargins(0, 0, 0, 0)
     header.setLayout(hbox)
     backbutton = QPushButton('< Back', header)
     backbutton.clicked.connect(self.back)
     hbox.addWidget(backbutton)
     hbox.addStretch(100)
     self.backbutton = backbutton
     layout.addWidget(header)
     layout.addSpacing(5)
     self.header = header
     stack = QStackedWidget(self)
     layout.addWidget(stack)
     self.stack = stack
示例#43
0
 def addWidgets(self):
     layout = QVBoxLayout()
     layout.setSpacing(0)
     self.setLayout(layout)
     header = QFrame(self)
     header.setObjectName('header')
     hbox = QHBoxLayout()
     hbox.addSpacing(10)
     hbox.setContentsMargins(0, 0, 0, 0)
     header.setLayout(hbox)
     backbutton = QPushButton('< Back', header)
     backbutton.clicked.connect(self.back)
     hbox.addWidget(backbutton)
     hbox.addStretch(100)
     self.backbutton = backbutton
     layout.addWidget(header)
     layout.addSpacing(5)
     self.header = header
     stack = QStackedWidget(self)
     layout.addWidget(stack)
     self.stack = stack
示例#44
0
    def __init__(self, parent):
        CstmPanel.__init__(self, parent)

        box = QGroupBox(u"Construction de quantiles")
        sizer = QHBoxLayout()
        box.setLayout(sizer)

        self.mediane = QCheckBox(u'Construire la médiane')
        self.mediane.setChecked(self.main.param("quantiles")["mediane"][0])
        self.mediane.stateChanged.connect(self.main.EvtCheck)

        sizer.addWidget(self.mediane)
        sizer.addSpacing(10) # valeur à ajuster

        self.quartiles = QCheckBox(u'Construire les quartiles')
        self.quartiles.setChecked(self.main.param("quantiles")["quartiles"][0])
        self.quartiles.stateChanged.connect(self.main.EvtCheck)
        sizer.addWidget(self.quartiles)
        sizer.addSpacing(10) # valeur à ajuster

        self.deciles = QCheckBox(u'Construire les déciles')
        self.deciles.setChecked(self.main.param("quantiles")["deciles"][0])
        self.deciles.stateChanged.connect(self.main.EvtCheck)
        sizer.addWidget(self.deciles)
        sizer.addSpacing(10) # valeur à ajuster

        self.add(box)

        self.finaliser()
    def __init__(self, parent, mt):
        super(BugReportsWidget, self).__init__(parent)
        self.mt = mt
        
        layout = QVBoxLayout(self)
#         layout.setContentsMargins(0, 0, 0, 0)
        
        self.entry = QTextEdit(self)
        
        self.issues = {}
        self.issuesComboModel = IssuesComboModel()
        
        self.dropdown_reports = QComboBox(self)
        self.dropdown_reports.setModel(self.issuesComboModel)
        self.display_report()
        self.details_btn = QPushButton("Details", self)
        self.details_btn.setEnabled(False)
        self.refresh_btn = QPushButton("Refresh", self)
        create_report_btn = QPushButton("New", self)
        
        topLayout = QHBoxLayout()
        topLayout.addWidget(self.dropdown_reports, 1)
        topLayout.addWidget(self.details_btn)
        topLayout.addWidget(self.refresh_btn)
        topLayout.addSpacing(20)
        topLayout.addWidget(create_report_btn)
        layout.addLayout(topLayout)

        layout.addWidget(QLabel("Description:", self))
        
        self.entry.setLineWrapMode(QTextEdit.WidgetWidth)
        self.entry.setReadOnly(True)
        layout.addWidget(self.entry)
                
        self.dropdown_reports.currentIndexChanged.connect(self.display_report)
        self.details_btn.clicked.connect(self.displayReportDetails)
        self.refresh_btn.clicked.connect(self.update_reports)
        create_report_btn.clicked.connect(self.createBugReport)
        
        self.update_reports()
示例#46
0
    def __init__(self):
        QWidget.__init__(self)

        layout = QHBoxLayout()
        layout.addSpacing(10)


        self._workflow_combo = QComboBox()
        addHelpToWidget(self._workflow_combo, "run/workflow")

        self._workflow_combo.addItems(getWorkflowNames())

        layout.addWidget(QLabel("Select Workflow:"), 0, Qt.AlignVCenter)
        layout.addWidget(self._workflow_combo, 0, Qt.AlignVCenter)

        # simulation_mode_layout.addStretch()
        layout.addSpacing(20)

        self.run_button = QToolButton()
        self.run_button.setIconSize(QSize(32, 32))
        self.run_button.setText("Start Workflow")
        self.run_button.setIcon(resourceIcon("ide/gear_in_play"))
        self.run_button.clicked.connect(self.startWorkflow)
        self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)

        layout.addWidget(self.run_button)
        layout.addStretch(1)

        self.setLayout(layout)

        self._running_workflow_dialog = None

        self.workflowSucceeded.connect(self.workflowFinished)
        self.workflowFailed.connect(self.workflowFinishedWithFail)
        self.workflowKilled.connect(self.workflowStoppedByUser)

        self._workflow_runner = None
        """:type: WorkflowRunner"""
示例#47
0
    def __init__(self, caption, default_value=None, caption_size=None, text_size=None):
        QWidget.__init__(self)

        self.description = QLabel(caption)
        self.description.setWordWrap(True)
        if caption_size:
            self.description.setMaximumWidth(caption_size)

        self.line_edit = QLineEdit()
        if default_value:
            self.line_edit.setText(default_value)
        if text_size:
            self.line_edit.setMaximumWidth(text_size)

        hbox = QHBoxLayout()
        hbox.addWidget(self.description)
        hbox.addSpacing(10)
        hbox.addWidget(self.line_edit)
        if text_size:
            hbox.addStretch(1)
        hbox.setMargin(0)
        self.setLayout(hbox)
        self.setContentsMargins(0, 0, 0, 0)
示例#48
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.setGeometry(300, 300, 1000, 1000)
        self.setWindowTitle('hello,pyqt4!')
        self.setToolTip('这是qt4程序')

        btok = QPushButton('ok', self)
        btcancel = QPushButton('cancel', self)
        btok.clicked.connect(self.close)

        hb = QHBoxLayout()
        hb.addStretch(1)
        hb.addWidget(btok)
        hb.addSpacing(20)
        hb.addWidget(btcancel)
        hb.addStretch(1)

        vb = QVBoxLayout()
        vb.addStretch(1)
        vb.addLayout(hb)
        vb.addSpacing(20)

        self.setLayout(vb)
示例#49
0
    def __init__(self):
        QWidget.__init__(self)

        layout = QHBoxLayout()
        layout.addSpacing(10)

        workflow_model = WorkflowsModel()

        # workflow_model.observable().attach(WorkflowsModel.CURRENT_CHOICE_CHANGED_EVENT, self.showWorkflow)
        workflow_combo = ComboChoice(workflow_model, "Select Workflow",
                                     "run/workflow")
        layout.addWidget(QLabel(workflow_combo.getLabel()), 0, Qt.AlignVCenter)
        layout.addWidget(workflow_combo, 0, Qt.AlignVCenter)

        # simulation_mode_layout.addStretch()
        layout.addSpacing(20)

        self.run_button = QToolButton()
        self.run_button.setIconSize(QSize(32, 32))
        self.run_button.setText("Start Workflow")
        self.run_button.setIcon(util.resourceIcon("ide/gear_in_play"))
        self.run_button.clicked.connect(self.startWorkflow)
        self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)

        layout.addWidget(self.run_button)
        layout.addStretch(1)

        self.setLayout(layout)

        self.__running_workflow_dialog = None

        self.workflowSucceeded.connect(self.workflowFinished)
        self.workflowFailed.connect(self.workflowFinishedWithFail)
        self.workflowKilled.connect(self.workflowStoppedByUser)

        self.__workflow_runner = None
        """:type: WorkflowRunner"""
示例#50
0
def boxLayout(orientation, *items, **kw):
    if orientation == Qt.Horizontal:
        layout = QHBoxLayout()
        lineClass = HLine
    else:
        layout = QVBoxLayout()
        lineClass = VLine
    layout.setMargin(0)
    layout.setSpacing(0)
    
    lastStretch=kw.pop("stretch", False)
    for item in items:
        if isinstance(item, (list, tuple)):
            x, w = item[:2]
            if item[2:]:
                alignment, = item[2:]
            else:
                alignment = Qt.Alignment(0)
        else:
            w = 0
            alignment = Qt.Alignment(0)
            x = item
            
        if x == "spacing":
            layout.addSpacing(w)
        elif x == "stretch":
            layout.addStretch(w)
        elif x == "line":
            layout.addWidget(lineClass(), w, alignment)
        elif isinstance(x, QLayout):
            layout.addLayout(x, w)
        else:
            layout.addWidget(x, w, alignment)
        
    if lastStretch:
        layout.addStretch(1)
    return layout
示例#51
0
    def __init__(self):
        QWidget.__init__(self)

        layout = QHBoxLayout()
        layout.addSpacing(10)

        self._workflow_combo = QComboBox()
        addHelpToWidget(self._workflow_combo, "run/workflow")

        self._workflow_combo.addItems(getWorkflowNames())

        layout.addWidget(QLabel("Select Workflow:"), 0, Qt.AlignVCenter)
        layout.addWidget(self._workflow_combo, 0, Qt.AlignVCenter)

        # simulation_mode_layout.addStretch()
        layout.addSpacing(20)

        self.run_button = QToolButton()
        self.run_button.setIconSize(QSize(32, 32))
        self.run_button.setText("Start Workflow")
        self.run_button.setIcon(resourceIcon("ide/gear_in_play"))
        self.run_button.clicked.connect(self.startWorkflow)
        self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)

        layout.addWidget(self.run_button)
        layout.addStretch(1)

        self.setLayout(layout)

        self._running_workflow_dialog = None

        self.workflowSucceeded.connect(self.workflowFinished)
        self.workflowFailed.connect(self.workflowFinishedWithFail)
        self.workflowKilled.connect(self.workflowStoppedByUser)

        self._workflow_runner = None
        """:type: WorkflowRunner"""
示例#52
0
    def initializePage(self):
        super(PanelPage, self).initializePage()

        rootLayout = QVBoxLayout()
        rootLayout.setContentsMargins(20, 20, 10, 20)

        row0 = QHBoxLayout()
        lable0 = QLabel('依赖库:')
        lable0.setAlignment(Qt.AlignTop | Qt.AlignHCenter)
        self.lw_files = QListWidget()
        items0 = QStringList()
        for moudel in app.g_configurations.libs:
            items0.append(moudel['name'])
        self.lw_files.addItems(items0)
        row0.addWidget(lable0)
        row0.addSpacing(25)
        row0.addWidget(self.lw_files)

        row1 = QHBoxLayout()
        lable1 = QLabel('工程文件:')
        lable1.setAlignment(Qt.AlignTop | Qt.AlignHCenter)
        self.lw_files = QListWidget()
        self.lw_files.setStyleSheet("Height:66px;")
        items1 = QStringList()
        for file in app.g_configurations.config['files']:
            items1.append(file['target'])
        self.lw_files.addItems(items1)
        row1.addWidget(lable1)
        row1.addSpacing(10)
        row1.addWidget(self.lw_files)

        rootLayout.addLayout(row0)
        rootLayout.addSpacing(10)
        rootLayout.addLayout(row1)
        self.setLayout(rootLayout)
        self.setStyleSheet(stylesheet)
示例#53
0
    def initUI(self):
        """Initialize ROS node."""
        self.setGeometry(300, 300, 500, 300)
        self.setWindowTitle('RDDA_GUI')

        btnRun = QPushButton('Run')
        btnRun.setFixedWidth(150)
        self.btnCls = QPushButton('Stop')
        self.btnCls.setFixedWidth(150)
        sldPos = QSlider()
        sldPos.setOrientation(Qt.Horizontal)
        sldPos.setMinimum(0)
        sldPos.setMaximum(100)
        sldStf = QSlider()
        sldStf.setOrientation(Qt.Horizontal)
        sldStf.setMinimum(0)
        sldStf.setMaximum(100)
        self.labelPos = QLabel()
        self.labelPos.setFixedWidth(200)
        self.labelPos.setText("Position: " + str(0))
        self.labelStf = QLabel()
        self.labelStf.setFixedWidth(200)
        self.labelStf.setText("Stiffness: " + str(0))

        hboxBtn = QHBoxLayout()
        hboxBtn.addStretch(1)
        hboxBtn.addWidget(btnRun)
        hboxBtn.addSpacing(20)
        hboxBtn.addWidget(self.btnCls)

        hboxPos = QHBoxLayout()
        hboxPos.addWidget(sldPos)
        hboxPos.addSpacing(50)
        hboxPos.addWidget(self.labelPos)

        hboxStf = QHBoxLayout()
        hboxStf.addWidget(sldStf)
        hboxStf.addSpacing(50)
        hboxStf.addWidget(self.labelStf)

        layout = QVBoxLayout()
        layout.addLayout(hboxPos)
        layout.addLayout(hboxStf)
        layout.addLayout(hboxBtn)
        self.setLayout(layout)

        # self.rosThread = RosThread(self.joint_cmds)
        self.rosThread = RosThread()

        btnRun.clicked.connect(self.start_ros)
        self.btnCls.clicked.connect(self.rosThread.stop)
        sldPos.valueChanged.connect(self.set_pos)
        sldStf.valueChanged.connect(self.set_stf)
示例#54
0
    def createImageView2DHud(self, axis, value, backgroundColor,
                             foregroundColor):
        self.axis = axis
        self.backgroundColor = backgroundColor
        self.foregroundColor = foregroundColor
        self.labelsWidth = 20
        self.labelsheight = 20

        self.layout.addSpacing(4)
        fontsize = 12

        self.axisLabel = self.createAxisLabel()
        self.sliceSelector = SpinBoxImageView(self.parent(),
                                              backgroundColor,
                                              foregroundColor,
                                              value,
                                              self.labelsheight, fontsize)

        self.buttons['slice'] = self.sliceSelector

        # Add left-hand items into a sub-layout so we can draw a frame
        # around them
        leftHudLayout = QHBoxLayout()
        leftHudLayout.setContentsMargins(0,0,0,0)
        leftHudLayout.setSpacing(0)
        leftHudLayout.addWidget( self.axisLabel )
        leftHudLayout.addSpacing(1)
        leftHudLayout.addLayout(self.sliceSelector)

        leftHudFrame = QFrame()
        leftHudFrame.setLayout( leftHudLayout )
        setupFrameStyle( leftHudFrame )

        self.layout.addWidget( leftHudFrame )

        self.layout.addSpacing(12)

        for name, handler in [('rotate-left', self.on_rotLeftButton),
                              ('swap-axes', self.on_swapAxesButton),
                              ('rotate-right', self.on_rotRightButton)]:
            self._add_button(name, handler)

        self.layout.addStretch()
        
        self.zoomLevelIndicator = ZoomLevelIndicator(self.parent(),
                                backgroundColor,
                                foregroundColor,
                                self.sliceSelector.spinBox.font(),
                                self.buttons["rotate-left"].sizeHint().height())

        self.buttons["zoomlevel"] = self.zoomLevelIndicator
        self.layout.addWidget(self.zoomLevelIndicator)
        self.layout.addSpacing(4)
        
        for name, handler in [('zoom-to-fit', self.on_zoomToFit),
                              ('reset-zoom', self.on_resetZoom),
                              ('undock', self.on_dockButton),
                              ('maximize', self.on_maxButton)]:
            self._add_button(name, handler)
        
        # some other classes access these members directly.
        self.sliceSelector = self.buttons['slice']
        self.dockButton = self.buttons['undock']
        self.maxButton = self.buttons['maximize']
示例#55
0
class ImageView2DHud(QWidget):
    dockButtonClicked = pyqtSignal()
    zoomToFitButtonClicked = pyqtSignal()
    resetZoomButtonClicked = pyqtSignal()
    maximizeButtonClicked = pyqtSignal()
    rotLeftButtonClicked = pyqtSignal()
    rotRightButtonClicked = pyqtSignal()
    swapAxesButtonClicked = pyqtSignal()
    def __init__(self, parent ):
        QWidget.__init__(self, parent)

        self.layout = QHBoxLayout()
        self.setLayout(self.layout)
        self.layout.setContentsMargins(0,4,0,0)
        self.layout.setSpacing(0)

        self.buttons = {}

    def _add_button(self, name, handler):
        button = LabelButtons(
            name,
            self.parent(),
            self.backgroundColor,
            self.foregroundColor,
            self.labelsWidth,
            self.labelsheight)
        self.buttons[name] = button
        button.clicked.connect(handler)
        setupFrameStyle(button)
        self.layout.addWidget(button)
        self.layout.addSpacing(4)

    def createImageView2DHud(self, axis, value, backgroundColor,
                             foregroundColor):
        self.axis = axis
        self.backgroundColor = backgroundColor
        self.foregroundColor = foregroundColor
        self.labelsWidth = 20
        self.labelsheight = 20

        self.layout.addSpacing(4)
        fontsize = 12

        self.axisLabel = self.createAxisLabel()
        self.sliceSelector = SpinBoxImageView(self.parent(),
                                              backgroundColor,
                                              foregroundColor,
                                              value,
                                              self.labelsheight, fontsize)

        self.buttons['slice'] = self.sliceSelector

        # Add left-hand items into a sub-layout so we can draw a frame
        # around them
        leftHudLayout = QHBoxLayout()
        leftHudLayout.setContentsMargins(0,0,0,0)
        leftHudLayout.setSpacing(0)
        leftHudLayout.addWidget( self.axisLabel )
        leftHudLayout.addSpacing(1)
        leftHudLayout.addLayout(self.sliceSelector)

        leftHudFrame = QFrame()
        leftHudFrame.setLayout( leftHudLayout )
        setupFrameStyle( leftHudFrame )

        self.layout.addWidget( leftHudFrame )

        self.layout.addSpacing(12)

        for name, handler in [('rotate-left', self.on_rotLeftButton),
                              ('swap-axes', self.on_swapAxesButton),
                              ('rotate-right', self.on_rotRightButton)]:
            self._add_button(name, handler)

        self.layout.addStretch()
        
        self.zoomLevelIndicator = ZoomLevelIndicator(self.parent(),
                                backgroundColor,
                                foregroundColor,
                                self.sliceSelector.spinBox.font(),
                                self.buttons["rotate-left"].sizeHint().height())

        self.buttons["zoomlevel"] = self.zoomLevelIndicator
        self.layout.addWidget(self.zoomLevelIndicator)
        self.layout.addSpacing(4)
        
        for name, handler in [('zoom-to-fit', self.on_zoomToFit),
                              ('reset-zoom', self.on_resetZoom),
                              ('undock', self.on_dockButton),
                              ('maximize', self.on_maxButton)]:
            self._add_button(name, handler)
        
        # some other classes access these members directly.
        self.sliceSelector = self.buttons['slice']
        self.dockButton = self.buttons['undock']
        self.maxButton = self.buttons['maximize']

    def setMaximum(self, v):
        self.sliceSelector.setNewValue(v)

    def on_dockButton(self):
        self.dockButtonClicked.emit()
    
    def on_zoomToFit(self):
        self.zoomToFitButtonClicked.emit()
    
    def on_resetZoom(self):
        self.resetZoomButtonClicked.emit()
    
    def on_maxButton(self):
        self.maximizeButtonClicked.emit()

    def on_rotLeftButton(self):
        self.rotLeftButtonClicked.emit()

    def on_rotRightButton(self):
        self.rotRightButtonClicked.emit()

    def on_swapAxesButton(self):
        self.swapAxesButtonClicked.emit()

    def createAxisLabel(self):
        axisLabel = QLabel()
        axisLabel.setAttribute(Qt.WA_TransparentForMouseEvents, True)
        pixmap = self.createAxisLabelPixmap()
        axisLabel.setPixmap(pixmap)
        return axisLabel

    def createAxisLabelPixmap(self):
        pixmap = QPixmap(250, 250)
        pixmap.fill(self.backgroundColor)
        painter = QPainter()
        painter.begin(pixmap)
        font = QFont()
        font.setBold(True)
        font.setPixelSize(250-30)
        path = QPainterPath()
        path.addText(QPointF(50, 250-50), font, self.axis)
        brush = QBrush(self.foregroundColor)
        painter.setBrush(brush)
        painter.drawPath(path)
        painter.setFont(font)
        painter.end()
        pixmap = pixmap.scaled(QSize(self.labelsWidth,
                                     self.labelsheight),
                               Qt.KeepAspectRatio,
                               Qt.SmoothTransformation)
        return pixmap

    def setAxes(self, rotation, swapped):
        self.buttons["swap-axes"].rotation = rotation
        self.buttons["swap-axes"].swapped = swapped
示例#56
0
    def __init__(self, base):
        Window.__init__(self, base, i18n.get('user_profile'))

        self.account_id = None
        self.setFixedSize(380, 450)

        self.username = QLabel('')
        self.username.setTextFormat(Qt.RichText)

        self.fullname = QLabel('')
        self.options = ImageButton(base, 'action-status-menu.png',
                                   i18n.get(''))
        self.options.clicked.connect(self.__options_clicked)

        self.verified_icon = QLabel()
        self.verified_icon.setPixmap(base.load_image('mark-verified.png',
                                                     True))

        self.protected_icon = QLabel()
        self.protected_icon.setPixmap(
            base.load_image('mark-protected.png', True))

        self.avatar = ClickableLabel()
        self.avatar.setPixmap(base.load_image('unknown.png', True))
        self.avatar.clicked.connect(self.__show_avatar)

        self.you_label = QLabel(i18n.get('this_is_you'))
        self.you_label.setVisible(False)

        info_line1 = QHBoxLayout()
        info_line1.setSpacing(5)
        info_line1.addWidget(self.username)
        info_line1.addSpacing(5)
        info_line1.addWidget(self.verified_icon)
        info_line1.addWidget(self.protected_icon)
        info_line1.addStretch(0)

        info_line2 = QHBoxLayout()
        info_line2.addWidget(self.fullname, 1)
        info_line2.addWidget(self.options)
        info_line2.addWidget(self.you_label)

        user_info = QVBoxLayout()
        user_info.addLayout(info_line1)
        user_info.addLayout(info_line2)

        self.loader = BarLoadIndicator()
        self.loader.setVisible(False)

        self.error_message = ErrorLabel()
        self.error_message.setVisible(False)

        header = QHBoxLayout()
        header.setContentsMargins(5, 10, 5, 0)
        header.addWidget(self.avatar)
        header.addSpacing(10)
        header.addLayout(user_info)

        # User Info
        self.bio = UserField(base, 'bio', 'icon-bio.png')
        self.bio.set_word_wrap(True)
        self.bio.set_info('')

        self.location = UserField(base, 'location', 'icon-location.png')
        self.location.set_info('')

        self.web = UserField(base, 'web', 'icon-home.png')
        self.web.set_info('')

        self.tweets = StatInfoBox('tweets', '')
        self.following = StatInfoBox('following', '')
        self.followers = StatInfoBox('followers', '')
        self.favorites = StatInfoBox('favorites', '')

        footer_layout = QHBoxLayout()
        footer_layout.setContentsMargins(0, 5, 0, 10)
        footer_layout.setSpacing(0)
        footer_layout.addLayout(self.tweets)
        footer_layout.addWidget(VLine())
        footer_layout.addLayout(self.following)
        footer_layout.addWidget(VLine())
        footer_layout.addLayout(self.followers)
        footer_layout.addWidget(VLine())
        footer_layout.addLayout(self.favorites)

        footer = QWidget()
        footer.setLayout(footer_layout)
        footer.setStyleSheet(
            "QWidget { background-color: #333; color: white; }")

        body_layout = QVBoxLayout()
        body_layout.setSpacing(15)
        body_layout.setContentsMargins(0, 0, 0, 0)
        body_layout.addLayout(self.bio)
        body_layout.addLayout(self.location)
        body_layout.addLayout(self.web)
        body_layout.addWidget(footer)

        body = QWidget()
        body.setLayout(body_layout)

        self.last_statuses = StatusesColumn(self.base, None, False)

        self.tabs = QTabWidget(self)
        self.tabs.setTabsClosable(False)
        self.tabs.setMovable(False)
        self.tabs.addTab(body, i18n.get('info'))
        self.tabs.addTab(self.last_statuses, i18n.get('recent'))

        self.hline = HLine()
        self.hline.setMinimumHeight(2)

        layout = QVBoxLayout()
        layout.addLayout(header)
        layout.addSpacing(10)
        layout.addWidget(self.hline)
        layout.addWidget(self.loader)
        layout.addWidget(self.error_message)
        layout.addSpacing(10)
        layout.addWidget(self.tabs, 1)
        layout.setSpacing(0)
        layout.setContentsMargins(5, 5, 5, 5)
        self.setLayout(layout)

        self.__clear()