Python PyQt5.QtWidgets.QComboBox() Examples

The following are 30 code examples for showing how to use PyQt5.QtWidgets.QComboBox(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .

Example 1
Project: idasec   Author: RobinDavid   File: AnalysisWidget.py    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
def add_input_action(self):
        self.inputs_table.setRowCount(self.inputs_table.rowCount()+1)
        i = self.inputs_table.rowCount()-1
        type_combo = QtWidgets.QComboBox()
        type_combo.addItems(["REG", "MEM"])
        action_combo = QtWidgets.QComboBox()
        action_combo.addItems(["DEFAULT", "PATCH", "CONC", "SYMB", "IGNORE"])
        when_combo = QtWidgets.QComboBox()
        when_combo.addItems(["BEFORE", "AFTER"])
        info = [type_combo, QtWidgets.QTableWidgetItem(), QtWidgets.QTableWidgetItem(), QtWidgets.QTableWidgetItem(),
                action_combo, when_combo]

        for col_id, widget in enumerate(info):
            if isinstance(widget, QtWidgets.QTableWidgetItem):
                self.inputs_table.setItem(i, col_id, widget)
            else:
                self.inputs_table.setCellWidget(i, col_id, widget)
        return i 
Example 2
Project: pyweed   Author: iris-edu   File: OptionsWidget.py    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
def getInputValue(self, key):
        """
        Get the value of a single input. This is intended to Pythonify the Qt values that come natively
        from the widgets. (ie. return a Python date rather than a QDate).

        This is used internally by getOptions()
        """
        one_input = self.inputs.get(key)
        if one_input:
            if isinstance(one_input, QtWidgets.QDateTimeEdit):
                # DateTime
                return one_input.dateTime().toString(QtCore.Qt.ISODate)
            elif isinstance(one_input, QtWidgets.QAbstractButton):
                # Radio/checkbox button
                return str(one_input.isChecked())
            elif isinstance(one_input, QtWidgets.QComboBox):
                return one_input.currentText()
            elif hasattr(one_input, 'text'):
                return one_input.text()
            raise Exception("Couldn't identify the QWidget type for %s (%s)" % (key, one_input))
        return None 
Example 3
Project: Lector   Author: BasioMeusPuga   File: dockwidgets.py    License: GNU General Public License v3.0 6 votes vote down vote up
def populate_combo_box(self):
        def set_toc_position(tocTree):
            currentIndex = tocTree.currentIndex()
            required_position = currentIndex.data(QtCore.Qt.UserRole)
            self.return_focus()
            self.parent.set_content(required_position, True, True)

        # Create the Combobox / Treeview combination
        tocTree = QtWidgets.QTreeView()
        self.tocComboBox.setView(tocTree)
        self.tocComboBox.setModel(self.parent.tocModel)
        tocTree.setRootIsDecorated(False)
        tocTree.setItemsExpandable(False)
        tocTree.expandAll()

        # Set the position of the QComboBox
        self.parent.set_tocBox_index(None, self.tocComboBox)

        # Make clicking do something
        self.tocComboBox.currentIndexChanged.connect(
            lambda: set_toc_position(tocTree)) 
Example 4
Project: KStock   Author: aseylys   File: ComboBoxDelegateQt.py    License: GNU General Public License v3.0 6 votes vote down vote up
def createEditor(self, parent, option, index):
        '''
        Return QComboBox with list of choices (either values or their associated keys if they exist).
        '''
        try:
            editor = QComboBox(parent)
            value = index.model().data(index, Qt.DisplayRole)
            for i, choice in enumerate(self.choices):
                if (type(choice) is tuple) and (len(choice) == 2):
                    # choice is a (key, value) tuple.
                    key, val = choice
                    editor.addItem(str(key))  # key MUST be representable as a str.
                    if val == value:
                        editor.setCurrentIndex(i)
                else:
                    # choice is a value.
                    editor.addItem(str(choice))  # choice MUST be representable as a str.
                    if choice == value:
                        editor.setCurrentIndex(i)
            return editor
        except:
            return None 
Example 5
Project: Writer-Tutorial   Author: goldsborough   File: datetime.py    License: MIT License 6 votes vote down vote up
def initUI(self):
 
        self.box = QtWidgets.QComboBox(self)

        for i in self.formats:
            self.box.addItem(strftime(i))

        insert = QtWidgets.QPushButton("Insert",self)
        insert.clicked.connect(self.insert)
 
        cancel = QtWidgets.QPushButton("Cancel",self)
        cancel.clicked.connect(self.close)
 
        layout = QtWidgets.QGridLayout()

        layout.addWidget(self.box,0,0,1,2)
        layout.addWidget(insert,1,0)
        layout.addWidget(cancel,1,1)
        
        self.setGeometry(300,300,400,80)
        self.setWindowTitle("Date and Time")
        self.setLayout(layout) 
Example 6
Project: attack_monitor   Author: yarox24   File: exception_dialog.py    License: GNU General Public License v3.0 6 votes vote down vote up
def get_gui_options(self):
        options = list()

        for name in self.CONTROLS.keys():
            gui_ctrl = self.CONTROLS[name]
            if gui_ctrl.control_enabled.isChecked():
                check_type = gui_ctrl.control_check_type.currentIndex()
                text = None

                if isinstance(gui_ctrl.control_value, QtWidgets.QLineEdit):
                    text = gui_ctrl.control_value.text()
                elif isinstance(gui_ctrl.control_value, QtWidgets.QComboBox):
                    text = gui_ctrl.control_value.currentText()

                options.append(gui_selection(name, check_type, text))

        return options 
Example 7
Project: imperialism-remake   Author: Trilarion   File: preferences.py    License: GNU General Public License v3.0 6 votes vote down vote up
def _layout_widget_preferences_general(self):
        """
        Create general options widget.
        """
        tab = QtWidgets.QWidget()
        tab_layout = QtWidgets.QVBoxLayout(tab)

        # language
        label = QtWidgets.QLabel('Choose')
        combobox = QtWidgets.QComboBox()
        tab_layout.addWidget(qt.wrap_in_groupbox(qt.wrap_in_boxlayout((label, combobox)), 'User Interface Language'))

        # vertical stretch
        tab_layout.addStretch()

        # add tab
        self.tab_general = tab
        self.stacked_layout.addWidget(tab) 
Example 8
Project: awesometts-anki-addon   Author: AwesomeTTS   File: listviews.py    License: GNU General Public License v3.0 6 votes vote down vote up
def createEditor(self, parent,    # pylint:disable=C0103
                     option, index):  # pylint:disable=W0613
        """Return a panel to change selected preset."""

        dropdown = QtWidgets.QComboBox()
        dropdown.addItem("(select preset)")
        dropdown.addItems(self._presets)

        hor = QtWidgets.QHBoxLayout()
        hor.addWidget(dropdown)

        panel = QtWidgets.QWidget(parent)
        panel.setObjectName('editor')
        panel.setAutoFillBackground(True)
        panel.setFocusPolicy(QtCore.Qt.StrongFocus)
        panel.setLayout(hor)
        return panel 
Example 9
Project: awesometts-anki-addon   Author: AwesomeTTS   File: base.py    License: GNU General Public License v3.0 6 votes vote down vote up
def _disable_inputs(self, flag=True):
        """
        Mass disable (or enable if flag is False) all inputs, except the
        cancel button.
        """

        for widget in (
                widget
                for widget in self.findChildren(self._INPUT_WIDGETS)
                if widget.objectName() != 'cancel'
                and (not isinstance(widget, QtWidgets.QComboBox) or
                     len(widget) > 1)
        ):
            widget.setDisabled(flag)

        if not flag:
            self.findChild(QtWidgets.QPushButton, 'presets_delete').setEnabled(
                self.findChild(QtWidgets.QComboBox,
                               'presets_dropdown').currentIndex() > 0
            )
            self.findChild(QtWidgets.QPushButton, 'presets_save').setEnabled(
                self.findChild(QtWidgets.QComboBox,
                               'service').currentIndex() < self._svc_count
            ) 
Example 10
Project: awesometts-anki-addon   Author: AwesomeTTS   File: base.py    License: GNU General Public License v3.0 6 votes vote down vote up
def _get_service_values(self):
        """
        Return the service ID and a dict of all the options.
        """

        dropdown = self.findChild(QtWidgets.QComboBox, 'service')
        idx = dropdown.currentIndex()
        svc_id = dropdown.itemData(idx)
        if svc_id.startswith('group:'):
            return svc_id, None

        vinputs = self.findChild(QtWidgets.QStackedWidget, 'panels') \
            .widget(idx).findChildren(self._OPTIONS_WIDGETS)
        options = self._addon.router.get_options(svc_id)

        assert len(options) == len(vinputs)

        return svc_id, {
            options[i]['key']:
                vinputs[i].value()
                if isinstance(vinputs[i], QtWidgets.QAbstractSpinBox)
                else vinputs[i].itemData(vinputs[i].currentIndex())
            for i in range(len(options))
        } 
Example 11
Project: awesometts-anki-addon   Author: AwesomeTTS   File: groups.py    License: GNU General Public License v3.0 6 votes vote down vote up
def _on_refresh(self, select=None):
        """Repopulate the group dropdown and initialize panel."""

        groups = self.findChild(QtWidgets.QComboBox, 'groups')
        groups.clear()
        groups.addItem("View/Edit Group...")

        if self._groups:
            groups.setEnabled(True)
            groups.insertSeparator(1)
            groups.addItems(sorted(self._groups.keys(),
                                   key=lambda name: name.upper()))
            if select:
                idx = groups.findText(select)
                groups.setCurrentIndex(idx)
                self._on_group_activated(idx)
            else:
                self._on_group_activated(0)

        else:
            groups.setEnabled(False)
            self._on_group_activated(0) 
Example 12
Project: awesometts-anki-addon   Author: AwesomeTTS   File: templater.py    License: GNU General Public License v3.0 6 votes vote down vote up
def show(self, *args, **kwargs):
        """
        Restore the three dropdown's last known state and then focus the
        field dropdown.
        """

        super(Templater, self).show(*args, **kwargs)

        for name in ['hide', 'target', 'field']:
            dropdown = self.findChild(QtWidgets.QComboBox, name)
            dropdown.setCurrentIndex(max(
                dropdown.findData(self._addon.config['templater_' + name]), 0
            ))

        if self._is_cloze:
            self.findChild(Checkbox, 'cloze') \
                .setChecked(self._addon.config['templater_cloze'])

        dropdown.setFocus()  # abuses fact that 'field' is last in the loop 
Example 13
Project: awesometts-anki-addon   Author: AwesomeTTS   File: templater.py    License: GNU General Public License v3.0 6 votes vote down vote up
def _get_all(self):
        """
        Adds support to remember the three dropdowns and cloze state (if any),
        in addition to the service options handled by the superclass.
        """

        combos = {
            name: widget.itemData(widget.currentIndex())
            for name in ['field', 'hide', 'target']
            for widget in [self.findChild(QtWidgets.QComboBox, name)]
        }

        return dict(
            list(super(Templater, self)._get_all().items()) +
            [('templater_' + name, value) for name, value in combos.items()] +
            (
                [(
                    'templater_cloze',
                    self.findChild(Checkbox, 'cloze').isChecked(),
                )]
                if self._is_cloze and combos['field']
                else []
            )
        ) 
Example 14
Project: awesometts-anki-addon   Author: AwesomeTTS   File: configurator.py    License: GNU General Public License v3.0 6 votes vote down vote up
def accept(self):
        """Saves state on inputs; rough opposite of show()."""

        for list_view in self.findChildren(QtWidgets.QListView):
            for editor in list_view.findChildren(QtWidgets.QWidget, 'editor'):
                list_view.commitData(editor)  # if an editor is open, save it

        self._addon.config.update({
            widget.objectName(): (
                widget.isChecked() if isinstance(widget, Checkbox)
                else widget.atts_value if isinstance(widget, QtWidgets.QPushButton)
                else widget.value() if isinstance(widget, QtWidgets.QSpinBox)
                else widget.itemData(widget.currentIndex()) if isinstance(
                    widget, QtWidgets.QComboBox)
                else [
                    i for i in widget.model().raw_data
                    if i['compiled'] and 'bad_replace' not in i
                ] if isinstance(widget, QtWidgets.QListView)
                else widget.text()
            )
            for widget in self.findChildren(self._PROPERTY_WIDGETS)
            if widget.objectName() in self._PROPERTY_KEYS
        })

        super(Configurator, self).accept() 
Example 15
Project: linux-show-player   Author: FrancescoCeruti   File: preset_src.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.setLayout(QVBoxLayout())
        self.layout().setAlignment(Qt.AlignTop)

        self.functionGroup = QGroupBox(self)
        self.functionGroup.setTitle(translate('PresetSrcSettings', 'Presets'))
        self.functionGroup.setLayout(QVBoxLayout())
        self.layout().addWidget(self.functionGroup)

        self.functionCombo = QComboBox(self.functionGroup)
        self.functionGroup.layout().addWidget(self.functionCombo)

        for function in sorted(PresetSrc.PRESETS.keys()):
            self.functionCombo.addItem(function)

        self.functionDuration = QTimeEdit(self.functionGroup)
        self.functionDuration.setDisplayFormat('HH.mm.ss.zzz')
        self.functionGroup.layout().addWidget(self.functionDuration) 
Example 16
Project: linux-show-player   Author: FrancescoCeruti   File: stop_all.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.setLayout(QVBoxLayout())
        self.layout().setAlignment(Qt.AlignTop)

        self.group = QGroupBox(self)
        self.group.setLayout(QVBoxLayout(self.group))
        self.layout().addWidget(self.group)

        self.actionCombo = QComboBox(self.group)
        for action in [CueAction.Stop, CueAction.FadeOutStop, CueAction.Pause,
                       CueAction.FadeOutPause, CueAction.Interrupt,
                       CueAction.FadeOutInterrupt]:
            self.actionCombo.addItem(
                translate('CueAction', action.name), action.value)
        self.group.layout().addWidget(self.actionCombo)

        self.retranslateUi() 
Example 17
Project: pychemqt   Author: jjgomera   File: UI_spreadsheet.py    License: GNU General Public License v3.0 6 votes vote down vote up
def cellChanged(self, i, j):
        obj = self.project.getObject(str(self.datamap.item(i, 0).text()))
        properties = [prop[0] for prop in obj.propertiesNames()]
        if j == 0:  # Entity cambiado, cambiar variables disponibles
            self.datamap.itemDelegateForRow(i).setItemsByIndex(1, properties)
            editor = QtWidgets.QComboBox()
            editor.addItems(self.datamap.itemDelegateForRow(i).items[1])
            self.datamap.setColumnWidth(1, editor.sizeHint().width())
        elif j == 1:   # Variable cambiada, cambiar unidades disponibles
            value = self.datamap.item(i, 1).text()
            ind = properties.index(value)
            if obj.propertiesUnit()[ind] == str:
                self.datamap.itemDelegateForRow(i).setItemsByIndex(2, [" "])
                self.datamap.item(i, 2).setText(" ")
            else:
                self.datamap.itemDelegateForRow(i).setItemsByIndex(
                    2, obj.propertiesNames()[ind][2].__text__)
        elif j == 3:
            self.datamap.item(i, 4).setText("") 
Example 18
Project: pychemqt   Author: jjgomera   File: widget.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent=None):
        super(FoulingWidget, self).__init__(parent)
        layout = QtWidgets.QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        self.list = QtWidgets.QComboBox()
        self.list.addItem("")
        layout.addWidget(self.list)
        self.value = Entrada_con_unidades(Fouling, decimales=6)
        self.value.valueChanged.connect(self.valueChanged.emit)
        layout.addWidget(self.value)

        for tipo in sorted(self.Fouling_Factor):
            self.list.insertSeparator(self.list.count()+1)
            for componente in sorted(self.Fouling_Factor[tipo]):
                self.list.addItem(" - ".join([tipo, componente]))
        self.list.currentIndexChanged["QString"].connect(self.rellenar) 
Example 19
Project: simnibs   Author: simnibs   File: main_gui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def set_position_layout(self):
        self.position_box = QtWidgets.QGroupBox("Position")
        load_pos = self.centre is not None and len(self.centre) == 3

        Layout = QtWidgets.QGridLayout()
        self.eeg_pos_selector = QtWidgets.QComboBox()
        self.eeg_pos_selector.activated.connect(self.select_eeg_pos)
        Layout.addWidget(self.eeg_pos_selector, 1,0)
        self.eeg_pos_selector.setEnabled(False)

        self.label_x = QtWidgets.QLabel("X:")
        Layout.addWidget(self.label_x,0,1)
        self.pos_x = QtWidgets.QDoubleSpinBox()
        self.pos_x.setRange(-1000,1000)
        if load_pos: self.pos_x.setValue(self.centre[0])
        #self.pos_x.valueChanged.connect(self.update_center)
        Layout.addWidget(self.pos_x,1,1)

        self.label_y = QtWidgets.QLabel("Y:")
        Layout.addWidget(self.label_y,0,2)
        self.pos_y = QtWidgets.QDoubleSpinBox()
        self.pos_y.setRange(-1000,1000)
        if load_pos: self.pos_y.setValue(self.centre[1])
       # self.pos_y.valueChanged.connect(self.update_center)
        Layout.addWidget(self.pos_y,1,2)

        self.label_z = QtWidgets.QLabel("Z:")
        Layout.addWidget(self.label_z,0,3)
        self.pos_z = QtWidgets.QDoubleSpinBox()
        self.pos_z.setRange(-1000,1000)
        if load_pos: self.pos_z.setValue(self.centre[2])
        #self.pos_z.valueChanged.connect(self.update_center)
        Layout.addWidget(self.pos_z,1,3)

        self.position_box.setLayout(Layout) 
Example 20
Project: idasec   Author: RobinDavid   File: AnalysisWidget.py    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
def add_policy_item_action(self):
        self.policy_table.setRowCount(self.policy_table.rowCount()+1)
        i = self.policy_table.rowCount()-1
        btn1 = ButtonLineEdit(['*', "'addr'", "[addr1..addr2]", "default"])
        btn2 = ButtonLineEdit(["*", " _ := _", "goto _"])
        btn3 = ButtonLineEdit(["*", "expr", "expr1 <: expr2"])
        btn4 = ButtonLineEdit(["*", "istainted(_)", "term1 && term2", "term1 || term2"])
        btn5 = QtWidgets.QComboBox()
        btn5.addItems(["C", "P", "Pc", "Ps", "S"])
        for col_id, widget in enumerate([btn1, btn2, btn3, btn4, btn5]):
            self.policy_table.setCellWidget(i, col_id, widget)
        return i 
Example 21
Project: pyweed   Author: iris-edu   File: OptionsWidget.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def setInputValue(self, key, value):
        """
        Set the input value based on a string from the options
        """
        one_input = self.inputs.get(key)
        if one_input:
            if isinstance(one_input, QtWidgets.QDateTimeEdit):
                # Ugh, complicated conversion from UTCDateTime
                dt = QtCore.QDateTime.fromString(value, QtCore.Qt.ISODate)
                one_input.setDateTime(dt)
            elif isinstance(one_input, QtWidgets.QDoubleSpinBox):
                # Float value
                one_input.setValue(float(value))
            elif isinstance(one_input, QtWidgets.QComboBox):
                # Combo box
                index = one_input.findText(value)
                if index > -1:
                    one_input.setCurrentIndex(index)
            elif isinstance(one_input, QtWidgets.QLineEdit):
                # Text input
                one_input.setText(value)
            elif isinstance(one_input, QtWidgets.QAbstractButton):
                # Radio/checkbox button
                one_input.setChecked(strtobool(str(value)))
            else:
                raise Exception("Don't know how to set an input for %s (%s)" % (key, one_input)) 
Example 22
Project: Lector   Author: BasioMeusPuga   File: contentwidgets.py    License: GNU General Public License v3.0 5 votes vote down vote up
def generate_combo_box_action(self, contextMenu):
        contextMenu.addSeparator()

        def set_toc_position(tocTree):
            currentIndex = tocTree.currentIndex()
            required_position = currentIndex.data(QtCore.Qt.UserRole)
            self.pw.parent.set_content(required_position, True, True)

        # Create the Combobox / Treeview combination
        tocComboBox = QtWidgets.QComboBox()
        tocTree = QtWidgets.QTreeView()
        tocComboBox.setView(tocTree)
        tocComboBox.setModel(self.pw.parent.tocModel)
        tocTree.setRootIsDecorated(False)
        tocTree.setItemsExpandable(False)
        tocTree.expandAll()

        # Set the position of the QComboBox
        self.pw.parent.set_tocBox_index(None, tocComboBox)

        # Make clicking do something
        tocComboBox.currentIndexChanged.connect(
            lambda: set_toc_position(tocTree))

        comboboxAction = QtWidgets.QWidgetAction(self.pw)
        comboboxAction.setDefaultWidget(tocComboBox)
        contextMenu.addAction(comboboxAction) 
Example 23
Project: pyleecan   Author: Eomys   File: Ui_WVent.py    License: Apache License 2.0 5 votes vote down vote up
def setupUi(self, WVent):
        WVent.setObjectName("WVent")
        WVent.resize(630, 470)
        WVent.setMinimumSize(QtCore.QSize(630, 470))
        self.main_layout = QtWidgets.QVBoxLayout(WVent)
        self.main_layout.setObjectName("main_layout")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.in_vent_type = QtWidgets.QLabel(WVent)
        self.in_vent_type.setObjectName("in_vent_type")
        self.horizontalLayout.addWidget(self.in_vent_type)
        self.c_vent_type = QtWidgets.QComboBox(WVent)
        self.c_vent_type.setObjectName("c_vent_type")
        self.c_vent_type.addItem("")
        self.c_vent_type.addItem("")
        self.c_vent_type.addItem("")
        self.horizontalLayout.addWidget(self.c_vent_type)
        spacerItem = QtWidgets.QSpacerItem(
            40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum
        )
        self.horizontalLayout.addItem(spacerItem)
        self.main_layout.addLayout(self.horizontalLayout)
        self.w_vent = QtWidgets.QWidget(WVent)
        self.w_vent.setMinimumSize(QtCore.QSize(640, 480))
        self.w_vent.setObjectName("w_vent")
        self.main_layout.addWidget(self.w_vent)

        self.retranslateUi(WVent)
        QtCore.QMetaObject.connectSlotsByName(WVent) 
Example 24
Project: pyleecan   Author: Eomys   File: Ui_WHoleMag.py    License: Apache License 2.0 5 votes vote down vote up
def setupUi(self, WHoleMag):
        WHoleMag.setObjectName("WHoleMag")
        WHoleMag.resize(760, 490)
        WHoleMag.setMinimumSize(QtCore.QSize(760, 490))
        self.main_layout = QtWidgets.QVBoxLayout(WHoleMag)
        self.main_layout.setContentsMargins(5, 5, 5, 5)
        self.main_layout.setSpacing(4)
        self.main_layout.setObjectName("main_layout")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.c_hole_type = QtWidgets.QComboBox(WHoleMag)
        self.c_hole_type.setObjectName("c_hole_type")
        self.c_hole_type.addItem("")
        self.c_hole_type.addItem("")
        self.c_hole_type.addItem("")
        self.c_hole_type.addItem("")
        self.c_hole_type.addItem("")
        self.c_hole_type.addItem("")
        self.c_hole_type.addItem("")
        self.horizontalLayout.addWidget(self.c_hole_type)
        spacerItem = QtWidgets.QSpacerItem(
            40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum
        )
        self.horizontalLayout.addItem(spacerItem)
        self.main_layout.addLayout(self.horizontalLayout)
        self.w_hole = QtWidgets.QWidget(WHoleMag)
        sizePolicy = QtWidgets.QSizePolicy(
            QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding
        )
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.w_hole.sizePolicy().hasHeightForWidth())
        self.w_hole.setSizePolicy(sizePolicy)
        self.w_hole.setMinimumSize(QtCore.QSize(750, 450))
        self.w_hole.setObjectName("w_hole")
        self.main_layout.addWidget(self.w_hole)

        self.retranslateUi(WHoleMag)
        QtCore.QMetaObject.connectSlotsByName(WHoleMag) 
Example 25
Project: ddt4all   Author: cedricp   File: sniffer.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent=None):
        super(sniffer, self).__init__(parent)
        self.ecu_file = None
        self.ecurequests = None
        self.snifferthread = None
        self.currentrequest = None
        self.names = []
        self.oktostart = False
        self.ecu_filter = ""

        hlayout = widgets.QHBoxLayout()

        self.framecombo = widgets.QComboBox()

        self.startbutton = widgets.QPushButton(">>")
        self.addressinfo = widgets.QLabel("0000")

        self.startbutton.setCheckable(True)
        self.startbutton.toggled.connect(self.startmonitoring)

        self.addressinfo.setFixedWidth(90)
        self.startbutton.setFixedWidth(90)

        hlayout.addWidget(self.addressinfo)
        hlayout.addWidget(self.framecombo)
        hlayout.addWidget(self.startbutton)

        vlayout = widgets.QVBoxLayout()
        self.setLayout(vlayout)

        vlayout.addLayout(hlayout)

        self.table = widgets.QTableWidget()
        vlayout.addWidget(self.table)

        self.framecombo.activated.connect(self.change_frame) 
Example 26
Project: BaiduNetDiskAutoTransfer   Author: VinylChloride   File: mainPrgGui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __createComboBox(self):
		self.__langLabel = QLabel()
		self.__langLabel.setText(self.__lang.get("langLabel"))
		self.__langSelectBox = QComboBox()
		for langItem in self.__langList:
			self.__langSelectBox.addItem(langItem)
		self.__langSelectBox.setCurrentIndex(self.__langSelectBox.findText(self.__curLang))

		self.__widgetList.append(self.__langLabel)
		self.__widgetList.append(self.__langSelectBox) 
Example 27
Project: BAG_framework   Author: ucb-art   File: gui.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self):
        QtWidgets.QWidget.__init__(self)

        # combo box label
        self.label = QtWidgets.QLabel('Log File: ', parent=self)
        # populate log selection combo box.
        self.combo_box = QtWidgets.QComboBox(parent=self)
        self.log_files = []
        self.reader = None

        self.logger = LogWidget(parent=self)

        # setup GUI
        self.setWindowTitle('BAG Simulation Log Viewer')
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        self.layout = QtWidgets.QGridLayout(self)
        self.layout.addWidget(self.label, 0, 0, alignment=QtCore.Qt.AlignRight)
        self.layout.addWidget(self.combo_box, 0, 1, alignment=QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.logger, 1, 0, -1, -1)
        self.layout.setRowStretch(0, 0.0)
        self.layout.setRowStretch(1, 1.0)
        self.layout.setColumnStretch(0, 0.0)
        self.layout.setColumnStretch(1, 0.0)

        # setup file watcher
        self.cur_paths = None
        self.watcher = QtCore.QFileSystemWatcher(parent=self)
        # setup signals
        self.watcher.fileChanged.connect(self.update_logfile)
        self.combo_box.currentIndexChanged.connect(self.change_log)

        # start thread
        self.thread = StdinThread(self)
        self.thread.update.connect(self.parse_cmd)
        self.thread.start() 
Example 28
Project: imperialism-remake   Author: Trilarion   File: editor.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, initial_province=None):
        super().__init__()

        widget_layout = QtWidgets.QVBoxLayout(self)

        # toolbar
        toolbar = QtWidgets.QToolBar()
        a = qt.create_action(tools.load_ui_icon('icon.add.png'), 'Add province', toolbar, self.add_province)
        toolbar.addAction(a)
        a = qt.create_action(tools.load_ui_icon('icon.delete.png'), 'Remove province', toolbar, self.remove_province)
        toolbar.addAction(a)
        widget_layout.addLayout(qt.wrap_in_boxlayout(toolbar))

        # provinces selection combo box
        label = QtWidgets.QLabel('Choose')
        self.provinces_combobox = QtWidgets.QComboBox()
        self.provinces_combobox.setFixedWidth(200)
        self.provinces_combobox.currentIndexChanged.connect(self.province_combobox_index_changed)
        widget_layout.addWidget(qt.wrap_in_groupbox(qt.wrap_in_boxlayout((label, self.provinces_combobox)),
                                                    'provinces'))

        # province info panel
        layout = QtWidgets.QVBoxLayout()

        # nation
        self.nation_label = QtWidgets.QLabel('Nation')
        layout.addWidget(self.nation_label)

        widget_layout.addWidget(qt.wrap_in_groupbox(layout, 'Info'))

        # vertical stretch
        widget_layout.addStretch()

        # reset content
        self.reset_content()

        # if province is given, select it
        if initial_province:
            index = utils.index_of_element(self.provinces, initial_province)
            self.provinces_combobox.setCurrentIndex(index) 
Example 29
Project: grap   Author: AirbusCyber   File: QtShim.py    License: MIT License 5 votes vote down vote up
def get_QComboBox():
    """QComboBox getter."""

    try:
        import PySide.QtGui as QtGui
        return QtGui.QComboBox
    except ImportError:
        import PyQt5.QtWidgets as QtWidgets
        return QtWidgets.QComboBox 
Example 30
Project: heap-viewer   Author: danigargu   File: structs.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _create_gui(self):
        self.cb_struct = QtWidgets.QComboBox()
        self.cb_struct.setFixedWidth(150)
        self.cb_struct.addItem('malloc_state')
        self.cb_struct.addItem('malloc_par')
        self.cb_struct.addItem('tcache_perthread')
        self.cb_struct.currentIndexChanged[int].connect(self.cb_struct_changed)

        self.widgets = {
            'malloc_state': StructView(self),
            'malloc_par': StructView(self),
            'tcache_perthread': StructView(self)
        }

        self.stacked = QtWidgets.QStackedWidget()
        self.stacked.addWidget(self.widgets['malloc_state'])
        self.stacked.addWidget(self.widgets['malloc_par'])
        self.stacked.addWidget(self.widgets['tcache_perthread'])

        self.btn_load = QtWidgets.QPushButton("Load")
        self.btn_load.clicked.connect(self.btn_load_on_click)

        hbox_struct = QtWidgets.QHBoxLayout()
        hbox_struct.addWidget(QtWidgets.QLabel("Struct"))
        hbox_struct.addWidget(self.cb_struct)
        hbox_struct.addWidget(self.btn_load)
        hbox_struct.addStretch(1)
        
        layout = QtWidgets.QVBoxLayout()
        layout.addLayout(hbox_struct)
        layout.addWidget(self.stacked)
        self.setLayout(layout)