def initUI(self): self.setWindowTitle(self.title) self.setGeometry(self.left, self.top, self.width, self.height) # create textboxs self.textbox1 = QTextEdit(self) self.textbox1.move(40, 40) self.textbox1.resize(560, 80) self.textbox1.setPlainText( 'The company fabricates plastic chairs.') # set an example self.textbox2 = QTextEdit(self) self.textbox2.move(40, 230) self.textbox2.resize(560, 80) # Create a button in the window self.button1 = QPushButton('Get triple', self) self.button1.move(500, 160) # connect button to function on_click self.button1.clicked.connect(self.on_click) # set button2 to clear textbox1 self.button2 = QPushButton('Clear', self) self.button2.move(420, 160) self.button2.clicked.connect(self.clear_click) # show must be the last self.show()
def __init__(self, console): super().__init__() self.layout = QVBoxLayout(self) self.titleText = QLabel("<H1>HashGenerator</H1>\nText Einfügen") self.layout.addWidget(self.titleText) self.textField = QTextEdit() self.layout.addWidget(self.textField) self.selectHash = QComboBox() self.selectHash.addItems( ["SHA1", "SHA224", "SHA256", "SHA384", "SHA512", "MD5"]) self.selectHash.setCurrentText("SHA512") self.layout.addWidget(self.selectHash) self.genButton = QPushButton("Generiere Hash") self.hashGenerator = HashGenerator() self.genButton.clicked.connect(self.generateHash) self.layout.addWidget(self.genButton) self.output = QTextEdit("Output") self.output.setReadOnly(True) self.layout.addWidget(self.output) self.layout.addStretch(1)
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(1205, 718) self.MainWindow = MainWindow self.buttonBox = QtWidgets.QDialogButtonBox(MainWindow) self.buttonBox.setGeometry(QtCore.QRect(840, 670, 341, 32)) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok) self.buttonBox.setObjectName("buttonBox") # 设置graphicsView,简称为view # 统一大小 self.viewHeight = 341 self.viewWidth = 301 # 设置显示窗口,一个一个添加 self.views: list = [] self.add_view(20, 50, self.viewHeight, self.viewWidth, name='input') self.add_view(440, 50, self.viewHeight, self.viewWidth, name='hidden1') self.add_view(850, 50, self.viewHeight, self.viewWidth, name='hidden2') self.add_view(20, 400, self.viewHeight, self.viewWidth, name='hidden3') self.add_view(440, 400, self.viewHeight, self.viewWidth, name='output') # 设置标签,并且用name作为其初始化内容,前7个是 self.labels = [] # for i in range(7): # self.add_label(940, 391 + i * 31, 111, 31, name='Top%d' % (i+1)) self.add_label(160, 10, 111, 31, name='原始图像') self.add_label(600, 10, 111, 31, name='隐藏层1') self.add_label(980, 10, 111, 31, name='隐藏层2') self.add_label(170, 360, 111, 31, name='隐藏层3') self.add_label(590, 360, 111, 31, name='输出层') self.add_label(980, 360, 111, 31, name='输出(Top7)') self.add_label(980, 550, 111, 31, name='位移坐标') # 设置结果的文本框(多文本框) self.textbox = QTextEdit(MainWindow) self.textbox.move(850, 400) self.textbox.resize(341, 150) l = [] for i in range(7): l.append(['Top%d' % (i + 1), [0, 0]]) self.textbox.setPlainText(self.list2str(l)) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) # 显示位移的框 self.indexbox = QTextEdit(MainWindow) self.indexbox.move(850, 580) self.indexbox.resize(341, 80) self.indexbox.setPlainText('(x, y) : (%d ,%d)' % (0, 0)) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def __init__(self, parent=None): super().__init__(parent) self.setWindowTitle('Direct tree') self.model = QFileSystemModel() self.model.setRootPath(QDir.rootPath()) self.tree = QTreeView() self.tree.setModel(self.model) self.tree.setRootIndex(self.model.index(os.getcwd())) self.tree.doubleClicked.connect(self._on_double_clicked) self.tree.setAnimated(False) self.tree.setIndentation(20) self.tree.setSortingEnabled(True) self.textEdit = QTextEdit() self.textEdit.setReadOnly(True) splitter = QSplitter() splitter.addWidget(self.tree) splitter.addWidget(self.textEdit) splitter.setSizes([50, 200]) self.setCentralWidget(splitter)
def setup_ui(self): self.splitter = QSplitter(self) self.l = l = QVBoxLayout(self) l.addWidget(self.splitter) l.addWidget(self.bb) self.w = w = QGroupBox(_('Theme Metadata'), self) self.splitter.addWidget(w) l = w.l = QFormLayout(w) self.missing_icons_group = mg = QGroupBox(self) self.mising_icons = mi = QListWidget(mg) mi.setSelectionMode(mi.NoSelection) mg.l = QVBoxLayout(mg) mg.l.addWidget(mi) self.splitter.addWidget(mg) self.title = QLineEdit(self) l.addRow(_('&Title:'), self.title) self.author = QLineEdit(self) l.addRow(_('&Author:'), self.author) self.version = v = QSpinBox(self) v.setMinimum(1), v.setMaximum(1000000) l.addRow(_('&Version:'), v) self.description = QTextEdit(self) l.addRow(self.description) self.refresh_button = rb = self.bb.addButton(_('&Refresh'), self.bb.ActionRole) rb.setIcon(QIcon(I('view-refresh.png'))) rb.clicked.connect(self.refresh) self.apply_report()
def setup_ui(self): self.l = l = QVBoxLayout(self) self.text = t = QTextEdit(self) t.setReadOnly(True) l.addWidget(t), l.addWidget(self.bb) self.bb.clear(), self.bb.setStandardButtons( QDialogButtonBox.StandardButton.Close)
def __init__(self, parent): TestableDialog.__init__(self, parent) self.text = QTextEdit() self.result = True self.btn_ok = QPushButton("OK") self.btn_cancel = QPushButton("Cancel") self.init_ui()
def __init__(self, parent): QDialog.__init__(self, parent) self.gui = parent self.setAttribute(Qt.WA_DeleteOnClose, False) self.setWindowIcon(QIcon(I('polish.png'))) self.reports = [] self.l = l = QGridLayout() self.setLayout(l) self.view = v = QTextEdit(self) v.setReadOnly(True) l.addWidget(self.view, 0, 0, 1, 2) self.backup_msg = la = QLabel('') l.addWidget(la, 1, 0, 1, 2) la.setVisible(False) la.setWordWrap(True) self.ign = QCheckBox(_('Ignore remaining report'), self) l.addWidget(self.ign, 2, 0) bb = self.bb = QDialogButtonBox(QDialogButtonBox.Close) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) b = self.log_button = bb.addButton(_('View full &log'), bb.ActionRole) b.clicked.connect(self.view_log) bb.button(bb.Close).setDefault(True) l.addWidget(bb, 2, 1) self.finished.connect(self.show_next, type=Qt.QueuedConnection) self.resize(QSize(800, 600))
def _init_controls(self): layout = QVBoxLayout(self) self.setLayout(layout) ml = QHBoxLayout() layout.addLayout(ml, 1) self.keys_list = QListWidget(self) self.keys_list.setSelectionMode(QAbstractItemView.SingleSelection) self.keys_list.setFixedWidth(150) self.keys_list.setAlternatingRowColors(True) ml.addWidget(self.keys_list) self.value_text = QTextEdit(self) self.value_text.setTabStopWidth(24) self.value_text.setReadOnly(False) ml.addWidget(self.value_text, 1) button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) button_box.accepted.connect(self._apply_changes) button_box.rejected.connect(self.reject) self.clear_button = button_box.addButton(_('Clear'), QDialogButtonBox.ResetRole) self.clear_button.setIcon(get_icon('trash.png')) self.clear_button.setToolTip(_('Clear all settings for this plugin')) self.clear_button.clicked.connect(self._clear_settings) layout.addWidget(button_box)
def create_host_details(host_layout, backend_data): """ Create QLabels for host details :param host_layout: layout of QWidget :type host_layout: QGridLayout :param backend_data: data of AppBackend :type backend_data: dict """ since_last_check = get_diff_since_last_check( backend_data['host']['ls_last_state_changed']) diff_last_check = get_diff_since_last_check( backend_data['host']['ls_last_check']) host_last_check = QLabel('<b>Since:</b> %s <b>Last check:</b> %s' % (since_last_check, diff_last_check)) host_layout.addWidget(host_last_check, 0, 2, 1, 2) date_output = get_date_from_timestamp( backend_data['host']['ls_last_check']) output = QTextEdit('<b>Output:</b> [%s] %s' % (date_output, backend_data['host']['ls_output'])) output.setObjectName('output') output.setTextInteractionFlags(Qt.TextSelectableByMouse) output.setFont(QFont('Times', 13)) host_layout.addWidget(output, 1, 2, 1, 2) address = QLabel('<b>Address:</b> %s' % backend_data['host']['address']) host_layout.addWidget(address, 2, 2, 1, 1) stars_widget = Service.get_stars_widget( int(backend_data['host']['business_impact'])) host_layout.addWidget(stars_widget, 2, 3, 1, 1) host_layout.setAlignment(stars_widget, Qt.AlignLeft)
def _set_down_frame_ui(self): self.down_frame = QFrame() self.down_layout = QHBoxLayout(self.down_frame) self.layout.addWidget(self.down_frame) self.textEdit = QTextEdit() self.down_layout.addWidget(self.textEdit)
def __init__(self, *args, **kwargs): super(GUIapp, self).__init__(*args, **kwargs) self.setWindowTitle("TEST 1.0") self.resize(800, 600) self.button1 = QPushButton("Input File") self.button1.clicked.connect(self.getFile) self.label1 = QLabel("Prediction") self.table = QTableWidget() self.label2 = QLabel("Insert CSV File") self.textEditor = QTextEdit() #self.setCentralWidget(self.graphWidget) #https: // stackoverflow.com / questions / 31775468 / show - string - values - on - x - axis - in -pyqtgraph # plot data: x, y values layout = QVBoxLayout() layout.addWidget(self.button1) layout.addWidget(self.label2) layout.addWidget(self.textEditor) layout.addWidget(self.label1) layout.addWidget(self.table) self.setLayout(layout)
def build_query_text_edit(self): # Add layouts query_edit_layout = QVBoxLayout(self) query_edit_layout.setContentsMargins(0, 0, 0, 0) query_control_layout = QHBoxLayout(self) query_control_layout.setContentsMargins(0, 0, 0, 0) # Execute query button self.query_execute_button = QPushButton( UI.QUERY_CONTROL_EXECUTE_BUTTON_TEXT, self) self.query_execute_button.clicked.connect(self.on_execute_click) query_control_layout.addWidget(self.query_execute_button) # Fetch data button self.query_fetch_button = QPushButton( UI.QUERY_CONTROL_FETCH_BUTTON_TEXT, self) self.query_fetch_button.clicked.connect(self.on_fetch_click) self.model.fetch_changed.connect(self.on_fetch_changed) query_control_layout.addWidget(self.query_fetch_button) # Commit button self.query_commit_button = QPushButton( UI.QUERY_CONTROL_COMMIT_BUTTON_TEXT, self) self.query_commit_button.clicked.connect(self.on_connect_click) query_control_layout.addWidget(self.query_commit_button) # Rollback button self.query_rollback_button = QPushButton( UI.QUERY_CONTROL_ROLLBACK_BUTTON_TEXT, self) self.query_rollback_button.clicked.connect(self.on_rollback_click) query_control_layout.addWidget(self.query_rollback_button) # Build control strip widget query_control = QWidget(self) query_control.setLayout(query_control_layout) query_edit_layout.addWidget(query_control) # Initialize query edit document for text editor # and use SQL Highlighter CSS styles for it. self.query_text_edit_document = QTextDocument(self) self.query_text_edit_document.setDefaultStyleSheet( SQLHighlighter.style()) # Initialize query text editor using previously built # text edutir document. self.query_text_edit = QTextEdit(self) self.query_text_edit.setDocument(self.query_text_edit_document) self.query_text_edit.textChanged.connect(self.on_query_changed) self.query_text_edit.setText(UI.QUERY_EDITOR_DEFAULT_TEXT) query_edit_layout.addWidget(self.query_text_edit) # Connect model's connected/disconnected signals self.model.connected.connect(self.on_connected) self.model.disconnected.connect(self.on_disconnected) query_edit = QWidget(self) query_edit.setLayout(query_edit_layout) query_edit.sizePolicy().setVerticalPolicy(QSizePolicy.Minimum) return query_edit
def setup_ui(self): l = QVBoxLayout(self) self.qte = qte = QTextEdit(self) qte.setMinimumHeight(400) qte.setMinimumWidth(600) if self.initial_notes: qte.setPlainText(self.initial_notes) l.addWidget(qte) l.addWidget(self.bb)
def initUI(self): # Title title = QLabel(self) title.setFont(self.titleFont) title.setText("TEXT TO THREAD") title.setMinimumWidth(int(self.width / 2)) title.move(5, 22) # Text box self.text = QTextEdit(self) self.text.setMinimumWidth(self.width - 10) self.text.setMinimumHeight(self.height - 110) self.text.move(5, 50) # Publish button self.send = QPushButton(self) self.send.setText("Publish") self.send.setMinimumWidth(self.width - 10) self.send.move(5, self.height - 35) self.send.clicked.connect(self.convertToThread) # Add images checkbox self.images = QCheckBox(self) self.images.setText("Add images") self.images.move(10, self.height - 62) # Create the menu bar menu = self.menuBar() actions = menu.addMenu("&Actions") # Clear the text box new = QAction("&New", self) new.setShortcut("Ctrl+N") new.setStatusTip("Clear the window") new.triggered.connect(self.text.clear) actions.addAction(new) # Send the tweets send = QAction("&Send", self) send.setShortcut("Ctrl+Return") send.setStatusTip("Send the tweets") send.triggered.connect(self.convertToThread) actions.addAction(send) # Rewrite the access credentials credentials = QAction("&Change credentials", self) credentials.setShortcut("Ctrl+R") credentials.setStatusTip("Change the credentials, restart required") credentials.triggered.connect(self.changeKeys) actions.addAction(credentials) # Exit from the app exit = QAction("&Exit", self) exit.setShortcut("Ctrl+Q") exit.setStatusTip("Exit from the app") exit.triggered.connect(sys.exit) actions.addAction(exit)
def test_width(self): cfg = Config() e = QTextEdit() ln = LineNumberArea(e, cfg) cfg["TextEditor/ShowLineNumbers"] = 1 self.assertTrue(ln.width() > 0) cfg["TextEditor/ShowLineNumbers"] = 0 self.assertTrue(ln.width() == 0)
def __init__(self, parent=None): super(EditQDialog, self).__init__(parent) self.setWindowTitle('Edit Dialog') self.setWindowFlags(Qt.FramelessWindowHint) self.setStyleSheet(settings.css_style) self.setWindowIcon(QIcon(settings.get_image('icon'))) self.setObjectName('dialog') self.setFixedSize(300, 300) # Fields self.text_edit = QTextEdit() self.old_text = ''
def __init__(self): super().__init__() layout = QVBoxLayout() self._output_field = QTextEdit() self._output_field.setTextInteractionFlags(Qt.NoTextInteraction) self._output_field.setPlaceholderText("Please wait for responses...") layout.addWidget(self._output_field) self.setLayout(layout)
def InitGUI(self): self.widget = QWidget() self.review = QTextEdit() grid = QHBoxLayout() grid.addWidget(self.review) self.creat_tool() self.setWindowTitle('Education') self.widget.setLayout(grid) self.setCentralWidget(self.widget) self.statusBar().showMessage('未选择') self.show()
def _set_log_ui(self): log_frame = QFrame() log_layout = QGridLayout(log_frame) self.main_layout.addWidget(log_frame) self.textedit_log = QTextEdit() self.textedit_log.setAcceptDrops(False) # self.textedit_log.setEnabled(False) log_layout.addWidget(self.textedit_log) btn_clear_log = QPushButton('ClearLog') btn_clear_log.clicked.connect(self.clear_log) log_layout.addWidget(btn_clear_log)
def __init__(self, gui, icon, do_user_config): QDialog.__init__(self, gui) self.gui = gui self.do_user_config = do_user_config self.threadpool = QThreadPool() # The current database shown in the GUI # db is an instance of the class LibraryDatabase from db/legacy.py # This class has many, many methods that allow you to do a lot of # things. For most purposes you should use db.new_api, which has # a much nicer interface from db/cache.py self.db = gui.current_db # Window properties self.setWindowTitle('Humble-Bundle Downloader') self.setWindowIcon(icon) # Create main layout self.mainlayout = QHBoxLayout() self.setLayout(self.mainlayout) # Create layout for buttons self.buttonlayout = QVBoxLayout() self.mainlayout.addLayout(self.buttonlayout) # Add label self.label = QLabel('') self.buttonlayout.addWidget(self.label) # Add config button self.conf_button = QPushButton('Configure', self) self.conf_button.clicked.connect(self.config) self.buttonlayout.addWidget(self.conf_button) # Add Sync button self.Import_button = QPushButton('Import', self) self.Import_button.clicked.connect(self.Download) self.buttonlayout.addWidget(self.Import_button) # Add 'about' button self.about_button = QPushButton('About', self) self.about_button.clicked.connect(self.about) self.buttonlayout.addWidget(self.about_button) # Add log pane self.textlog = QTextEdit(self) self.mainlayout.addWidget(self.textlog) self.textlog.setReadOnly(True) self.refresh_label() self.check_field_exists() self.resize(800, 200)
def init_results_widget(self): results_widget = QTabWidget(self) results_widget.setTabsClosable(False) table_view = QTableView(self) table_view.setModel(self.model) table_view.sizePolicy().setVerticalPolicy( QSizePolicy.MinimumExpanding) results_widget.addTab(table_view, 'Data') log = QTextEdit(self) log.setReadOnly(True) self.model.executed.connect(log.append) results_widget.addTab(log, 'Events') return results_widget
def create_main_frame(self): page = QWidget() self.button = QPushButton('OK', page) self.textWindow = QTextEdit() vbox1 = QVBoxLayout() vbox1.addWidget(self.textWindow) vbox1.addWidget(self.button) page.setLayout(vbox1) self.setCentralWidget(page) self.button.clicked.connect(self.clicked)
def __init__(self): super(LogWindow, self).__init__() self.text_area = QTextEdit() self.text_area.setReadOnly(True) self.clear_btn = QPushButton("Clear") self.run_btn = QPushButton("Run") v_box = QVBoxLayout() v_box.addWidget(self.text_area) h1 = QHBoxLayout() h1.addWidget(self.run_btn) h1.addWidget(self.clear_btn) v_box.addLayout(h1) self.setLayout(v_box)
def __init__(self, parent=None): super(DownQDialog, self).__init__(parent) self.setWindowTitle(_('Request a Downtime')) self.setWindowFlags(Qt.FramelessWindowHint) self.setStyleSheet(settings.css_style) self.setWindowIcon(QIcon(settings.get_image('icon'))) self.setMinimumSize(360, 460) self.setObjectName('dialog') # Fields self.fixed = True self.fixed_toggle_btn = ToggleQWidgetButton() self.duration = QTimeEdit() self.start_time = QDateTimeEdit() self.end_time = QDateTimeEdit() self.comment_edit = QTextEdit() self.offset = None
def setup_ui(self, window): window.setObjectName("MainWindow") window.showMaximized() bt = QPushButton('Submit', window) bt.move(480, 480) bt.setToolTip("This is a <a style=\"color:red\">button</a>!") bt.clicked.connect(lambda: print("Hi,mouse.")) bt.show() text_box = QTextEdit(window) text_box.move(180, 50) text_box.resize(700, 400) text_box.show() timer = QtCore.QTimer(window) timer.timeout.connect(lambda: print("aaa")) timer.start(1000) timer.timeout.connect(lambda: print("aaa"))
def __init__(self, parent, plugin_name, html): SizePersistedDialog.__init__(self, parent, 'Plugin Updater plugin:version history dialog') self.setWindowTitle(_('Version History for %s')%plugin_name) layout = QVBoxLayout(self) self.setLayout(layout) self.notes = QTextEdit(html, self) self.notes.setReadOnly(True) layout.addWidget(self.notes) self.button_box = QDialogButtonBox(QDialogButtonBox.Close) self.button_box.rejected.connect(self.reject) layout.addWidget(self.button_box) # Cause our dialog size to be restored from prefs or created on first usage self.resize_dialog()
def build_results_widget(self): # Initialize QTabWidget to display table view and log # in differnt unclosable tabs results_widget = QTabWidget(self) results_widget.setTabsClosable(False) # Add table view table_view = QTableView(self) table_view.setModel(self.model) table_view.sizePolicy().setVerticalPolicy(QSizePolicy.MinimumExpanding) results_widget.addTab(table_view, UI.QUERY_RESULTS_DATA_TAB_TEXT) # Att log view log = QTextEdit(self) log.setReadOnly(True) self.model.executed.connect(log.append) results_widget.addTab(log, UI.QUERY_RESULTS_EVENTS_TAB_TEXT) return results_widget
def manual_input(self): self.status_label.setText("") edit_dialog = QDialog(self) verticalLayout = QVBoxLayout(edit_dialog) title_input = QLineEdit('title here', edit_dialog) editor = QTextEdit(edit_dialog) verticalLayout.addWidget(title_input) verticalLayout.addWidget(editor) buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.manual_input_text = "" self.manual_input_title = "" def editor_accepted(): if editor.toPlainText(): self.manual_input_text = editor.toHtml() self.manual_input_title = title_input.text().strip() edit_dialog.close() def editor_rejected(): edit_dialog.close() buttonBox.accepted.connect(editor_accepted) buttonBox.rejected.connect(editor_rejected) verticalLayout.addWidget(buttonBox) edit_dialog.exec_() if self.manual_input_text: existing_doc_id_list_part = [] # existing feed id between now and mark conn = sqlite3.connect(get_path("user_files", "doc.db"), detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES) cur = conn.cursor() cur.execute("select feed_id from doc where feed_id between ? and ?", (int(time.time()*1000), int(time.time()*1000)+10000)) while True: doc_id = int(time.time()*1000) if doc_id not in existing_doc_id_list_part: break cur.execute("""insert into doc (doc_id, title, descr, doc_type) values (?, ?, ?, 'mi')""", (doc_id, self.manual_input_title, self.manual_input_text)) conn.commit() conn.close() self.manual_input_text = "" self.status_label.setText("Manual Load Completed")
def init_results_widget(self): # Initialize QTabWidget to display table view and log # in differnt unclosable tabs results_widget = QTabWidget(self) results_widget.setTabsClosable(False) # Add table view table_view = QTableView(self) table_view.setModel(self.model) table_view.sizePolicy().setVerticalPolicy( QSizePolicy.MinimumExpanding) results_widget.addTab(table_view, 'Data') # Att log view log = QTextEdit(self) log.setReadOnly(True) self.model.executed.connect(log.append) results_widget.addTab(log, 'Events') return results_widget