def init_ui(self):
     self.tuple_method = ("Connect to Server", "Connect to /dev")
     self.combobox = QComboBox()
     self.combobox.addItems(self.tuple_method)
     self.addr_edit = QLineEdit()
     self.port_edit = QLineEdit()
     self.btn_open_conn = QPushButton("Connect/Open")
     self.btn_close_conn = QPushButton("Close Conn")
     self.fd = None
     self.method_layout = QVBoxLayout()
     self.method_layout.addWidget(self.combobox)
     self.method_layout.addWidget(self.addr_edit)
     self.method_layout.addWidget(self.port_edit)
     self.method_layout.addWidget(self.btn_open_conn)
     self.method_layout.addWidget(self.btn_close_conn)
     self.btn_status = QPushButton("Send Status Packet")
     self.btn_head = QPushButton("Send Head Packet")
     self.btn_motion = QPushButton("Send Motion Packet")
     self.packet_layout = QVBoxLayout()
     self.packet_layout.addWidget(self.btn_status)
     self.packet_layout.addWidget(self.btn_head)
     self.packet_layout.addWidget(self.btn_motion)
     self.main_layout = QVBoxLayout()
     self.main_layout.addLayout(self.method_layout)
     self.main_layout.addLayout(self.packet_layout)
     self.setLayout(self.main_layout)
     self.set_send_btn_statu(False)
示例#2
0
文件: pryme2.py 项目: qt4cpp/pryme2
    def __init__(self, parent=None):

        super(Pryme2, self).__init__(parent)

        self.timer_instances = (SimpleTimer(), AlarmClock(), PomoTimer())
        self.timer_selection = QComboBox(self)
        for t in self.timer_instances:
            self.timer_selection.addItem(t.name)
        self.timer = self.timer_instances[0]
        self.commitment_textbox = QLineEdit(self)
        self.commitment_textbox.setPlaceholderText(
            'What do you want to commit?')
        self.commitment_textbox.setClearButtonEnabled(True)
        self.commit_done_btn = QPushButton('&Done', self)
        self.start_btn = QPushButton('&Start', self)
        self.abort_btn = QPushButton('&Abort', self)
        self.abort_btn.hide()
        self.pause_btn = QPushButton('&Pause', self)
        self.pause_btn.hide()
        self.resume_btn = QPushButton('&Resume', self)
        self.resume_btn.hide()

        self.tray = QSystemTrayIcon(self)
        self.tray.setIcon(QIcon('pryme-logo.svg'))
        self.tray.show()

        self.set_ui()
        self.set_connection()
        self.show()
示例#3
0
    def initUI(self):
        title = QLabel('标题')
        author = QLabel('提交人')
        review = QLabel('申告内容')

        titleEdit = QLineEdit()
        authorEdit = QLineEdit()
        reviewEdit = QTextEdit()

        grid = QGridLayout()
        grid.setSpacing(10)

        grid.addWidget(title, 1, 0)
        grid.addWidget(titleEdit, 1, 1)

        grid.addWidget(author, 2, 0)
        grid.addWidget(authorEdit, 2, 1)

        grid.addWidget(review, 3, 0)
        grid.addWidget(reviewEdit, 3, 1, 5, 1)

        self.setLayout(grid)

        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle('故障申告')
    def __init__(self, parent=None):
        super(AddDialogWidget, self).__init__(parent)

        nameLabel = QLabel("Name")
        addressLabel = QLabel("Address")
        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                     | QDialogButtonBox.Cancel)

        self.nameText = QLineEdit()
        self.addressText = QTextEdit()

        grid = QGridLayout()
        grid.setColumnStretch(1, 2)
        grid.addWidget(nameLabel, 0, 0)
        grid.addWidget(self.nameText, 0, 1)
        grid.addWidget(addressLabel, 1, 0, Qt.AlignLeft | Qt.AlignTop)
        grid.addWidget(self.addressText, 1, 1, Qt.AlignLeft)

        layout = QVBoxLayout()
        layout.addLayout(grid)
        layout.addWidget(buttonBox)

        self.setLayout(layout)

        self.setWindowTitle("Add a Contact")

        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
示例#5
0
    def initUI(self):
        title = QLabel("Title")
        author = QLabel("Author")
        review = QLabel("Review")

        titleEdit = QLineEdit()
        authorEdit = QLineEdit()
        reviewEdit = QLineEdit()

        grid = QGridLayout()
        grid.setSpacing(10)

        grid.addWidget(title, 1, 0)
        grid.addWidget(titleEdit, 1, 1)

        grid.addWidget(author, 2, 0)
        grid.addWidget(authorEdit, 2, 1)

        grid.addWidget(review, 3, 0)
        grid.addWidget(reviewEdit, 3, 1)

        self.setLayout(grid)

        self.setGeometry(300, 300, 400, 500)
        self.setWindowTitle("Review")
示例#6
0
    def __init__(self):
        super(FindToolBar, self).__init__()
        self._line_edit = QLineEdit()
        self._line_edit.setClearButtonEnabled(True)
        self._line_edit.setPlaceholderText("Find...")
        self._line_edit.setMaximumWidth(300)
        self._line_edit.returnPressed.connect(self._find_next)
        self.addWidget(self._line_edit)

        self._previous_button = QToolButton()
        style_icons = ':/qt-project.org/styles/commonstyle/images/'
        self._previous_button.setIcon(QIcon(style_icons + 'up-32.png'))
        self._previous_button.clicked.connect(self._find_previous)
        self.addWidget(self._previous_button)

        self._next_button = QToolButton()
        self._next_button.setIcon(QIcon(style_icons + 'down-32.png'))
        self._next_button.clicked.connect(self._find_next)
        self.addWidget(self._next_button)

        self._case_sensitive_checkbox = QCheckBox('Case Sensitive')
        self.addWidget(self._case_sensitive_checkbox)

        self._hideButton = QToolButton()
        self._hideButton.setShortcut(QKeySequence(Qt.Key_Escape))
        self._hideButton.setIcon(QIcon(style_icons + 'closedock-16.png'))
        self._hideButton.clicked.connect(self.hide)
        self.addWidget(self._hideButton)
    def _init_options_group_box(self) -> None:
        """Creates the group of training options."""
        self._options_group_box = QGroupBox("Options")

        options_layout = QGridLayout()
        left_options = QGridLayout()
        right_options = QGridLayout()

        self._lists['data'] = QListWidget()
        self._lists['data'].setSelectionMode(
            QtWidgets.QAbstractItemView.SingleSelection)
        self._lists['data'].currentTextChanged.connect(self._refresh_pandas)

        self._lists['type'] = QComboBox()
        for dt in IngestTypes:
            self._lists['type'].addItem(dt.value)

        self._refresh_lists()

        self._lists['type'].currentTextChanged.connect(self._type_changed)

        validator = QRegularExpressionValidator(r'^[\w\-. ]+$')
        cat_validator = QRegularExpressionValidator(r'^[0-9]\d*$')

        dataset_label = QLabel("Avaliable Datasets:")
        search_type_label = QLabel("Symbol/Search Type:")
        search_label = QLabel("Symbol/Search Term:")
        name_label = QLabel("Dataset Name:")
        cat_label = QLabel("Trends Category Code:")

        left_options.addWidget(dataset_label, 0, 0)
        left_options.addWidget(self._lists['data'], 1, 0)

        right_options.addWidget(search_type_label, 0, 0)
        right_options.addWidget(self._lists['type'], 1, 0)

        self._txt_var['ds_name'] = QLineEdit()
        self._txt_var['data_search'] = QLineEdit()
        self._txt_var['search_cat'] = QLineEdit()
        self._txt_var['ds_name'].setValidator(validator)
        self._txt_var['data_search'].setValidator(validator)
        self._txt_var['search_cat'].setValidator(cat_validator)

        self._txt_var['search_cat'].setPlaceholderText('0')

        right_options.addWidget(search_label, 2, 0)
        right_options.addWidget(self._txt_var['data_search'], 3, 0)

        right_options.addWidget(name_label, 4, 0)
        right_options.addWidget(self._txt_var['ds_name'], 5, 0)

        right_options.addWidget(cat_label, 6, 0)
        right_options.addWidget(self._txt_var['search_cat'], 7, 0)

        options_layout.addLayout(left_options, 0, 0)
        options_layout.addLayout(right_options, 0, 1)

        options_layout.setColumnStretch(0, 1)

        self._options_group_box.setLayout(options_layout)
示例#8
0
    def __init__(self, step: Steps.KeyPress, timeline):
        super(KeyPressWidget, self).__init__(step, timeline)

        detail_layout = self.ui.detailFrame.layout()

        # Key input
        self.key_label = QLabel("Key: ", self)
        self.key_line_edit = QLineEdit(self)
        self.key_line_edit.setMaxLength(1)
        self.key_line_edit.setText(self.step.key)
        self.key_line_edit.textChanged.connect(self.update_key)

        # Mod Input
        self.mod_label = QLabel("Mod: ", self)
        self.mod_combo = QComboBox(self)
        mod_list = ["None", "Ctrl", "Shift", "Alt", "Super"]
        self.mod_combo.addItems(mod_list)

        if self.step.mod:
            current_mod_index = mod_list.index(self.step.mod.capitalize())
            self.mod_combo.setCurrentIndex(current_mod_index)

        self.mod_combo.currentIndexChanged.connect(self.update_mod)

        # Add to layout
        detail_layout.addWidget(self.key_label)
        detail_layout.addWidget(self.key_line_edit)
        detail_layout.addWidget(self.mod_label)
        detail_layout.addWidget(self.mod_combo)
示例#9
0
    def setupUi(self, Dialog):
        if not Dialog.objectName():
            Dialog.setObjectName(u"Dialog")
        Dialog.resize(480, 150)
        self.buttonBox = QDialogButtonBox(Dialog)
        self.buttonBox.setObjectName(u"buttonBox")
        self.buttonBox.setGeometry(QRect(0, 100, 461, 32))
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Apply|QDialogButtonBox.Cancel)
        self.label = QLabel(Dialog)
        self.label.setObjectName(u"label")
        self.label.setGeometry(QRect(10, 20, 81, 16))
        self.label_2 = QLabel(Dialog)
        self.label_2.setObjectName(u"label_2")
        self.label_2.setGeometry(QRect(240, 20, 57, 14))
        self.key = QLineEdit(Dialog)
        self.key.setObjectName(u"key")
        self.key.setGeometry(QRect(10, 40, 211, 22))
        font = QFont()
        font.setFamilies([u"Monospace"])
        self.key.setFont(font)
        self.val = QLineEdit(Dialog)
        self.val.setObjectName(u"val")
        self.val.setGeometry(QRect(240, 40, 211, 22))
        font1 = QFont()
        self.val.setFont(font1)

        self.retranslateUi(Dialog)
        self.buttonBox.accepted.connect(Dialog.accept)
        self.buttonBox.rejected.connect(Dialog.reject)

        QMetaObject.connectSlotsByName(Dialog)
示例#10
0
    def __init__(self, valve: Valve):
        super().__init__()

        AppGlobals.Instance().onChipModified.connect(self.CheckForValve)

        self._valve = valve

        self.valveToggleButton = QToolButton()
        self.valveNumberLabel = QLabel("Number")
        self.valveNumberDial = QSpinBox()
        self.valveNumberDial.setMinimum(0)
        self.valveNumberDial.setValue(self._valve.solenoidNumber)
        self.valveNumberDial.setMaximum(9999)
        self.valveNumberDial.valueChanged.connect(self.UpdateValve)

        self.valveNameLabel = QLabel("Name")
        self.valveNameField = QLineEdit(self._valve.name)
        self.valveNameField.textChanged.connect(self.UpdateValve)

        mainLayout = QVBoxLayout()
        mainLayout.addWidget(self.valveToggleButton, alignment=Qt.AlignCenter)

        layout = QGridLayout()
        layout.addWidget(self.valveNameLabel, 0, 0)
        layout.addWidget(self.valveNameField, 0, 1)
        layout.addWidget(self.valveNumberLabel, 1, 0)
        layout.addWidget(self.valveNumberDial, 1, 1)

        mainLayout.addLayout(layout)
        self.containerWidget.setLayout(mainLayout)
        self.valveToggleButton.clicked.connect(self.Toggle)

        self.Update()
        self.Move(QPointF())
示例#11
0
class AlfabetoWidget(QWidget):
    def __init__(self):
        super().__init__()
        self.principal = QGridLayout()
        self.label = QLabel("Alfabetos")
        self.principal.addWidget(self.label, 0, 0)
        self.input = QLineEdit()
        self.input.setPlaceholderText("Ingrese el alfabeto")
        self.input.setClearButtonEnabled(True)
        self.principal.addWidget(self.input, 1, 0)
        self.button_add = QPushButton("Add")
        self.principal.addWidget(self.button_add, 1, 1)
        self.button_add.clicked.connect(self.texto)
        self.button_union = QPushButton("Union")
        self.principal.addWidget(self.button_union, 2, 0)
        self.button_diff = QPushButton("Diferencia")
        self.principal.addWidget(self.button_diff, 3, 0)
        self.button_inter = QPushButton("Interseccion")
        self.principal.addWidget(self.button_inter, 4, 0)

        self.setLayout(self.principal)

    def texto(self):
        res = "texto ingresado: " + self.input.displayText()
        print(res)
示例#12
0
    def __init__(self, program: Program):
        super().__init__()

        AppGlobals.Instance().onChipOpened.connect(self.CheckForProgram)
        AppGlobals.Instance().onChipModified.connect(self.CheckForProgram)

        self.program = program
        self.modified = False
        self.codeEditor = CodeTextEditor()

        layout = QHBoxLayout()
        self.setLayout(layout)

        self._programNameField = QLineEdit(program.name)
        self._programNameField.textChanged.connect(self.UpdateProgramName)

        self._parameterEditor = ParameterEditor(program)
        self._parameterEditor.onParametersChanged.connect(self.ProgramEdited)

        programNameLabel = QLabel("Name:")
        sideLayout = QVBoxLayout()
        sideLayout.addWidget(programNameLabel)
        sideLayout.addWidget(self._programNameField)
        sideLayout.addWidget(self._parameterEditor)
        layout.addLayout(sideLayout, stretch=0)
        layout.addWidget(self.codeEditor, stretch=1)

        self.codeEditor.SetCode(self.program.script)

        self.codeEditor.codeChanged.connect(self.ProgramEdited)
示例#13
0
    def __init__(self, parent: QWidget, parent_layout: QVBoxLayout,
                 line_layout: QHBoxLayout, resource_database: ResourceDatabase,
                 requirement: RequirementArrayBase):
        self._editors = []
        self.resource_database = resource_database
        self._array_type = type(requirement)

        # the parent is added to a layout which is added to parent_layout, so we
        index = parent_layout.indexOf(line_layout) + 1

        self.group_box = QGroupBox(parent)
        self.group_box.setStyleSheet("QGroupBox { margin-top: 2px; }")
        parent_layout.insertWidget(index, self.group_box)
        self.item_layout = QVBoxLayout(self.group_box)
        self.item_layout.setContentsMargins(8, 2, 2, 6)
        self.item_layout.setAlignment(Qt.AlignTop)

        self.new_item_button = QPushButton(self.group_box)
        self.new_item_button.setMaximumWidth(75)
        self.new_item_button.setText("New Row")
        self.new_item_button.clicked.connect(self.new_item)

        self.comment_text_box = QLineEdit(parent)
        self.comment_text_box.setText(requirement.comment or "")
        self.comment_text_box.setPlaceholderText("Comment")
        line_layout.addWidget(self.comment_text_box)

        for item in requirement.items:
            self._create_item(item)

        self.item_layout.addWidget(self.new_item_button)
示例#14
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.completer = None
        self.p_selected_id = 0

        self.layout = QHBoxLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.name = QLineEdit()
        self.name.setText("")
        self.layout.addWidget(self.name)
        self.details = QLabel()
        self.details.setText("")
        self.details.setVisible(False)
        self.layout.addWidget(self.details)
        self.button = QPushButton("...")
        self.button.setFixedWidth(
            self.button.fontMetrics().horizontalAdvance("XXXX"))
        self.layout.addWidget(self.button)
        self.setLayout(self.layout)

        self.setFocusProxy(self.name)

        self.button.clicked.connect(self.on_button_clicked)

        if self.details_field:
            self.name.setFixedWidth(
                self.name.fontMetrics().horizontalAdvance("X") * 15)
            self.details.setVisible(True)
        self.completer = QCompleter(self.dialog.model.completion_model)
        self.completer.setCompletionColumn(
            self.dialog.model.completion_model.fieldIndex(self.selector_field))
        self.completer.setCaseSensitivity(Qt.CaseInsensitive)
        self.name.setCompleter(self.completer)
        self.completer.activated[QModelIndex].connect(self.on_completion)
示例#15
0
    def __init__(self, dose, notes):
        super(Dialog_Dose, self).__init__()

        # Class variables
        self.dose = dose
        self.notes = notes
        self.setWindowIcon(
            QtGui.QIcon("res/images/btn-icons/onkodicom_icon.png"))
        buttonBox = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self)
        self.iso_dose = QLineEdit()
        self.iso_dose.setText(self.dose)
        self.iso_unit = QComboBox()
        self.iso_unit.addItems(["cGy", "%"])
        self.iso_notes = QLineEdit()
        self.iso_notes.setText(self.notes)

        # Input dialog layout
        layout = QFormLayout(self)
        layout.addRow(QLabel("Isodose Level:"), self.iso_dose)
        layout.addRow(QLabel("Unit:"), self.iso_unit)
        layout.addRow(QLabel("Notes:"), self.iso_notes)
        layout.addWidget(buttonBox)
        buttonBox.accepted.connect(self.accepting)
        buttonBox.rejected.connect(self.reject)
        self.setWindowTitle("Isodose Levels")
示例#16
0
    def __init__(self):
        super(MainWindow, self).__init__()

        self.setWindowTitle('PySide6 WebEngineWidgets Example')

        self.toolBar = QToolBar()
        self.addToolBar(self.toolBar)
        self.backButton = QPushButton()
        self.backButton.setIcon(QIcon(':/qt-project.org/styles/commonstyle/images/left-32.png'))
        self.backButton.clicked.connect(self.back)
        self.toolBar.addWidget(self.backButton)
        self.forwardButton = QPushButton()
        self.forwardButton.setIcon(QIcon(':/qt-project.org/styles/commonstyle/images/right-32.png'))
        self.forwardButton.clicked.connect(self.forward)
        self.toolBar.addWidget(self.forwardButton)

        self.addressLineEdit = QLineEdit()
        self.addressLineEdit.returnPressed.connect(self.load)
        self.toolBar.addWidget(self.addressLineEdit)

        self.webEngineView = QWebEngineView()
        self.setCentralWidget(self.webEngineView)
        initialUrl = 'http://qt.io'
        self.addressLineEdit.setText(initialUrl)
        self.webEngineView.load(QUrl(initialUrl))
        self.webEngineView.page().titleChanged.connect(self.setWindowTitle)
        self.webEngineView.page().urlChanged.connect(self.urlChanged)
示例#17
0
    def change_settings(self, settings):

        # First clean up all previous items
        for i in range(self.layout.count()):
            self.layout.removeItem(self.layout.takeAt(0))
        for w in self.widgets:
            w.deleteLater()
        self.widgets = []

        if not settings:
            label = QLabel(self.parentWidget())
            label.setObjectName("settings_empty_label")
            label.setText("Для данной операции настройки отсутствуют")
            label.setWordWrap(True)
            self.widgets.append(label)
            self.layout.addWidget(label, 0, 0)

        else:
            x = 0
            for s in settings:
                if isinstance(s.type, range):
                    label = QLabel(self.parentWidget())
                    label.setText(s.text)
                    label.setWordWrap(True)
                    self.widgets.append(label)
                    self.layout.addWidget(label, x, 0)

                    slider = QSlider(self.parentWidget())
                    slider.setOrientation(Qt.Horizontal)
                    slider.setMinimum(s.type.start // s.type.step)
                    slider.setMaximum(s.type.stop // s.type.step - 1)
                    slider.setValue(s.value // s.type.step)
                    self.layout.addWidget(slider, x + 1, 0)

                    line_edit = QLineEdit(self.parentWidget())
                    line_edit.setText(str(s.value))
                    self.layout.addWidget(line_edit, x + 1, 1)

                    slider.valueChanged.connect(
                        partial(self.slider_change, line_edit, s))
                    line_edit.returnPressed.connect(
                        partial(self.line_edit_change, slider, line_edit, s))

                    self.widgets.append(slider)
                    self.widgets.append(line_edit)
                    x += 2

                elif s.type == bool:
                    checkbox = QCheckBox(self.parentWidget())
                    checkbox.setText('\n'.join(wrap(s.text, 40)))
                    checkbox.setChecked(s.value)
                    checkbox.clicked.connect(
                        partial(self.checkbox_changed, checkbox, s))

                    self.layout.addWidget(checkbox, x, 0)
                    self.widgets.append(checkbox)
                    x += 1
                elif s.type in (int, float, str):
                    pass
示例#18
0
    def setup_ui(self):
        super(SettingUI, self).setup_ui()
        max_width_label = QLabel(text="最大宽度",
                                 alignment=QtCore.Qt.AlignRight
                                 | QtCore.Qt.AlignVCenter)
        max_width_combo = QComboBox()
        max_width_combo.addItems(Globals.max_width_arr)
        max_width_combo.setCurrentIndex(self.max_width_index)
        max_width_combo.currentIndexChanged.connect(self.on_combo_changed)

        size_label = QLabel(text="输出字号",
                            alignment=QtCore.Qt.AlignRight
                            | QtCore.Qt.AlignVCenter)
        size_spin = QSpinBox()
        size_spin.setRange(10, 64)
        size_spin.setValue(Globals.config.get(Globals.UserData.font_size))
        size_spin.valueChanged.connect(self.on_save_font_size)

        output_name_label = QLabel(text="输出名称",
                                   alignment=QtCore.Qt.AlignRight
                                   | QtCore.Qt.AlignVCenter)
        output_name_edit = QLineEdit(
            Globals.config.get(Globals.UserData.font_save_name))
        output_name_edit.textEdited.connect(self.on_output_name_edited)

        output_label = QLabel(text="输出目录",
                              alignment=QtCore.Qt.AlignRight
                              | QtCore.Qt.AlignVCenter)
        output_line_edit = QLineEdit(
            Globals.config.get(Globals.UserData.output_dir))
        output_line_edit.setReadOnly(True)
        output_line_edit.cursorPositionChanged.connect(
            self.on_output_choose_clicked)

        mode_1_radio = QRadioButton("图集模式")
        mode_2_radio = QRadioButton("字体模式")
        mode_1_radio.setChecked(True)
        mode_1_radio.toggled.connect(self.on_mode_1_radio_toggled)
        mode_radio_group = QButtonGroup(self)
        mode_radio_group.addButton(mode_1_radio, 0)
        mode_radio_group.addButton(mode_2_radio, 1)

        self.main_layout.setColumnStretch(1, 1)
        self.main_layout.setColumnStretch(3, 1)
        self.main_layout.addWidget(mode_1_radio, 0, 0, 1, 1)
        self.main_layout.addWidget(mode_2_radio, 0, 1, 1, 1)
        self.main_layout.addWidget(output_name_label, 1, 0, 1, 1)
        self.main_layout.addWidget(output_name_edit, 1, 1, 1, 1)
        self.main_layout.addWidget(max_width_label, 1, 2, 1, 1)
        self.main_layout.addWidget(max_width_combo, 1, 3, 1, 1)
        self.main_layout.addWidget(output_label, 2, 0, 1, 1)
        self.main_layout.addWidget(output_line_edit, 2, 1, 1, 1)
        self.main_layout.addWidget(size_label, 2, 2, 1, 1)
        self.main_layout.addWidget(size_spin, 2, 3, 1, 1)

        self.max_width_combo = max_width_combo
        self.size_spin = size_spin
        self.output_name_edit = output_name_edit
        self.output_line_edit = output_line_edit
示例#19
0
def prompt_for_output_directory(parent: QtWidgets.QWidget, suggested_name: str,
                                output_file_edit: QtWidgets.QLineEdit) -> Optional[Path]:
    if output_file_edit.text():
        suggested_name = output_file_edit.text()

    return _prompt_for_output_common(
        parent, suggested_name, [""]
    )
示例#20
0
def prompt_for_input_directory(parent: QtWidgets.QWidget, input_file_edit: QtWidgets.QLineEdit) -> Optional[Path]:
    existing_file = None
    if input_file_edit.text():
        input_file = Path(input_file_edit.text())
        if input_file.is_dir():
            existing_file = input_file

    return common_qt_lib.prompt_user_for_vanilla_input_file(parent, [""], existing_file=existing_file)
    def __init__(self, parent=None):
        super(BlockingClient, self).__init__(parent)

        self.thread = FortuneThread()
        self.currentFortune = ''

        hostLabel = QLabel("&Server name:")
        portLabel = QLabel("S&erver port:")

        for ipAddress in QNetworkInterface.allAddresses():
            if ipAddress != QHostAddress.LocalHost and ipAddress.toIPv4Address(
            ) != 0:
                break
        else:
            ipAddress = QHostAddress(QHostAddress.LocalHost)

        ipAddress = ipAddress.toString()

        self.hostLineEdit = QLineEdit(ipAddress)
        self.portLineEdit = QLineEdit()
        self.portLineEdit.setValidator(QIntValidator(1, 65535, self))

        hostLabel.setBuddy(self.hostLineEdit)
        portLabel.setBuddy(self.portLineEdit)

        self.statusLabel = QLabel(
            "This example requires that you run the Fortune Server example as well."
        )
        self.statusLabel.setWordWrap(True)

        self.getFortuneButton = QPushButton("Get Fortune")
        self.getFortuneButton.setDefault(True)
        self.getFortuneButton.setEnabled(False)

        quitButton = QPushButton("Quit")

        buttonBox = QDialogButtonBox()
        buttonBox.addButton(self.getFortuneButton, QDialogButtonBox.ActionRole)
        buttonBox.addButton(quitButton, QDialogButtonBox.RejectRole)

        self.getFortuneButton.clicked.connect(self.requestNewFortune)
        quitButton.clicked.connect(self.close)
        self.hostLineEdit.textChanged.connect(self.enableGetFortuneButton)
        self.portLineEdit.textChanged.connect(self.enableGetFortuneButton)
        self.thread.newFortune.connect(self.showFortune)
        self.thread.error.connect(self.displayError)

        mainLayout = QGridLayout()
        mainLayout.addWidget(hostLabel, 0, 0)
        mainLayout.addWidget(self.hostLineEdit, 0, 1)
        mainLayout.addWidget(portLabel, 1, 0)
        mainLayout.addWidget(self.portLineEdit, 1, 1)
        mainLayout.addWidget(self.statusLabel, 2, 0, 1, 2)
        mainLayout.addWidget(buttonBox, 3, 0, 1, 2)
        self.setLayout(mainLayout)

        self.setWindowTitle("Blocking Fortune Client")
        self.portLineEdit.setFocus()
示例#22
0
    def __init__(self):
        super().__init__()
        self._line_edit = QLineEdit()
        self._line_edit.setReadOnly(True)

        # setup layout
        h_layout = AHBoxLayout(self)
        h_layout.addWidget(self._line_edit)
        h_layout.setContentsMargins(QMargins(0, 0, 0, 0))
示例#23
0
    def __init__(self):
        QWidget.__init__(self)
        self.items = 0

        # Example data
        self._data = {
            "Water": 24.5,
            "Electricity": 55.1,
            "Rent": 850.0,
            "Supermarket": 230.4,
            "Internet": 29.99,
            "Spätkauf": 21.85,
            "BVG Ticket": 60.0,
            "Coffee": 22.45,
            "Meetup": 0.0
        }

        # Left
        self.table = QTableWidget()
        self.table.setColumnCount(2)
        self.table.setHorizontalHeaderLabels(["Description", "Quantity"])
        self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)

        # Right
        self.description = QLineEdit()
        self.quantity = QLineEdit()
        self.add = QPushButton("Add")
        self.clear = QPushButton("Clear")
        self.quit = QPushButton("Quit")

        self.right = QVBoxLayout()
        self.right.setContentsMargins(10, 10, 10, 10)
        self.right.addWidget(QLabel("Description"))
        self.right.addWidget(self.description)
        self.right.addWidget(QLabel("Quantity"))
        self.right.addWidget(self.quantity)
        self.right.addWidget(self.add)
        self.right.addStretch()
        self.right.addWidget(self.quit)

        # QWidget Layout
        self.layout = QHBoxLayout()

        self.layout.addWidget(self.table)
        self.layout.addLayout(self.right)

        # Set the layout to the QWidget
        self.setLayout(self.layout)

        # Signals and Slots
        self.add.clicked.connect(self.add_element)
        self.quit.clicked.connect(self.quit_application)
        self.clear.clicked.connect(self.clear_table)

        # Fill example data
        self.fill_table()
示例#24
0
    def initUI(self):
        self.btn = QPushButton('Dialog', self)
        self.btn.move(20, 20)
        self.btn.clicked.connect(self.showDialog)

        self.le = QLineEdit(self)
        self.le.move(130, 22)

        self.setGeometry(300, 300, 300, 250)
        self.setWindowTitle("Input dialog")
示例#25
0
def set_edit_if_different(edit: QtWidgets.QLineEdit, new_text: str):
    """
    Sets the text of the given QLineEdit only if it differs from the current value.
    Prevents snapping the user's cursor to the end unnecessarily.
    :param edit:
    :param new_text:
    :return:
    """
    if edit.text() != new_text:
        edit.setText(new_text)
示例#26
0
    def __init__(self):
        super(PatientWeightDialog, self).__init__()

        # Class variables
        self.patient_weight_message = "Patient weight is needed for SUV2ROI "
        self.patient_weight_message += "conversion.\nPlease enter patient "
        self.patient_weight_message += "weight in kg."

        # Get stylesheet
        if platform.system() == 'Darwin':
            self.stylesheet_path = "res/stylesheet.qss"
        else:
            self.stylesheet_path = "res/stylesheet-win-linux.qss"
        self.stylesheet = open(resource_path(self.stylesheet_path)).read()

        self.setWindowIcon(
            QtGui.QIcon("res/images/btn-icons/onkodicom_icon.png"))
        buttonBox = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self)
        self.patient_weight_message_label = QLabel(self.patient_weight_message)
        self.patient_weight_prompt = QLabel("Patient Weight:")
        self.patient_weight_entry = QLineEdit()
        self.text_font = QtGui.QFont()
        self.text_font.setPointSize(11)

        # Set button object names
        buttonBox.button(QDialogButtonBox.Ok).setProperty(
            "QPushButtonClass", "success-button")
        buttonBox.button(QDialogButtonBox.Cancel).setProperty(
            "QPushButtonClass", "fail-button")

        # Set stylesheets
        buttonBox.setStyleSheet(self.stylesheet)

        self.patient_weight_message_label.setFont(self.text_font)
        self.patient_weight_message_label.setStyleSheet(self.stylesheet)

        self.patient_weight_prompt.setMinimumHeight(36)
        self.patient_weight_prompt.setMargin(4)
        self.patient_weight_prompt.setFont(self.text_font)
        self.patient_weight_prompt.setAlignment(QtCore.Qt.AlignVCenter
                                                | QtCore.Qt.AlignHCenter)
        self.patient_weight_prompt.setStyleSheet(self.stylesheet)

        self.patient_weight_entry.setStyleSheet(self.stylesheet)

        # Input dialog layout
        entry_layout = QFormLayout(self)
        entry_layout.addRow(self.patient_weight_message_label)
        entry_layout.addRow(self.patient_weight_prompt,
                            self.patient_weight_entry)
        entry_layout.addWidget(buttonBox)
        buttonBox.accepted.connect(self.accepting)
        buttonBox.rejected.connect(self.rejecting)
        self.setWindowTitle("Enter Patient Weight")
示例#27
0
    def __init__(self, tab, config_path):
        self.name_field = QLineEdit()
        self.name_field.setEnabled(False)

        self.file_button = QPushButton("Select")
        self.file_button.clicked.connect(self.on_select_clicked)

        super().__init__(tab, config_path)

        self.addWidget(self.name_field)
        self.addWidget(self.file_button)
示例#28
0
def check_extracted_game(input_file_edit: QLineEdit, input_file_button: QPushButton, contents_file_path: Path) -> bool:
    prompt_input_file = not has_internal_copy(contents_file_path)
    input_file_edit.setEnabled(prompt_input_file)

    if prompt_input_file:
        input_file_button.setText("Select File")
    else:
        input_file_button.setText("Delete internal copy")
        input_file_edit.setText(_VALID_GAME_TEXT)

    return prompt_input_file
示例#29
0
 def __init__(self):
     super().__init__()
     self.principal = QGridLayout()
     self.label = QLabel("Lenguajes")
     self.principal.addWidget(self.label, 0, 0, 1, 1)
     self.input = QLineEdit()
     self.principal.addWidget(self.input, 0, 1, 1, 1)
     self.button1 = QPushButton("Submit")
     self.principal.addWidget(self.button1, 0, 2, 1, 1)
     self.button1.clicked.connect(self.texto)
     self.setLayout(self.principal)
示例#30
0
 def __init__(self, save, failCallback, *args, **kwargs):
     QLabel.__init__(self, *args, **kwargs)
     self.save = save
     self.editable = True
     self.failCallback = failCallback
     self.editor = QLineEdit(self)
     self.editor.setWindowFlags(Qt.Popup)
     self.editor.setFocusProxy(self)
     self.editor.editingFinished.connect(self.handleEditingFinished)
     self.editor.installEventFilter(self)
     self.callback = lambda text: 0