Exemple #1
0
class JahrAuswahlDialog(QDialog):
    def __init__(self, jahre: List[int]):
        QDialog.__init__(self)
        self.jahr = jahre[0]
        self.cboJahr = QComboBox()
        self.cboJahr.setMaximumWidth(85)
        self.cboJahr.setFont(QFont("Arial", 14, QFont.Bold))
        self.cboJahr.addItems([str(j) for j in jahre])
        self.okButton = QPushButton("OK")
        self.okButton.setDefault(True)
        self.cancelButton = QPushButton("Abbrechen")
        self.okButton.clicked.connect(self.onAccepted)
        self.cancelButton.clicked.connect(self.reject)
        self._layout = QVBoxLayout()
        self.setLayout(self._layout)
        self._layout.addWidget(self.cboJahr)
        hbox = QHBoxLayout()
        hbox.addWidget(self.okButton)
        hbox.addWidget(self.cancelButton)
        self._layout.addLayout(hbox)
        self.setWindowTitle("Veranlagungsjahr")
        self.setFixedSize(QSize(200, 100))

    def onAccepted(self):
        self.jahr = int(self.cboJahr.currentText())
        self.accept()
Exemple #2
0
    def setup_table(self, manual_assign):
        table = self.ui.match_detectors_table
        table.clearContents()
        table.setRowCount(len(self.image_files))
        imgs_per_det = len(self.image_files) / len(
            HexrdConfig().detector_names)
        for i in range(len(self.image_files)):
            if manual_assign:
                det_cb = QComboBox()
                det_cb.addItems(list(set(self.detectors)))
                table.setCellWidget(i, 0, det_cb)
            else:
                d = QTableWidgetItem(self.detectors[i])
                table.setItem(i, 0, d)

            trans_cb = QComboBox()
            options = [
                "None", "Mirror about Vertical", "Mirror about Horizontal",
                "Transpose", "Rotate 90°", "Rotate 180°", "Rotate 270°"
            ]
            trans_cb.addItems(options)
            idx = 0
            if 'trans' in HexrdConfig().load_panel_state:
                det = int(i / imgs_per_det)
                idx = HexrdConfig().load_panel_state['trans'][det]
            trans_cb.setCurrentIndex(idx)
            table.setCellWidget(i, 1, trans_cb)

            f = QTableWidgetItem(self.image_files[i])
            table.setItem(i, 2, f)
        table.resizeColumnsToContents()
 def onActionsComboBoxChange(self, index):
     return
     if index == 0:  # session ctrl
         self.mainwindow.udsActionContentsLayout.addWidget(
             QLabel("Switch to Session:"))
         sessionTypesComboBox = QComboBox(self.mainwindow)
         sessionTypesComboBox.addItems(
             ["Default", "Programming", "Extended", "Custom"])
         self.mainwindow.udsActionContentsLayout.addWidget(
             sessionTypesComboBox)
         self.scanForAvailableSessionsBtn = QPushButton(
             "Scan for available Sessions")
         self.scanForAvailableSessionsBtn.clicked.connect(
             self.onScanForAvailableSessions)
         self.mainwindow.udsActionContentsLayout.addWidget(
             self.scanForAvailableSessionsBtn)
     elif index == 1:  # read data by id
         self.mainwindow.udsActionContentsLayout.addWidget(
             QLabel("Select what data to read:"))
         self.readDataType = QComboBox(self.mainwindow)
         self.readDataType.addItems([
             "All Data", "VIN", "ECU HW", "Supplier ECU HW",
             "ECU HW Version", "Supplier ECU SW", "ECU SW Version",
             "Custom ID", "Scan for Supported IDs"
         ])
         self.readDataBtn = QPushButton("Read")
         self.readDataBtn.clicked.connect(self.onReadDataById)
         self.mainwindow.tpActionContentsLayout.addWidget(self.readDataType)
         self.mainwindow.tpActionContentsLayout.addWidget(self.readDataBtn)
Exemple #4
0
    def _createSelectablePluginType(self, a: PluginAttribute):
        """
        Creates widget for attribute of SELECTABLE_PLUGIN type.
        
        :param a: The attribute.
        :type a: PluginAttribute
        :return: Widget for attribute.
        :rtype: QWidget
        """

        attrW = QWidget(self._widget)

        attrLayout = QVBoxLayout(attrW)
        attrLayout.setMargin(0)
        attrW.setLayout(attrLayout)

        inputW = QComboBox()
        inputW.addItems(
            [None if n is None else n.getName() for n in a.selVals])

        inputW.currentTextChanged.connect(self._pluginSelected(a, attrLayout))

        if a.value is not None:
            inputW.setCurrentText(str(a.value.getName()))

        resW = self._createWidget(a, inputW)
        resW.layout().addWidget(attrW)
        return resW
Exemple #5
0
class ComboBoxDelegate(QItemDelegate):
    def __init__(self, parent, choices):
        super().__init__(parent)
        self.editor = None
        self.items = choices

    def createEditor(self, parent, option, index):
        self.editor = QComboBox(parent)
        self.editor.addItems(self.items)
        # self.editor.currentIndexChanged.connect(self.currentItemChanged)
        return self.editor

    def paint(self, painter, option, index):
        value = index.data(Qt.DisplayRole)
        style = QApplication.style()
        opt = QStyleOptionComboBox()
        opt.text = str(value)
        opt.rect = option.rect
        style.drawComplexControl(QStyle.CC_ComboBox, opt, painter)
        QItemDelegate.paint(self, painter, option, index)

    def setEditorData(self, editor, index):
        value = index.data(Qt.DisplayRole)
        num = self.items.index(value)
        editor.setCurrentIndex(num)

    def setModelData(self, editor, model, index):
        value = editor.currentText()
        model.setData(index, value, Qt.EditRole)

    def updateEditorGeometry(self, editor, option, index):
        editor.setGeometry(option.rect)

    def currentItemChanged(self):
        self.commitData.emit(self.sender())
class Ui_FE14SupportWidget(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.characters_widget = QListWidget()
        self.supports_widget = QListWidget()
        self.add_button = QPushButton(text="Add")
        self.remove_button = QPushButton(text="Remove")
        self.add_remove_layout = QHBoxLayout()
        self.add_remove_layout.addWidget(self.add_button)
        self.add_remove_layout.addWidget(self.remove_button)
        self.add_remove_layout.setAlignment(QtGui.Qt.AlignCenter)

        self.selection_layout = QVBoxLayout()
        self.selection_layout.addWidget(self.characters_widget)
        self.selection_layout.addLayout(self.add_remove_layout)
        self.selection_layout.addWidget(self.supports_widget)

        self.support_type_box = QComboBox()
        self.support_type_box.addItems(
            ["Romantic", "Platonic", "Fast Romantic", "Fast Platonic"])
        self.edit_conversation_button = QPushButton(text="Edit Conversation")
        self.bottom_layout = QHBoxLayout()
        self.bottom_layout.setAlignment(QtGui.Qt.AlignCenter)
        self.bottom_layout.addWidget(QLabel("Support Type"))
        self.bottom_layout.addWidget(self.support_type_box)
        self.bottom_layout.addWidget(self.edit_conversation_button)
        self.selection_layout.addLayout(self.bottom_layout)

        self.setLayout(self.selection_layout)
Exemple #7
0
class mySearch(QWidget):
    def __init__(self):
        super().__init__()
        vbox = QVBoxLayout()
        self.mylist = ["Sepia","Thumbnail","Negative","Grayscale","None"]
        self.userline = QLineEdit("Enter a image tag")
        self.userline.setMinimumWidth(250)
        self.userline.returnPressed.connect(self.on_submit)
        self.filterbox = QComboBox()
        self.filterbox.addItems(self.mylist)
        self.nameline = QLabel("")
        vbox.addWidget(self.userline)
        vbox.addWidget(self.filterbox)
        vbox.addWidget(self.nameline)



        self.setLayout(vbox)

    
    @Slot()
    def on_submit(self):
        search = self.userline.text()
        keylist = search.split()
        self.nameline.setText("Image name: " + image_info[keyimage(image_info,keylist)]['title'])
        imageopen = Image.open(image_info[keyimage(image_info,keylist)]['id'] + ".jpg")
        filter1(imageopen,self.filterbox.currentText()).show()
        print(self.filterbox.currentText())
Exemple #8
0
class AdamUI(QWidget):
    def __init__(self):
        super().__init__()
        self.main_layout = QGridLayout()
        self.main_layout.setAlignment(Qt.AlignTop)        
        self.learning_rate = QLineEdit("0.001")
        self.learning_rate.setValidator(QDoubleValidator(0., 1., 5))
        self.epsilon = QLineEdit("1e-07")
        self.epsilon.setValidator(QDoubleValidator(0., 1e-10, 10))        
        self.amsgrad = QComboBox()
        self.amsgrad.addItems(["True", "False"])        
        self.beta_1 = QLineEdit("0.9")
        self.beta_1.setValidator(QDoubleValidator(0., 1e-10, 10))        
        self.beta_2 = QLineEdit("0.999")
        self.beta_2.setValidator(QDoubleValidator(0., 1e-10, 10))
        self.main_layout.addWidget(QLabel("Learning rate:"), 0, 0)
        self.main_layout.addWidget(self.learning_rate, 0, 1)
        self.main_layout.addWidget(QLabel("Epsilon:"),1 ,0)
        self.main_layout.addWidget(self.epsilon,1, 1)
        self.main_layout.addWidget(QLabel("Beta 1:"), 2, 0)
        self.main_layout.addWidget(self.beta_1,2, 1)
        self.main_layout.addWidget(QLabel("Beta 2:"), 3, 0)
        self.main_layout.addWidget(self.beta_2,3, 1)
        self.main_layout.addWidget(QLabel("Amsgrad:"), 4, 0)
        self.main_layout.addWidget(self.amsgrad, 4, 1)        
        self.setLayout(self.main_layout)        

    def get_optimizer(self):
        return None
Exemple #9
0
class NameEditDialog(QDialog):
    sig_name_edit = Signal(str, int)

    def __init__(self):
        super().__init__()
        self.cmb_option = QComboBox(self)
        self.cmb_option.addItems(['접두', '접미'])
        self.cmb_option.setStyleSheet('font: 10pt \'맑은 고딕\'')
        self.cmb_option.setMinimumWidth(70)
        self.cmb_option.setMaximumWidth(100)
        self.line_text = NPLine()
        self.line_text.setStyleSheet('font: 10pt \'맑은 고딕\'')
        self.btn_ok = NPButton('실행', 10, self)
        self.btn_ok.clicked.connect(self.emit_sig_name_edit)

        box_h = QHBoxLayout()
        box_h.addWidget(self.line_text)
        box_h.addWidget(self.cmb_option)
        box_h.addWidget(self.btn_ok)
        box_h.setStretchFactor(self.cmb_option, 1)
        box_h.setStretchFactor(self.line_text, 4)
        box_h.setStretchFactor(self.btn_ok, 1)
        # box_h.setContentsMargins(3, 3, 3, 3)
        self.setLayout(box_h)
        self.setWindowTitle('선택한 이미지 파일 표제어 일괄 변경')
        self.setWindowIcon(QIcon('icon.png'))
        self.setWindowFlag(Qt.WindowContextHelpButtonHint, False)
        # self.resize(300, 40)

    def emit_sig_name_edit(self):
        self.sig_name_edit.emit(self.line_text.text(),
                                self.cmb_option.currentIndex())
Exemple #10
0
class DialogNewGame(QDialog):
    def __init__(self, games):
        super().__init__()
        self.setWindowTitle('Start New Game')
        self.setFixedSize(QSize(250, 150))
        v_main = QVBoxLayout()
        v_main.addWidget(QLabel('Select the game you wish to track:'))

        self.combo = QComboBox()
        self.combo.addItems(games)
        self.combo.setCurrentIndex(0)
        v_main.addWidget(self.combo)

        h_buttons = QHBoxLayout()
        b_cancel = QPushButton('Cancel')
        b_cancel.clicked.connect(self.cancel)
        h_buttons.addWidget(b_cancel)

        b_start = QPushButton('Start New Game')
        b_start.clicked.connect(self.start)
        b_start.setDefault(True)
        h_buttons.addWidget(b_start)

        v_main.addLayout(h_buttons)
        self.setLayout(v_main)

    def start(self):
        self.accept()
        return self.combo.currentText()

    def cancel(self):
        self.reject()
Exemple #11
0
    def __init__(self, meal_name: str, week_days: List[str],
                 meals_amount: int) -> None:
        super().__init__()

        week_day_list_widget = QComboBox()
        week_day_list_widget.addItems(week_days)

        meal_idx_list_widget = QComboBox()
        meal_idx_list_widget.addItems(
            list(map(str, range(1, meals_amount + 1))))

        add_push_button = QPushButton("+")

        remove_push_button = QPushButton("-")

        # Layout for the widget

        layout = QHBoxLayout()
        layout.addWidget(week_day_list_widget)
        layout.addWidget(meal_idx_list_widget)
        layout.addWidget(add_push_button)
        layout.addWidget(remove_push_button)

        self.setLayout(layout)

        # Init self data

        self._meal_name = meal_name
        self._on_meal_planned: Optional[PlannedCallbackType] = None
        self._on_element_removed: Optional[RemovedCallbackType] = None

        self._week_day_list_widget = week_day_list_widget
        self._meal_idx_list_widget = meal_idx_list_widget
        self._add_push_button = add_push_button
        self._remove_push_button = remove_push_button
Exemple #12
0
class DemoPlotWidget(QWidget):
    tips = sns.load_dataset("tips")

    def __init__(self):
        super().__init__()

        self._setupView()
        self._updatePlot()
        self._connectSignals()

    def _setupView(self):
        self.dropdown1 = QComboBox()
        self.dropdown1.addItems(["sex", "time", "smoker"])
        self.dropdown2 = QComboBox()
        self.dropdown2.addItems(["sex", "time", "smoker", "day"])
        self.dropdown2.setCurrentIndex(2)

        self._createFigure()

        self.layout = QGridLayout(self)
        self.layout.addWidget(QLabel("Select category for subplots"))
        self.layout.addWidget(self.dropdown1)
        self.layout.addWidget(QLabel("Select category for markers"))
        self.layout.addWidget(self.dropdown2)
        self.layout.addWidget(self.canvas)

        self.label = QLabel("A plot:")

    def _createFigure(self):
        self.fig = Figure()
        self.ax1 = self.fig.add_subplot(121)
        self.ax2 = self.fig.add_subplot(122, sharex=self.ax1, sharey=self.ax1)
        self.axes = [self.ax1, self.ax2]

        self.canvas = FigureCanvas(self.fig)
        self.canvas.setSizePolicy(QSizePolicy.Expanding,
                                  QSizePolicy.Expanding)
        self.canvas.updateGeometry()

    def _connectSignals(self):
        self.dropdown1.currentIndexChanged.connect(self._updatePlot)
        self.dropdown2.currentIndexChanged.connect(self._updatePlot)

    def _updatePlot(self):
        colors = ["b", "r", "g", "y", "k", "c"]
        self.ax1.clear()
        self.ax2.clear()

        cat1 = self.dropdown1.currentText()
        cat2 = self.dropdown2.currentText()

        for i, value in enumerate(self.tips[cat1].unique().to_numpy()):
            df = self.tips.loc[self.tips[cat1] == value]
            self.axes[i].set_title(cat1 + ": " + value)
            for j, value2 in enumerate(df[cat2].unique().to_numpy()):
                df.loc[self.tips[cat2] == value2].plot(
                    kind="scatter", x="total_bill", y="tip", ax=self.axes[i], c=colors[j], label=value2
                )
        self.axes[i].legend()
        self.fig.canvas.draw_idle()
Exemple #13
0
class EntitySelector(QWidget):
    def __init__(self, parent):
        self.parent = parent
        QWidget.__init__(self)
        self.initUI()

    def initUI(self):
        self.layout = QGridLayout()
        self.setLayout(self.layout)

        asksel = QLabel(
            "Please select the entity information you wish to peruse:")
        self.layout.addWidget(asksel, 0, 0)

        self.entityTypes = QComboBox()
        self.getEntityTypes()
        self.layout.addWidget(self.entityTypes, 0, 1)

        self.go = QPushButton("Go")
        self.go.clicked.connect(self.enterentview)
        self.layout.addWidget(self.go, 1, 0, 1, 2)

    def getEntityTypes(self):
        self.entityTypes.addItems(json_reader.getcomplexdata('entities'))

    def enterentview(self):
        self.parent.changeState(
            EntityViewer(self, self.entityTypes.currentText()))
    def createEditor(self, parent, option, index):
        """
        createEditor edit item at index

        Args:
            parent (QWidget): editor parent object
            option (QStyleOptionViewItem): item options
            index (QModelIndex): index of item in table

        Returns:
            QComboBox: editor is a ComboBox. Defaults to None if no list of
            items can be made.
        """

        sourceIndex = self.model.mapToSource(index)
        row = sourceIndex.row()
        column = sourceIndex.column()
        status = self.model.sourceModel().dataset[row, column]
        self.comboItems = _comboBoxItems(status)

        if self.comboItems:
            editor = QComboBox(parent)
            editor.addItems(self.comboItems)
            editor.currentIndexChanged.connect(self.currentIndexChanged)
            editor.setEditable(True)
            editor.lineEdit().setReadOnly(True)
            editor.lineEdit().setAlignment(Qt.AlignCenter)

            return editor

        return None
    def createEditor(self, parent, option, proxyModelIndex):

        editor = QComboBox(self)
        editor.addItems(self.comboItems)
        editor.currentIndexChanged.connect(self.currentIndexChanged)

        return editor
Exemple #16
0
class ViewPanel(DataView):
    def __init__(self, workbench, parent: QWidget = None):
        super().__init__(workbench, parent)
        self.__currentFrameName: str = None
        self.__chartTypeCB = QComboBox(self)
        self.fLayout = QFormLayout(self)
        self.fLayout.addRow(__config__['description'], self.__chartTypeCB)
        moduleNames = __classes__.keys()
        self.fLayout.setHorizontalSpacing(40)
        self.__chartTypeCB.addItems(list(moduleNames))
        defaultSelection = __config__['default']
        self.__chartTypeCB.setCurrentText(defaultSelection)
        self.chartSelectionChanged(defaultSelection)
        self.__chartTypeCB.currentTextChanged.connect(self.chartSelectionChanged)

    @Slot(str)
    def chartSelectionChanged(self, text: str) -> None:
        if self.fLayout.rowCount() == 2:
            self.fLayout.removeRow(1)
        widget: type = locate(__classes__[text])  # subclass of DataView
        self.fLayout.addRow(widget(self._workbench, self))
        self.onFrameSelectionChanged(self.__currentFrameName, '')

    @Slot(str, str)
    def onFrameSelectionChanged(self, name: str, oldName: str) -> None:
        self.__currentFrameName = name
        self.fLayout.itemAt(1, QFormLayout.SpanningRole).widget().onFrameSelectionChanged(name, oldName)
Exemple #17
0
class IccTableEditorYearSpecificView(IccTableEditorView):
    """
    Eine von IccTableEditorView abgeleitete Klasse, die in der Toolbar neben dem Speichern-Button eine Jahr-Combobox
    hat. Sie wird mit den Methoden addJahr, addJahre, setCurrentJahr und clearJahre bedient.
    Wird das Jahr geändert, wird ein yearChanged-Signal gesendet.
    """
    yearChanged = Signal(int)

    def __init__(self, model: XBaseTableModel = None):
        IccTableEditorView.__init__(self, model)
        self._cboYear = QComboBox()
        self._cboYear.setFont(QFont("Arial", 14, weight=QFont.Bold))
        self._cboYear.currentTextChanged.connect(self.onCurrentYearChanged)
        self.addTool(self._cboYear)

    def addJahr(self, jahr: int):
        self._cboYear.addItem(str(jahr))

    def addJahre(self, jahre: List[int]):
        self._cboYear.addItems([str(j) for j in jahre])

    def setCurrentJahr(self, jahr: int):
        self._cboYear.setCurrentText(str(jahr))

    def clearJahre(self):
        self._cboYear.clear()

    def onCurrentYearChanged(self, sJahrNeu: str):
        self.yearChanged.emit(int(sJahrNeu))
Exemple #18
0
class WdParameterValueEdit(WdParameterEditBase):
    def __init__(self, parent=None):
        super().__init__('val', parent)
        self.edit_widget = QLineEdit()
        self.combo_widget = QComboBox()
        self.add_subwidget(self.edit_widget)
        self.add_subwidget(self.combo_widget)
        self.combo_widget.setVisible(False)
        self.edit_widget.editingFinished.connect(self.on_text_edited)
        self.combo_widget.activated.connect(self.on_combo_selected)

    def set_parameter(self, parameter: Parameter):
        use_combo = parameter.help_val is not None
        self.combo_widget.setVisible(use_combo)
        self.edit_widget.setVisible(not use_combo)
        if use_combo:
            vals, labels = parameter.values_choice()
            self.combo_widget.clear()
            self.combo_widget.addItems(labels)
        else:
            self.combo_widget.clear()
        super().set_parameter(parameter)

    @Slot()
    def on_text_edited(self):
        if self.wdparameter is not None:
            try:
                val = self.wdparameter.scan_str(self.edit_widget.text())
            except:
                self.update_from_model()
                return
            self.set_model_value(val)

    @Slot(int)
    def on_combo_selected(self, index: int):
        if self.wdparameter is not None:
            vals, labels = self.wdparameter.values_choice()
            val = list(vals)[index]
            self.set_model_value(val)

    def set_view_value(self, value):
        if value is None:
            value = ''
        if not isinstance(value, str):
            vals, labels = self.wdparameter.values_choice()
            if labels:
                try:
                    index = vals.index(value)
                except ValueError:
                    index = -1
                self.combo_widget.setCurrentIndex(index)
            else:
                if isinstance(self.wdparameter, IntParameter):
                    value = f'{value:.0f}'
                else:
                    value = f'{value:g}'
                self.edit_widget.setText(value)
        else:
            self.edit_widget.setText(value)
            self.combo_widget.setEditText(value)
Exemple #19
0
class AssociationItem(MimeTypeItem):

    def __init__(self, mime_type, apps, main_window, listview):
        MimeTypeItem.__init__(self, mime_type, listview)

        self.apps = apps
        self.main_window = main_window

        self.selector = QComboBox()
        self.selector.addItems(self.apps)
        self.selector.currentTextChanged.connect(self._on_selected)

        self.hbox.addWidget(self.selector, 2)

    def _on_selected(self, _):
        mime = self.mime_type.identifier
        app = self.selector.currentText()
        self.main_window.status.showMessage(f'Setting {mime} to {app}...')
        def run():
            success = self.main_window.assocdb.set_app_for_mimetype(mime, app)
            if success:
                msg = f'{app} was successfully set to open {mime}.'
            else:
                msg = f'Could not set {app} to open {mime}, please check ' \
                      f'the logs!'
            self.main_window.status.showMessage(msg)
        t = Thread(target=run)
        t.start()

    def __hash__(self):
        return hash(self.mime_type)
Exemple #20
0
def combo_box(items, status, key, connect):
    """Creates a combo box with given information"""
    box = QComboBox()
    box.addItems(items)
    box.setStatusTip(status)
    box.activated[str].connect(functools.partial(connect, key))
    return box
Exemple #21
0
class RMSpropUI(QWidget):
    def __init__(self):
        super().__init__()
        self.main_layout = QGridLayout()
        self.main_layout.setAlignment(Qt.AlignTop)        
        self.learning_rate = QLineEdit("0.01")
        self.learning_rate.setValidator(QDoubleValidator(0., 1., 5))
        self.momentum = QLineEdit("0.00")
        self.momentum.setValidator(QDoubleValidator(0., 1e5, 2))        
        self.rho = QLineEdit("0.9")
        self.rho.setValidator(QDoubleValidator(0., 1e5, 10))
        self.epsilon = QLineEdit("1e-07")
        self.epsilon.setValidator(QDoubleValidator(0., 1e-10, 10))        
        self.centered = QComboBox()
        self.centered.addItems(["True", "False"])
        self.main_layout.addWidget(QLabel("Learning rate:"), 0, 0)
        self.main_layout.addWidget(self.learning_rate, 0, 1)
        self.main_layout.addWidget(QLabel("Momentum:"), 1, 0)
        self.main_layout.addWidget(self.momentum,1, 1)
        self.main_layout.addWidget(QLabel("rho:"), 2, 0)
        self.main_layout.addWidget(self.rho,2 , 1)
        self.main_layout.addWidget(QLabel("epsilon:"),3 ,0)
        self.main_layout.addWidget(self.epsilon,3, 1)
        self.main_layout.addWidget(QLabel("centered:"), 4, 0)
        self.main_layout.addWidget(self.centered, 4, 1)
        self.setLayout(self.main_layout)

    def get_optimizer(self):
        return None
Exemple #22
0
class Layout(Slots):
    def __init__(self):
        super().__init__()

    def stored_location_layout(self):
        self.stored_directories_title = QLabel(constants.stored_dir_str)

        # Combo box and its properties
        self.stored_dir_dropdown = QComboBox()
        self.stored_dir_dropdown.addItems(self.get_list_items())
        self.stored_dir_dropdown.setCursor(QCursor(Qt.PointingHandCursor))
        self.stored_dir_dropdown.setStyleSheet(stored_dir_dropdown_styles)

        # Layout grid for combo box widget
        self.stored_dirs_layout = QGridLayout()
        self.stored_dirs_layout.addWidget(self.stored_directories_title, 0, 0)
        self.stored_dirs_layout.addWidget(self.stored_dir_dropdown, 0, 1)
        self.stored_dirs_layout.setColumnStretch(1, 2)
        self.stored_dirs_layout.setContentsMargins(0, 16, 0, 32)

        return self.stored_dirs_layout

    def push_to_group_layout(self):
        # Create a group
        self.group_push_to = QGroupBox(constants.push_branch_str)
        self.group_push_to.setStyleSheet(group_widgets_styles)

        # Create the layout for the branch widgets
        self.pushToLayout = QVBoxLayout()
        self.pushToLayout.setAlignment(Qt.AlignTop)
        self.pushToLayout.setContentsMargins(16, 24, 16, 24)

        # Set the layout to the group
        self.group_push_to.setLayout(self.pushToLayout)

        # Create the staging button and its properties
        self.staging_btn = QPushButton(constants.master_to_staging_str)
        self.staging_btn.clicked.connect(
            lambda: self.handle_branch_push_to_git(constants.master, constants.
                                                   staging))
        self.staging_btn.setCursor(QCursor(Qt.PointingHandCursor))
        self.staging_btn.setStyleSheet(button_styles)

        # Create the production button and its properties
        self.prod_btn = QPushButton(constants.staging_to_prod_str)
        self.prod_btn.setCursor(QCursor(Qt.PointingHandCursor))
        self.prod_btn.clicked.connect(lambda: self.handle_branch_push_to_git(
            constants.staging, constants.production))
        self.prod_btn.setStyleSheet(button_styles)

        self.thread = Thread()
        self.thread.finished.connect(lambda: self.staging_btn.setEnabled(True))
        self.thread.finished.connect(lambda: self.prod_btn.setEnabled(True))

        # Add the button widgets to the layout
        self.pushToLayout.addWidget(self.staging_btn)
        self.pushToLayout.addWidget(self.prod_btn)

        return self.group_push_to
    def displayWidgets(self):
        """
        Configura os widgets da app
        """

        info_lbl = QLabel("Selecione 2 itens que você almoçou e seus preços.")
        info_lbl.setFont(QFont('Arial', 16))
        info_lbl.setAlignment(Qt.AlignCenter)
        self.total_lbl = QLabel("Total: R$")
        self.total_lbl.setFont(QFont('Arial', 16))
        self.total_lbl.setAlignment(Qt.AlignRight)

        list_comida = [
            "ovos", "misto quente", "queijo quente", "queijo", "homus",
            "iogurte", "maçã", "banana", "laranja", "pão de queijo",
            "cenouras", "pão", "macarrão", "biscoitos", "tapioca",
            "batatas fritas", "café", "refrigerante", "água"
        ]

        alm1_cbx = QComboBox()
        alm1_cbx.addItems(list_comida)
        alm2_cbx = QComboBox()
        alm2_cbx.addItems(list_comida)

        self.pre1R_sbx = QSpinBox()
        self.pre1R_sbx.setRange(0, 100)
        self.pre1R_sbx.setPrefix("R$ ")
        self.pre1R_sbx.valueChanged.connect(self.calculaTotal)
        self.pre1C_sbx = QSpinBox()
        self.pre1C_sbx.setRange(0, 99)
        self.pre1C_sbx.setPrefix(".")
        self.pre1C_sbx.valueChanged.connect(self.calculaTotal)

        self.pre2R_sbx = QSpinBox()
        self.pre2R_sbx.setRange(0, 100)
        self.pre2R_sbx.setPrefix("R$ ")
        self.pre2R_sbx.valueChanged.connect(self.calculaTotal)
        self.pre2C_sbx = QSpinBox()
        self.pre2C_sbx.setRange(0, 99)
        self.pre2C_sbx.setPrefix(".")
        self.pre2C_sbx.valueChanged.connect(self.calculaTotal)

        hbox1 = QHBoxLayout()
        hbox2 = QHBoxLayout()

        hbox1.addWidget(alm1_cbx)
        hbox1.addWidget(self.pre1R_sbx)
        hbox1.addWidget(self.pre1C_sbx)
        hbox2.addWidget(alm2_cbx)
        hbox2.addWidget(self.pre2R_sbx)
        hbox2.addWidget(self.pre2C_sbx)

        vbox = QVBoxLayout()
        vbox.addWidget(info_lbl)
        vbox.addLayout(hbox1)
        vbox.addLayout(hbox2)
        vbox.addWidget(self.total_lbl)

        self.setLayout(vbox)
Exemple #24
0
class MyWidget(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):

        formlayout = QFormLayout()
        formlayout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
        formlayout.setVerticalSpacing(20)

        explain = QLabel("推送小工具请粘贴微博文章详情页链接,并选择类型,提交。")
        url = QLabel('微博链接:')
        data_type = QLabel('选择类型:')

        self.url_edit = QLineEdit()
        self.data_type_edit = QComboBox()
        self.data_type_edit.addItems(['负面', '中性', '正面'])

        button = QPushButton('提交', self)
        button.setStyleSheet("background-color: rgb(255, 255, 255);")

        formlayout.addRow(explain)
        formlayout.addRow(url, self.url_edit)
        formlayout.addRow(data_type, self.data_type_edit)

        hbox = QHBoxLayout()
        hbox.addStretch(0)
        hbox.addWidget(button)
        vbox = QVBoxLayout()
        vbox.addStretch(0)
        vbox.addLayout(hbox)
        formlayout.addRow(vbox)
        self.setLayout(formlayout)
        # x y 宽 高
        self.setGeometry(500, 200, 600, 400)
        self.setWindowTitle('推送小工具')
        self.show()
        # self.data_type_edit.currentIndexChanged[str].connect(self.print_value)  # 条目发生改变,发射信号,传递条目内容
        button.clicked.connect(self.but_click)

    def but_click(self):
        url = self.url_edit.text()
        data_type_edit = self.data_type_edit.currentText()
        if not url:
            QMessageBox.critical(self, '错误', '请输入微博链接')
            return False
        mid = get_mid(url)
        if not mid:
            QMessageBox.critical(self, '错误', '请输入符合正确的微博链接')
            self.url_edit.setText('')
            return False
        status = get_response(mid)
        result = get_context(status)
        tem = '{}\n'.format(data_type_edit) + result + '{}\n'.format(url)
        write_context(tem)
        QMessageBox.information(self, '提示', '已成功写入')
        self.url_edit.setText('')
        return True
Exemple #25
0
    def createComboBox(self):
        cb = QComboBox()

        # ports = serial.tools.list_ports.comports()
        portNames = get_usb_ports()
        cb.addItems(portNames)

        return cb
Exemple #26
0
    def generateVirtualityField():
        """
		@rtype: QComboBox
		"""
        field = QComboBox()
        field.addItems(['', 'VIRTUAL', 'PERSISTENT'])

        return field
    def exportToCSV(self):
        def doexport():
            filetype = filetypes.currentText()
            exportTables = []
            db = self.consolesTableView.model.database()
            if tablesBox.currentIndex() == 0:
                for table in tables[1:]:
                    exportTables.append(table.lower())
            elif tablesBox.currentIndex() == 1:
                exportTables.append("games")
            elif tablesBox.currentIndex() == 2:
                exportTables.append("consoles")
            elif tablesBox.currentIndex() == 3:
                exportTables.append("accessories")

            sql2csv(db, exportTables, filetype)
            exportWindow.close()

        exportWindow = QDialog()

        tables = ["All", "Games", "Consoles", "Accessories"]
        tablesLabel = QLabel("Tables to export")
        tablesBox = QComboBox()
        # tablesBox.addItem(None, text="All")
        tablesBox.addItems(tables)
        tablesLayout = QHBoxLayout()
        tablesLayout.addWidget(tablesLabel)
        tablesLayout.addWidget(tablesBox)

        filetypesLabel = QLabel("Filetype")
        filetypes = QComboBox()
        filetypes.addItems(["csv", "tsv"])
        filetypesLayout = QHBoxLayout()
        filetypesLayout.addWidget(filetypesLabel)
        filetypesLayout.addWidget(filetypes)

        # filenameLabel = QLabel("Filename")
        # filename = QLineEdit()
        # filesLayout = QHBoxLayout()
        # filesLayout.addWidget(filenameLabel)
        # filesLayout.addWidget(filename)

        ok = QPushButton("Ok")
        ok.clicked.connect(doexport)
        cancel = QPushButton("Cancel")
        cancel.clicked.connect(exportWindow.close)
        buttonLayout = QHBoxLayout()
        buttonLayout.addWidget(ok)
        buttonLayout.addWidget(cancel)

        layout = QVBoxLayout()
        layout.addLayout(tablesLayout)
        # layout.addLayout(filesLayout)
        layout.addLayout(filetypesLayout)
        layout.addLayout(buttonLayout)

        exportWindow.setLayout(layout)
        exportWindow.exec_()
Exemple #28
0
    def __init__(self):
        super().__init__()
        widget = QComboBox()

        widget.addItems(["First", "Second", "Third"])
        widget.currentIndexChanged.connect(self.index_changed)
        widget.currentTextChanged.connect(self.text_changed)

        self.setCentralWidget(widget)
    def __init__(self, parent=None):
        super(WidgetGallery, self).__init__(parent)

        self.originalPalette = QApplication.palette()

        styleComboBox = QComboBox()
        styleComboBox.addItems(QStyleFactory.keys())

        styleLabel = QLabel("&Style:")
        styleLabel.setBuddy(styleComboBox)

        self.useStylePaletteCheckBox = QCheckBox(
            "&Use style's standard palette")
        self.useStylePaletteCheckBox.setChecked(True)

        disableWidgetsCheckBox = QCheckBox("&Disable widgets")

        self.createTopLeftGroupBox()
        self.createTopRightGroupBox()
        self.createBottomLeftTabWidget()
        self.createBottomRightGroupBox()
        self.createProgressBar()

        styleComboBox.activated[str].connect(self.changeStyle)
        self.useStylePaletteCheckBox.toggled.connect(self.changePalette)
        disableWidgetsCheckBox.toggled.connect(
            self.topLeftGroupBox.setDisabled)
        disableWidgetsCheckBox.toggled.connect(
            self.topRightGroupBox.setDisabled)
        disableWidgetsCheckBox.toggled.connect(
            self.bottomLeftTabWidget.setDisabled)
        disableWidgetsCheckBox.toggled.connect(
            self.bottomRightGroupBox.setDisabled)

        topLayout = QHBoxLayout()
        topLayout.addWidget(styleLabel)
        topLayout.addWidget(styleComboBox)
        topLayout.addStretch(1)
        topLayout.addWidget(self.useStylePaletteCheckBox)
        topLayout.addWidget(disableWidgetsCheckBox)

        mainLayout = QGridLayout()
        mainLayout.addLayout(topLayout, 0, 0, 1, 2)
        mainLayout.addWidget(self.topLeftGroupBox, 1, 0)
        mainLayout.addWidget(self.topRightGroupBox, 1, 1)
        mainLayout.addWidget(self.bottomLeftTabWidget, 2, 0)
        mainLayout.addWidget(self.bottomRightGroupBox, 2, 1)
        mainLayout.addWidget(self.progressBar, 3, 0, 1, 2)
        mainLayout.setRowStretch(1, 1)
        mainLayout.setRowStretch(2, 1)
        mainLayout.setColumnStretch(0, 1)
        mainLayout.setColumnStretch(1, 1)
        self.setLayout(mainLayout)

        self.setWindowTitle("Common Qt Widgets")
        self.changeStyle('Fusion')
Exemple #30
0
class MyWindow(QWidget):
    def __init__(self):
        super().__init__()

        vbox1 = QVBoxLayout()
        self.my_lineedit = QLineEdit("What type of photo are you looking for?")
        self.my_lineedit.setMinimumWidth(250)
        self.my_lineedit.selectAll()
        self.my_btn = QPushButton("Submit")
        self.my_lbl = QLabel('')
        self.my_btn.clicked.connect(self.on_submit)
        self.my_lineedit.returnPressed.connect(self.on_submit)
        vbox1.addWidget(self.my_lineedit)
        vbox1.addWidget(self.my_btn)
        vbox1.addWidget(self.my_lbl)
        self.setLayout(vbox1)

        gbox1 = QGroupBox('Photo Search')
        gbox1.setLayout(vbox1)

        self.my_list = [
            "Pick a filter", 'None', 'Sepia', 'Negative', 'Grayscale',
            'Thumbnail'
        ]
        #                        0             1       2          3           4          5
        self.my_combo_box = QComboBox()
        self.my_combo_box.addItems(self.my_list)
        self.my_label = QLabel("")

        vbox2 = QVBoxLayout()
        vbox2.addWidget(self.my_combo_box)
        vbox2.addWidget(self.my_label)

        self.setLayout(vbox2)
        self.my_combo_box.currentIndexChanged.connect(self.update_ui)

        gbox2 = QGroupBox("Filters")
        gbox2.setLayout(vbox2)

        mbox = QVBoxLayout()
        mbox.addWidget(gbox1)
        mbox.addWidget(gbox2)

        self.setLayout(mbox)
        self.setWindowTitle("CST 205 App")

    @Slot()
    def on_submit(self):
        your_photo = self.my_lineedit.text()
        self.my_lbl.setText(f'Your photo is {your_photo}')

    @Slot()
    def update_ui(self):
        my_text = self.my_combo_box.currentText()
        my_index = self.my_combo_box.currentIndex()
        self.my_label.setText(f'You chose {self.my_list[my_index]}.')
    def createEditor(self, parent, option, index):
        editor = QComboBox(parent)
        editor.addItems(self._choices)

        # Use the model data to pre-select a choice in the combo box.
        currentValue = index.model().data(index)
        if currentValue in self._choices:
            currentIndex = self._choices.index(currentValue)
            editor.setCurrentIndex(currentIndex)

        editor.currentIndexChanged.connect(self.currentIndexChanged)
        return editor
Exemple #32
0
    def initUI(self):
        self.setWindowTitle(self.tr("Tic-Tac-Toe"))
        layout = QVBoxLayout()
        self.setLayout(layout)
        gridLayout = QGridLayout()
        gridLayout.setSpacing(3)
        aiComboBox = QComboBox(self)
        aiComboBox.addItems([self.tr(ai) for ai in self.AIs])
        aiComboBox.currentTextChanged.connect(self.selectAI)
        layout.addWidget(aiComboBox)
        layout.addLayout(gridLayout)

        for tile in self.ticTacToe:
            button = QTicTacToe.QTileButton(self, tile)
            gridLayout.addWidget(button, tile.row, tile.column)
            button.clicked.connect(button.clickEvent)
            tile.delegate = button
Exemple #33
0
    def initUI(self):
        self.setWindowTitle(self.tr("Fourplay"))
        layout = QVBoxLayout()
        self.setLayout(layout)
        discGridLayout = QGridLayout()
        discGridLayout.setSpacing(4)
        aiComboBox = QComboBox(self)
        aiComboBox.addItems([self.tr(ai) for ai in self.AIs])
        aiComboBox.currentTextChanged.connect(lambda: self.selectAI())
        layout.addWidget(aiComboBox)
        layout.addLayout(discGridLayout)

        for disc in self.fourPlay:
            qDisc = QFourPlay.QDiscButton(self)
            discGridLayout.addWidget(qDisc, disc.row, disc.column)
            qDisc.clicked.connect(lambda qDisc=qDisc, disc=disc: qDisc.clickEvent(disc))
            qDisc.marked(disc)
            disc.delegate = qDisc
Exemple #34
0
class QGameOfLife(QWidget):

    Games = {
        "Game of Life": (GameOfLife, {'fill_rate': 0.50}),
        "Bacteria": (GrayScottDiffusion, {'coeffs': (0.16, 0.08, 0.035, 0.065)}),
        "Coral": (GrayScottDiffusion, {'coeffs': (0.16, 0.08, 0.062, 0.062)}),
        "Fingerprint": (GrayScottDiffusion, {'coeffs': (0.19, 0.05, 0.060, 0.062)}),
        "Spirals": (GrayScottDiffusion, {'coeffs': (0.10, 0.10, 0.018, 0.050)}),
        "Unstable": (GrayScottDiffusion, {'coeffs': (0.16, 0.08, 0.020, 0.055)}),
        "Worms": (GrayScottDiffusion, {'coeffs': (0.16, 0.08, 0.050, 0.065)}),
        "Zebrafish": (GrayScottDiffusion, {'coeffs': (0.16, 0.08, 0.035, 0.060)}),
    }

    def __init__(self, size=(400, 400)):
        super(QGameOfLife, self).__init__()
        self.size = size
        self.game = None
        self.initUI()
        self.show()

    def initUI(self):
        self.setWindowTitle(self.tr("Game of Life"))
        self.setLayout(QVBoxLayout())
        self.layout().setSpacing(0)
        self.layout().setContentsMargins(0, 0, 0, 0)

        self.comboBox = QComboBox()
        self.comboBox.addItems([*QGameOfLife.Games.keys()])
        self.comboBox.currentTextChanged.connect(self.select)
        self.layout().addWidget(self.comboBox)

        self.scene = QGraphicsScene()
        self.view = QGraphicsView(self.scene)
        self.view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.view.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        self.view.setFrameShape(QFrame.NoFrame)
        self.layout().addWidget(self.view)

        self.item = None
        self.timer = QTimer()
        self.timer.setInterval(10)
        self.timer.timeout.connect(self.tick)
        initialGame = random.choice([*QGameOfLife.Games.keys()])
        self.select(initialGame)
        self.view.fitInView(self.item, Qt.KeepAspectRatioByExpanding)
        self.comboBox.setCurrentText(initialGame)

    def select(self, name: str):
        self.timer.stop()
        Game, args = QGameOfLife.Games[name]
        self.game = Game(self.size, **args)
        self.tick()
        self.timer.start()

    def tick(self):
        self.game.tick()
        bitmap = self.game.visualize()
        image = QImage(bitmap.data, bitmap.shape[1], bitmap.shape[0], QImage.Format_Grayscale8)
        self.scene.removeItem(self.item)
        pixmap = QPixmap.fromImage(image)
        self.item = self.scene.addPixmap(pixmap)

    def resizeEvent(self, event: QResizeEvent):
        self.view.fitInView(self.item, Qt.KeepAspectRatioByExpanding)

    def sizeHint(self) -> QSize:
        return QSize(self.size[0], self.size[1])