def createOrdersTab(self): """Create the page to view the Orders table from the database.""" ord_sql_model = QSqlRelationalTableModel() ord_sql_model.setTable("Orders") ord_sql_model.setRelation( ord_sql_model.fieldIndex("product_id"), QSqlRelation("Products", "product_id", "product_name")) ord_sql_model.setRelation( ord_sql_model.fieldIndex("customer_id"), QSqlRelation("Customers", "customer_id", "first_name")) ord_sql_model.setHeaderData(ord_sql_model.fieldIndex("customer_id"), Qt.Orientation.Horizontal, "customer_name") ord_sql_model.select() # Populate the model with data ord_proxy_model = QSortFilterProxyModel() ord_proxy_model.setSourceModel(ord_sql_model) ord_table = QTableView() ord_table.setSortingEnabled(True) ord_table.setModel(ord_proxy_model) ord_table.setItemDelegate(SqlProxyDelegate(ord_table)) ord_table.setItemDelegateForColumn( ord_sql_model.fieldIndex("date_of_order"), DateDelegate()) ord_table.horizontalHeader().setSectionResizeMode( QHeaderView.ResizeMode.Stretch) ord_h_box = QHBoxLayout() ord_h_box.addWidget(ord_table) self.orders_tab.setLayout(ord_h_box)
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())
def initUI(self): hbox = QHBoxLayout(self) topleft = QFrame(self) topleft.setFrameShape(QFrame.Shape.StyledPanel) topright = QFrame(self) topright.setFrameShape(QFrame.Shape.StyledPanel) bottom = QFrame(self) bottom.setFrameShape(QFrame.Shape.StyledPanel) splitter1 = QSplitter(Qt.Orientations.Horizontal) splitter1.addWidget(topleft) splitter1.addWidget(topright) splitter2 = QSplitter(Qt.Orientations.Vertical) splitter2.addWidget(splitter1) splitter2.addWidget(bottom) hbox.addWidget(splitter2) self.setLayout(hbox) self.setGeometry(300, 300, 450, 400) self.setWindowTitle('QSplitter') self.show()
def createCustomersTab(self): """Create the page to view the Customers table from the database.""" cust_sql_model = QSqlRelationalTableModel() cust_sql_model.setTable("Customers") cust_sql_model.setRelation( cust_sql_model.fieldIndex("staff_id"), QSqlRelation("Staff", "staff_id", "username")) cust_sql_model.setHeaderData(cust_sql_model.fieldIndex("staff_id"), Qt.Orientation.Horizontal, "staff_username") cust_sql_model.select() # Populate the model with data cust_proxy_model = QSortFilterProxyModel() cust_proxy_model.setSourceModel(cust_sql_model) cust_table = QTableView() cust_table.setSortingEnabled(True) cust_table.setModel(cust_proxy_model) cust_table.setItemDelegate(SqlProxyDelegate(cust_table)) cust_table.setItemDelegateForColumn(cust_sql_model.fieldIndex("phone"), PhoneDelegate()) cust_table.horizontalHeader().setSectionResizeMode( QHeaderView.ResizeMode.Stretch) cust_h_box = QHBoxLayout() cust_h_box.addWidget(cust_table) self.customer_tab.setLayout(cust_h_box)
def configure_gui(self): self.undo = [''] self.redo = [] self.layout = QHBoxLayout(self) self.layout.setContentsMargins(0, 0, 5, 0)
def initUI(self): OVER_CAPACITY = 750 sld = QSlider(Qt.Orientations.Horizontal, self) sld.setFocusPolicy(Qt.FocusPolicy.NoFocus) sld.setRange(1, OVER_CAPACITY) sld.setValue(75) sld.setGeometry(30, 40, 150, 30) self.c = Communicate() self.wid = BurningWidget() self.c.updateBW[int].connect(self.wid.setValue) sld.valueChanged[int].connect(self.changeValue) hbox = QHBoxLayout() hbox.addWidget(self.wid) vbox = QVBoxLayout() vbox.addStretch(1) vbox.addLayout(hbox) self.setLayout(vbox) self.setGeometry(300, 300, 390, 210) self.setWindowTitle('Burning widget') self.show()
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)
def createLineEdit(self): hboxLayout = QHBoxLayout() self.lineEdit.returnPressed.connect(self.onReturn_pressed) hboxLayout.addWidget(self.lineEdit) self.groupBox.setLayout(hboxLayout)
def configure_gui(self): self.center = QWidget(self) self.layout = QHBoxLayout() self.center.setLayout(self.layout) self.setCentralWidget(self.center) self.layout.setContentsMargins(5, 0, 5, 0) self.layout.setSpacing(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()
def init_ui(self): layout = QHBoxLayout() self.setLayout(layout) self.dtr_btn = QCheckBox('DTR') self.dtr_btn.clicked.connect(self.handle_dtr) self.rts_btn = QCheckBox('RTS') self.rts_btn.clicked.connect(self.handle_rts) layout.addWidget(self.dtr_btn) layout.addWidget(self.rts_btn)
def __init__(self, parent=None): """Initializer.""" super().__init__(parent) self.setWindowTitle("RP Contacts") self.resize(550, 250) self.centralWidget = QWidget() self.setCentralWidget(self.centralWidget) self.layout = QHBoxLayout() self.centralWidget.setLayout(self.layout) self.ContactsModel = ContactsModel() self.setupUI()
def show_setting(self, conf: dict, layout: QGridLayout): groups = list() x = 0 y = 0 shape = 3 for key in conf.keys(): if type(conf[key]) == bool or type(conf[key]) == str: continue conf_title = conf[key]["title"] conf_enabled = conf[key]["enabled"] conf_times = conf[key]["times"] group = QGroupBox(conf_title) group.setStyleSheet("QGroupBox{border-radius:5px;}") group.setToolTip(conf_title + " 的设置") enabled = QCheckBox("启用") enabled.setObjectName(key) enabled.setToolTip("单击切换开关状态") enabled.setChecked(conf_enabled) enabled.setStyleSheet( "QCheckBox::indicator{width:10px;height:10px;border:none;border-radius:5px;background:#9BE3DE;}QCheckBox::indicator:unchecked{background:#BEEBE9;}QCheckBox::indicator:unchecked:hover{background:#9AD3BC;}QCheckBox::indicator:checked{background:#95E1D3;}QCheckBox::indicator:checked:hover{background:#98DED9;}" ) times = QHBoxLayout() times_label = QLabel("次数:") times_label.setStyleSheet( "QLabel{background:transparent;border:none;border-radius:5px;}" ) times_input = EnhancedEdit() times_input.setObjectName(key) times_input.setText(str(conf_times)) times_input.setToolTip("仅限正整数") times_input.setValidator( QRegularExpressionValidator( QRegularExpression("^[1-9][0-9]{1,8}$"))) times_input.setStyleSheet( "QLineEdit{border:1px solid #F3EAC2;border-radius:5px;background:transparent;}QLineEdit:hover{border:1px solid #F5B461;}" ) times.addWidget(times_label) times.addWidget(times_input) group_layout = QVBoxLayout() group_layout.addWidget(enabled) group_layout.addLayout(times) group.setLayout(group_layout) group.setObjectName(key) groups.append(group) for group in groups: if y >= shape: x = x + 1 y = 0 layout.addWidget(group, x, y) y = y + 1 self.logger.debug("最后的元素位置:(%d,%d)" % (x, y)) return (x, y)
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 initUI(self): hbox = QHBoxLayout(self) pixmap = QPixmap('sid.jpg') lbl = QLabel(self) lbl.setPixmap(pixmap) hbox.addWidget(lbl) self.setLayout(hbox) self.move(300, 200) self.setWindowTitle('Sid') self.show()
def createLayout(self): self.groupBox = QGroupBox("What Is Your Favorite Sport?") hboxlayout = QHBoxLayout() self.button = QPushButton("Football", self) self.button.setIcon(QtGui.QIcon("home.png")) self.button.setIconSize(QSize(40, 40)) self.button.setToolTip("This Is Click Me Button") self.button.setMinimumHeight(40) hboxlayout.addWidget(self.button) self.button1 = QPushButton("Cricket", self) self.button1.setIcon(QtGui.QIcon("home.png")) self.button1.setIconSize(QSize(40, 40)) self.button1.setMinimumHeight(40) self.button1.setToolTip("This Is Click Me Button") hboxlayout.addWidget(self.button1) self.button2 = QPushButton("Tennis", self) self.button2.setIcon(QtGui.QIcon("home.png")) self.button2.setIconSize(QSize(40, 40)) self.button2.setMinimumHeight(40) self.button2.setToolTip("This Is Click Me Button") hboxlayout.addWidget(self.button2) self.groupBox.setLayout(hboxlayout)
class AttributeCreatorWidget(CustomScrollableListItem): def __init__(self, document_base_creator_widget) -> None: super(AttributeCreatorWidget, self).__init__(document_base_creator_widget) self.document_base_creator_widget = document_base_creator_widget self.setFixedHeight(40) self.setStyleSheet("background-color: white") self.layout = QHBoxLayout(self) self.layout.setContentsMargins(20, 0, 20, 0) self.layout.setSpacing(10) self.name = QLineEdit() self.name.setFont(CODE_FONT_BOLD) self.name.setStyleSheet("border: none") self.layout.addWidget(self.name) self.delete_button = QPushButton() self.delete_button.setIcon(QIcon("aset_ui/resources/trash.svg")) self.delete_button.setFlat(True) self.delete_button.clicked.connect(self._delete_button_clicked) self.layout.addWidget(self.delete_button) def update_item(self, item, params=None): self.name.setText(item) def _delete_button_clicked(self): self.document_base_creator_widget.delete_attribute(self.name.text()) def enable_input(self): self.delete_button.setEnabled(True) def disable_input(self): self.delete_button.setEnabled(False)
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, parent=None): super(ConfigDialog, self).__init__(parent) self.classifyExercises = parent.classifyExercises self.setFixedSize(500, 400) self.setWindowTitle("Model Configurations") self.epochValue = QLabel() self.vbox = QVBoxLayout() self.label_maximum = QLabel() self.label_minimum = QLabel() self.slider_hbox = QHBoxLayout() self.slider_vbox = QVBoxLayout() self.batchSizeMenu = QComboBox() self.properties = QFormLayout() self.epochSlider = Slider(orientation=Qt.Orientations.Horizontal) self.trainButton = QPushButton('Train Model') self.resultButton = QPushButton('Show result image') self.progress = QProgressBar() self.batchSizeMenu.addItems(['2', '4', '8', '16', '32', '64', '128']) self.batchSizeMenu.setCurrentIndex(3) self.batchSizeMenu.setMaximumWidth(100) self.initSlider() self.properties.addRow('Batch Size', self.batchSizeMenu) self.resultButton.setEnabled(False) self.actionsLayout = QHBoxLayout() self.actionsLayout.addWidget(self.trainButton) self.actionsLayout.addWidget(self.resultButton) self.optionsLayout = QVBoxLayout() self.optionsLayout.addWidget(QLabel('Model properties')) self.optionsLayout.addLayout(self.vbox) self.optionsLayout.addLayout(self.properties) self.optionsLayout.addLayout(self.actionsLayout) self.progress.setAlignment(QtCore.Qt.Alignment.AlignCenter) self.optionsLayout.addWidget(self.progress) # self.options_layout.addWidget(self.label) # self.options_layout.addWidget(self.list_widget) self.setLayout(self.optionsLayout) self.trainThread = TrainThread(self.classifyExercises) self.connections() print("init config")
def __init__(self, nugget_list_widget): super(NuggetListItemWidget, self).__init__(nugget_list_widget) self.nugget_list_widget = nugget_list_widget self.nugget = None self.setFixedHeight(40) self.setStyleSheet("background-color: white") self.layout = QHBoxLayout(self) self.layout.setContentsMargins(20, 0, 20, 0) self.layout.setSpacing(10) self.info_label = QLabel() self.info_label.setFont(CODE_FONT_BOLD) self.layout.addWidget(self.info_label) self.left_split_label = QLabel("|") self.left_split_label.setFont(CODE_FONT_BOLD) self.layout.addWidget(self.left_split_label) self.text_edit = QTextEdit() self.text_edit.setReadOnly(True) self.text_edit.setFrameStyle(0) self.text_edit.setFont(CODE_FONT) self.text_edit.setLineWrapMode(QTextEdit.LineWrapMode.FixedPixelWidth) self.text_edit.setLineWrapColumnOrWidth(10000) self.text_edit.setHorizontalScrollBarPolicy( Qt.ScrollBarPolicy.ScrollBarAlwaysOff) self.text_edit.setVerticalScrollBarPolicy( Qt.ScrollBarPolicy.ScrollBarAlwaysOff) self.text_edit.setFixedHeight(30) self.text_edit.setText("") self.layout.addWidget(self.text_edit) self.right_split_label = QLabel("|") self.right_split_label.setFont(CODE_FONT_BOLD) self.layout.addWidget(self.right_split_label) self.match_button = QPushButton() self.match_button.setIcon(QIcon("aset_ui/resources/correct.svg")) self.match_button.setFlat(True) self.match_button.clicked.connect(self._match_button_clicked) self.layout.addWidget(self.match_button) self.fix_button = QPushButton() self.fix_button.setIcon(QIcon("aset_ui/resources/incorrect.svg")) self.fix_button.setFlat(True) self.fix_button.clicked.connect(self._fix_button_clicked) self.layout.addWidget(self.fix_button)
def __init__( self, minimum: XY, maximum: XY, initialValue: XY, parent: Optional[QWidget] = None, label: str = "by", *args: Tuple[Any, Any], **kwargs: Tuple[Any, Any], ) -> None: """ A horizontal dual spin box widget designed for the XY size of a maze. """ valid = True if (initialValue.x < minimum.x) or (initialValue.y > maximum.y): valid = False elif (initialValue.x < minimum.x) or (initialValue.y > maximum.y): valid = False if not valid: raise ValueError( f"Initial value for XYPicker must be between {minimum} and {maximum}." ) super(XYPicker, self).__init__(parent=parent, *args, **kwargs) self.setContentsMargins(0, 0, 0, 0) mazeSizePickerLayout = QHBoxLayout() mazeSizePickerLayout.setContentsMargins(0, 0, 0, 0) self.__xSpinBox = QSpinBox() self.__ySpinBox = QSpinBox() self.__xSpinBox.setMinimum(minimum.x) self.__ySpinBox.setMinimum(minimum.y) self.__xSpinBox.setMaximum(maximum.x) self.__ySpinBox.setMaximum(maximum.y) self.__xSpinBox.setValue(initialValue.x) self.__ySpinBox.setValue(initialValue.y) mazeSizePickerLayout.addWidget(self.__xSpinBox) mazeSizePickerLayout.addWidget(QLabel(label)) mazeSizePickerLayout.addWidget(self.__ySpinBox) self.setLayout(mazeSizePickerLayout)
class StatsFrame(QWidget): """Calculate statistics for each turn of the players.""" label_ssheet = """QLabel { font-size: 15pt; font-weight: bold; padding-right: 5px; color: #fca018;}""" def __init__(self, parent=None, window=None): super().__init__(parent=parent) self.window = window self.hlayout = QHBoxLayout() self.setLayout(self.hlayout) self.vbox1 = QVBoxLayout() self.vbox2 = QVBoxLayout() self.cardCount = HLabels("Cards in Deck: ", "0") self.deckCount = HLabels("Number of Decks: ", "0") self.playerCount = HLabels("Number of Players: ", "0") self.breaking21 = HLabels("Breaking 21: ", " 0") self.exactly = HLabels("Exactly 21: ", " 0") self.under21 = HLabels("Under 21: ", " 0") self.probabilities = QLabel("Probabilities", parent=self) self.quantities = QLabel("Quantities", parent=self) self.vbox2.addWidget(self.quantities) self.vbox2.addLayout(self.cardCount) self.vbox2.addLayout(self.deckCount) self.vbox2.addLayout(self.playerCount) self.vbox1.addWidget(self.probabilities) self.vbox1.addLayout(self.breaking21) self.vbox1.addLayout(self.exactly) self.vbox1.addLayout(self.under21) self.hlayout.addLayout(self.vbox1) self.hlayout.addLayout(self.vbox2) self.quantities.setStyleSheet(self.label_ssheet) self.probabilities.setStyleSheet(self.label_ssheet) self.probabilities.setAlignment(Qt.AlignmentFlag(4)) self.quantities.setAlignment(Qt.AlignmentFlag(4)) self.labels = { "cards": self.cardCount, "decks": self.deckCount, "players": self.playerCount, "breaking": self.breaking21, "exactly": self.exactly, "under": self.under21, } self.window.driver.hook(self.labels)
def __init__(self, interactive_matching_widget): super(DocumentWidget, self).__init__(interactive_matching_widget) self.interactive_matching_widget = interactive_matching_widget self.layout = QVBoxLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(10) self.setLayout(self.layout) self.document = None self.current_nugget = None self.base_formatted_text = "" self.idx_mapper = {} self.nuggets_in_order = [] self.text_edit = QTextEdit() self.layout.addWidget(self.text_edit) self.text_edit.setReadOnly(True) self.text_edit.setFrameStyle(0) self.text_edit.setFont(CODE_FONT) self.text_edit.setHorizontalScrollBarPolicy( Qt.ScrollBarPolicy.ScrollBarAlwaysOff) self.text_edit.setText("") self.buttons_widget = QWidget() self.buttons_widget_layout = QHBoxLayout(self.buttons_widget) self.layout.addWidget(self.buttons_widget) self.left_button = QPushButton("Skip Left") self.left_button.setFont(BUTTON_FONT) self.left_button.clicked.connect(self._left_button_clicked) self.buttons_widget_layout.addWidget(self.left_button) self.right_button = QPushButton("Skip Right") self.right_button.setFont(BUTTON_FONT) self.right_button.clicked.connect(self._right_button_clicked) self.buttons_widget_layout.addWidget(self.right_button) self.match_button = QPushButton("Confirm Match") self.match_button.setFont(BUTTON_FONT) self.match_button.clicked.connect(self._match_button_clicked) self.buttons_widget_layout.addWidget(self.match_button) self.no_match_button = QPushButton("There Is No Match") self.no_match_button.setFont(BUTTON_FONT) self.no_match_button.clicked.connect(self._no_match_button_clicked) self.buttons_widget_layout.addWidget(self.no_match_button)
def setupTasksTab(self): settings = QSettings() """ Create vertical tasks container """ self.tasksWidget = QWidget(self.tabWidget) self.tasksWidgetLayout = QVBoxLayout(self.tasksWidget) self.tasksWidget.setLayout(self.tasksWidgetLayout) """ Create horizontal input container """ self.inputContainer = QWidget() self.inputContainer.setFixedHeight(50) self.inputContainerLayout = QHBoxLayout(self.inputContainer) self.inputContainerLayout.setContentsMargins(0, 0, 0, 0) self.inputContainer.setLayout(self.inputContainerLayout) """ Create text edit """ self.taskTextEdit = QTextEdit( placeholderText="Describe your task briefly.", undoRedoEnabled=True) """ Create vertical buttons container """ self.inputButtonContainer = QWidget() self.inputButtonContainerLayout = QVBoxLayout( self.inputButtonContainer) self.inputButtonContainerLayout.setContentsMargins(0, 0, 0, 0) self.inputButtonContainer.setLayout(self.inputButtonContainerLayout) """ Create buttons """ self.acceptTaskButton = QToolButton(icon=makeIcon("check")) self.deleteTaskButton = QToolButton(icon=makeIcon("trash")) """ Create tasks tablewidget """ self.tasksTableWidget = QTableWidget(0, 1) self.tasksTableWidget.setHorizontalHeaderLabels(["Tasks"]) self.tasksTableWidget.horizontalHeader().setStretchLastSection(True) self.tasksTableWidget.verticalHeader().setVisible(False) self.tasksTableWidget.setWordWrap(True) self.tasksTableWidget.setTextElideMode(Qt.TextElideMode.ElideNone) self.tasksTableWidget.setEditTriggers( QAbstractItemView.EditTriggers.NoEditTriggers) self.tasksTableWidget.setSelectionMode( QAbstractItemView.SelectionMode.SingleSelection) self.insertTasks(*settings.value(tasksKey, [])) """ Add widgets to container widgets """ self.inputButtonContainerLayout.addWidget(self.acceptTaskButton) self.inputButtonContainerLayout.addWidget(self.deleteTaskButton) self.inputContainerLayout.addWidget(self.taskTextEdit) self.inputContainerLayout.addWidget(self.inputButtonContainer) self.tasksWidgetLayout.addWidget(self.inputContainer) self.tasksWidgetLayout.addWidget(self.tasksTableWidget) return self.tasksWidget
def initUI(self): self.setWindowTitle("合并文件") self.setWindowIcon(QIcon(SRC_DIR + "upload.ico")) self.logo = QLabel() self.logo.setPixmap(QPixmap(SRC_DIR + "logo3.gif")) self.logo.setStyleSheet("background-color:rgb(0,153,255);") self.logo.setAlignment(Qt.AlignmentFlag.AlignCenter) # lable self.choose_lb = QLabel("选择文件夹") # folder self.choose_folder = MyLineEdit(self) self.choose_folder.setObjectName("choose_folder") self.choose_folder.clicked.connect(self.slot_choose_folder) self.status = QLabel(self) 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.buttonBox.setStyleSheet(btn_style) vbox = QVBoxLayout() hbox_head = QHBoxLayout() hbox_button = QHBoxLayout() hbox_head.addWidget(self.choose_lb) hbox_head.addWidget(self.choose_folder) hbox_button.addWidget(self.buttonBox) vbox.addWidget(self.logo) vbox.addStretch(1) vbox.addWidget(self.status) vbox.addLayout(hbox_head) vbox.addStretch(1) vbox.addLayout(hbox_button) self.setLayout(vbox) self.setMinimumWidth(350) # 设置信号 self.buttonBox.accepted.connect(self.slot_btn_ok) self.buttonBox.rejected.connect(self.slot_btn_no) self.buttonBox.rejected.connect(self.reject)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.l = l = QHBoxLayout(self) l.setContentsMargins(0, 0, 0, 0) self.la = la = QLabel(self) l.addWidget(la) self.edit = Search(self) la.setBuddy(self.edit) l.addWidget(self.edit)
def __init__(self, document_base_viewer): super(AttributeWidget, self).__init__(document_base_viewer) self.document_base_viewer = document_base_viewer self.attribute = None self.setFixedHeight(40) self.setStyleSheet("background-color: white") self.layout = QHBoxLayout(self) self.layout.setContentsMargins(20, 0, 20, 0) self.layout.setSpacing(40) self.attribute_name = QLabel() self.attribute_name.setFont(CODE_FONT_BOLD) self.layout.addWidget(self.attribute_name, alignment=Qt.AlignmentFlag.AlignLeft) self.num_matched = QLabel("matches: -") self.num_matched.setFont(CODE_FONT) self.layout.addWidget(self.num_matched, alignment=Qt.AlignmentFlag.AlignLeft) self.buttons_widget = QWidget() self.buttons_layout = QHBoxLayout(self.buttons_widget) self.buttons_layout.setContentsMargins(0, 0, 0, 0) self.buttons_layout.setSpacing(10) self.layout.addWidget(self.buttons_widget, alignment=Qt.AlignmentFlag.AlignRight) self.forget_matches_button = QPushButton() self.forget_matches_button.setIcon(QIcon("aset_ui/resources/redo.svg")) self.forget_matches_button.setToolTip( "Forget matches for this attribute.") self.forget_matches_button.setFlat(True) self.forget_matches_button.clicked.connect( self._forget_matches_button_clicked) self.buttons_layout.addWidget(self.forget_matches_button) self.remove_button = QPushButton() self.remove_button.setIcon(QIcon("aset_ui/resources/trash.svg")) self.remove_button.setToolTip("Remove this attribute.") self.remove_button.setFlat(True) self.remove_button.clicked.connect(self._remove_button_clicked) self.buttons_layout.addWidget(self.remove_button)
def __addInputAndSelect__(self, input, top): hbox = QHBoxLayout() hbox.setContentsMargins(0, 0, 0, 0) hbox.addWidget(input) browseButton = BrowseButton(self, input, top) browseButton.adjustSize() hbox.addWidget(browseButton) widget = QWidget(self) widget.setLayout(hbox) self.layout.addWidget(widget, self.row, 0, 1, -1) self.row += 1
def __init__( self, onValueChanged: Callable[[int], None], parent: Optional[QWidget] = None, *args: Tuple[Any, Any], **kwargs: Tuple[Any, Any], ) -> None: """ Slow/fast slider for maze solver agents speed """ super(MazeSolverSpeedControlView, self).__init__(parent=parent, *args, **kwargs) self.setContentsMargins(0, 0, 0, 0) layout = QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) slider = QSlider(Qt.Orientations.Horizontal) # minimum of 1 op/s (0 would result in a divide by zero op and thus crash) slider.setMinimum(1) # maximum of 50 op/s slider.setMaximum(70) # initial value in the middle slider.setValue(35) # connect the onValueChange event to the method passed to this widget slider.valueChanged.connect(onValueChanged) # type: ignore # slow/fast horizontal labels view slowFastLabelsLayout = QHBoxLayout() slowFastLabelsLayout.setContentsMargins(0, 0, 0, 0) slowLabel = QLabel("Slow") fastLabel = QLabel("Fast") slowFastLabelsLayout.addWidget(slowLabel) slowFastLabelsLayout.addStretch() slowFastLabelsLayout.addWidget(fastLabel) layout.addWidget(slider) layout.addLayout(slowFastLabelsLayout) self.setLayout(layout)
def __init__(self, table_view): """ A simple class that inherits QWidget and acts as a container for items added to QTableView cells """ super().__init__() self.table_view = table_view self.setAutoFillBackground(True) view_button = QPushButton(QIcon("icons/view.png"), None) view_button.clicked.connect(self.displayItemValues) delete_button = QPushButton(QIcon("icons/trash.png"), None) delete_button.clicked.connect(self.deleteTableRows) # Create the layout for the buttons cell_layout = QHBoxLayout() cell_layout.setContentsMargins(0, 0, 0, 0) cell_layout.setSpacing(0) cell_layout.addWidget(view_button) cell_layout.addWidget(delete_button) self.setLayout(cell_layout)