Ejemplo n.º 1
0
        def __init__(self, parent=None):
            QToolButton.__init__(self)
            self.setParent(parent)\

            # Set the layout of the button
            layout = QGridLayout()

            # Button formatting
            self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
            self.setAutoRaise(True)

            # Icon part of the button
            self.icon = QLabel()
            self.icon.setAlignment(Qt.AlignCenter)
            self.icon.setSizePolicy(QSizePolicy.Expanding,
                                    QSizePolicy.Expanding)
            self.iconPixmap = QPixmap()

            # Text part of the button
            # Initialise label
            self.text = QLabel()
            self.text.setAlignment(Qt.AlignBottom)
            # TODO: Change colour with universal theme
            self.text.setStyleSheet("color: white")
            # Add font styling
            font = QFont()
            font.setPixelSize(15)
            self.text.setFont(font)

            # Add components to the layer
            layout.addWidget(self.icon, 0, 0, 3, 3)
            layout.addWidget(self.text, 2, 0, 1, 3)
            self.setLayout(layout)
Ejemplo n.º 2
0
    def load_game_list(self, game_layout: QGridLayout):
        while game_layout.count():
            child = game_layout.takeAt(0)
            if child.widget():
                child.widget().deleteLater()
        games = self.all_displays
        all_entries = iter_entry_points('zero_play.game_display')
        filtered_entries = self.filter_games(all_entries)
        for game_entry in filtered_entries:
            display_class = game_entry.load()
            display: GameDisplay = display_class()
            self.destroyed.connect(display.close)  # type: ignore
            display.game_ended.connect(self.on_game_ended)  # type: ignore
            games.append(display)
        games.sort(key=attrgetter('start_state.game_name'))
        column_count = math.ceil(math.sqrt(len(games)))
        for i, display in enumerate(games):
            row = i // column_count
            column = i % column_count
            game_name = display.start_state.game_name
            game_button = QPushButton(game_name)
            game_button.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)

            game_button.clicked.connect(
                partial(
                    self.show_game,  # type: ignore
                    display))
            game_layout.addWidget(game_button, row, column)

            self.ui.history_game.addItem(game_name, userData=display)

            if display.rules_path is not None:
                game_rules_action = self.ui.menu_rules.addAction(game_name)
                game_rules_action.triggered.connect(
                    partial(self.on_rules, display))
Ejemplo n.º 3
0
    def __init__(self, parent=None):
        super().__init__(parent)

        layout_map = [
            [None, None, Symbol.CLEAR, Symbol.ALL_CLEAR],
            [Symbol.SEVEN, Symbol.EIGHT, Symbol.NINE, Symbol.DIVISION],
            [Symbol.FOUR, Symbol.FIVE, Symbol.SIX, Symbol.MULTIPLICATION],
            [Symbol.ONE, Symbol.TWO, Symbol.THREE, Symbol.SUBTRACTION],
            [Symbol.ZERO, Symbol.POINT, Symbol.EQUALS, Symbol.ADDITION]
        ]

        layout = QGridLayout()

        for row, columns in enumerate(layout_map):
            for column, symbol in enumerate(columns):
                if symbol is None:
                    continue
                button = QPushButton(symbol.value)
                button.clicked.connect(partial(self.button_clicked.emit, symbol))
                layout.addWidget(button, row, column)
                shortcut = QShortcut(QKeySequence(symbol.value), self)
                shortcut.activated.connect(button.click)

                alt_shortcut = None

                if symbol == Symbol.MULTIPLICATION:
                    alt_shortcut = QShortcut(QKeySequence('*'), self)
                elif symbol == Symbol.EQUALS:
                    alt_shortcut = QShortcut(QKeySequence.InsertParagraphSeparator, self)

                if alt_shortcut:
                    alt_shortcut.activated.connect(button.click)

        self.setLayout(layout)
Ejemplo n.º 4
0
    def init_ui(self):
        self.setFixedSize(400, 180)
        self.move2center()

        content = ([] if 'darwin' not in sys.platform else [
            'Press Cmd + r to speed up(refresh)',
            'Press Cmd + , to open settings',
            'Press Cmd + q to quit',
        ])

        content.append(f'Version {VERSION}')

        grid = QGridLayout()
        grid.setSpacing(10)

        a_tag = '''
        <a href="https://ukiyoesoragoto.com" style="color:Black">
            By UkiyoESoragoto (๑•̀ㅂ•́)و✧
        </a>
        '''
        lab = QLabel(a_tag)
        lab.setOpenExternalLinks(True)
        grid.addWidget(lab, 0, 0)
        for index, line in enumerate(content):
            grid.addWidget(QLabel(line), index + 1, 0)

        self.setLayout(grid)

        self.setWindowTitle('About')
Ejemplo n.º 5
0
    def __init__(self):
        super(Window, self).__init__()

        aliasedLabel = self.createLabel("Aliased")
        antialiasedLabel = self.createLabel("Antialiased")
        intLabel = self.createLabel("Int")
        floatLabel = self.createLabel("Float")

        layout = QGridLayout()
        layout.addWidget(aliasedLabel, 0, 1)
        layout.addWidget(antialiasedLabel, 0, 2)
        layout.addWidget(intLabel, 1, 0)
        layout.addWidget(floatLabel, 2, 0)

        timer = QTimer(self)

        for i in range(2):
            for j in range(2):
                w = CircleWidget()
                w.setAntialiased(j != 0)
                w.setFloatBased(i != 0)

                timer.timeout.connect(w.nextAnimationFrame)

                layout.addWidget(w, i + 1, j + 1)

        timer.start(100)
        self.setLayout(layout)

        self.setWindowTitle("Concentric Circles")
Ejemplo n.º 6
0
class Board(QWidget):  # pylint: disable=R0903
    """The board widge"""
    def __init__(self, board_size: int = 4) -> None:
        """
        Creates a 2048 board
        Args:
            board (Table[Table[int]]) = The 2048 game board

        Returns (QtWidgets.QWidget) = The game board as qt widget
        """
        super().__init__()
        self.board = QGridLayout(self)
        self.board_size = 100
        self._font_size = round(self.board_size / 5)
        self._default_bg_color = COLORSET_2[0]
        self._default_color = "#" + contrasting_text_color(
            self._default_bg_color[1:])
        self.__create_cells(board_size)

    @Slot(MoveResult)
    def update_cells(self, move_result: MoveResult) -> None:
        """update the cells with the new board data"""
        for y_position, row in enumerate(move_result["board"]):
            for x_position, value in enumerate(row):
                cell = self.board.itemAtPosition(y_position,
                                                 x_position).widget()
                self._update_cell(cell, value)

    def _update_cell(self, cell: QWidget, value: int):
        cell_label = cell.findChild(QLabel)
        cell_text = str(value).strip("0")
        cell_label.setText(cell_text)
        bg_color = COLORSET_2[
            value] if value in COLORSET_2 else self._default_bg_color
        font_color = "#" + contrasting_text_color(bg_color[1:])
        cell.setStyleSheet(f"background-color:{bg_color}; color:{font_color};")

    def __create_cells(self, board_size: int):
        size_range = range(board_size)
        for y_position in size_range:
            for x_position in size_range:
                cell = self.__create_cell()
                self.board.addWidget(cell, y_position, x_position,
                                     Qt.AlignCenter)

    def __create_cell(self) -> QWidget:
        cell_label = QLabel()
        cell_label.setAlignment(Qt.AlignCenter)
        cell_label.setStyleSheet("QLabel {font-size: " + str(self._font_size) +
                                 "px;}")
        cell_content = QHBoxLayout()
        cell_content.addWidget(cell_label)
        cell = QWidget()
        cell.setLayout(cell_content)
        cell.setStyleSheet(
            f"background-color:{self._default_bg_color}; color:{self._default_color};"
        )
        cell.setFixedSize(self.board_size, self.board_size)
        return cell
Ejemplo n.º 7
0
    def initUI(self):
        """
        Init widget

        """
        vbox = QVBoxLayout()
        vbox.addSpacing(2)

        # Head
        hbox = QHBoxLayout()
        hbox.addSpacing(3)

        # Create button which returns to the menu
        self._buttonBack = QPushButton(QIcon(PATH_IMAGE_BACK_NEDDLE), "", self)
        self._buttonBack.clicked.connect(self.signalController.back2menu)
        hbox.addWidget(self._buttonBack, 0, QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)

        # Header of this widget
        self._headWidget = QLabel("Add new figure")
        hbox.addWidget(self._headWidget, 1, QtCore.Qt.AlignCenter | QtCore.Qt.AlignTop)

        # Create button to choose color of new figure
        self._pickColorButton = QPushButton('Pick color')
        self._pickColorButton.clicked.connect(self.update_color_name)
        hbox.addWidget(self._pickColorButton, 2, QtCore.Qt.AlignRight | QtCore.Qt.AlignTop)

        # Create button to save figure
        self._saveFigureButton = QPushButton('Save')
        self._saveFigureButton.clicked.connect(self.save_figure_shape)
        hbox.addWidget(self._saveFigureButton, 2, QtCore.Qt.AlignRight | QtCore.Qt.AlignTop)

        vbox.addLayout(hbox, 0)

        grid = QGridLayout()
        self._sheet = []
        self._choosenFigureList = []
        self._proposedFiguresList = []
        self._savedColor = 'black'

        for i in range(self.MAX_X):
            row = []
            for j in range(self.MAX_Y):
                single = DrawBlockQFrame(self.signalPressedFrames, j, i)
                if i == 3 and j == 3:
                    # Button in the center - must be with blur color
                    # Save figure - possible only if blue button also clicked
                    # This magic stuff are made in order to simplify saving figure
                    single.COLOR_DEFAULT = 'blue'
                    single.default_color()
                    self.centerSheet = single
                row.append(single)
                grid.addWidget(single, i, j)

            self._sheet.append(row)

        vbox.addLayout(grid, 1)

        self.setLayout(vbox)
        self.setWindowTitle("Add new figure")
Ejemplo n.º 8
0
class Page3Widget(QWidget):
    def __init__(self):
        super().__init__()

        self.line_edit = QLineEdit()

        self.layout = QGridLayout(self)
        self.layout.addWidget(self.line_edit)
Ejemplo n.º 9
0
class TableWidget(QWidget):
    def __init__(self):
        QWidget.__init__(self)

        self.model = CustomTableModel()

        self.table_view = QTableView()
        self.table_view.setModel(self.model)
        self.table_view.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
        self.table_view.verticalHeader().setSectionResizeMode(QHeaderView.Stretch)

        self.chart = QtCharts.QChart()
        self.chart.setAnimationOptions(QtCharts.QChart.AllAnimations)

        self.series = QtCharts.QLineSeries()
        self.series.setName("Line 1")
        self.mapper = QtCharts.QVXYModelMapper(self)
        self.mapper.setXColumn(0)
        self.mapper.setYColumn(1)
        self.mapper.setSeries(self.series)
        self.mapper.setModel(self.model)
        self.chart.addSeries(self.series)

        # for storing color hex from the series
        seriesColorHex = "#000000"

        # get the color of the series and use it for showing the mapped area
        seriesColorHex = "{}".format(self.series.pen().color().name())
        self.model.add_mapping(seriesColorHex, QRect(0, 0, 2, self.model.rowCount()))

        # series 2
        self.series = QtCharts.QLineSeries()
        self.series.setName("Line 2")

        self.mapper = QtCharts.QVXYModelMapper(self)
        self.mapper.setXColumn(2)
        self.mapper.setYColumn(3)
        self.mapper.setSeries(self.series)
        self.mapper.setModel(self.model)
        self.chart.addSeries(self.series)

        # get the color of the series and use it for showing the mapped area
        seriesColorHex = "{}".format(self.series.pen().color().name())
        self.model.add_mapping(seriesColorHex, QRect(2, 0, 2, self.model.rowCount()))

        self.chart.createDefaultAxes()
        self.chart_view = QtCharts.QChartView(self.chart)
        self.chart_view.setRenderHint(QPainter.Antialiasing)
        self.chart_view.setMinimumSize(640, 480)

        # create main layout
        self.main_layout = QGridLayout()
        self.main_layout.addWidget(self.table_view, 1, 0)
        self.main_layout.addWidget(self.chart_view, 1, 1)
        self.main_layout.setColumnStretch(1, 1)
        self.main_layout.setColumnStretch(0, 0)
        self.setLayout(self.main_layout)
Ejemplo n.º 10
0
 def __init__(self):
     super(Window, self).__init__()
     self.tabs = QTabWidget(self)
     # self.tabs.setTabsClosable(True)
     layout = QGridLayout(self)
     layout.addWidget(self.tabs, 0, 0, 1, 2)
     self.tab1 = Homepage()
     self.tabs.addTab(self.tab1, "Home")
     self.tab2 = savedpage()
     self.tabs.addTab(self.tab2, "Saved")
Ejemplo n.º 11
0
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.resize(353, 223)
        self.actionsetting = QAction(MainWindow)
        self.actionsetting.setObjectName(u"actionsetting")
        self.actionabout = QAction(MainWindow)
        self.actionabout.setObjectName(u"actionabout")
        self.actionimg_convert = QAction(MainWindow)
        self.actionimg_convert.setObjectName(u"actionimg_convert")
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")
        self.gridLayout_4 = QGridLayout(self.centralwidget)
        self.gridLayout_4.setObjectName(u"gridLayout_4")
        self.gridLayout_3 = QGridLayout()
        self.gridLayout_3.setObjectName(u"gridLayout_3")
        self.stackedWidget = QStackedWidget(self.centralwidget)
        self.stackedWidget.setObjectName(u"stackedWidget")
        self.stackedWidget.setMinimumSize(QSize(0, 0))

        self.gridLayout_3.addWidget(self.stackedWidget, 0, 0, 1, 1)


        self.gridLayout_4.addLayout(self.gridLayout_3, 0, 0, 1, 1)

        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(MainWindow)
        self.menubar.setObjectName(u"menubar")
        self.menubar.setGeometry(QRect(0, 0, 353, 22))
        self.menuabout = QMenu(self.menubar)
        self.menuabout.setObjectName(u"menuabout")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(MainWindow)
        self.statusbar.setObjectName(u"statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.menubar.addAction(self.menuabout.menuAction())
        self.menuabout.addAction(self.actionabout)

        self.retranslateUi(MainWindow)

        self.stackedWidget.setCurrentIndex(-1)


        QMetaObject.connectSlotsByName(MainWindow)
    # setupUi

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"Waifu2x-GUI", None))
        self.actionsetting.setText(QCoreApplication.translate("MainWindow", u"setting", None))
        self.actionabout.setText(QCoreApplication.translate("MainWindow", u"about", None))
        self.actionimg_convert.setText(QCoreApplication.translate("MainWindow", u"img convert", None))
        self.menuabout.setTitle(QCoreApplication.translate("MainWindow", u"\u5de5\u5177", None))
Ejemplo n.º 12
0
class Ui_UpdateQuotesDlg(object):
    def setupUi(self, UpdateQuotesDlg):
        if not UpdateQuotesDlg.objectName():
            UpdateQuotesDlg.setObjectName(u"UpdateQuotesDlg")
        UpdateQuotesDlg.setWindowModality(Qt.ApplicationModal)
        UpdateQuotesDlg.resize(256, 107)
        self.gridLayout = QGridLayout(UpdateQuotesDlg)
        self.gridLayout.setObjectName(u"gridLayout")
        self.StartDateLbl = QLabel(UpdateQuotesDlg)
        self.StartDateLbl.setObjectName(u"StartDateLbl")

        self.gridLayout.addWidget(self.StartDateLbl, 0, 0, 1, 1)

        self.StartDateEdit = QDateEdit(UpdateQuotesDlg)
        self.StartDateEdit.setObjectName(u"StartDateEdit")
        self.StartDateEdit.setCalendarPopup(True)
        self.StartDateEdit.setTimeSpec(Qt.UTC)

        self.gridLayout.addWidget(self.StartDateEdit, 0, 1, 1, 1)

        self.buttonBox = QDialogButtonBox(UpdateQuotesDlg)
        self.buttonBox.setObjectName(u"buttonBox")
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)

        self.gridLayout.addWidget(self.buttonBox, 2, 1, 1, 1)

        self.EndDateLbl = QLabel(UpdateQuotesDlg)
        self.EndDateLbl.setObjectName(u"EndDateLbl")

        self.gridLayout.addWidget(self.EndDateLbl, 1, 0, 1, 1)

        self.EndDateEdit = QDateEdit(UpdateQuotesDlg)
        self.EndDateEdit.setObjectName(u"EndDateEdit")
        self.EndDateEdit.setCalendarPopup(True)
        self.EndDateEdit.setTimeSpec(Qt.UTC)

        self.gridLayout.addWidget(self.EndDateEdit, 1, 1, 1, 1)


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

        QMetaObject.connectSlotsByName(UpdateQuotesDlg)
    # setupUi

    def retranslateUi(self, UpdateQuotesDlg):
        UpdateQuotesDlg.setWindowTitle(QCoreApplication.translate("UpdateQuotesDlg", u"Update asset's quotes", None))
        self.StartDateLbl.setText(QCoreApplication.translate("UpdateQuotesDlg", u"Start date", None))
        self.StartDateEdit.setDisplayFormat(QCoreApplication.translate("UpdateQuotesDlg", u"dd/MM/yyyy", None))
        self.EndDateLbl.setText(QCoreApplication.translate("UpdateQuotesDlg", u"End date", None))
        self.EndDateEdit.setDisplayFormat(QCoreApplication.translate("UpdateQuotesDlg", u"dd/MM/yyyy", None))
Ejemplo n.º 13
0
	def __init__(self, parent, data):
		super(SegmentsWidget, self).__init__(parent)

		layout = QGridLayout()
		layout.setContentsMargins(0, 0, 0, 0)
		layout.setVerticalSpacing(1)
		layout.setHorizontalSpacing(UIContext.getScaledWindowSize(16, 16).width())

		self.segments = []
		for segment in data.segments:
			if segment.readable or segment.writable or segment.executable:
				self.segments.append(segment)
		self.segments.sort(key = lambda segment: segment.start)

		row = 0
		for segment in self.segments:
			begin = "0x%x" % segment.start
			end = "0x%x" % segment.end

			permissions = ""
			if segment.readable:
				permissions += "r"
			else:
				permissions += "-"
			if segment.writable:
				permissions += "w"
			else:
				permissions += "-"
			if segment.executable:
				permissions += "x"
			else:
				permissions += "-"

			rangeLayout = QHBoxLayout()
			rangeLayout.setContentsMargins(0, 0, 0, 0)
			beginLabel = headers.ClickableAddressLabel(begin)
			dashLabel = QLabel("-")
			dashLabel.setFont(binaryninjaui.getMonospaceFont(self))
			endLabel = headers.ClickableAddressLabel(end)
			rangeLayout.addWidget(beginLabel)
			rangeLayout.addWidget(dashLabel)
			rangeLayout.addWidget(endLabel)
			layout.addLayout(rangeLayout, row, 0)

			permissionsLabel = QLabel(permissions)
			permissionsLabel.setFont(binaryninjaui.getMonospaceFont(self))
			layout.addWidget(permissionsLabel, row, 1)

			row += 1

		layout.setColumnStretch(2, 1)
		self.setLayout(layout)
Ejemplo n.º 14
0
    def __init__(self, parent: Optional[QWidget] = None, size: QSize = QSize(600, 600), image: Optional[QImage] = None):
        super(CLusterPreviewWindow, self).__init__(parent)
        self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint)
        self.resize(size)

        self.imageLabel = QLabel("Cluster Preview", self)
        self.imageLabel.setAlignment(Qt.AlignCenter)

        layout = QGridLayout(self)
        layout.addWidget(self.imageLabel)

        if image is not None:
            self.__update_cluster_preview(QPixmap.fromImage(image))
Ejemplo n.º 15
0
    def __init__(self, parent, start, stop):
        super().__init__(parent)
        self.setWindowTitle("Crop data")
        vbox = QVBoxLayout(self)
        grid = QGridLayout()
        self.start_checkbox = QCheckBox("Start time:")
        self.start_checkbox.setChecked(True)
        self.start_checkbox.stateChanged.connect(self.toggle_start)
        grid.addWidget(self.start_checkbox, 0, 0)
        self._start = QDoubleSpinBox()
        self._start.setMaximum(999999)
        self._start.setValue(start)
        self._start.setDecimals(2)
        self._start.setSuffix(" s")
        grid.addWidget(self._start, 0, 1)

        self.stop_checkbox = QCheckBox("Stop time:")
        self.stop_checkbox.setChecked(True)
        self.stop_checkbox.stateChanged.connect(self.toggle_stop)
        grid.addWidget(self.stop_checkbox, 1, 0)
        self._stop = QDoubleSpinBox()
        self._stop.setMaximum(999999)
        self._stop.setValue(stop)
        self._stop.setDecimals(2)
        self._stop.setSuffix(" s")
        grid.addWidget(self._stop, 1, 1)
        vbox.addLayout(grid)
        buttonbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        vbox.addWidget(buttonbox)
        buttonbox.accepted.connect(self.accept)
        buttonbox.rejected.connect(self.reject)
        vbox.setSizeConstraint(QVBoxLayout.SetFixedSize)
Ejemplo n.º 16
0
    def __init__(self, parent=None):
        QWidget.__init__(self)
        self.setParent(parent)
        
        # Set the colour of the overlay
        self.setStyleSheet("QWidget { background-color: rgba(255, 255, 255, 0.05)}")

        # Set OverlayTop heights
        # TODO: Change heights with increasing resolution
        self.setFixedHeight(50)

        # Create layout with margins/spacings
        layout = QGridLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)

        # Initialise MarqueeText
        self.marqueeText = self.MarqueeText(self)
        layout.addWidget(self.marqueeText, 0, 0, 2, 1)
        
        # Initialise search button
        self.initButton()
        layout.addWidget(self.button, 0, 1, 2, 1)

        # Initialise elapsedTime/localTime
        self.initTimes()
        layout.addWidget(self.elapsedTime, 0, 2, 1, 1)
        layout.addWidget(self.localTime, 1, 2, 1, 1)
        
        self.setLayout(layout)
Ejemplo n.º 17
0
    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)
Ejemplo n.º 18
0
 def user_map(self):
     """Slot to show user map from bgg to ludopedia"""
     user_map_dialog = QDialog(self)
     user_map_dialog.setModal(True)
     bgg_to_ludo = self.get_bgg_to_ludo_users()
     user_list = [f'{key} -> {value}' for key, value in bgg_to_ludo.items()]
     list_widget = QListWidget(user_map_dialog)
     list_widget.addItems(user_list)
     list_widget.setResizeMode(QListView.Adjust)
     list_widget.sortItems()
     grid_layout = QGridLayout(user_map_dialog)
     grid_layout.addWidget(list_widget, 1, 1)
     user_map_dialog.resize(400, 400)
     user_map_dialog.show()
Ejemplo n.º 19
0
    def __init__(self) -> None:
        super().__init__()

        main_layout = QGridLayout()
        button_box = self._create_button_box()
        main_layout.addWidget(self._create_options_group_box(), 0, 0)
        main_layout.addWidget(button_box, 1, 0)

        main_layout.setSizeConstraint(QLayout.SetMinimumSize)

        self.setLayout(main_layout)

        self._refresh_model_info()
        self.setWindowTitle('Predict')
        self._plot_window = QMainWindow()
Ejemplo n.º 20
0
    def __init__(self) -> None:
        super().__init__()

        self._pool = QThreadPool.globalInstance()

        self._init_options_group_box()
        self._init_button_box()

        main_layout = QGridLayout()
        main_layout.addWidget(self._options_group_box, 0, 0)
        main_layout.addWidget(self._button_box, 1, 0)
        main_layout.setSizeConstraint(QLayout.SetMinimumSize)

        self._main_layout = main_layout
        self.setLayout(self._main_layout)

        self.setWindowTitle('Train Model')
Ejemplo n.º 21
0
    def __init__(self, parent, compatibles, title="Append data"):
        super().__init__(parent)
        self.setWindowTitle(title)

        vbox = QVBoxLayout(self)
        grid = QGridLayout()

        grid.addWidget(QLabel("Source"), 0, 0, Qt.AlignCenter)
        grid.addWidget(QLabel("Destination"), 0, 2, Qt.AlignCenter)

        self.source = QListWidget(self)
        self.source.setAcceptDrops(True)
        self.source.setDragEnabled(True)
        self.source.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.source.setDefaultDropAction(Qt.DropAction.MoveAction)
        self.source.insertItems(0, [d["name"] for d in compatibles])
        grid.addWidget(self.source, 1, 0)

        self.move_button = QPushButton("→")
        self.move_button.setEnabled(False)
        grid.addWidget(self.move_button, 1, 1, Qt.AlignHCenter)

        self.destination = QListWidget(self)
        self.destination.setAcceptDrops(True)
        self.destination.setDragEnabled(True)
        self.destination.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.destination.setDefaultDropAction(Qt.DropAction.MoveAction)
        grid.addWidget(self.destination, 1, 2)
        vbox.addLayout(grid)

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

        vbox.addWidget(self.buttonbox)
        vbox.setSizeConstraint(QVBoxLayout.SetFixedSize)
        self.destination.model().rowsInserted.connect(self.toggle_ok_button)
        self.destination.model().rowsRemoved.connect(self.toggle_ok_button)
        self.source.itemSelectionChanged.connect(self.toggle_move_source)
        self.destination.itemSelectionChanged.connect(
            self.toggle_move_destination)
        self.move_button.clicked.connect(self.move)
        self.toggle_ok_button()
        self.toggle_move_source()
        self.toggle_move_destination()
Ejemplo n.º 22
0
    def __init__(self):
        super().__init__()
        self.setWindowTitle('嵌套布局示例')

        # 全局布局(1个):水平
        wlayout = QHBoxLayout()
        # 局部布局(4个):水平、竖直、网格、表单
        hlayout = QHBoxLayout()
        vlayout = QVBoxLayout()
        glayout = QGridLayout()
        formlayout = QFormLayout()

        # 局部布局添加部件(例如:按钮)
        hlayout.addWidget(QPushButton(str(1)))
        hlayout.addWidget(QPushButton(str(2)))
        vlayout.addWidget(QPushButton(str(3)))
        vlayout.addWidget(QPushButton(str(4)))
        glayout.addWidget(QPushButton(str(5)), 0, 0)
        glayout.addWidget(QPushButton(str(6)), 0, 1)
        glayout.addWidget(QPushButton(str(7)), 1, 0)
        glayout.addWidget(QPushButton(str(8)), 1, 1)
        formlayout.addWidget(QPushButton(str(9)))
        formlayout.addWidget(QPushButton(str(10)))
        formlayout.addWidget(QPushButton(str(11)))
        formlayout.addWidget(QPushButton(str(12)))

        # 准备四个部件
        hwg = QWidget()
        vwg = QWidget()
        gwg = QWidget()
        fwg = QWidget()

        # 四个部件设置局部布局
        hwg.setLayout(hlayout)
        vwg.setLayout(vlayout)
        gwg.setLayout(glayout)
        fwg.setLayout(formlayout)

        # 四个部件加至全局布局
        wlayout.addWidget(hwg)
        wlayout.addWidget(vwg)
        wlayout.addWidget(gwg)
        wlayout.addWidget(fwg)

        # 窗体本体设置全局布局
        self.setLayout(wlayout)
Ejemplo n.º 23
0
    def createOptionsGroupBox(self):
        self.optionsGroupBox = QGroupBox("Options")

        buttonsOrientationLabel = QLabel("Orientation of buttons:")

        buttonsOrientationComboBox = QComboBox()
        buttonsOrientationComboBox.addItem("Horizontal", Qt.Horizontal)
        buttonsOrientationComboBox.addItem("Vertical", Qt.Vertical)
        buttonsOrientationComboBox.currentIndexChanged[int].connect(
            self.buttonsOrientationChanged)

        self.buttonsOrientationComboBox = buttonsOrientationComboBox

        optionsLayout = QGridLayout()
        optionsLayout.addWidget(buttonsOrientationLabel, 0, 0)
        optionsLayout.addWidget(self.buttonsOrientationComboBox, 0, 1)
        optionsLayout.setColumnStretch(2, 1)
        self.optionsGroupBox.setLayout(optionsLayout)
Ejemplo n.º 24
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.setWindowTitle('About')

        textElement = QLabel(
            "For more information, visit: https://github.com/noobiept/screen_ruler\n\n"
            "You can find there a readme (with the documentation), the source code, and an issues tracker,\n"
            "where you can write suggestions or problems with the application.\n\n"
            "Thanks for using this program.")
        textElement.setTextInteractionFlags(Qt.TextSelectableByMouse
                                            | Qt.TextSelectableByKeyboard)

        layout = QGridLayout()
        layout.addWidget(textElement)
        layout.setSizeConstraint(QLayout.SetFixedSize)

        self.setLayout(layout)
Ejemplo n.º 25
0
    def initUI(self):
        """
        Init widget

        """
        grid = QGridLayout()
        hbox = QHBoxLayout()
        hbox.addSpacing(2)

        self._buttonBack = QPushButton(QIcon(PATH_IMAGE_BACK_NEDDLE), "", self)
        self._buttonBack.clicked.connect(self.signalController.back2menu)
        hbox.addWidget(self._buttonBack, 0, QtCore.Qt.AlignLeft)

        self.label = QLabel("SettingsView")
        hbox.addWidget(self.label, 1, QtCore.Qt.AlignCenter)

        grid.addLayout(hbox, 0, 0, QtCore.Qt.AlignTop)

        jsonDataSettings = self.get_settings(None)

        # TODO: Possibility to change settings via this widget
        #self._labels_settings = []

        counter = 1

        for name in jsonDataSettings:
            single = jsonDataSettings[name]

            translated = single[self.TRANSLATED]
            value = single[self.VALUE]

            newLabel = QLabel(name.replace('_', ' '))
            if translated:
                secondLabel = QLabel(QKeySequence(value).toString())
            else:
                secondLabel = QLabel(str(value))

            grid.addWidget(newLabel, counter, 0, QtCore.Qt.AlignLeft)
            grid.addWidget(secondLabel, counter, 1, QtCore.Qt.AlignRight)

            counter += 1

        self.setLayout(grid)
        self.setWindowTitle("Game settings")
Ejemplo n.º 26
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.icons = Icons()

        grid = QGridLayout()
        base = QWidget()
        base.setLayout(grid)
        but = QPushButton('OK')

        layout = QVBoxLayout()
        layout.addWidget(base)
        layout.addWidget(but)
        self.setLayout(layout)

        # click
        but.clicked.connect(self.closeEvent)
        row = 0

        lab_app_name = QLabel(parent.APP_NAME)
        lab_app_name.setStyleSheet("QLabel {font-size:14pt; padding: 0 2px;}")
        grid.addWidget(lab_app_name, row, 0, 1, 2)
        row += 1

        lab_app_ver1 = QLabel('VERSION')
        lab_app_ver1.setStyleSheet("QLabel {font-size:10pt; padding: 0 2px;}")
        lab_app_ver2 = QLabel(parent.APP_VER)
        lab_app_ver2.setStyleSheet("QLabel {font-size:10pt; padding: 0 2px;}")
        grid.addWidget(lab_app_ver1, row, 0)
        grid.addWidget(lab_app_ver2, row, 1)
        row += 1

        lab_app_copyright1 = QLabel('COPYRIGHT')
        lab_app_copyright1.setStyleSheet(
            "QLabel {font-size:10pt; padding: 0 2px;}")
        lab_app_copyright2 = QLabel(parent.APP_COPYRIGHT)
        lab_app_copyright2.setStyleSheet(
            "QLabel {font-size:10pt; padding: 0 2px;}")
        grid.addWidget(lab_app_copyright1, row, 0)
        grid.addWidget(lab_app_copyright2, row, 1)
        row += 1

        lab_app_license1 = QLabel('LICENSE')
        lab_app_license1.setStyleSheet(
            "QLabel {font-size:10pt; padding: 0 2px;}")
        lab_app_license2 = QLabel(parent.APP_LICENSE)
        lab_app_license2.setStyleSheet(
            "QLabel {font-size:10pt; padding: 0 2px;}")
        lab_app_license2.setOpenExternalLinks(True)
        grid.addWidget(lab_app_license1, row, 0)
        grid.addWidget(lab_app_license2, row, 1)
        row += 1

        self.setWindowIcon(QIcon(self.icons.INFO))
        self.show()
Ejemplo n.º 27
0
    def __init__(self):
        super(Dialog, self).__init__()

        self.rotableWidgets = []

        self.createRotableGroupBox()
        self.createOptionsGroupBox()
        self.createButtonBox()

        mainLayout = QGridLayout()
        mainLayout.addWidget(self.rotableGroupBox, 0, 0)
        mainLayout.addWidget(self.optionsGroupBox, 1, 0)
        mainLayout.addWidget(self.buttonBox, 2, 0)
        mainLayout.setSizeConstraint(QLayout.SetMinimumSize)

        self.mainLayout = mainLayout
        self.setLayout(self.mainLayout)

        self.setWindowTitle("Dynamic Layouts")
Ejemplo n.º 28
0
    def _create_widgets_with_quantity(
        self,
        pickup: PickupEntry,
        parent_widget: QtWidgets.QWidget,
        parent_layout: QtWidgets.QGridLayout,
        row: int,
        quantity: int,
    ):
        label = QtWidgets.QLabel(parent_widget)
        label.setText(pickup.name)
        parent_layout.addWidget(label, row, 0)

        spin_bix = ScrollProtectedSpinBox(parent_widget)
        spin_bix.setMaximumWidth(50)
        spin_bix.setMaximum(quantity)
        spin_bix.valueChanged.connect(
            functools.partial(self._change_item_quantity, pickup, False))
        self._widget_for_pickup[pickup] = spin_bix
        parent_layout.addWidget(spin_bix, row, 1)
Ejemplo n.º 29
0
 def show_play_table(self, plays):
     """Shows a table with all the plays to be imported, allowing user to select some to skip"""
     tree_model = PlayTableModel(plays)
     table_widget = QTableView()
     table_widget.setModel(tree_model)
     table_widget.verticalHeader().setVisible(False)
     table_view_header = table_widget.horizontalHeader()
     table_view_header.setStretchLastSection(True)
     for column in range(tree_model.columnCount()):
         column_size = tree_model.data(tree_model.index(0, column),
                                       PlayTableModel.SIZE_ROLE)
         table_view_header.resizeSection(column, column_size)
     table_widget_dialog = QDialog(self)
     table_widget_dialog.setModal(True)
     grid_layout = QGridLayout(table_widget_dialog)
     grid_layout.addWidget(table_widget, 1, 1)
     table_widget_dialog.resize(800, 600)
     table_widget_dialog.exec_()
     skipped_plays = tree_model.get_skipped_plays()
     return [play for play in plays if play.id not in skipped_plays]
Ejemplo n.º 30
0
class InfoWidget(QWidget):
    """Display basic file information in a table (two columns).

    Parameters
    ----------
    values : dict
        Each key/value pair in this dict will be displayed in a row, separated by a colon.
    """
    def __init__(self, values=None):
        super().__init__()
        vbox = QVBoxLayout(self)
        self.grid = QGridLayout()
        self.grid.setColumnStretch(1, 1)
        vbox.addLayout(self.grid)
        vbox.addStretch(1)
        self.set_values(values)

    def set_values(self, values=None):
        """Set values (and overwrite existing values).

        Parameters
        ----------
        values : dict
            Each key/value pair in this dict is displayed in a row separated by a colon.
        """
        self.clear()
        if values:
            for row, (key, value) in enumerate(values.items()):
                left = QLabel(str(key) + ":")
                right = QLabel(str(value))
                right.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed)
                self.grid.addWidget(left, row, 0)
                self.grid.addWidget(right, row, 1)

    def clear(self):
        """Clear all values."""
        item = self.grid.takeAt(0)
        while item:
            item.widget().deleteLater()
            del item
            item = self.grid.takeAt(0)