Python PyQt5.QtWidgets.QComboBox() Examples

The following are 30 code examples of PyQt5.QtWidgets.QComboBox(). 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 also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .
Example #1
Source File: AnalysisWidget.py    From idasec with GNU Lesser General Public License v2.1 7 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
Source File: preferences.py    From imperialism-remake with 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 #3
Source File: OptionsWidget.py    From pyweed with 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 #4
Source File: UI_spreadsheet.py    From pychemqt with 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 #5
Source File: stop_all.py    From linux-show-player with 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 #6
Source File: preset_src.py    From linux-show-player with 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 #7
Source File: widget.py    From pychemqt with 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 #8
Source File: configurator.py    From awesometts-anki-addon with 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 #9
Source File: templater.py    From awesometts-anki-addon with 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 #10
Source File: templater.py    From awesometts-anki-addon with 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 #11
Source File: groups.py    From awesometts-anki-addon with 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
Source File: ComboBoxDelegateQt.py    From KStock with 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 #13
Source File: datetime.py    From Writer-Tutorial with 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 #14
Source File: exception_dialog.py    From attack_monitor with 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 #15
Source File: base.py    From awesometts-anki-addon with 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 #16
Source File: base.py    From awesometts-anki-addon with 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 #17
Source File: listviews.py    From awesometts-anki-addon with 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 #18
Source File: FunctionViewEx.py    From DIE with MIT License 5 votes vote down vote up
def createEditor(self, parent, option, index):

        parsed_val_list = index.data(role=DIE.UI.ParsedValuesRole)

        # Show combobox only if parsed_value as two or more items.
        if parsed_val_list is not None and len(parsed_val_list) > 1:
            lines = []
            for parsed_val in parsed_val_list:
                line_txt = "%d, %s, %s" % (parsed_val.score, parsed_val.data, parsed_val.description)
                lines.append(line_txt)

            combo_box = QtWidgets.QComboBox(parent)
            combo_box.addItems(lines)

            return combo_box 
Example #19
Source File: presets_ui.py    From linux-show-player with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.resize(320, 105)
        self.setMaximumSize(self.size())
        self.setMinimumSize(self.size())
        self.setModal(True)
        self.setLayout(QGridLayout())

        self.nameLabel = QLabel(self)
        self.layout().addWidget(self.nameLabel, 0, 0)

        self.nameLineEdit = QLineEdit(self)
        self.layout().addWidget(self.nameLineEdit, 0, 1)

        self.typeLabel = QLabel(self)
        self.layout().addWidget(self.typeLabel, 1, 0)

        self.typeComboBox = QComboBox(self)
        for cue_class in CueSettingsRegistry().ref_classes():
            self.typeComboBox.addItem(translate('CueName', cue_class.Name),
                                      cue_class.__name__)
        self.layout().addWidget(self.typeComboBox, 1, 1)

        self.dialogButtons = QDialogButtonBox(self)
        self.dialogButtons.setStandardButtons(QDialogButtonBox.Ok |
                                              QDialogButtonBox.Cancel)
        self.dialogButtons.accepted.connect(self.accept)
        self.dialogButtons.rejected.connect(self.reject)
        self.layout().addWidget(self.dialogButtons, 2, 0, 1, 2)

        self.layout().setColumnStretch(0, 1)
        self.layout().setColumnStretch(1, 3)

        self.retranslateUi() 
Example #20
Source File: midi_settings.py    From linux-show-player with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.setLayout(QVBoxLayout())
        self.layout().setAlignment(Qt.AlignTop)

        self.midiGroup = QGroupBox(self)
        self.midiGroup.setTitle(
            translate('MIDISettings', 'MIDI default devices'))
        self.midiGroup.setLayout(QGridLayout())
        self.layout().addWidget(self.midiGroup)

        self.inputLabel = QLabel(translate('MIDISettings', 'Input'),
                                 self.midiGroup)
        self.midiGroup.layout().addWidget(self.inputLabel, 0, 0)
        self.inputCombo = QComboBox(self.midiGroup)
        self.midiGroup.layout().addWidget(self.inputCombo, 0, 1)

        self.outputLabel = QLabel(translate('MIDISettings', 'Output'),
                                  self.midiGroup)
        self.midiGroup.layout().addWidget(self.outputLabel, 1, 0)
        self.outputCombo = QComboBox(self.midiGroup)
        self.midiGroup.layout().addWidget(self.outputCombo, 1, 1)

        self.midiGroup.layout().setColumnStretch(0, 2)
        self.midiGroup.layout().setColumnStretch(1, 3)

        if check_module('Midi'):
            try:
                self._load_devices()
            except Exception:
                self.setEnabled(False)
        else:
            self.setEnabled(False) 
Example #21
Source File: configurator.py    From awesometts-anki-addon with GNU General Public License v3.0 5 votes vote down vote up
def _ui_tabs_mp3gen_filenames(self):
        """Returns the "Filenames of MP3s" group."""

        dropdown = QtWidgets.QComboBox()
        dropdown.setObjectName('filenames')
        dropdown.addItem("hashed (safe and portable)", 'hash')
        dropdown.addItem("human-readable (may not work everywhere)", 'human')

        dropdown_line = QtWidgets.QHBoxLayout()
        dropdown_line.addWidget(Label("Filenames should be "))
        dropdown_line.addWidget(dropdown)
        dropdown_line.addStretch()

        human = QtWidgets.QLineEdit()
        human.setObjectName('filenames_human')
        human.setPlaceholderText("e.g. {{service}} {{voice}} - {{text}}")
        human.setEnabled(False)

        human_line = QtWidgets.QHBoxLayout()
        human_line.addWidget(Label("Format human-readable filenames as "))
        human_line.addWidget(human)
        human_line.addWidget(Label(".mp3"))

        dropdown.currentIndexChanged. \
            connect(lambda index: human.setEnabled(index > 0))

        vertical = QtWidgets.QVBoxLayout()
        vertical.addLayout(dropdown_line)
        vertical.addLayout(human_line)
        vertical.addWidget(Note("Changes are not retroactive to old files."))

        group = QtWidgets.QGroupBox("Filenames of MP3s Stored in Your Collection")
        group.setLayout(vertical)

        return group 
Example #22
Source File: generator.py    From awesometts-anki-addon with GNU General Public License v3.0 5 votes vote down vote up
def _get_field_values(self):
        """
        Returns the user's source and destination fields, append state,
        and handling mode.
        """

        return (
            self.findChild(QtWidgets.QComboBox, 'source').currentText(),
            self.findChild(QtWidgets.QComboBox, 'dest').currentText(),
            self.findChild(QtWidgets.QRadioButton, 'append').isChecked(),
            self.findChild(Checkbox, 'behavior').isChecked(),
        ) 
Example #23
Source File: base.py    From awesometts-anki-addon with GNU General Public License v3.0 5 votes vote down vote up
def _on_preset_reset(self):
        """Sets preset dropdown back and disables delete button."""

        if next((True
                 for frame in inspect.stack()
                 if frame[3] == '_on_preset_activated'),
                False):
            return  # ignore value change events triggered by preset loads

        self.findChild(QtWidgets.QPushButton, 'presets_delete').setDisabled(True)
        self.findChild(QtWidgets.QComboBox, 'presets_dropdown').setCurrentIndex(0) 
Example #24
Source File: base.py    From awesometts-anki-addon with GNU General Public License v3.0 5 votes vote down vote up
def _ui_services_presets(self):
        """Returns the preset controls as a horizontal layout."""

        label = Label("Quickly access this service later?")
        label.setObjectName('presets_label')

        dropdown = QtWidgets.QComboBox()
        dropdown.setObjectName('presets_dropdown')
        dropdown.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                               QtWidgets.QSizePolicy.Preferred)
        dropdown.activated.connect(self._on_preset_activated)

        delete = QtWidgets.QPushButton(QtGui.QIcon(f'{ICONS}/editdelete.png'), "")
        delete.setObjectName('presets_delete')
        delete.setIconSize(QtCore.QSize(16, 16))
        delete.setFixedSize(18, 18)
        delete.setFlat(True)
        delete.setToolTip("Remove this service configuration from\n"
                          "the list of remembered services.")
        delete.clicked.connect(self._on_preset_delete)

        save = QtWidgets.QPushButton("Save")
        save.setObjectName('presets_save')
        save.setFixedWidth(save.fontMetrics().width(save.text()) + 20)
        save.setToolTip("Remember the selected service and its input\n"
                        "settings so that you can quickly access it later.")
        save.clicked.connect(self._on_preset_save)

        layout = QtWidgets.QHBoxLayout()
        layout.addWidget(label)
        layout.addWidget(dropdown)
        layout.addWidget(delete)
        layout.addSpacing(self._SPACING)
        layout.addWidget(save)

        return layout 
Example #25
Source File: listviews.py    From awesometts-anki-addon with GNU General Public License v3.0 5 votes vote down vote up
def setModelData(self, editor, model, index):  # pylint:disable=C0103
        """Update the underlying model after edit."""

        dropdown = editor.findChild(QtWidgets.QComboBox)
        model.setData(
            index,
            dropdown.currentText() if dropdown.currentIndex() > 0 else ""
        ) 
Example #26
Source File: listviews.py    From awesometts-anki-addon with GNU General Public License v3.0 5 votes vote down vote up
def setEditorData(self, editor, index):  # pylint:disable=C0103
        """Changes the preset in the dropdown."""

        dropdown = editor.findChild(QtWidgets.QComboBox)
        value = index.data(QtCore.Qt.EditRole)
        dropdown.setCurrentIndex(dropdown.findText(value) if value else 0)

        QtCore.QTimer.singleShot(0, dropdown.setFocus) 
Example #27
Source File: magic.py    From heap-viewer with GNU General Public License v3.0 5 votes vote down vote up
def _create_gui(self):
        self.cb_magic = QtWidgets.QComboBox()
        self.cb_magic.setFixedWidth(200)
        self.cb_magic.addItem('Unlink merge info', 0)
        self.cb_magic.addItem('Find fake fast', 0)
        self.cb_magic.addItem('House of force helper', 0)
        self.cb_magic.addItem('Useful libc offsets')
        self.cb_magic.addItem('Calc chunk size')
        self.cb_magic.addItem('IO_FILE structs')
        self.cb_magic.addItem('Freeable chunk')
        self.cb_magic.currentIndexChanged[int].connect(self.cb_magic_changed)

        self.stacked_magic = QtWidgets.QStackedWidget()

        self.unlink_widget = UnlinkWidget(self)
        self.fakefast_widget = FakefastWidget(self)
        self.house_of_force_widget = HouseOfForceWidget(self)
        self.libc_offsets_widget = LibcOffsetsWidget(self)
        self.req2size_widget = Req2sizeWidget(self)
        self.io_file_widget = IOFileWidget(self)
        self.freeable_widget = FreeableWidget(self)

        self.stacked_magic.addWidget(self.unlink_widget)
        self.stacked_magic.addWidget(self.fakefast_widget)
        self.stacked_magic.addWidget(self.house_of_force_widget)
        self.stacked_magic.addWidget(self.libc_offsets_widget)
        self.stacked_magic.addWidget(self.req2size_widget)
        self.stacked_magic.addWidget(self.io_file_widget)
        self.stacked_magic.addWidget(self.freeable_widget)

        hbox_magic = QtWidgets.QHBoxLayout()
        hbox_magic.addWidget(QtWidgets.QLabel('Select util'))
        hbox_magic.addWidget(self.cb_magic)
        hbox_magic.addStretch(1)

        self.vbox_magic = QtWidgets.QVBoxLayout()
        self.vbox_magic.addLayout(hbox_magic)
        self.vbox_magic.addWidget(self.stacked_magic)
        self.setLayout(self.vbox_magic) 
Example #28
Source File: structs.py    From heap-viewer with 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) 
Example #29
Source File: QtShim.py    From grap with 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
Source File: UI_mixer.py    From pychemqt with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, equipment=None, entradas=1, parent=None):
        """
        equipment: Initial equipment instance to model
        entradas: Stream Input number to equipment
        """
        super().__init__(Mixer, salida=False, parent=parent)

        # Input tab
        for i in range(entradas):
            entrada = UI_corriente.Ui_corriente()
            entrada.Changed.connect(partial(self.cambiarEntrada, i))
            self.Entrada.addTab(entrada, str(i+1))

        # Calculate tab
        lyt_Calc = QtWidgets.QGridLayout(self.tabCalculo)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Output Pressure Method")), 1, 1)
        self.criterio = QtWidgets.QComboBox()
        for txt in self.Equipment.TEXT_METODO:
            self.criterio.addItem(txt)
        self.criterio.currentIndexChanged.connect(self.criterio_Changed)
        lyt_Calc.addWidget(self.criterio, 1, 2)

        lyt_Calc.addItem(QtWidgets.QSpacerItem(
            20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed),
            2, 1, 1, 3)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Output Pressure")), 3, 1)
        self.Pout = Entrada_con_unidades(Pressure)
        self.Pout.valueChanged.connect(partial(self.changeParams, "Pout"))
        lyt_Calc.addWidget(self.Pout, 3, 2)
        lyt_Calc.addItem(QtWidgets.QSpacerItem(
            20, 20, QtWidgets.QSizePolicy.Expanding,
            QtWidgets.QSizePolicy.Expanding), 4, 1, 1, 3)

        self.criterio_Changed(0)

        if equipment:
            self.setEquipment(equipment)
        else:
            self.Equipment = Mixer(entradas=entradas)