예제 #1
0
 def setActionsBox(self, TrainPanel):
     hLayout = QVBoxLayout()
     hLayout.addWidget(self.calibrateButton)
     hLayout.addWidget(self.sessionButton)
     hLayout.setAlignment(self.calibrateButton, Qt.Alignment.AlignCenter)
     hLayout.setAlignment(self.sessionButton, Qt.Alignment.AlignCenter)
     self.box2.setLayout(hLayout)
예제 #2
0
    def initUI(self):
        self.setWindowTitle("查看回收站文件夹内容")
        self.form = QVBoxLayout()
        for item in iter(self.files):
            ico = QPushButton(set_file_icon(item.name), item.name)
            ico.setStyleSheet(
                "QPushButton {border:none; background:transparent; color:black;}"
            )
            ico.adjustSize()
            it = QLabel(f"<font color='#CCCCCC'>({item.size})</font>")
            hbox = QHBoxLayout()
            hbox.addWidget(ico)
            hbox.addStretch(1)
            hbox.addWidget(it)
            self.form.addLayout(hbox)

        self.form.setSpacing(10)
        self.buttonBox = QDialogButtonBox()
        self.buttonBox.setOrientation(Qt.Orientation.Horizontal)
        self.buttonBox.setStandardButtons(
            QDialogButtonBox.StandardButton.Close)
        self.buttonBox.button(
            QDialogButtonBox.StandardButton.Close).setText("关闭")
        self.buttonBox.setStyleSheet(btn_style)
        self.buttonBox.rejected.connect(self.reject)

        vbox = QVBoxLayout()
        vbox.addLayout(self.form)
        vbox.addStretch(1)
        vbox.addWidget(self.buttonBox)
        self.setLayout(vbox)
    def __init__(self, interactive_matching_widget):
        super(NuggetListWidget, self).__init__(interactive_matching_widget)
        self.interactive_matching_widget = interactive_matching_widget

        self.layout = QVBoxLayout(self)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setSpacing(10)

        # top widget
        self.top_widget = QWidget()
        self.top_layout = QHBoxLayout(self.top_widget)
        self.top_layout.setContentsMargins(0, 0, 0, 0)
        self.top_layout.setSpacing(10)
        self.layout.addWidget(self.top_widget)

        self.description = QLabel(
            "Below you see a list of guessed matches for you to confirm or correct."
        )
        self.description.setFont(LABEL_FONT)
        self.top_layout.addWidget(self.description)

        self.stop_button = QPushButton("Continue With Next Attribute")
        self.stop_button.setFont(BUTTON_FONT)
        self.stop_button.clicked.connect(self._stop_button_clicked)
        self.stop_button.setMaximumWidth(240)
        self.top_layout.addWidget(self.stop_button)

        # nugget list
        self.nugget_list = CustomScrollableList(self, NuggetListItemWidget)
        self.layout.addWidget(self.nugget_list)
예제 #4
0
class Window(QMainWindow):
    def __init__(self):
        super().__init__()
        self.width = 150
        self.height = 150
        self.xPos = 600
        self.yPos = 400
        self.initUI()

    def initUI(self):
        self.setGeometry(self.xPos, self.yPos, self.width, self.height)
        self.vBoxLayout = QVBoxLayout()

        self.canvas = Canvas(width=150,
                             height=150,
                             penColor=(21, 21, 21),
                             canvasColor=(245, 177, 66),
                             strokeWidth=5,
                             borderWidth=2,
                             borderColor=(21, 21, 21))
        self.vBoxLayout.addWidget(self.canvas,
                                  alignment=Qt.AlignmentFlag.AlignCenter)

        self.centralWidget = QWidget(self)
        self.centralWidget.setLayout(self.vBoxLayout)
        self.setCentralWidget(self.centralWidget)
        self.show()
예제 #5
0
class App(QDialog):
    def __init__(self):
        app = QApplication(sys.argv)
        super().__init__()
        self.setWindowTitle('PyQt6 Grid Layout')
        self.setGeometry(100, 100, 320, 100)
        self.CreateGridLayout()

        self.windowLayout = QVBoxLayout()
        self.windowLayout.addWidget(self.horizontalGroupBox)
        self.setLayout(self.windowLayout)

        self.show()
        sys.exit(app.exec())

    def CreateGridLayout(self):
        self.horizontalGroupBox = QGroupBox("Grid")
        self.layout = QGridLayout()
        self.layout.setColumnStretch(2, 4)
        self.layout.setColumnStretch(1, 4)

        for label in "123456789":
            self.MakeButton(label)

        self.horizontalGroupBox.setLayout(self.layout)

    def MakeButton(self, label):
        button = QPushButton(label)
        button.clicked.connect(lambda: self.on_click(button))
        self.layout.addWidget(button)

    def on_click(self, pushButton):
        print('PyQt5 {0} button clicked.'.format(pushButton.text()))
예제 #6
0
    def add_header_fields(self) -> None:
        layout: QLayout = QHBoxLayout()

        self.layout().addItem(layout)

        labels_layout: QLayout = QVBoxLayout()
        line_edits_layout: QLayout = QVBoxLayout()

        layout.addItem(labels_layout)
        layout.addItem(line_edits_layout)

        labels_layout.addWidget(QLabel("""Header File Name""", self))
        labels_layout.addWidget(
            QLabel("""Output Path (relative to root of project)""", self))

        line_edits_layout.addWidget(self.header_name_input)

        path_edit_layout: QLayout = QHBoxLayout()
        path_edit_layout.addWidget(self.header_output_path_input)
        path_edit_layout.addWidget(self.header_output_path_selector)

        path_edit_layout.setAlignment(self.header_output_path_selector,
                                      Qt.AlignmentFlag.AlignRight)

        self.header_output_path_selector.setFixedSize(QSize(25, 25))

        line_edits_layout.addItem(path_edit_layout)

        self.header_output_path_selector.clicked.connect(
            lambda: self.open_path_selection_dialog())
예제 #7
0
def startGUI():
    app = QApplication([])
    app.setStyle('Fusion')
    if opts.timeclockOpts["darkTheme"]:
        pass
    window = QWidget()
    window.setWindowTitle(opts.timeclockOpts["title"])
    window.setWindowIcon(
        QtGui.QIcon("../data/assets/" + opts.timeclockOpts["logo"]))
    mainLayout = QVBoxLayout()
    mainLayout.setSpacing(20)

    mainLayout.addLayout(makeTitle())

    global tabsObject
    tabsObject = makeNameArea()
    mainLayout.addWidget(tabsObject)
    updateNamesTable()

    mainLayout.addLayout(makeActions(app))

    window.setLayout(mainLayout)
    window.show()
    print("1024  x  768")
    print(window.width(), " x ", window.height())
    print("", 1024 - window.width(), "\t", 768 - window.height())
    app.exec()
예제 #8
0
    def initUI(self):
        self.setGeometry(self.xPos, self.yPos, self.width, self.height)
        self.vBoxLayout = QVBoxLayout()

        self.tagbox = TagBox()
        self.tagbox.addTag('Homelander')
        self.tagbox.addTag('Queen Maeve')
        self.tagbox.addTag('Black Noir')
        self.tagbox.addTag('Transluscent')
        self.tagbox.addTag('A-Train')
        self.tagbox.addTag('The Deep')
        self.vBoxLayout.addWidget(self.tagbox)

        self.tagEdit = QLineEdit()
        self.vBoxLayout.addWidget(self.tagEdit)

        self.addButton = QPushButton()
        self.addButton.setText('Add New Tag')
        self.addButton.clicked.connect(self.addNewTag)
        self.vBoxLayout.addWidget(self.addButton)

        self.centralWidget = QWidget(self)
        self.centralWidget.setLayout(self.vBoxLayout)
        self.setCentralWidget(self.centralWidget)
        self.show()
예제 #9
0
파일: test.py 프로젝트: alvii147/MangoUI
    def initUI(self):
        self.setGeometry(self.xPos, self.yPos, self.width, self.height)
        self.vBoxLayout = QVBoxLayout()
        
        self.button = Button(
            borderWidth = 1,
            borderRadius = 4,
        )
        self.button.setText('Default Button')
        self.vBoxLayout.addWidget(self.button)

        self.blueButton = Button(
            primaryColor  = (17, 46, 133),
            secondaryColor = (202, 209, 232),
            borderWidth = 1,
            borderRadius = 4,
        )
        self.blueButton.setText('Blue Button')
        self.vBoxLayout.addWidget(self.blueButton)

        self.redButton = Button(
            primaryColor  = (171, 3, 3),
            secondaryColor = (247, 173, 173),
            borderWidth = 1,
            borderRadius = 4,
        )
        self.redButton.setText('Red Button')
        self.vBoxLayout.addWidget(self.redButton)

        self.centralWidget = QWidget(self)
        self.centralWidget.setLayout(self.vBoxLayout)
        self.setCentralWidget(self.centralWidget)
        self.show()
예제 #10
0
    def __init__(self, parent, item_type, floating_widget=None):
        super(CustomScrollableList, self).__init__()
        self.parent = parent
        self.item_type = item_type
        self.floating_widget = floating_widget

        self.layout = QVBoxLayout(self)
        self.layout.setContentsMargins(0, 0, 0, 0)

        self.list_widget = QWidget()
        self.list_layout = QVBoxLayout(self.list_widget)
        self.list_layout.setContentsMargins(0, 0, 0, 0)
        self.list_layout.setSpacing(10)
        self.list_layout.setAlignment(Qt.AlignmentFlag.AlignTop)

        self.scroll_area = QScrollArea()
        self.scroll_area.setWidgetResizable(True)
        self.scroll_area.setFrameStyle(0)
        self.scroll_area.setWidget(self.list_widget)
        self.layout.addWidget(self.scroll_area)

        if self.floating_widget is not None:
            self.list_layout.addWidget(self.floating_widget)

        self.item_widgets = []
        self.num_visible_item_widgets = 0
예제 #11
0
    def __init__(
        self,
        onLoadLastMazePressed: Callable[[], None],
        onMazeLoadedFromPath: Callable[[str], None],
        onMazeSpecificationChosen: Callable[[MazeGenerationSpecification],
                                            None],
        parent: Optional[QWidget] = None,
        *args: Tuple[Any, Any],
        **kwargs: Tuple[Any, Any],
    ) -> None:
        """
        The view used for prompting the user to load, generate or load last maze.
        """
        super(MazeLoaderView, self).__init__(parent=parent, *args, **kwargs)
        self.setContentsMargins(0, 0, 0, 0)
        self.setWindowTitle("Load a Maze")

        self.__onLoadLastMazeChosen = onLoadLastMazePressed
        self.__onMazeFilePathChosen = onMazeLoadedFromPath
        self.__onMazeSpecificationChosen = onMazeSpecificationChosen

        # create layout
        layout = QVBoxLayout()

        # add all the buttons to the layout
        for button in self.__getButtons():
            layout.addWidget(button)

        self.setLayout(layout)
예제 #12
0
class AddDialog(QDialog):
    """Add Contact dialog."""

    def __init__(self, parent=None):
        """Initializer"""
        super().__init__(parent=parent)
        self.setWindowTitle("Add Contact")
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)
        self.data = None

        self.setupUI()

    def setupUI(self):
        """Setup the Add Contact dialog's GUI."""
        # Create line edits for data fields
        self.nameField = QLineEdit()
        self.nameField.setObjectName("Name")
        self.jobField = QLineEdit()
        self.jobField.setObjectName("Job")
        self.emailField = QLineEdit()
        self.emailField.setObjectName("Email")
        # Lay out the data fields
        layout = QFormLayout()
        layout.addrow("Name:", self.nameField)
        layout.addrow("Job:", self.jobField)
        layout.addrow("Email:", self.emailField)
        self.layout.addLayout(layout)
        # add standard buttons to the dialog and conntect them
        self.buttonsBox = QDialogButtonBox(self)
        self.buttonsBox.setOrientation(Qt.Horizontal)
        self.buttonsBox.setStandardButtons(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel
        )
        self.buttonsBox.accepted.connect(self.accept)
        self.buttonsBox.rejected.connect(self.reject)
        self.layout.addWidget(self.buttonsBox)

    def accept(self):
        """Accept the data provided through the dialog."""
        self.data = []
        for field in (self.nameField, self.jobField, self.emailField):
            if not field.text():
                QMessageBox.critical(
                    self,
                    "Error!",
                    f"You must provide a contact's{field.objectName()}",
                )
                self.data = None  # reset .data
                return

            self.data.append(field.text())

        if not self.data:
            return()

        super().accept()
예제 #13
0
    def __init__(self, parent=None):
        """Initializer"""
        super().__init__(parent=parent)
        self.setWindowTitle("Add Contact")
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)
        self.data = None

        self.setupUI()
예제 #14
0
    def initUI(self):
        self.setGeometry(self.xPos, self.yPos, self.width, self.height)
        self.vBoxLayout = QVBoxLayout()

        self.slider = Slider(
            direction=Qt.Orientation.Horizontal,
            duration=750,
            animationType=QEasingCurve.Type.OutQuad,
            wrap=False,
        )

        self.label1 = QLabel()
        self.label1.setText('First Slide')
        self.label1.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.label1.setStyleSheet(
            'QLabel{background-color: rgb(245, 177, 66); color: rgb(21, 21, 21); font: 25pt;}'
        )
        self.slider.addWidget(self.label1)

        self.label2 = QLabel()
        self.label2.setText('Second Slide')
        self.label2.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.label2.setStyleSheet(
            'QLabel{background-color: rgb(21, 21, 21); color: rgb(245, 177, 66); font: 25pt;}'
        )
        self.slider.addWidget(self.label2)

        self.label3 = QLabel()
        self.label3.setText('Third Slide')
        self.label3.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.label3.setStyleSheet(
            'QLabel{background-color: rgb(93, 132, 48); color: rgb(245, 177, 66); font: 25pt;}'
        )
        self.slider.addWidget(self.label3)

        self.buttonPrevious = QPushButton()
        self.buttonPrevious.setText('Previous Slide')
        self.buttonPrevious.clicked.connect(self.slider.slidePrevious)

        self.buttonNext = QPushButton()
        self.buttonNext.setText('Next Slide')
        self.buttonNext.clicked.connect(self.slider.slideNext)

        self.buttonLayout = QHBoxLayout()
        self.buttonLayout.addWidget(self.buttonPrevious)
        self.buttonLayout.addWidget(self.buttonNext)

        self.vBoxLayout.addWidget(self.slider)
        self.vBoxLayout.addLayout(self.buttonLayout)

        self.centralWidget = QWidget(self)
        self.centralWidget.setLayout(self.vBoxLayout)
        self.setCentralWidget(self.centralWidget)

        self.show()
예제 #15
0
    def InitWindow(self):
        self.setWindowIcon(QtGui.QIcon("home.png"))
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        self.createLayout()
        vbox = QVBoxLayout()
        vbox.addWidget(self.groupBox)
        self.setLayout(vbox)

        self.show()
예제 #16
0
    def __init__(self, main_window, header_text):
        super(MainWindowContent, self).__init__()
        self.main_window = main_window

        self.layout = QVBoxLayout(self)
        self.layout.setContentsMargins(10, 5, 10, 5)
        self.layout.setAlignment(Qt.AlignmentFlag.AlignTop)
        self.layout.setSpacing(20)

        self.header = QLabel(header_text)
        self.header.setFont(HEADER_FONT)
        self.layout.addWidget(self.header)
예제 #17
0
    def __init__(self):
        app = QApplication(sys.argv)
        super().__init__()
        self.setWindowTitle('PyQt6 Horizontal Layout')
        self.setGeometry(100, 100, 400, 100)
        self.CreateHorizontalLayout()

        windowLayout = QVBoxLayout()
        windowLayout.addWidget(self.horizontalGroupBox)
        self.setLayout(windowLayout)
        self.show()
        sys.exit(app.exec())
예제 #18
0
    def __init__(self, main_window_content, sub_header_text):
        super(MainWindowContentSection, self).__init__()
        self.main_window_content = main_window_content

        self.layout = QVBoxLayout(self)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setAlignment(Qt.AlignmentFlag.AlignTop)
        self.layout.setSpacing(10)

        self.sub_header = QLabel(sub_header_text)
        self.sub_header.setFont(SUBHEADER_FONT)
        self.layout.addWidget(self.sub_header)
예제 #19
0
 def _setupUi(self):
     """Create UI elements."""
     self.vbox = QVBoxLayout()
     self.vbox.setObjectName(self.player.title + "BoxVertLayout")
     self.grid = QGridLayout()
     self.grid.setObjectName(self.player.title + "BoxCardPicsLayout")
     self.hbox = QHBoxLayout()
     self.hbox.setObjectName(self.player.title + "BoxHorizLayout")
     self.vbox.addLayout(self.hbox)
     self.vbox.addLayout(self.grid)
     self.setLayout(self.vbox)
     self._setupLabels()
     self._setupCards()
    def __init__(self):
        """ Dialog to manage the settings of the application """
        super().__init__()
        self.setWindowTitle("Settings")
        self.setFixedSize(310, 250)

        # Create the general settings widgets for managing the text color,
        # text alignment, and author of the app's content
        # NOTE: Altering the default CSS attributes, such as the color, of a
        # widget can change its appearance. Hence, the button may appear
        # rectangular depending upon your platform
        self.text_color_button = QPushButton()
        self.text_color_button.setStyleSheet(
            "background-color: #000000")  # Black
        self.text_color_button.clicked.connect(self.selectTextColor)

        self.align_left = QRadioButton(text="Left")  # Default
        self.align_left.setChecked(True)
        self.align_center = QRadioButton(text="Center")
        self.align_center.setChecked(False)
        self.align_right = QRadioButton(text="Right")
        self.align_right.setChecked(False)

        # Layout and container for alignment radio buttons
        align_v_box = QVBoxLayout()
        align_v_box.setContentsMargins(0, 5, 0, 0)
        align_v_box.addWidget(self.align_left)
        align_v_box.addWidget(self.align_center)
        align_v_box.addWidget(self.align_right)

        align_frame = QFrame()
        align_frame.setFrameShape(QFrame.Shape.NoFrame)
        align_frame.setLayout(align_v_box)

        self.author_name = QLineEdit()
        self.author_name.setMinimumWidth(160)

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

        dialog_layout = QFormLayout()
        dialog_layout.addRow("<b>Text Color:</b>", self.text_color_button)
        dialog_layout.addRow(HorizontalSeparator())
        dialog_layout.addRow("<b>Text Alignment:</b>", align_frame)
        dialog_layout.addRow(HorizontalSeparator())
        dialog_layout.addRow("<b>Author:</b>", self.author_name)
        dialog_layout.addWidget(self.button_box)
        self.setLayout(dialog_layout)
예제 #21
0
    def InitWindow(self):
        self.setWindowIcon(QtGui.QIcon(self.iconName))
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        vbox = QVBoxLayout()
        labelImage = QLabel(self)
        pixmap = QPixmap("resources/pyqt5_image_window-300x180.png")
        labelImage.setPixmap(pixmap)
        vbox.addWidget(labelImage)

        self.setLayout(vbox)

        self.show()
예제 #22
0
    def __init__(
        self,
        parent: Optional[QWidget] = None,
        *args: Tuple[Any, Any],
        **kwargs: Tuple[Any, Any],
    ) -> None:
        """
        The log layout consisting of, for each command:
            Left: Command name
            Right: Command result
        """
        super(VerticalLogLayout, self).__init__(parent=parent, *args, **kwargs)
        # set layout and add placeholder layouts to ensure they aren't automatically destroyed later
        layout = QHBoxLayout()

        self.__commandNames.append("Command name")
        self.__commandResults.append("Result")

        commandNamesBox = QVBoxLayout()
        commandResultsBox = QVBoxLayout()

        # add the human descriptions text to the layouts
        for i in range(0, len(self.__commandNames)):
            commandNamesBox.addWidget(QLabel(self.__commandNames[i]))
            commandResultsBox.addWidget(QLabel(self.__commandResults[i]))

        layout.addLayout(commandNamesBox)
        layout.addLayout(commandResultsBox)

        # remember to set the layout!
        self.setLayout(layout)
예제 #23
0
    def createApp(self):
        self.layout = QVBoxLayout()

        self.tabBar = QTabBar()

        self.tabBar.addTab("Tab 1")
        self.tabBar.addTab("Tab 2")

        self.tabBar.setCurrentIndex(0)

        self.layout.addWidget(self.tabBar)
        self.setLayout(self.layout)

        self.show()
예제 #24
0
    def __init__(self):
        super().__init__()
        self.setWindowTitle('PyQt6 Table Example')
        self.setGeometry(100, 100, 800, 600)
        #
        # Create a table, create a box layout, add the table to box layout and
        # then set the overall widget layout to the box layout.
        #
        self.createTable()
        self.layout = QVBoxLayout()
        self.layout.addWidget(self.tableWidget)
        self.setLayout(self.layout)

        self.show()
예제 #25
0
파일: pycalc.py 프로젝트: imssyang/python3
 def __init__(self):
     """View initializer."""
     super().__init__()
     # Set some main window's properties
     self.setWindowTitle("PyCalc")
     self.setFixedSize(235, 235)
     # Set the central widget and the general layout
     self.generalLayout = QVBoxLayout()
     self._centralWidget = QWidget(self)
     self.setCentralWidget(self._centralWidget)
     self._centralWidget.setLayout(self.generalLayout)
     # Create the display and the buttons
     self._createDisplay()
     self._createButtons()
예제 #26
0
class Settings(QDialog):
    """Open new window with editable options that effect gameplay."""
    def __init__(self, parent=None, window=None):
        """Construct Settings Dialog.

        Args:
            parent (QWidget, optional) Parent widget object. Defaults to None.
            window (QWidget, optional) Program's MainWindow. Defaults to None.
        """
        super().__init__(parent=parent)
        self.setObjectName("Preferences")
        self.window = window
        self.setSizeGripEnabled(False)
        self.setObjectName("Settings")
        self.setWindowTitle("Preferences")
        self.setModal(True)
        self.vlayout = QVBoxLayout()
        self.setLayout(self.vlayout)
        self.playersLabel = QLabel("Number of Players", parent=self)
        self.decksLabel = QLabel("Number of Decks", parent=self)
        self.playersSpin = QSpinBox(parent=self)
        self.decksSpin = QSpinBox(parent=self)
        self.hLayout1 = QHBoxLayout()
        self.hLayout2 = QHBoxLayout()
        self.hLayout1.addWidget(self.playersLabel)
        self.hLayout1.addWidget(self.playersSpin)
        self.hLayout2.addWidget(self.decksLabel)
        self.hLayout2.addWidget(self.decksSpin)
        self.vlayout.addLayout(self.hLayout1)
        self.vlayout.addLayout(self.hLayout2)
        self.hLayout3 = QHBoxLayout()
        self.okayButton = QPushButton("Submit", parent=self)
        self.cancelButton = QPushButton("Cancel", parent=self)
        self.hLayout3.addWidget(self.okayButton)
        self.hLayout3.addWidget(self.cancelButton)
        self.vlayout.addLayout(self.hLayout3)
        self.okayButton.pressed.connect(self.accept)
        self.cancelButton.pressed.connect(self.reject)
        self.finished.connect(self.finishedSignal)

    def accept(self):
        """Close Window."""
        return self.window.driver.reset_prefs(self.decksSpin.value(),
                                              self.playersSpin.value())

    def finishedSignal(self):
        """When Settings Window returns accept or reject signals."""
        self.window.dealer.deck_count = self.decksSpin.value()
        self.window.dealer.player_count = self.playersSpin.value()
예제 #27
0
    def initUI(self):

        lcd = QLCDNumber(self)
        sld = QSlider(Qt.Orientation.Horizontal, self)

        vbox = QVBoxLayout()
        vbox.addWidget(lcd)
        vbox.addWidget(sld)

        self.setLayout(vbox)
        sld.valueChanged.connect(lcd.display)

        self.setGeometry(300, 300, 350, 250)
        self.setWindowTitle('Signal and slot')
        self.show()
    def __init__(
        self,
        onPlayButtonPressed: Callable[[], None],
        onPauseButtonPressed: Callable[[], None],
        onStepButtonPressed: Callable[[], None],
        onRestartButtonPressed: Callable[[], None],
        onSpeedControlValueChanged: Callable[[int], None],
        onOpenLogButtonPressed: Callable[[], None],
        onAgentVarsButtonPressed: Callable[[], None],
        parent: Optional[QWidget] = None,
        *args: Tuple[Any, Any],
        **kwargs: Tuple[Any, Any],
    ) -> None:
        """
        The "Solver Controls…" dropdown view of the solver controls for the active solver
        """
        super(SolverControlsView, self).__init__(parent=parent,
                                                 *args,
                                                 **kwargs)
        self.setContentsMargins(0, 0, 0, 0)

        layout = QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        self.__stateControlBoxView = SolverControlButtonsView(
            onPlayButtonPressed=onPlayButtonPressed,
            onPauseButtonPressed=onPauseButtonPressed,
            onStepButtonPressed=onStepButtonPressed,
            onRestartButtonPressed=onRestartButtonPressed,
            parent=self,
        )

        self.__speedControl = MazeSolverSpeedControlView(
            onValueChanged=onSpeedControlValueChanged,
            parent=self,
        )

        self.__solverWindowsButtons = SolverWindowsButtonsView(
            onOpenLogButtonPressed=onOpenLogButtonPressed,
            onAgentVarsButtonPressed=onAgentVarsButtonPressed,
            parent=self,
        )

        layout.addWidget(self.__stateControlBoxView)
        layout.addWidget(self.__speedControl)
        layout.addWidget(self.__solverWindowsButtons)

        self.setLayout(layout)
예제 #29
0
    def initUI(self):
        self.setWindowTitle("确认删除")
        self.setWindowIcon(QIcon(SRC_DIR + "delete.ico"))
        self.layout = QVBoxLayout()
        self.list_view = QListView()
        self.list_view.setViewMode(QListView.ViewMode.ListMode)
        # 列表
        self.slm = QStandardItem()
        self.model = QStandardItemModel()
        max_len = 10
        count = 0
        for info in self.infos:
            if info.is_file:  # 文件
                self.model.appendRow(
                    QStandardItem(set_file_icon(info.name), info.name))
            else:
                self.model.appendRow(
                    QStandardItem(QIcon(SRC_DIR + "folder.gif"), info.name))
            self.out.append({
                'fid': info.id,
                'is_file': info.is_file,
                'name': info.name
            })  # id,文件标示, 文件名
            count += 1
            if max_len < len(info.name):  # 使用最大文件名长度
                max_len = len(info.name)
        self.list_view.setModel(self.model)

        self.lb_name = QLabel("尝试删除以下{}个文件(夹):".format(count))
        self.buttonBox = QDialogButtonBox()
        self.buttonBox.setOrientation(Qt.Orientation.Horizontal)
        self.buttonBox.setStandardButtons(
            QDialogButtonBox.StandardButton.Ok
            | QDialogButtonBox.StandardButton.Cancel)
        self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setText("确定")
        self.buttonBox.button(
            QDialogButtonBox.StandardButton.Cancel).setText("取消")

        self.layout.addWidget(self.lb_name)
        self.layout.addWidget(self.list_view)
        self.layout.addWidget(self.buttonBox)
        self.setLayout(self.layout)

        self.buttonBox.accepted.connect(self.btn_ok)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
        self.setMinimumWidth(400)
        self.resize(int(max_len * 8), int(count * 34 + 60))
예제 #30
0
파일: gui.py 프로젝트: kovidgoyal/vise
 def setup_ui(self):
     self.l = l = QVBoxLayout(self)
     self.splitter = s = QSplitter(self)
     l.addWidget(s)
     self.ab = b = self.bb.addButton(_('Add new account'),
                                     QDialogButtonBox.ButtonRole.ActionRole)
     b.clicked.connect(self.add_account)
     l.addWidget(self.bb)
     self.accounts = a = QListWidget(self)
     a.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove)
     self.edit_account = e = EditAccount(self)
     e.changed.connect(self.data_changed)
     e.delete_requested.connect(self.delete_requested)
     s.addWidget(a), s.addWidget(e)
     for n, account in enumerate(self.db[self.key]['accounts']):
         if n == 0:
             e.data = account
         i = QListWidgetItem(account['username'], a)
         i.setData(Qt.ItemDataRole.UserRole, account)
     if a.count() < 1:
         na = {'username': '', 'password': '', 'notes': ''}
         i = QListWidgetItem('', a)
         i.setData(Qt.ItemDataRole.UserRole, na)
     a.setCurrentRow(0)
     a.currentItemChanged.connect(self.current_item_changed)