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)
class SettingsDialog(QDialog): 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) def selectTextColor(self): """Change the background color of the QPushButton to reflect the selected color. This is used to set the text color of the main window's QLineEdit.""" color = QColorDialog.getColor() # Returns QColor object # Use color.name() to get the color in the format "#RRGGBB" self.text_color_button.setStyleSheet( f"background-color: {color.name()}")
def UiComponents(self): button = QPushButton("Close Window", self) button.setGeometry(QRect(100, 100, 111, 50)) button.setIcon(QtGui.QIcon("home.png")) button.setIconSize(QSize(40, 40)) button.setToolTip("This Is Click Me Button") button.clicked.connect(ClickMe)
class SerialPortSelector(QWidget): open_port = pyqtSignal(str, int) close_port = pyqtSignal() def __init__(self, *args): super(SerialPortSelector, self).__init__(*args) self.disabled = False self.init_ui() self.add_ports() def init_ui(self): layout = QHBoxLayout() self.setLayout(layout) self.ports_list_combobox = QComboBox() layout.addWidget(self.ports_list_combobox) self.baud_rate_combobox = QComboBox() self.baud_rate_combobox.addItems([ '300', '600', '1200', '2400', '4800', '9600', '19200', '38400', '43000', '56000', '57600', '115200' ]) self.baud_rate_combobox.setCurrentText('115200') self.baud_rate_combobox.setEditable(True) layout.addWidget(self.baud_rate_combobox) self.open_btn = QPushButton('打开') self.open_btn.clicked.connect(self.handle_open_port) layout.addWidget(self.open_btn) self.refresh_btn = QPushButton('刷新') self.refresh_btn.clicked.connect(self.add_ports) layout.addWidget(self.refresh_btn) def add_ports(self): self.ports_list_combobox.clear() for port in comports(False): self.ports_list_combobox.addItem(port.name, port) def handle_open_port(self): if self.disabled: self.close_port.emit() else: port = self.ports_list_combobox.currentText() if port == "": return baud_rate = int(self.baud_rate_combobox.currentText()) self.open_port.emit(port, baud_rate) def set_disable(self, b): self.disabled = b self.ports_list_combobox.setDisabled(b) self.baud_rate_combobox.setDisabled(b) if self.disabled: self.open_btn.setText('关闭') else: self.open_btn.setText('打开')
def initUi(self): self.setWindowTitle('Calculadora Suma 💻') self.setFixedSize(300, 400) self.lbl_numero_1 = QLabel('Número 1: ', self) self.lbl_numero_1.move(50, 50) self.lbl_numero_2 = QLabel('Número 2: ', self) self.lbl_numero_2.move(50, 100) self.txt_numero_1 = QLineEdit(self) self.txt_numero_1.setFixedWidth(100) self.txt_numero_1.move(150, 50) self.txt_numero_1.setValidator(QDoubleValidator()) self.txt_numero_2 = QLineEdit(self) self.txt_numero_2.setFixedWidth(100) self.txt_numero_2.move(150, 100) self.txt_numero_2.setValidator(QDoubleValidator()) self.btn_sumar = QPushButton('Sumar', self) self.btn_sumar.setFixedWidth(100) self.btn_sumar.move(100, 170) self.btn_sumar.clicked.connect(self.sumar) # Evento Click self.lbl_resultado = QLabel('Resultado: ', self) self.lbl_resultado.move(50, 250) self.lbl_resultado = QLabel(self) self.lbl_resultado.setFixedWidth(100) self.lbl_resultado.move(150, 250)
def accountCreationPageUI(self): layout = QFormLayout() self.accountCreationPage.nameInput = QLineEdit() layout.addRow("Name", self.accountCreationPage.nameInput) self.accountCreationPage.phoneNumberInput = QLineEdit() layout.addRow("Phone Number", self.accountCreationPage.phoneNumberInput) self.accountCreationPage.passwordInput = QLineEdit() layout.addRow("New Password", self.accountCreationPage.passwordInput) self.accountCreationPage.passwordConfirmInput = QLineEdit() layout.addRow("Confirm New Password", self.accountCreationPage.passwordConfirmInput) self.accountCreationPage.createAccountButton = QPushButton( "&Create Account") self.accountCreationPage.createAccountButton.clicked.connect( self.createAccount) self.accountCreationPage.finishCreatingAccountsButton = QPushButton( "&Done") self.accountCreationPage.finishCreatingAccountsButton.clicked.connect( self.goTo_PlayerAdmissionsPage) layout.addRow(self.accountCreationPage.finishCreatingAccountsButton, self.accountCreationPage.createAccountButton) self.accountCreationPage.setLayout(layout)
def questionPlayPageUI(self): layout = QFormLayout() self.questionPlayPage.titleDisplay = QLabel() layout.addRow(self.questionPlayPage.titleDisplay) self.questionPlayPage.contentDisplay = QLabel() layout.addRow(self.questionPlayPage.contentDisplay) self.questionPlayPage.choiceList = QListWidget() self.questionPlayPage.playerScores = QLabel() layout.addRow(self.questionPlayPage.choiceList, self.questionPlayPage.playerScores) self.questionPlayPage.chooseButton = QPushButton("&Submit") self.questionPlayPage.chooseButton.clicked.connect( self.submitPlayQuestion) layout.addRow(self.questionPlayPage.chooseButton) self.questionPlayPage.collapseButton = QPushButton("Collapse!") self.questionPlayPage.collapseButton.clicked.connect( self.goTo_CollapsePage) self.questionPlayPage.abortButton = QPushButton("Abort") self.questionPlayPage.abortButton.clicked.connect( self.abortGameInProgress) layout.addRow(self.questionPlayPage.collapseButton, self.questionPlayPage.abortButton) self.questionPlayPage.setLayout(layout)
def __init__( self, onOpenLogButtonPressed: Callable[[], None], onAgentVarsButtonPressed: Callable[[], None], parent: Optional[QWidget] = None, *args: Tuple[Any, Any], **kwargs: Tuple[Any, Any], ) -> None: """ The "Open Log" and "Agent Variables" buttons view used for opening those windows. """ super(SolverWindowsButtonsView, self).__init__(parent=parent, *args, **kwargs) self.setContentsMargins(0, 0, 0, 0) layout = QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) # define the buttons openLogButton = QPushButton("Open Log") agentVarsButton = QPushButton("Agent Variables") # connect them to their respective methods openLogButton.pressed.connect(onOpenLogButtonPressed) # type: ignore agentVarsButton.pressed.connect(onAgentVarsButtonPressed) # type: ignore layout.addWidget(openLogButton) layout.addWidget(agentVarsButton) layout.setAlignment(openLogButton, Qt.Alignment.AlignHCenter) layout.setAlignment(agentVarsButton, Qt.Alignment.AlignHCenter) self.setLayout(layout)
def playerAdmissionsPageUI(self): layout = QFormLayout() self.playerAdmissionsPage.createAnAccountButton = QPushButton( "&Create New Account!") self.playerAdmissionsPage.createAnAccountButton.clicked.connect( self.goTo_AccountCreationPage) layout.addRow(self.playerAdmissionsPage.createAnAccountButton) self.playerAdmissionsPage.proceedToLoginButton = QPushButton("&Login") self.playerAdmissionsPage.proceedToLoginButton.clicked.connect( self.goTo_LoginPage) layout.addRow(self.playerAdmissionsPage.proceedToLoginButton) self.playerAdmissionsPage.readyList = QListWidget() layout.addRow(self.playerAdmissionsPage.readyList) self.playerAdmissionsPage.removePlayerButton = QPushButton( "&Remove Selected Players") self.playerAdmissionsPage.removePlayerButton.clicked.connect( self.removePlayerFromPlayerAdmissionsPageList) layout.addRow(self.playerAdmissionsPage.removePlayerButton) self.playerAdmissionsPage.startGameButton = QPushButton("&Start Game!") self.playerAdmissionsPage.startGameButton.clicked.connect( self.startNewGame) layout.addRow(self.playerAdmissionsPage.startGameButton) self.playerAdmissionsPage.proceedToFacilAuthPageButton = QPushButton( "&Faciliator Page") self.playerAdmissionsPage.proceedToFacilAuthPageButton.clicked.connect( self.goTo_FacilAuthPage) layout.addRow(self.playerAdmissionsPage.proceedToFacilAuthPageButton) self.playerAdmissionsPage.setLayout(layout)
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()
class Example(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): col = QColor(0, 0, 0) self.btn = QPushButton('Dialog', self) self.btn.move(20, 20) self.btn.clicked.connect(self.showDialog) self.frm = QFrame(self) self.frm.setStyleSheet("QWidget { background-color: %s }" % col.name()) self.frm.setGeometry(130, 22, 200, 200) self.setGeometry(300, 300, 450, 350) self.setWindowTitle('Color dialog') self.show() def showDialog(self): col = QColorDialog.getColor() if col.isValid(): self.frm.setStyleSheet("QWidget { background-color: %s }" % col.name())
def initUi(self): self.setWindowTitle('Demo QMessageBox') self.setFixedSize(400, 400) self.btn_mostrar_mensaje = QPushButton('Mostrar mensaje', self) self.btn_mostrar_mensaje.move(125, 150) self.btn_mostrar_mensaje.setFixedWidth(150) self.btn_mostrar_mensaje.clicked.connect(self.mostrar_mensaje)
def add_refresh_button(self, name, func): layout = self.v_layout btn = QPushButton(name, self) btn.setMaximumWidth(60) layout.insertWidget(0, btn) btn.clicked.connect(self._add_items_to_filter) btn.clicked.connect(super().accept) btn.clicked.connect(func)
class MainUi(QWidget): def __init__(self): super(MainUi, self).__init__() self.setFixedSize(600,500) self.setWindowTitle("妹子图爬虫工具 version: 1.0.0 ") self.download_progressbar = QProgressBar() self.download_progressbar.setAlignment(QtCore.Qt.Alignment.AlignCenter)#文字居中 self.download_progressbar.setStyleSheet(".QProgressBar::chunk { background-color: red;}")#背景 self.download_progressbar.setValue(100) label01 = QLabel("下载URL:") label02 = QLabel("下载目录:") self.url_input = QLineEdit() self.url_input.setText("https://www.mzitu.com/221746") self.url_input.setContentsMargins(0,0,0,0) self.download_dir = QLineEdit() self.download_dir.setContentsMargins(0,0,0,0) self.start_btn = QPushButton("开始爬虫") self.start_btn.setFixedHeight(50) self.start_btn.setContentsMargins(0,0,0,0) inputlayout = QGridLayout() inputlayout.addWidget(label01, 0, 0) #第0行 0列 inputlayout.addWidget(label02, 1, 0) inputlayout.addWidget(self.url_input, 0, 1) inputlayout.addWidget(self.download_dir, 1, 1) inputlayout.addWidget(self.start_btn, 0, 2, 2,1,QtCore.Qt.Alignment.AlignRight) #起始行,起始列, 占行数,占列数 inputlayout.setColumnStretch(0, 1) #设置每一列比例 inputlayout.setColumnStretch(1, 10) inputlayout.setColumnStretch(2, 1) vlayout = QVBoxLayout() vlayout.addLayout(inputlayout) vlayout.addWidget(self.download_progressbar) self.frame = QFrame() self.frame.setFixedHeight(400) vlayout.addWidget(self.frame) vlayout.addStretch() inputlayout.setContentsMargins(0,0,0,0) vlayout01 = QVBoxLayout() self.frame.setLayout(vlayout01) self.qtablewidget = QTableWidget(1,3) self.qtablewidget.setHorizontalHeaderLabels(['目录','下载图片总数目', '删除']) vlayout01.addWidget(self.qtablewidget) self.qtablewidget.setColumnWidth(0, 358) # 将第0列的单元格,设置成300宽度 self.qtablewidget.setColumnWidth(1, 100 ) # 将第0列的单元格,设置成50宽度 self.qtablewidget.verticalHeader().setVisible(False) #隐藏水平表头 #self.qtablewidget.setDisabled(True) #设置不可编辑 self.setLayout(vlayout) self.current_index = 0 def tableupdate(self,dir, pic_num, pushbtn ) -> None: self.qtablewidget.setRowCount(self.current_index+1) #设置行 diritem = QTableWidgetItem(str(dir)) self.qtablewidget.setItem( self.current_index, 0, diritem) pic_numitem = QTableWidgetItem(str(pic_num)) self.qtablewidget.setItem( self.current_index, 1, pic_numitem) self.qtablewidget.setCellWidget( self.current_index, 2, pushbtn ) self.current_index += 1
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()
class MainWidget(QWidget): def __init__(self): super(MainWidget, self).__init__() self.resize(500, 600) self.setWindowTitle("喜马拉雅下载 by[Zero] " + __VERSION__) self.mainlayout = QVBoxLayout() self.setLayout(self.mainlayout) self.groupbox = QGroupBox("选择类型") self.groupbox.setFixedHeight(50) hlayout = QHBoxLayout(self.groupbox) self.signal_m4a = QRadioButton("单个下载") self.mut_m4a = QRadioButton("专辑下载") self.vip_signal_m4a = QRadioButton("VIP单个下载") self.vip_m4a = QRadioButton("VIP专辑下载") hlayout.addWidget(self.signal_m4a) hlayout.addWidget(self.mut_m4a) hlayout.addWidget(self.vip_signal_m4a) hlayout.addWidget(self.vip_m4a) self.mainlayout.addWidget(self.groupbox) frame01 = QFrame(self) child_layout = QVBoxLayout() print(self.width()) label01 = QLabel("链 接", self) label02 = QLabel("下载目录", self) self.url_lineedit = QLineEdit(self) self.dir_lineedit = QLineEdit(self) hlayout01 = QHBoxLayout() hlayout01.addWidget(label01, 1) hlayout01.addWidget(self.url_lineedit, 9) hlayout02 = QHBoxLayout() hlayout02.addWidget(label02, 1) hlayout02.addWidget(self.dir_lineedit, 9) child_layout.addLayout(hlayout01) child_layout.addLayout(hlayout02) child_layout.setContentsMargins( 5, 0, 5, 0) #(int left, int top, int right, int bottom) frame01.setLayout(child_layout) self.download_progressbar = QProgressBar() self.download_progressbar.setAlignment( QtCore.Qt.Alignment.AlignCenter) #文字居中 self.download_progressbar.setValue(88) self.download_btn = QPushButton("开始下载") self.show_plaintextedit = QPlainTextEdit() self.show_plaintextedit.setMinimumHeight(400) self.mainlayout.addWidget(frame01) self.mainlayout.addWidget(self.download_progressbar) self.mainlayout.addWidget(self.download_btn) self.mainlayout.addWidget(self.show_plaintextedit) self.mainlayout.addStretch() ### 设置stylesheet self.download_btn.setStyleSheet( 'QPushButton:pressed{ text-align: center;background-color:red;}')
class Ventanaprincipal(QMainWindow): def __init__(self): QMainWindow.__init__(self) self.initGui() def initGui(self): self.setWindowTitle('Eliminacion de producto por ID') self.setFixedSize(400, 400) self.lbl_producto = QLabel('Producto:', self) self.lbl_producto.move(60, 120) self.txt_producto = QLineEdit(self) self.txt_producto.move(140, 120) self.txt_producto.setFixedWidth(200) self.txt_producto.setValidator(QIntValidator()) self.btn_eliminar = QPushButton('Eliminar', self) self.btn_eliminar.move(140, 170) self.btn_eliminar.setFixedWidth(200) self.btn_eliminar.clicked.connect(self.eliminar) self.lbl_resultado = QLabel('Resultado:', self) self.lbl_resultado.move(25, 250) self.lbl_resultado = QLabel(self) self.lbl_resultado.move(25, 270) self.lbl_resultado.setFixedWidth(350) #self.txt_resultado.setEnabled(False) def eliminar(self): confirmacion = QMessageBox(self) confirmacion.setText( f'Desea Eliminar el Producto con ID {self.txt_producto.text()}?') confirmacion.setIcon(QMessageBox.Icon.Question) confirmacion.setDetailedText( 'El producto se eliminará definitivamente...') confirmacion.setWindowTitle('Confirmación...') confirmacion.setStandardButtons(QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No) boton_yes = confirmacion.button(QMessageBox.StandardButton.Yes) confirmacion.exec() if confirmacion.clickedButton() == boton_yes: self.lbl_resultado.setText( f'Se ha eliminado el producto con ID {self.txt_producto.text()}.' ) else: self.lbl_resultado.setText( f'No se ha eliminado el producto con ID {self.txt_producto.text()}.' )
def button(self): self.btn0 = QPushButton('Start', self) self.btn0.setGeometry(0, 30, 150, 70) self.btn0.setStyleSheet('background-color:green') self.btn0.setFont(QFont('san serif', 15)) self.btn1 = QPushButton('Stop', self) self.btn1.setGeometry(150, 30, 150, 70) self.btn1.setStyleSheet('background-color:grey') self.btn1.setFont(QFont('san serif', 15)) self.btn0.clicked.connect(self.clickButton0) self.btn1.clicked.connect(self.clickButton1)
def __init__(self, parent): super(QWidget, self).__init__(parent) self.parent = parent self.saveButton = QPushButton("Save") self.saveButton.setEnabled(False) closeButton = QPushButton("Close") closeButton.clicked.connect(self.closeOnClick) hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(self.saveButton) hbox.addWidget(closeButton) self.setLayout(hbox)
def __init__(self, parent=None): super(MainWidget, self).__init__(parent) self.setWindowTitle("QThread Demo") self.thread = Worker() self.listFile = QListWidget() self.buttonStart = QPushButton("开始") layout = QGridLayout(self) layout.addWidget(self.listFile, 0, 0, 1, 2) layout.addWidget(self.buttonStart, 1, 1) self.buttonStart.clicked.connect(self.slotStart) self.thread.sinOut.connect(self.slodAdd)
def facilStartPageUI(self): layout = QFormLayout() self.facilStartPage.loginPlayersButton = QPushButton("Log In Players") self.facilStartPage.loginPlayersButton.clicked.connect( self.goTo_PlayerAdmissionsPage) layout.addRow(self.facilStartPage.loginPlayersButton) self.facilStartPage.questionBankButton = QPushButton("Question Bank") self.facilStartPage.questionBankButton.clicked.connect( self.goTo_QuestionBankPage) layout.addRow(self.facilStartPage.questionBankButton) self.facilStartPage.setLayout(layout)
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 __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 initUi(self): self.setWindowTitle('Demo Ventana de Saludo!!!') self.setFixedSize(400, 400) self.lbl_nombre = QLabel('Nombre: ', self) self.lbl_nombre.move(75, 50) self.txt_nombre = QLineEdit(self) self.txt_nombre.setFixedWidth(250) self.txt_nombre.move(75, 80) self.btn_saludar = QPushButton('Saludar', self) self.btn_saludar.setFixedWidth(250) self.btn_saludar.move(75, 120) self.btn_saludar.clicked.connect(self.mostrar_saludo)
class Ventana_Calculadora(QMainWindow): def __init__(self): QMainWindow.__init__(self) self.initUi() def initUi(self): self.setWindowTitle('Calculadora Suma') self.setFixedSize(300, 400) self.lbl_numero_1 = QLabel('Número 1: ', self) self.lbl_numero_1.move(50, 50) self.lbl_numero_2 = QLabel('Número 2: ', self) self.lbl_numero_2.move(50, 100) self.txt_numero_1 = QLineEdit(self) self.txt_numero_1.setFixedWidth(100) self.txt_numero_1.move(150, 50) self.txt_numero_1.setValidator(QIntValidator()) self.txt_numero_2 = QLineEdit(self) self.txt_numero_2.setFixedWidth(100) self.txt_numero_2.move(150, 100) self.txt_numero_2.setValidator(QIntValidator()) self.btn_sumar = QPushButton('Sumar', self) self.btn_sumar.setFixedWidth(100) self.btn_sumar.move(100, 170) self.btn_sumar.clicked.connect(self.sumar) # Evento Click self.lbl_resultado = QLabel('Resultado: ', self) self.lbl_resultado.move(50, 250) self.lbl_resultado = QLabel(self) self.lbl_resultado.setFixedWidth(100) self.lbl_resultado.move(150, 250) #self.lbl_resultado.setEnabled(False) def sumar(self): numero_1 = int(self.txt_numero_1.text()) numero_2 = int(self.txt_numero_2.text()) suma = numero_1 + numero_2 self.lbl_resultado.setText(str(suma))
def __init__(self, parent=None): QWidget.__init__(self, parent) self.l = l = QFormLayout(self) self.username = u = QLineEdit(self) u.textChanged.connect(self.changed.emit) l.addRow(_('&Username:'******'Username for this account')) self.password = p = QLineEdit(self) l.addRow(_('&Password:'******'Password for this account')) p.textChanged.connect(self.changed.emit) p.setEchoMode(QLineEdit.EchoMode.Password) self.show_password = sp = QCheckBox(_('&Show password')) l.addWidget(sp) sp.toggled.connect(self.show_password_toggled) self.la = la = QLabel(_('&Notes:')) l.addRow(la) self.notes = n = QPlainTextEdit(self) la.setBuddy(n) n.textChanged.connect(self.changed.emit) l.addRow(n) self.autosubmit = asb = QCheckBox( _('&Auto login with these credentials'), self) l.addRow(asb) asb.stateChanged.connect(self.on_change) self.rb = b = QPushButton(_('&Delete this account')) b.clicked.connect(self.delete_requested.emit) l.addRow(b)
def __init__(self, summary_plots=None): super(SummaryWindow, self).__init__() ## Create GUI Layout layout = QVBoxLayout() self.fig, self.axs = summary_plots() for axis in self.axs: axis.tick_params(axis='both', which='major', labelsize=9) axis.xaxis.label.set_fontsize(10) axis.yaxis.label.set_fontsize(10) self.fig.subplots_adjust(bottom=0.11) self.fig.subplots_adjust(hspace=0.3) self.canvas = FigureCanvas(self.fig) self.toolbar = NavigationToolbar(self.canvas, self) # Attach figure to the layout lf = QVBoxLayout() lf.addWidget(self.toolbar) lf.addWidget(self.canvas) layout.addLayout(lf) # add quit button bq = QPushButton("QUIT") bq.pressed.connect(self.close) lb = QVBoxLayout() # Layout for buttons lb.addWidget(bq) layout.addLayout(lb) self.setLayout(layout) self.setGeometry(100, 150, 1500, 900) # self.adjustSize() self.show() self.setWindowTitle('Last experiment summary')
def __init__(self): super().__init__() self.setWindowTitle("File Hash Checker") self.setGeometry(0, 0, 600, 300) self.labelFileDropper = FileDropper("Datei auswählen") #self.selectFileButton.clicked.connect(self.get_file_to_check) self.labelFileDropper.setAcceptDrops(True) self.labelFileDropper.setStyleSheet( "border: 1px solid black; border-radius: 15px; text-align: center; " "height: 200px") self.labelFileDropper.move(0, 0) self.labelFileDropper.resize(500, 150) self.labelMD5Hash = QLabel( "Bitte zu vergleichenden MD5 Hash eingeben:") self.textMD5Hash = QLineEdit() self.buttonCompareMD5 = QPushButton('MD5 Vergleichen') self.buttonCompareMD5.clicked.connect(self.compare_md5) self.labelIsSame = QLabel() layout = QVBoxLayout() layout.addWidget(self.labelFileDropper) layout.addWidget(self.labelMD5Hash) layout.addWidget(self.textMD5Hash) layout.addWidget(self.buttonCompareMD5) layout.addWidget(self.labelIsSame) self.setLayout(layout)
def _createButtons(self): """Create the buttons.""" self.buttons = {} buttonsLayout = QGridLayout() # Button text | position on the QGridLayout buttons = { "7": (0, 0), "8": (0, 1), "9": (0, 2), "/": (0, 3), "C": (0, 4), "4": (1, 0), "5": (1, 1), "6": (1, 2), "*": (1, 3), "(": (1, 4), "1": (2, 0), "2": (2, 1), "3": (2, 2), "-": (2, 3), ")": (2, 4), "0": (3, 0), "00": (3, 1), ".": (3, 2), "+": (3, 3), "=": (3, 4), } # Create the buttons and add them to the grid layout for btnText, pos in buttons.items(): self.buttons[btnText] = QPushButton(btnText) self.buttons[btnText].setFixedSize(40, 40) buttonsLayout.addWidget(self.buttons[btnText], pos[0], pos[1]) # Add buttonsLayout to the general layout self.generalLayout.addLayout(buttonsLayout)