def __init__(self, parent, main, app: FastFlixApp, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.main = main self.app = app self.widgets = Box() self.labels = Box() self.opts = Box() self.only_int = QtGui.QIntValidator() self.only_float = QtGui.QDoubleValidator()
def __init__(self, parent=None): super(Client, self).__init__(parent) self.blockSize = 0 self.currentFortune = '' hostLabel = QtWidgets.QLabel("&Server name:") portLabel = QtWidgets.QLabel("S&erver port:") self.hostLineEdit = QtWidgets.QLineEdit('Localhost') self.portLineEdit = QtWidgets.QLineEdit() self.portLineEdit.setValidator(QtGui.QIntValidator(1, 65535, self)) hostLabel.setBuddy(self.hostLineEdit) portLabel.setBuddy(self.portLineEdit) self.statusLabel = QtWidgets.QLabel("This examples requires that you run " "the Fortune Server example as well.") self.getFortuneButton = QtWidgets.QPushButton("Get Fortune") self.getFortuneButton.setDefault(True) self.getFortuneButton.setEnabled(False) quitButton = QtWidgets.QPushButton("Quit") buttonBox = QtWidgets.QDialogButtonBox() buttonBox.addButton(self.getFortuneButton, QtWidgets.QDialogButtonBox.ActionRole) buttonBox.addButton(quitButton, QtWidgets.QDialogButtonBox.RejectRole) self.tcpSocket = QtNetwork.QTcpSocket(self) self.hostLineEdit.textChanged.connect(self.enableGetFortuneButton) self.portLineEdit.textChanged.connect(self.enableGetFortuneButton) self.getFortuneButton.clicked.connect(self.requestNewFortune) quitButton.clicked.connect(self.close) self.tcpSocket.readyRead.connect(self.readFortune) self.tcpSocket.errorOccurred.connect(self.displayError) mainLayout = QtWidgets.QGridLayout() mainLayout.addWidget(hostLabel, 0, 0) mainLayout.addWidget(self.hostLineEdit, 0, 1) mainLayout.addWidget(portLabel, 1, 0) mainLayout.addWidget(self.portLineEdit, 1, 1) mainLayout.addWidget(self.statusLabel, 2, 0, 1, 2) mainLayout.addWidget(buttonBox, 3, 0, 1, 2) self.setLayout(mainLayout) self.setWindowTitle("Fortune Client") self.portLineEdit.setFocus()
def __init__(self, parent, app: FastFlixApp): super().__init__(parent) self.app = app self.main = parent.main self.attachments = Box() self.updating = False self.only_int = QtGui.QIntValidator() self.layout = QtWidgets.QGridLayout() self.last_row = 0 self.init_fps() self.add_spacer() self.init_video_speed() self.add_spacer() self.init_eq() self.add_spacer() self.init_denoise() self.add_spacer() self.init_deblock() self.add_spacer() self.init_color_info() self.add_spacer() self.init_vbv() self.last_row += 1 self.layout.setRowStretch(self.last_row, True) # self.layout.setColumnStretch(6, True) self.last_row += 1 warning_label = QtWidgets.QLabel() ico = QtGui.QIcon(get_icon("onyx-warning", app.fastflix.config.theme)) warning_label.setPixmap(ico.pixmap(22)) self.layout.addWidget(warning_label, self.last_row, 0, alignment=QtCore.Qt.AlignRight) self.layout.addWidget( QtWidgets.QLabel( t("Advanced settings are currently not saved in Profiles")), self.last_row, 1, 1, 4) for i in range(6): self.layout.setColumnMinimumWidth(i, 155) self.setLayout(self.layout)
def __init__(self, values, *args): super().__init__(*args) self.values = values self.setModal(True) self.setWindowTitle('Connect to WeeChat') grid = QtWidgets.QGridLayout() grid.setSpacing(10) self.fields = {} focus = None # hostname grid.addWidget(QtWidgets.QLabel('<b>Hostname</b>'), 0, 0) line_edit = QtWidgets.QLineEdit() line_edit.setFixedWidth(200) value = self.values.get('hostname', '') line_edit.insert(value) grid.addWidget(line_edit, 0, 1) self.fields['hostname'] = line_edit if not focus and not value: focus = 'hostname' # port / SSL grid.addWidget(QtWidgets.QLabel('<b>Port</b>'), 1, 0) line_edit = QtWidgets.QLineEdit() line_edit.setFixedWidth(200) value = self.values.get('port', '') line_edit.insert(value) grid.addWidget(line_edit, 1, 1) self.fields['port'] = line_edit if not focus and not value: focus = 'port' ssl = QtWidgets.QCheckBox('SSL') ssl.setChecked(self.values['ssl'] == 'on') grid.addWidget(ssl, 1, 2) self.fields['ssl'] = ssl # password grid.addWidget(QtWidgets.QLabel('<b>Password</b>'), 2, 0) line_edit = QtWidgets.QLineEdit() line_edit.setFixedWidth(200) line_edit.setEchoMode(QtWidgets.QLineEdit.Password) value = self.values.get('password', '') line_edit.insert(value) grid.addWidget(line_edit, 2, 1) self.fields['password'] = line_edit if not focus and not value: focus = 'password' # TOTP (Time-Based One-Time Password) label = QtWidgets.QLabel('TOTP') label.setToolTip('Time-Based One-Time Password (6 digits)') grid.addWidget(label, 3, 0) line_edit = QtWidgets.QLineEdit() line_edit.setPlaceholderText('6 digits') validator = QtGui.QIntValidator(0, 999999, self) line_edit.setValidator(validator) line_edit.setFixedWidth(80) value = self.values.get('totp', '') line_edit.insert(value) grid.addWidget(line_edit, 3, 1) self.fields['totp'] = line_edit if not focus and not value: focus = 'totp' # lines grid.addWidget(QtWidgets.QLabel('Lines'), 4, 0) line_edit = QtWidgets.QLineEdit() line_edit.setFixedWidth(200) validator = QtGui.QIntValidator(0, 2147483647, self) line_edit.setValidator(validator) line_edit.setFixedWidth(80) value = self.values.get('lines', '') line_edit.insert(value) grid.addWidget(line_edit, 4, 1) self.fields['lines'] = line_edit if not focus and not value: focus = 'lines' self.dialog_buttons = QtWidgets.QDialogButtonBox() self.dialog_buttons.setStandardButtons( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) self.dialog_buttons.rejected.connect(self.close) grid.addWidget(self.dialog_buttons, 5, 0, 1, 2) self.setLayout(grid) self.show() if focus: self.fields[focus].setFocus()
def argument_widget_factory(component: str, title: str = None, optional: bool = True) -> QtWidgets.QWidget: """ Factory function for generating various subclasses of instance `PySide6.QtWidgets.QWidgets` pre-configured for user-input. Parameters ---------- 1. **components** : ``str`` Allowable values: `date`, `decimal`, `currency`, `integer`, `select`, `flag`, `symbols`, `symbol`. If `components=None`, a `PySide6.QtWidgets.QWidget` will be returned. """ widget = atomic_widget_factory(None, None) widget.setObjectName('input-container') if optional: toggle_widget = QtWidgets.QCheckBox() toggle_widget.setObjectName('input-toggle') toggle_widget.setSizePolicy(QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum)) label_widget = QtWidgets.QLabel(title) label_widget.setAlignment(QtCore.Qt.AlignBottom) label_widget.setObjectName('input-label') if component == 'date': main_widget = QtWidgets.QDateEdit() main_widget.setDate(QtCore.QDate.currentDate()) main_widget.setMaximumDate(QtCore.QDate.currentDate()) main_widget.setMinimumDate(QtCore.QDate( constants.constants['PRICE_YEAR_CUTOFF'], 1, 1)) main_widget.setObjectName(component) main_widget.setEnabled(False) elif component == 'decimal': main_widget = QtWidgets.QLineEdit() main_widget.setObjectName(component) main_widget.setValidator( QtGui.QDoubleValidator(-100, 100, 5, main_widget)) main_widget.setEnabled(False) main_widget.setSizePolicy(QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum)) elif component == 'currency': main_widget = QtWidgets.QLineEdit() main_widget.setObjectName(component) # https://stackoverflow.com/questions/354044/what-is-the-best-u-s-currency-regex main_widget.setValidator(QtGui.QRegularExpressionValidator( r"[+-]?[0-9]{1,3}(?:,?[0-9]{3})*(?:\.[0-9]{2})", main_widget)) main_widget.setEnabled(False) main_widget.setSizePolicy(QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum)) elif component == 'integer': main_widget = QtWidgets.QLineEdit() main_widget.setObjectName(component) main_widget.setValidator(QtGui.QIntValidator(0, 100, main_widget)) main_widget.setEnabled(False) main_widget.setSizePolicy(QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum)) elif component == 'select': return None elif component == 'flag': main_widget = QtWidgets.QRadioButton(title) main_widget.setObjectName(component) main_widget.setSizePolicy(QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum)) elif component == 'symbols': main_widget = QtWidgets.QLineEdit() main_widget.setObjectName(component) main_widget.setMaxLength(100) main_widget.setSizePolicy(QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Maximum)) elif component == 'symbol': main_widget = QtWidgets.QLineEdit() main_widget.setObjectName(component) main_widget.setMaxLength(100) main_widget.setSizePolicy(QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Maximum)) main_widget.setValidator( QtGui.QRegularExpressionValidator(r"[A-Za-z]+", main_widget)) else: main_widget = QtWidgets.QWidget() widget.layout().addWidget(label_widget) widget.layout().addWidget(main_widget) if optional: toggle_widget.stateChanged.connect( lambda: main_widget.setEnabled((not main_widget.isEnabled()))) widget.layout().addWidget(toggle_widget) return widget
def __init__(self, options: Options, patch_data: dict, word_hash: str, spoiler: bool, games: list[RandovaniaGame]): super().__init__(options, patch_data, word_hash, spoiler, games) per_game = options.options_for_game(self._game) assert isinstance(per_game, DreadPerGameOptions) self._validate_input_file() self._validate_custom_path() # Input self.input_file_edit.textChanged.connect(self._on_input_file_change) self.input_file_button.clicked.connect(self._on_input_file_button) # Target Platform if per_game.target_platform == DreadModPlatform.ATMOSPHERE: self.atmosphere_radio.setChecked(True) else: self.ryujinx_radio.setChecked(True) self.atmosphere_radio.toggled.connect(self._on_update_target_platform) self.ryujinx_radio.toggled.connect(self._on_update_target_platform) self._on_update_target_platform() # Small Size self.exlaunch_check.setChecked(per_game.reduce_mod_size) # Output to SD self.sd_non_removable.clicked.connect(self.refresh_drive_list) self.sd_refresh_button.clicked.connect(self.refresh_drive_list) self.tab_sd_card.serialize_options = lambda: { "drive": serialize_path(self.sd_combo.currentData()), "non_removable": self.sd_non_removable.isChecked(), "mod_manager": self.sd_mod_manager_check.isChecked(), } self.tab_sd_card.restore_options = self.sd_restore_options self.tab_sd_card.is_valid = lambda: self.sd_combo.currentData() is not None # Output to FTP self.tab_ftp.is_valid = self.ftp_is_valid self.ftp_test_button.setVisible(False) self.ftp_anonymous_check.clicked.connect(self.ftp_on_anonymous_check) add_validation(self.ftp_username_edit, lambda: self.ftp_anonymous_check.isChecked() or self.ftp_username_edit.text(), self.update_accept_validation) add_validation(self.ftp_password_edit, lambda: self.ftp_anonymous_check.isChecked() or self.ftp_password_edit.text(), self.update_accept_validation) add_validation(self.ftp_ip_edit, lambda: self.ftp_ip_edit.text(), self.update_accept_validation) self.ftp_port_edit.setValidator(QtGui.QIntValidator(1, 65535, self)) self.tab_ftp.serialize_options = lambda: { "anonymous": self.ftp_anonymous_check.isChecked(), "username": self.ftp_username_edit.text(), "password": self.ftp_password_edit.text(), "ip": self.ftp_ip_edit.text(), "port": self.ftp_port_edit.text(), } self.tab_ftp.restore_options = self.ftp_restore_options update_validation(self.ftp_username_edit) update_validation(self.ftp_ip_edit) self.ftp_on_anonymous_check() # Output to Ryujinx self.update_ryujinx_ui() self.tab_ryujinx.serialize_options = lambda: {} self.tab_ryujinx.restore_options = lambda p: None self.tab_ryujinx.is_valid = lambda: True # Output to Custom self.custom_path_edit.textChanged.connect(self._on_custom_path_change) self.custom_path_button.clicked.connect(self._on_custom_path_button) self.tab_custom_path.serialize_options = lambda: { "path": serialize_path(path_in_edit(self.custom_path_edit)), } self.tab_custom_path.restore_options = self.custom_restore_options self.tab_custom_path.is_valid = lambda: not self.custom_path_edit.has_error self._output_tab_by_name = { "sd": self.tab_sd_card, "ftp": self.tab_ftp, "ryujinx": self.tab_ryujinx, "custom": self.tab_custom_path, } # Restore options if per_game.input_directory is not None: self.input_file_edit.setText(str(per_game.input_directory)) if per_game.output_preference is not None: output_preference = json.loads(per_game.output_preference) tab_options = output_preference["tab_options"] for tab_name, the_tab in self._output_tab_by_name.items(): if tab_name == output_preference.get("selected_tab"): index = self.output_tab_widget.indexOf(the_tab) if self.output_tab_widget.isTabVisible(index): self.output_tab_widget.setCurrentIndex(index) try: if tab_name in tab_options: the_tab.restore_options(tab_options[tab_name]) except Exception: logging.exception("Unable to restore preferences for output") # Accept self.output_tab_widget.currentChanged.connect(self.update_accept_validation) self.sd_combo.currentIndexChanged.connect(self.update_accept_validation) self.update_accept_validation()
def __init__(self): super().__init__() # global self.config_params self.xml_root = None # self.tab = QWidget() # self.tabs.resize(200,5) #------------------------------------------- label_width = 110 domain_value_width = 100 value_width = 60 label_height = 20 units_width = 70 self.scroll = QScrollArea() # might contain centralWidget self.config_params = QWidget() self.vbox = QVBoxLayout() self.vbox.addStretch(0) #============ Domain ================================ label = QLabel("Domain (micron)") label.setFixedHeight(label_height) label.setStyleSheet("background-color: orange") label.setAlignment(QtCore.Qt.AlignCenter) self.vbox.addWidget(label) hbox = QHBoxLayout() label = QLabel("Xmin") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.xmin = QLineEdit() self.xmin.setFixedWidth(domain_value_width) self.xmin.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.xmin) label = QLabel("Xmax") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.xmax = QLineEdit() self.xmax.setFixedWidth(domain_value_width) self.xmax.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.xmax) label = QLabel("dx") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.xdel = QLineEdit() self.xdel.setFixedWidth(value_width) self.xdel.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.xdel) self.vbox.addLayout(hbox) #---------- hbox = QHBoxLayout() label = QLabel("Ymin") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.ymin = QLineEdit() self.ymin.setFixedWidth(domain_value_width) self.ymin.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.ymin) label = QLabel("Ymax") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.ymax = QLineEdit() self.ymax.setFixedWidth(domain_value_width) self.ymax.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.ymax) label = QLabel("dy") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.ydel = QLineEdit() self.ydel.setFixedWidth(value_width) self.ydel.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.ydel) self.vbox.addLayout(hbox) #---------- hbox = QHBoxLayout() label = QLabel("Zmin") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.zmin = QLineEdit() self.zmin.setFixedWidth(domain_value_width) self.zmin.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.zmin) label = QLabel("Zmax") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.zmax = QLineEdit() self.zmax.setFixedWidth(domain_value_width) self.zmax.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.zmax) label = QLabel("dz") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.zdel = QLineEdit() self.zdel.setFixedWidth(value_width) self.zdel.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.zdel) self.vbox.addLayout(hbox) #---------- hbox = QHBoxLayout() self.virtual_walls = QCheckBox("Virtual walls") # self.motility_enabled.setAlignment(QtCore.Qt.AlignRight) # label.setFixedWidth(label_width) hbox.addWidget(self.virtual_walls) self.vbox.addLayout(hbox) # self.vbox.addWidget(QHLine()) #============ Misc ================================ label = QLabel("Misc runtime parameters") label.setFixedHeight(label_height) label.setStyleSheet("background-color: orange") label.setAlignment(QtCore.Qt.AlignCenter) self.vbox.addWidget(label) hbox = QHBoxLayout() # hbox.setFixedHeight(label_width) label = QLabel("Max Time") # label_width = 210 label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.max_time = QLineEdit() # self.max_time.setFixedWidth(200) self.max_time.setFixedWidth(domain_value_width) self.max_time.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.max_time) label = QLabel("min") label.setFixedWidth(units_width) label.setAlignment(QtCore.Qt.AlignLeft) hbox.addWidget(label) self.vbox.addLayout(hbox) #---------- hbox = QHBoxLayout() label = QLabel("# threads") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.num_threads = QLineEdit() # self.num_threads.setFixedWidth(value_width) self.num_threads.setFixedWidth(domain_value_width) self.num_threads.setValidator(QtGui.QIntValidator()) hbox.addWidget(self.num_threads) label = QLabel(" ") label.setFixedWidth(units_width) label.setAlignment(QtCore.Qt.AlignLeft) hbox.addWidget(label) self.vbox.addLayout(hbox) #------------------ hbox = QHBoxLayout() label = QLabel("Save data:") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignLeft) hbox.addWidget(label) #------ self.save_svg = QCheckBox("SVG") # self.motility_2D.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(self.save_svg) label = QLabel("every") # label_width = 210 # label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.svg_interval = QLineEdit() self.svg_interval.setFixedWidth(value_width) self.svg_interval.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.svg_interval) label = QLabel("min") # label.setFixedWidth(units_width) label.setAlignment(QtCore.Qt.AlignLeft) hbox.addWidget(label) #------ self.save_full = QCheckBox("Full") # self.motility_2D.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(self.save_full) label = QLabel("every") # label_width = 210 # label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.full_interval = QLineEdit() self.full_interval.setFixedWidth(value_width) self.full_interval.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.full_interval) label = QLabel("min") # label.setFixedWidth(units_width) label.setAlignment(QtCore.Qt.AlignLeft) hbox.addWidget(label) self.vbox.addLayout(hbox) #============ Cells IC ================================ label = QLabel("Initial conditions of cells (x,y,z, type)") label.setFixedHeight(label_height) label.setStyleSheet("background-color: orange") label.setAlignment(QtCore.Qt.AlignCenter) self.vbox.addWidget(label) self.cells_csv = QCheckBox("config/cells.csv") self.vbox.addWidget(self.cells_csv) #-------------------------- # Dummy widget for filler?? # label = QLabel("") # label.setFixedHeight(1000) # # label.setStyleSheet("background-color: orange") # label.setAlignment(QtCore.Qt.AlignCenter) # self.vbox.addWidget(label) self.vbox.addStretch() #================================================================== self.config_params.setLayout(self.vbox) self.scroll.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.scroll.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.scroll.setWidgetResizable(True) self.scroll.setWidget( self.config_params) # self.config_params = QWidget() self.layout = QVBoxLayout(self) self.layout.addWidget(self.scroll)
def createToolbars(self): self.editToolBar = self.addToolBar("Edit") self.editToolBar.addAction(self.deleteAction) self.editToolBar.addAction(self.toFrontAction) self.editToolBar.addAction(self.sendBackAction) self.fontCombo = QtWidgets.QFontComboBox() self.fontCombo.currentFontChanged.connect(self.currentFontChanged) self.fontSizeCombo = QtWidgets.QComboBox() self.fontSizeCombo.setEditable(True) for i in range(8, 30, 2): self.fontSizeCombo.addItem(str(i)) validator = QtGui.QIntValidator(2, 64, self) self.fontSizeCombo.setValidator(validator) self.fontSizeCombo.currentIndexChanged.connect(self.fontSizeChanged) self.fontColorToolButton = QtWidgets.QToolButton() self.fontColorToolButton.setPopupMode( QtWidgets.QToolButton.MenuButtonPopup) self.fontColorToolButton.setMenu( self.createColorMenu(self.textColorChanged, QtCore.Qt.black)) self.textAction = self.fontColorToolButton.menu().defaultAction() self.fontColorToolButton.setIcon( self.createColorToolButtonIcon(':/images/textpointer.png', QtCore.Qt.black)) self.fontColorToolButton.setAutoFillBackground(True) self.fontColorToolButton.clicked.connect(self.textButtonTriggered) self.fillColorToolButton = QtWidgets.QToolButton() self.fillColorToolButton.setPopupMode( QtWidgets.QToolButton.MenuButtonPopup) self.fillColorToolButton.setMenu( self.createColorMenu(self.itemColorChanged, QtCore.Qt.white)) self.fillAction = self.fillColorToolButton.menu().defaultAction() self.fillColorToolButton.setIcon( self.createColorToolButtonIcon(':/images/floodfill.png', QtCore.Qt.white)) self.fillColorToolButton.clicked.connect(self.fillButtonTriggered) self.lineColorToolButton = QtWidgets.QToolButton() self.lineColorToolButton.setPopupMode( QtWidgets.QToolButton.MenuButtonPopup) self.lineColorToolButton.setMenu( self.createColorMenu(self.lineColorChanged, QtCore.Qt.black)) self.lineAction = self.lineColorToolButton.menu().defaultAction() self.lineColorToolButton.setIcon( self.createColorToolButtonIcon(':/images/linecolor.png', QtCore.Qt.black)) self.lineColorToolButton.clicked.connect(self.lineButtonTriggered) self.textToolBar = self.addToolBar("Font") self.textToolBar.addWidget(self.fontCombo) self.textToolBar.addWidget(self.fontSizeCombo) self.textToolBar.addAction(self.boldAction) self.textToolBar.addAction(self.italicAction) self.textToolBar.addAction(self.underlineAction) self.colorToolBar = self.addToolBar("Color") self.colorToolBar.addWidget(self.fontColorToolButton) self.colorToolBar.addWidget(self.fillColorToolButton) self.colorToolBar.addWidget(self.lineColorToolButton) pointerButton = QtWidgets.QToolButton() pointerButton.setCheckable(True) pointerButton.setChecked(True) pointerButton.setIcon(QtGui.QIcon(':/images/pointer.png')) linePointerButton = QtWidgets.QToolButton() linePointerButton.setCheckable(True) linePointerButton.setIcon(QtGui.QIcon(':/images/linepointer.png')) self.pointerTypeGroup = QtWidgets.QButtonGroup() self.pointerTypeGroup.addButton(pointerButton, DiagramScene.MoveItem) self.pointerTypeGroup.addButton(linePointerButton, DiagramScene.InsertLine) self.pointerTypeGroup.idClicked.connect(self.pointerGroupClicked) self.sceneScaleCombo = QtWidgets.QComboBox() self.sceneScaleCombo.addItems(["50%", "75%", "100%", "125%", "150%"]) self.sceneScaleCombo.setCurrentIndex(2) self.sceneScaleCombo.currentTextChanged.connect(self.sceneScaleChanged) self.pointerToolbar = self.addToolBar("Pointer type") self.pointerToolbar.addWidget(pointerButton) self.pointerToolbar.addWidget(linePointerButton) self.pointerToolbar.addWidget(self.sceneScaleCombo)
def __init__(self, parent): super().__init__(parent) menu_layout = QtWidgets.QHBoxLayout() self._game_instance = parent.game_instance # Set Up Start Game Options new_game_layout = QtWidgets.QVBoxLayout() new_game_layout.add_widget(QtWidgets.QLabel('New Game')) line = QtWidgets.QFrame() line.frame_shape = QtWidgets.QFrame.HLine line.frame_shadow = QtWidgets.QFrame.Sunken new_game_layout.add_widget(line) new_game_layout.add_widget(QtWidgets.QLabel('Game Name')) self.game_name_box = QtWidgets.QLineEdit(self) new_game_layout.add_widget(self.game_name_box) new_game_layout.add_widget( QtWidgets.QLabel('Set Game Password (Optional)')) self.create_password_box = QtWidgets.QLineEdit(self) self.create_password_box.echo_mode = QtWidgets.QLineEdit.Password new_game_layout.add_widget(self.create_password_box) new_game_layout.add_widget(QtWidgets.QLabel('Username')) self.create_username_box = QtWidgets.QLineEdit(self) new_game_layout.add_widget(self.create_username_box) new_game_button = QtWidgets.QPushButton('Start', self) self.connect(new_game_button, QtCore.SIGNAL('clicked()'), self.start_new_game) new_game_layout.add_widget(new_game_button) menu_layout.add_layout(new_game_layout) # Add Vertical Seperator line = QtWidgets.QFrame() line.frame_shape = QtWidgets.QFrame.VLine line.frame_shadow = QtWidgets.QFrame.Sunken menu_layout.add_widget(line) # Set Up Join Game Options join_game_layout = QtWidgets.QVBoxLayout() join_game_layout.add_widget(QtWidgets.QLabel('Join Game')) line = QtWidgets.QFrame() line.frame_shape = QtWidgets.QFrame.HLine line.frame_shadow = QtWidgets.QFrame.Sunken join_game_layout.add_widget(line) join_game_layout.add_widget(QtWidgets.QLabel('Game Code')) self.game_code_box = QtWidgets.QLineEdit(self) self.game_code_box.set_validator(QtGui.QIntValidator()) join_game_layout.add_widget(self.game_code_box) join_game_layout.add_widget( QtWidgets.QLabel('Game Password (Optional)')) self.join_password_box = QtWidgets.QLineEdit(self) self.join_password_box.echo_mode = QtWidgets.QLineEdit.Password join_game_layout.add_widget(self.join_password_box) join_game_layout.add_widget(QtWidgets.QLabel('Username')) self.join_username_box = QtWidgets.QLineEdit(self) join_game_layout.add_widget(self.join_username_box) join_game_button = QtWidgets.QPushButton('Join', self) self.connect(join_game_button, QtCore.SIGNAL('clicked()'), self.join_game) join_game_layout.add_widget(join_game_button) menu_layout.add_layout(join_game_layout) self.set_layout(menu_layout)