Exemplo n.º 1
0
    def __init__(self, parent):
        super(EditSourceCodeDialog, self).__init__(parent)

        # create UI
        self.main_grid_layout = QGridLayout(self)

        main_vertical_splitter = QSplitter()
        main_vertical_splitter.setOrientation(Qt.Vertical)

        #   instructions and actions layout
        header_widget = QWidget()
        header_layout = QHBoxLayout()

        instructions_text_edit = QTextEdit()
        instructions_text_edit.setText(instructions_text)
        instructions_text_edit.setEnabled(False)

        reset_button = QPushButton()
        reset_button.setText('reset')
        reset_button.clicked.connect(self.reset)

        header_layout.addWidget(instructions_text_edit)
        header_layout.addWidget(reset_button)

        header_widget.setLayout(header_layout)


        main_vertical_splitter.addWidget(header_widget)

        #   code text edit
        self.code_text_edit = CodeEditor()
        self.code_text_edit.static_elements = ['def update(self, input_called=-1, token=None):',
                                               'self.data_outputs_updated()',
                                               'def get_data(self):',
                                               'def set_data(self, data):',
                                               '''	def __init__(self, parent_node: Node, flow, configuration=None):
		super(%NODE_TITLE%_NodeInstance, self).__init__(parent_node, flow, configuration)''',
                                               'class %NODE_TITLE%_NodeInstance']
        self.code_text_edit.components = ['self.main_widget',
                                          'self.outputs',
                                          'self.input',
                                          'self.special_actions']
        main_vertical_splitter.addWidget(self.code_text_edit)



        self.main_grid_layout.addWidget(main_vertical_splitter)


        button_box = QDialogButtonBox()
        button_box.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok)
        button_box.accepted.connect(self.accept)
        button_box.rejected.connect(self.reject)
        self.main_grid_layout.addWidget(button_box)

        self.setWindowTitle('Edit Source Code')
        self.resize(1300, 950)


        self.reset()
    def book_id_widget(self):
        """
        Tworzy widgety niezbędne do obsługi edycji, usunięcia i wypożyczenia książki.
        """
        btn_save_box = QDialogButtonBox()
        lbl_isbn = QLabel('ISBN:')
        lbl_book_name = QLabel('Tytuł książki:')
        lbl_author_name = QLabel('Autor książki:')
        lbl_publisher = QLabel('Wydawaca:')
        lbl_publish_date = QLabel('Data wydania:')
        lbl_category = QLabel('Kategoria:')
        lbl_language = QLabel('Język książki:')
        lbl_book_description = QLabel('Opis książki:')
        layout_hbox = QHBoxLayout()
        self.btn_delete_book.setStyleSheet("color: #dc3545; border-color : #dc3545")

        btn_save_box.setStandardButtons(self.btn_cancel_box | self.btn_save_box)

        layout_hbox.addWidget(self.btn_delete_book)
        layout_hbox.addWidget(self.btn_borrow_book)
        self.layout_book.addRow(layout_hbox)
        self.layout_book.addRow(lbl_isbn, self.edit_isbn)
        self.layout_book.addRow(lbl_book_name, self.edit_book_name)
        self.layout_book.addRow(lbl_author_name, self.edit_author)
        self.layout_book.addRow(lbl_publisher, self.edit_publisher)
        self.layout_book.addRow(lbl_publish_date, self.edit_publish_date)
        self.layout_book.addRow(lbl_category, self.edit_category)
        self.layout_book.addRow(lbl_language, self.edit_language_book)
        self.layout_book.addRow(lbl_book_description, self.edit_book_description)
        self.layout_book.addItem(self.v_spacer)
        self.layout_book.addRow(btn_save_box)
        self.dialog_book.setLayout(self.layout_book)

        btn_save_box.rejected.connect(self.on_home_clicked)
        btn_save_box.accepted.connect(lambda: self.new_book(self._book_id))
Exemplo n.º 3
0
    def __init__(self, parent, var):
        super(EditVarVal_Dialog, self).__init__(parent)

        # shortcut
        save_shortcut = QShortcut(QKeySequence.Save, self)
        save_shortcut.activated.connect(self.save_triggered)

        main_layout = QVBoxLayout()

        self.val_text_edit = QPlainTextEdit()
        var_val_str = ''
        try:
            var_val_str = str(var.val)
        except Exception as e:
            var_val_str = 'couldn\'nt stringify value'
        self.val_text_edit.setPlainText(var_val_str)

        main_layout.addWidget(self.val_text_edit)

        button_box = QDialogButtonBox()
        button_box.setStandardButtons(QDialogButtonBox.Cancel
                                      | QDialogButtonBox.Ok)
        button_box.accepted.connect(self.accept)
        button_box.rejected.connect(self.reject)

        main_layout.addWidget(button_box)

        self.setLayout(main_layout)
        self.resize(450, 300)

        self.setWindowTitle('edit var val \'' + var.name + '\'')
Exemplo n.º 4
0
    def _init_widgets(self):

        # name label

        name_label = QLabel(self)
        name_label.setText('New name')

        name_box = LabelNameBox(self._on_name_changed, self)
        if self._label_addr in self._disasm_view.disasm.kb.labels:
            name_box.setText(
                self._disasm_view.disasm.kb.labels[self._label_addr])
            name_box.selectAll()
        self._name_box = name_box

        label_layout = QHBoxLayout()
        label_layout.addWidget(name_label)
        label_layout.addWidget(name_box)
        self.main_layout.addLayout(label_layout)

        # status label
        status_label = QLabel(self)
        self.main_layout.addWidget(status_label)
        self._status_label = status_label

        # buttons
        buttons = QDialogButtonBox(parent=self)
        buttons.setStandardButtons(QDialogButtonBox.StandardButton.Cancel
                                   | QDialogButtonBox.StandardButton.Ok)
        buttons.accepted.connect(self._on_ok_clicked)
        buttons.rejected.connect(self.close)
        self._ok_button = buttons.button(QDialogButtonBox.Ok)
        self._ok_button.setEnabled(False)
        self.main_layout.addWidget(buttons)
    def role_profile_widget(self):
        """
        Tworzy widgety niezbędne do obsługi utworzenia użytkownika z uprawnieniami.
        """
        self.combo_role_id.addItem('Użytkownik')
        self.combo_role_id.addItem('Pracownik')
        self.combo_role_id.addItem('Administrator')
        self.combo_role_id.activated[str].connect(self.on_changed)
        self.edit_pass2.setEchoMode(QLineEdit.Password)
        self.edit_pass3.setEchoMode(QLineEdit.Password)
        self.edit_new_email.setValidator(self.validator)

        btn_box = QDialogButtonBox()
        lbl_name = QLabel('Imię:')
        lbl_subname = QLabel('Nazwisko:')
        lbl_email = QLabel('Email:')
        lbl_pass2 = QLabel('Wpisz hasło:')
        lbl_pass3 = QLabel('Wpisz hasło ponownie:')
        lbl_role = QLabel('Rola:')

        btn_box.setStandardButtons(self.btn_cancel_box | self.btn_ok_box)
        self.layout_permission.addRow(lbl_name, self.edit_new_name)
        self.layout_permission.addRow(lbl_subname, self.edit_new_surname)
        self.layout_permission.addRow(lbl_email, self.edit_new_email)
        self.layout_permission.addRow(lbl_pass2, self.edit_pass2)
        self.layout_permission.addRow(lbl_pass3, self.edit_pass3)
        self.layout_permission.addRow(lbl_role, self.combo_role_id)
        self.layout_permission.setItem(7, QFormLayout.LabelRole, self.v_spacer)
        self.layout_permission.setWidget(8, QFormLayout.FieldRole, btn_box)
        self.dialog_permission.setLayout(self.layout_permission)

        btn_box.rejected.connect(self.on_home_clicked)
        btn_box.accepted.connect(self.post_user)
Exemplo n.º 6
0
    def _init_widgets(self, base_text, multiline):
        buttons = QDialogButtonBox(parent=self)
        buttons.setStandardButtons(QDialogButtonBox.StandardButton.Cancel
                                   | QDialogButtonBox.StandardButton.Ok)
        buttons.accepted.connect(self._on_ok_pressed)
        buttons.rejected.connect(self._on_cancel_pressed)
        self._ok_button = buttons.button(QDialogButtonBox.Ok)

        if multiline:
            editor = QCommentTextBox(
                parent=self,
                textconfirmed_callback=self._on_ok_pressed,
                textchanged_callback=self._evaluate)
            editor.setFont(Conf.disasm_font)
            self.text = editor.toPlainText

            editor.setPlainText(base_text)
            editor.selectAll()

        else:
            editor = QLineEdit(self)
            editor.setFont(Conf.disasm_font)
            self.text = editor.text
            editor.returnPressed.connect(self._on_ok_pressed)
            editor.textChanged.connect(self._evaluate)

            editor.setText(base_text)
            editor.setFocus()
            editor.selectAll()

        layout = QVBoxLayout()
        layout.addWidget(editor)
        layout.addWidget(buttons)

        self.setLayout(layout)
Exemplo n.º 7
0
    def _init_widgets(self):

        # name label
        comment_lbl = QLabel(self)
        comment_lbl.setText('Comment text')

        # comment textbox
        comment_txtbox = QCommentTextBox(
            textconfirmed_callback=self._on_ok_clicked, parent=self)
        if self._comment_addr in self._workspace.instance.project.kb.comments:
            comment_txtbox.setPlainText(
                self._workspace.instance.project.kb.comments[
                    self._comment_addr])
            comment_txtbox.selectAll()
        self._comment_textbox = comment_txtbox

        comment_layout = QVBoxLayout()
        comment_layout.addWidget(comment_lbl)
        comment_layout.addWidget(comment_txtbox)
        self.main_layout.addLayout(comment_layout)

        # buttons
        buttons = QDialogButtonBox(parent=self)
        buttons.setStandardButtons(QDialogButtonBox.StandardButton.Cancel
                                   | QDialogButtonBox.StandardButton.Ok)
        buttons.accepted.connect(self._on_ok_clicked)
        buttons.rejected.connect(self.close)
        self.main_layout.addWidget(buttons)
 def __init__(self, parent):
     super().__init__(parent)
     self.setWindowTitle("Select position parameters")
     button_box = QDialogButtonBox(self)
     button_box.setStandardButtons(QDialogButtonBox.Cancel
                                   | QDialogButtonBox.Ok)
     layout = QVBoxLayout(self)
     self._table_widget = QTableWidget(1, 2, self)
     self._table_widget.setHorizontalHeaderLabels(
         ["Position x", "Position y"])
     self._table_widget.setItem(0, 0,
                                QTableWidgetItem(parent._pos_x_parameter))
     self._table_widget.setItem(0, 1,
                                QTableWidgetItem(parent._pos_y_parameter))
     self._table_widget.horizontalHeader().setStretchLastSection(True)
     self._table_widget.verticalHeader().hide()
     self._table_widget.verticalHeader().setDefaultSectionSize(
         parent.default_row_height)
     self._delegate = ParameterNameDelegate(self, parent.db_mngr,
                                            *parent.db_maps)
     self._table_widget.setItemDelegate(self._delegate)
     layout.addWidget(self._table_widget)
     layout.addWidget(button_box)
     button_box.accepted.connect(self.accept)
     button_box.rejected.connect(self.reject)
Exemplo n.º 9
0
class Ui_successDialog(object):
    def setupUi(self, successDialog):
        if not successDialog.objectName():
            successDialog.setObjectName(u"successDialog")
        successDialog.resize(294, 108)
        self.successButton = QDialogButtonBox(successDialog)
        self.successButton.setObjectName(u"successButton")
        self.successButton.setGeometry(QRect(100, 60, 91, 31))
        self.successButton.setOrientation(Qt.Horizontal)
        self.successButton.setStandardButtons(QDialogButtonBox.Ok)
        self.successButton.setCenterButtons(True)
        self.successLabel = QLabel(successDialog)
        self.successLabel.setObjectName(u"successLabel")
        self.successLabel.setGeometry(QRect(50, 20, 201, 31))
        self.successLabel.setTextFormat(Qt.MarkdownText)
        self.successLabel.setAlignment(Qt.AlignCenter)

        self.retranslateUi(successDialog)
        self.successButton.accepted.connect(successDialog.accept)
        self.successButton.rejected.connect(successDialog.reject)

        QMetaObject.connectSlotsByName(successDialog)

    # setupUi

    def retranslateUi(self, successDialog):
        successDialog.setWindowTitle(
            QCoreApplication.translate("successDialog",
                                       u"\u64cd\u4f5c\u6210\u529f", None))
        self.successLabel.setText(
            QCoreApplication.translate("successDialog",
                                       u"**\u64cd\u4f5c\u6210\u529f\uff01**",
                                       None))
Exemplo n.º 10
0
    def _init_widgets(self):
        name_label = QLabel(self)
        name_label.setText('New name')
        name_box = NameLineEdit(self._on_name_changed, self)
        name_box.setText(self._initial_text)
        name_box.selectAll()
        self._name_box = name_box

        label_layout = QHBoxLayout()
        label_layout.addWidget(name_label)
        label_layout.addWidget(name_box)
        self.main_layout.addLayout(label_layout)

        status_label = QLabel(self)
        self.main_layout.addWidget(status_label)
        self._status_label = status_label

        buttons = QDialogButtonBox(parent=self)
        buttons.setStandardButtons(QDialogButtonBox.StandardButton.Cancel
                                   | QDialogButtonBox.StandardButton.Ok)
        buttons.accepted.connect(self._on_ok_clicked)
        buttons.rejected.connect(self.close)
        self._ok_button = buttons.button(QDialogButtonBox.Ok)
        self._ok_button.setEnabled(False)
        self.main_layout.addWidget(buttons)
class Dialog(QDialog):
    def __init__(self, game, parent):
        super(Dialog, self).__init__(parent)
        self.Parent = parent
        self.setWindowTitle('Hypixel Games Randomizer')
        self.setWindowIcon(QIcon(self.Parent.windowIcon()))
        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Ok)
        self.buttonBox.setCenterButtons(True)
        self.label = QLabel(self)
        self.label.setAlignment(Qt.AlignHCenter)
        font = QFont()
        font.setPointSize(14)
        font.setFamily('Roboto Th')
        self.label.setFont(font)
        self.label.setText('The wheel of games has chosen and\ndecided that you will now play')
        self.game = QLabel(self)
        self.game.setText(game)
        self.game.setAlignment(Qt.AlignHCenter)
        font.setPointSize(16)
        font.setFamily('Roboto Th')
        font.setBold(True)
        self.game.setFont(font)
        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.addWidget(self.label)
        self.verticalLayout.addWidget(self.game)
        self.verticalLayout.addWidget(self.buttonBox)
        self.buttonBox.button(QDialogButtonBox.Ok).clicked.connect(self.close)
Exemplo n.º 12
0
    def _init_widgets(self):

        # address label

        address_label = QLabel(self)
        address_label.setText('Address')

        address = QAddressInput(self._on_address_changed,
                                self._disasm_view.workspace,
                                parent=self)
        self._address_box = address

        address_layout = QHBoxLayout()
        address_layout.addWidget(address_label)
        address_layout.addWidget(address)
        self.main_layout.addLayout(address_layout)

        # status label
        status_label = QLabel(self)
        self.main_layout.addWidget(status_label)
        self._status_label = status_label

        # buttons
        buttons = QDialogButtonBox(parent=self)
        buttons.setStandardButtons(QDialogButtonBox.StandardButton.Cancel
                                   | QDialogButtonBox.StandardButton.Ok)
        buttons.accepted.connect(self._on_ok_clicked)
        buttons.rejected.connect(self.close)
        self._ok_button = buttons.button(QDialogButtonBox.Ok)
        self._ok_button.setEnabled(False)
        self.main_layout.addWidget(buttons)
Exemplo n.º 13
0
 def _initButtons(self):
     buttons = QDialogButtonBox()
     buttons.setStandardButtons(QDialogButtonBox.Ok
                                | QDialogButtonBox.Cancel)
     buttons.button(QDialogButtonBox.Ok).clicked.connect(self.onOkClicked)
     buttons.button(QDialogButtonBox.Cancel).clicked.connect(
         self.onCancelClicked)
     self.layout().addWidget(buttons)
Exemplo n.º 14
0
    def _init_widgets(self):

        # name label

        name_label = QLabel(self)
        name_label.setText('New name')

        name_box = NodeNameBox(self._on_name_changed, self)
        if self._node is not None:
            # parse node type, either a Function header or a Variable.
            if isinstance(
                    self._node, CVariable
            ) and self._node.unified_variable and self._node.unified_variable.name:
                name_box.setText(self._node.unified_variable.name)
            elif isinstance(self._node,
                            CVariable) and self._node.variable.region == '':
                name_box.setText(self._node.variable.name)
            elif isinstance(self._node, CFunction) and self._node.name:
                name_box.setText(self._node.name)
            elif isinstance(self._node, CFunctionCall):
                name_box.setText(self._node.callee_func.name)
            elif isinstance(self._node, CStructField):
                name_box.setText(self._node.field)

            name_box.selectAll()
        self._name_box = name_box

        label_layout = QHBoxLayout()
        label_layout.addWidget(name_label)
        label_layout.addWidget(name_box)
        self.main_layout.addLayout(label_layout)

        # suggestions
        suggest_label = QLabel(self)
        suggest_label.setText("Suggestions")

        suggestion_box = QListWidget()
        self._suggestion_box = suggestion_box
        suggestion_layout = QHBoxLayout()
        suggestion_layout.addWidget(suggest_label)
        suggestion_layout.addWidget(suggestion_box)
        self.main_layout.addLayout(suggestion_layout)

        # status label
        status_label = QLabel(self)
        self.main_layout.addWidget(status_label)
        self._status_label = status_label

        # buttons
        buttons = QDialogButtonBox(parent=self)
        buttons.setStandardButtons(QDialogButtonBox.StandardButton.Cancel
                                   | QDialogButtonBox.StandardButton.Ok)
        buttons.accepted.connect(self._on_ok_clicked)
        buttons.rejected.connect(self.close)
        self._ok_button = buttons.button(QDialogButtonBox.Ok)
        self._ok_button.setEnabled(False)
        self.main_layout.addWidget(buttons)
Exemplo n.º 15
0
    def __init__(self, modules: dict, parent=None):
        super(CodeGenDialog, self).__init__(parent)

        self.modules = modules

        main_layout = QVBoxLayout()

        imports_group_box = QGroupBox('Imports')
        imports_group_box.setLayout(QVBoxLayout())

        info_text_edit = QPlainTextEdit(
            '''I found the following imports in the inspected components. Please unselect all imports whose source code you want me to include in the output. All checked modules remain imported using the import statements. Notice that import alias names (import ... as ...) of course won\'t work when including the module\'s source. Same goes for imports using 'from' (indicated in the list below). And for those, the whole (direct) source will be included if you unselect a module.'''
        )
        info_text_edit.setReadOnly(True)
        imports_group_box.layout().addWidget(info_text_edit)

        imports_scroll_area = QScrollArea()
        imports_scroll_area.setLayout(QVBoxLayout())

        self.import_widget_assignment = {'imports': {}, 'fromimports': {}}

        # imports
        imports_scroll_area.layout().addWidget(QLabel('imports:'))
        for i in modules['imports'].keys():
            import_check_box = QCheckBox(i)
            import_check_box.setChecked(True)
            imports_scroll_area.layout().addWidget(import_check_box)
            self.import_widget_assignment['imports'][import_check_box] = i

        # from-imports
        imports_scroll_area.layout().addWidget(QLabel('\'from\'-imports:'))
        for i in modules['fromimports'].keys():
            names = modules['fromimports'][i][2]
            from_names_list = ', '.join(names)
            import_check_box = QCheckBox(i + ': ' + from_names_list)
            import_check_box.setChecked(True)
            imports_scroll_area.layout().addWidget(import_check_box)
            self.import_widget_assignment['fromimports'][import_check_box] = i

        imports_group_box.layout().addWidget(imports_scroll_area)

        main_layout.addWidget(imports_group_box)

        button_box = QDialogButtonBox()
        button_box.setStandardButtons(QDialogButtonBox.Cancel
                                      | QDialogButtonBox.Ok)
        button_box.accepted.connect(self.accept)
        button_box.rejected.connect(self.reject)

        main_layout.addWidget(button_box)

        self.setLayout(main_layout)
        self.resize(500, 500)

        self.setWindowTitle('Source Code Gen Manager')
Exemplo n.º 16
0
    def _init_widgets(self):

        layout = QGridLayout()
        self.main_layout.addLayout(layout)

        # filename

        filename_caption = QLabel(self)
        filename_caption.setText('File name:')

        filename = QLabel(self)
        filename.setText(self.filename)

        layout.addWidget(filename_caption, 0, 0, Qt.AlignRight)
        layout.addWidget(filename, 0, 1)

        # md5

        if self.md5 is not None:
            md5_caption = QLabel(self)
            md5_caption.setText('MD5:')
            md5 = QLineEdit(self)
            md5.setText(self.md5)
            md5.setReadOnly(True)

            layout.addWidget(md5_caption, 1, 0, Qt.AlignRight)
            layout.addWidget(md5, 1, 1)

        # sha256

        if self.sha256 is not None:
            sha256_caption = QLabel(self)
            sha256_caption.setText('SHA256:')
            sha256 = QLineEdit(self)
            sha256.setText(self.sha256)
            sha256.setReadOnly(True)

            layout.addWidget(sha256_caption, 2, 0, Qt.AlignRight)
            layout.addWidget(sha256, 2, 1)

        # central tab

        tab = QTabWidget()
        self._init_central_tab(tab)

        self.main_layout.addWidget(tab)

        # buttons

        buttons = QDialogButtonBox(parent=self)
        buttons.setStandardButtons(QDialogButtonBox.StandardButton.Cancel
                                   | QDialogButtonBox.StandardButton.Ok)
        buttons.accepted.connect(self._on_ok_clicked)
        buttons.rejected.connect(self._on_cancel_clicked)
        self.main_layout.addWidget(buttons)
Exemplo n.º 17
0
    def __init__(self, parent):
        super(EditInputWidgetDialog, self).__init__(parent)

        # create UI
        self.main_grid_layout = QGridLayout(self)

        main_vertical_splitter = QSplitter()
        main_vertical_splitter.setOrientation(Qt.Vertical)

        #   instructions and actions layout
        header_widget = QWidget()
        header_layout = QHBoxLayout()

        instructions_text_edit = QTextEdit()
        instructions_text_edit.setText(instructions_text)
        instructions_text_edit.setEnabled(False)

        reset_button = QPushButton()
        reset_button.setText('reset')
        reset_button.clicked.connect(self.reset)

        header_layout.addWidget(instructions_text_edit)
        header_layout.addWidget(reset_button)

        header_widget.setLayout(header_layout)

        main_vertical_splitter.addWidget(header_widget)

        #   code text edit
        self.code_text_edit = CodeEditor()
        self.code_text_edit.static_elements = [
            'def get_data(self):', 'def set_data(self, data):'
        ]
        self.code_text_edit.components = [
            'self.parent_node_instance',
            'self.parent_node_instance.update_shape()',
            'self.parent_port_instance'
        ]
        main_vertical_splitter.addWidget(self.code_text_edit)

        self.main_grid_layout.addWidget(main_vertical_splitter)

        button_box = QDialogButtonBox()
        button_box.setStandardButtons(QDialogButtonBox.Cancel
                                      | QDialogButtonBox.Ok)
        button_box.accepted.connect(self.accept)
        button_box.rejected.connect(self.reject)
        self.main_grid_layout.addWidget(button_box)

        self.setWindowTitle('Edit Source Code')
        self.resize(1300, 950)

        self.reset()
Exemplo n.º 18
0
    def _init_widgets(self):
        layout = QGridLayout()
        self.main_layout.addLayout(layout)
        self._status_label = QLabel(self)

        row = 0
        layout.addWidget(QLabel('Break on:', self), row, 0, Qt.AlignRight)
        self._type_radio_group = QButtonGroup(self)
        self._type_radio_group.addButton(QRadioButton('Execute', self),
                                         BreakpointType.Execute.value)
        self._type_radio_group.addButton(QRadioButton('Write', self),
                                         BreakpointType.Write.value)
        self._type_radio_group.addButton(QRadioButton('Read', self),
                                         BreakpointType.Read.value)
        for b in self._type_radio_group.buttons():
            layout.addWidget(b, row, 1)
            row += 1

        self._type_radio_group.button(
            self.breakpoint.type.value).setChecked(True)

        layout.addWidget(QLabel('Address:', self), row, 0, Qt.AlignRight)
        self._address_box = QAddressInput(self._on_address_changed,
                                          self.workspace,
                                          parent=self,
                                          default=f'{self.breakpoint.addr:#x}')
        layout.addWidget(self._address_box, row, 1)
        row += 1

        layout.addWidget(QLabel('Size:', self), row, 0, Qt.AlignRight)
        self._size_box = QLineEdit(self)
        self._size_box.setText(f'{self.breakpoint.size:#x}')
        self._size_box.textChanged.connect(self._on_size_changed)
        layout.addWidget(self._size_box, row, 1)
        row += 1

        layout.addWidget(QLabel('Comment:', self), row, 0, Qt.AlignRight)
        self._comment_box = QLineEdit(self)
        self._comment_box.setText(self.breakpoint.comment)
        layout.addWidget(self._comment_box, row, 1)
        row += 1

        self.main_layout.addWidget(self._status_label)

        buttons = QDialogButtonBox(parent=self)
        buttons.setStandardButtons(QDialogButtonBox.StandardButton.Cancel
                                   | QDialogButtonBox.StandardButton.Ok)
        buttons.accepted.connect(self._on_ok_clicked)
        buttons.rejected.connect(self.close)
        self._ok_button = buttons.button(QDialogButtonBox.Ok)
        self._ok_button.setEnabled(False)
        self.main_layout.addWidget(buttons)
Exemplo n.º 19
0
    def __init__(self, parent, db_mngr, *db_maps):
        """Initialize class.

        Args:
            parent (SpineDBEditor)
            db_mngr (SpineDBManager)
            db_maps (DiffDatabaseMapping): the dbs to select items from
        """
        super().__init__(parent)
        self.db_mngr = db_mngr
        self.db_maps = db_maps
        top_widget = QWidget()
        top_layout = QHBoxLayout(top_widget)
        db_maps_group_box = QGroupBox("Databases", top_widget)
        db_maps_layout = QVBoxLayout(db_maps_group_box)
        db_maps_layout.setContentsMargins(self._MARGIN, self._MARGIN,
                                          self._MARGIN, self._MARGIN)
        self.db_map_check_boxes = {
            db_map: QCheckBox(db_map.codename, db_maps_group_box)
            for db_map in self.db_maps
        }
        for check_box in self.db_map_check_boxes.values():
            check_box.stateChanged.connect(lambda _: QTimer.singleShot(
                0, self._set_item_check_box_enabled))
            check_box.setChecked(True)
            db_maps_layout.addWidget(check_box)
        items_group_box = QGroupBox("Items", top_widget)
        items_layout = QGridLayout(items_group_box)
        items_layout.setContentsMargins(self._MARGIN, self._MARGIN,
                                        self._MARGIN, self._MARGIN)
        self.item_check_boxes = {
            item_type: QCheckBox(item_type, items_group_box)
            for item_type in self._ITEM_TYPES
        }
        for k, check_box in enumerate(self.item_check_boxes.values()):
            row = k // self._COLUMN_COUNT
            column = k % self._COLUMN_COUNT
            check_box.setChecked(True)
            items_layout.addWidget(check_box, row, column)
        top_layout.addWidget(db_maps_group_box)
        top_layout.addWidget(items_group_box)
        button_box = QDialogButtonBox(self)
        button_box.setStandardButtons(QDialogButtonBox.Cancel
                                      | QDialogButtonBox.Ok)
        button_box.accepted.connect(self.accept)
        button_box.rejected.connect(self.reject)
        layout = QVBoxLayout(self)
        layout.addWidget(top_widget)
        layout.addWidget(button_box)
        layout.setContentsMargins(self._MARGIN, self._MARGIN, self._MARGIN,
                                  self._MARGIN)
        self.setAttribute(Qt.WA_DeleteOnClose)
Exemplo n.º 20
0
    def _init_widgets(self):
        load_button = QPushButton(self)
        load_button.setText("Load Plugin")
        load_button.clicked.connect(self._on_load_clicked)
        self.main_layout.addWidget(load_button)

        self._init_plugin_list()

        buttons = QDialogButtonBox(parent=self)
        buttons.setStandardButtons(QDialogButtonBox.StandardButton.Cancel
                                   | QDialogButtonBox.StandardButton.Ok)
        buttons.accepted.connect(self._on_ok_clicked)
        buttons.rejected.connect(self.close)
        self.main_layout.addWidget(buttons)
class ManagePluginsDialog(QDialog):
    item_removed = Signal(str)
    item_updated = Signal(str)

    def __init__(self, parent):
        """Initialize class"""
        super().__init__(parent)
        self.setWindowTitle('Manage plugins')
        QVBoxLayout(self)
        self._list_view = QListView(self)
        self._model = _ManagePluginsModel(self)
        self._list_view.setModel(self._model)
        self._button_box = QDialogButtonBox(self)
        self._button_box.setStandardButtons(QDialogButtonBox.Close)
        self.layout().addWidget(self._list_view)
        self.layout().addWidget(self._button_box)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setMinimumWidth(400)
        self._button_box.button(QDialogButtonBox.Close).clicked.connect(
            self.close)

    def populate_list(self, names):
        for name, can_update in names:
            item = QStandardItem(name)
            self._model.appendRow(item)
            widget = self._create_plugin_widget(name, can_update)
            index = self._model.indexFromItem(item)
            self._list_view.setIndexWidget(index, widget)

    def _create_plugin_widget(self, plugin_name, can_update):
        widget = ToolBarWidget(plugin_name, self)
        widget.tool_bar.addAction(
            "Remove",
            lambda _=False, n=plugin_name: self._emit_item_removed(n))
        update = widget.tool_bar.addAction(
            "Update",
            lambda _=False, n=plugin_name: self._emit_item_updated(n))
        update.setEnabled(can_update)
        update.triggered.connect(lambda _=False: update.setEnabled(False))
        return widget

    def _emit_item_removed(self, plugin_name):
        for row in range(self._model.rowCount()):
            if self._model.index(row, 0).data(Qt.DisplayRole) == plugin_name:
                self._model.removeRow(row)
                break
        self.item_removed.emit(plugin_name)

    def _emit_item_updated(self, plugin_name):
        self.item_updated.emit(plugin_name)
Exemplo n.º 22
0
Arquivo: main.py Projeto: istvans/typx
class OkDialog(QDialog):
    def __init__(self, title, message, parent=None):
        super(OkDialog, self).__init__(parent)
        self.setWindowTitle(title)
        self.message = QLabel(message)
        self.button_box = QDialogButtonBox(self)
        self.button_box.setOrientation(Qt.Orientation.Horizontal)
        self.button_box.setStandardButtons(QDialogButtonBox.Ok)
        self.button_box.accepted.connect(self.accept)

        layout = QVBoxLayout()
        layout.addWidget(self.message)
        layout.addWidget(self.button_box)

        self.setLayout(layout)
Exemplo n.º 23
0
 def __init__(self, parent=None):
     """Initializer."""
     super().__init__(parent)
     self.setWindowTitle('QDialog')
     dlgLayout = QVBoxLayout()
     formLayout = QFormLayout()
     formLayout.addRow('Name:', QLineEdit())
     formLayout.addRow('Age:', QLineEdit())
     formLayout.addRow('Job:', QLineEdit())
     formLayout.addRow('Hobbies:', QLineEdit())
     dlgLayout.addLayout(formLayout)
     btns = QDialogButtonBox()
     btns.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok)
     dlgLayout.addWidget(btns)
     self.setLayout(dlgLayout)
Exemplo n.º 24
0
class ManageItemsDialogBase(QDialog):
    def __init__(self, parent, db_mngr):
        """Init class.

        Args:
            parent (SpineDBEditor): data store widget
            db_mngr (SpineDBManager)
        """
        super().__init__(parent)
        self.db_mngr = db_mngr
        self.table_view = self.make_table_view()
        self.table_view.horizontalHeader().setSectionResizeMode(
            QHeaderView.Interactive)
        self.table_view.horizontalHeader().setStretchLastSection(True)
        self.table_view.horizontalHeader().setMinimumSectionSize(120)
        self.table_view.verticalHeader().setDefaultSectionSize(
            parent.default_row_height)
        self.button_box = QDialogButtonBox(self)
        self.button_box.setStandardButtons(QDialogButtonBox.Cancel
                                           | QDialogButtonBox.Ok)
        layout = QGridLayout(self)
        layout.addWidget(self.table_view)
        layout.addWidget(self.button_box)
        self.setAttribute(Qt.WA_DeleteOnClose)

    def make_table_view(self):
        return CopyPasteTableView(self)

    def connect_signals(self):
        """Connect signals to slots."""
        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)

    def resize_window_to_columns(self, height=None):
        if height is None:
            height = self.sizeHint().height()
        slack = 64
        margins = self.layout().contentsMargins()
        self.resize(
            slack + margins.left() + margins.right() +
            self.table_view.frameWidth() * 2 +
            self.table_view.verticalHeader().width() +
            self.table_view.horizontalHeader().length(),
            height,
        )
Exemplo n.º 25
0
    def _init_widgets(self):

        # contents
        contents = QListWidget()
        contents.setViewMode(QListView.IconMode)
        contents.setIconSize(QSize(96, 84))
        contents.setMovement(QListView.Static)
        contents.setMaximumWidth(128)
        contents.setSpacing(12)

        def item_changed(item: QListWidgetItem):
            pageno = item.data(1)  # type: Page
            pages.setCurrentIndex(pageno)

        contents.itemClicked.connect(item_changed)

        self._pages.append(Integration())
        self._pages.append(ThemeAndColors())

        pages = QStackedWidget()
        for idx, page in enumerate(self._pages):
            pages.addWidget(page)
            list_item = QListWidgetItem(page.NAME)
            list_item.setData(1, idx)
            contents.addItem(list_item)

        # buttons
        buttons = QDialogButtonBox(parent=self)
        buttons.setStandardButtons(QDialogButtonBox.StandardButton.Close
                                   | QDialogButtonBox.StandardButton.Ok)
        buttons.button(QDialogButtonBox.Ok).setText('Save')
        buttons.accepted.connect(self._on_ok_clicked)
        buttons.rejected.connect(self.close)

        # layout
        top_layout = QHBoxLayout()
        top_layout.addWidget(contents)
        top_layout.addWidget(pages)

        main_layout = QVBoxLayout()
        main_layout.addLayout(top_layout)
        main_layout.addWidget(buttons)

        self.setLayout(main_layout)
 def __init__(self, parent=None) -> None:
     super().__init__(parent)
     # Sets the title and size of the dialog box
     self.setWindowTitle('Connect to a new WIFI')
     self.resize(200, 100)
     # Set the window to modal, and the user can only close the main
     # interface after closing the popover
     self.setWindowModality(Qt.ApplicationModal)
     # Table layout used to layout QLabel and QLineEdit and QSpinBox
     grid = QGridLayout()
     grid.addWidget(QLabel('SSID', parent=self), 0, 0, 1, 1)
     self.SSIDName = QLineEdit(parent=self)
     self.SSIDName.setText('SSID')
     grid.addWidget(self.SSIDName, 0, 1, 1, 1)
     grid.addWidget(QLabel('password', parent=self), 1, 0, 1, 1)
     self.WIFIpassword = QLineEdit(parent=self)
     self.WIFIpassword.setText('password')
     grid.addWidget(self.WIFIpassword, 1, 1, 1, 1)
     grid.addWidget(
         QLabel(
             'Please enter the SSID and password of the new wifi your '
             'device will connect.After connected,\n'
             'the device will no longer be on this LAN and info in the list '
             'will be refreshed in 5 mins.',
             parent=self), 2, 0, 2, 2)
     # Create ButtonBox, and the user confirms and cancels
     buttonbox = QDialogButtonBox(parent=self)
     buttonbox.setOrientation(Qt.Horizontal)
     buttonbox.setStandardButtons(QDialogButtonBox.Cancel
                                  | QDialogButtonBox.Ok)
     buttonbox.accepted.connect(self.accept)
     buttonbox.rejected.connect(self.reject)
     # Vertical layout, layout tables and buttons
     layout = QVBoxLayout()
     # Add the table layout you created earlier
     layout.addLayout(grid)
     # Put a space object to beautify the layout
     spacer = QSpacerItem(20, 48, QSizePolicy.Minimum,
                          QSizePolicy.Expanding)
     layout.addItem(spacer)
     # ButtonBox
     layout.addWidget(buttonbox)
     self.setLayout(layout)
Exemplo n.º 27
0
    def __init__(self, parent=None):
        super().__init__(parent)

        options = {
            #"pen_pos_down": ("Pen position down:", (0, 100), 40),
            #"pen_pos_up": ("Pen position up:", (0, 100), 60),
            "pen_rate_lower": ("Pen rate lower:", (1, 100), 50),
            "pen_rate_raise": ("Pen rate raise:", (1, 100), 75),
            "pen_delay_down": ("Pen delay down:", (-500, 500), 0),
            "pen_delay_up": ("Pen delay up:", (-500, 500), 0),
            "speed_pendown": ("Speed (pen down):", (1, 110), 25),
            "speed_penup": ("Speed (pen up):", (1, 110), 75),
            "accel": ("Acceleration:", (1, 100), 75),
        }

        settings = QSettings()
        layout = QFormLayout()

        for key, (label, (min_val, max_val), default) in options.items():
            spin_box = AxySettingsSpinBox(settings, key, default)
            spin_box.setRange(min_val, max_val)
            spin_box.setSingleStep(1)
            layout.addRow(label, spin_box)

        model = QComboBox()
        model.addItem("Axidraw V2 or V3", 1)
        model.addItem("Axidraw V3/A3 or SE/A3", 2)
        model.addItem("Axidraw V3 XLX", 3)
        model.addItem("Axidraw MiniKit", 4)
        model.currentIndexChanged.connect(
            lambda index: axy.set_option("model", model.itemData(index))
        )
        model.setCurrentIndex(settings.value("model", 0))
        model.currentIndexChanged.connect(lambda index: settings.setValue("model", index))
        layout.addRow("Model:", model)

        btn_box = QDialogButtonBox()
        btn_box.setStandardButtons(QDialogButtonBox.Ok)
        btn_box.accepted.connect(self.accept)
        btn_box.rejected.connect(self.reject)
        layout.addRow(btn_box)

        self.setLayout(layout)
Exemplo n.º 28
0
 def get_item(cls,
              parent,
              title,
              label,
              items,
              icons=None,
              editable_text=""):
     if icons is None:
         icons = {}
     dialog = cls(parent, title)
     layout = QVBoxLayout(dialog)
     label = QLabel(label)
     label.setWordWrap(True)
     if editable_text:
         dialog._editable_text = editable_text
         items.append(dialog._editable_text)
     dialog._list_wg.addItems(items)
     for item in dialog._list_wg.findItems("*", Qt.MatchWildcard):
         icon = icons.get(item.text())
         if icon is not None:
             item.setData(Qt.DecorationRole, icon)
     if editable_text:
         dialog._new_item = dialog._list_wg.item(dialog._list_wg.count() -
                                                 1)
         dialog._new_item.setFlags(dialog._new_item.flags()
                                   | Qt.ItemIsEditable)
         foreground = qApp.palette().text()  # pylint: disable=undefined-variable
         color = foreground.color()
         color.setAlpha(128)
         foreground.setColor(color)
         dialog._new_item.setForeground(foreground)
     button_box = QDialogButtonBox()
     button_box.setStandardButtons(QDialogButtonBox.Cancel
                                   | QDialogButtonBox.Ok)
     layout.addWidget(label)
     layout.addWidget(dialog._list_wg)
     layout.addWidget(button_box)
     button_box.accepted.connect(dialog.accept)
     button_box.rejected.connect(dialog.close)
     if dialog.exec_() == QDialog.Rejected:
         return None
     return dialog._accepted_item.text()
    def __init__(self):
        super(Register, self).__init__()
        self.url_register = 'account/register'

        layout = QFormLayout()
        btn_box = QDialogButtonBox()
        lbl_name = QLabel('Imię:')
        lbl_subname = QLabel('Nazwisko:')
        lbl_email = QLabel('Email:')
        lbl_pass2 = QLabel('Wpisz hasło:')
        lbl_pass3 = QLabel('Wpisz hasło ponownie:')
        self.edit_name = QLineEdit()
        self.edit_surname = QLineEdit()
        self.edit_email = QLineEdit()
        self.edit_pass2 = QLineEdit()
        self.edit_pass3 = QLineEdit()
        self.edit_pass2.setEchoMode(QLineEdit.Password)
        self.edit_pass3.setEchoMode(QLineEdit.Password)
        v_spacer = QSpacerItem(20, 40, QSizePolicy.Minimum,
                               QSizePolicy.Expanding)
        self.regex = QRegExp('^(\w|\.|\_|\-)+[@](\w|\_|\-|\.)+[.]\w{2,3}$')
        self.validator = QRegExpValidator(self.regex)
        self.edit_email.setValidator(self.validator)

        self.setWindowTitle('Rejestracja')
        self.setWindowIcon(QtGui.QIcon('resources/library_icon.png'))
        self.setMinimumWidth(640)
        self.setMinimumHeight(400)

        btn_box.setStandardButtons(QDialogButtonBox.Cancel
                                   | QDialogButtonBox.Save)
        layout.addRow(lbl_name, self.edit_name)
        layout.addRow(lbl_subname, self.edit_surname)
        layout.addRow(lbl_email, self.edit_email)
        layout.addRow(lbl_pass2, self.edit_pass2)
        layout.addRow(lbl_pass3, self.edit_pass3)
        layout.setItem(6, QFormLayout.LabelRole, v_spacer)
        layout.setWidget(7, QFormLayout.FieldRole, btn_box)
        self.setLayout(layout)

        btn_box.rejected.connect(self.reject)
        btn_box.accepted.connect(self.register_user)
    def set_permission(self, user_id):
        """
        Zmienia uprawnienia użytkownika.
        """
        layout_set = QFormLayout()
        self.combo_role_id.activated[str].connect(self.on_changed)

        btn_box = QDialogButtonBox()
        lbl_role = QLabel('Rola:')

        btn_box.setStandardButtons(self.btn_cancel_box | self.btn_ok_box)
        layout_set.addRow(lbl_role, self.combo_role_id)
        layout_set.setItem(1, QFormLayout.LabelRole, self.v_spacer)
        layout_set.setWidget(2, QFormLayout.FieldRole, btn_box)
        self.dialog_set_permission.setLayout(layout_set)

        btn_box.rejected.connect(self.on_home_clicked)
        btn_box.accepted.connect(lambda: self.change_permission(user_id))

        self.on_set_permission()