def __init__(self, data, parent=None): QWidget.__init__(self, parent) self.data = data vbox = QVBoxLayout() self.setLayout(vbox) title = QLabel('Indexed Strings') vbox.addWidget(title) self.frame = QFrame() vbox.addWidget(self.frame) self.vbox = QVBoxLayout() self.frame.setLayout(self.vbox) self.frame.setFrameShape(QFrame.Panel) self.frame.setFrameShadow(QFrame.Sunken) self.table = QTableWidget() self.table.horizontalHeader().hide() self.vbox.addWidget(self.table) self.table.hide() self.noStringsLabel = QLabel('<i>No indexed strings</i>') self.vbox.addWidget(self.noStringsLabel) self.widgets = [] self.populate() self.data.attributeAdded.connect(self.attributeAddedSlot) self.data.dataReset.connect(self.dataResetSlot) self.data.dirtied.connect(self.dataDirtiedSlot)
def setupUi(self, widget): """ Creates and lays out the widgets defined in the ui file. :Parameters: widget : `QtGui.QWidget` Base widget """ #super(PreferencesDialog, self).setupUi(widget) # TODO: Switch back to this if we get loadUiType working. self.baseInstance = loadUiWidget("preferences_dialog.ui", self) self.setWindowIcon(QIcon.fromTheme("preferences-system")) self.buttonFont.setIcon(QIcon.fromTheme("preferences-desktop-font")) self.buttonNewProg.setIcon(QIcon.fromTheme("list-add")) # ----- General tab ----- # Set initial preferences. parent = self.parent() self.checkBox_parseLinks.setChecked(parent.preferences['parseLinks']) self.checkBox_newTab.setChecked(parent.preferences['newTab']) self.checkBox_syntaxHighlighting.setChecked( parent.preferences['syntaxHighlighting']) self.checkBox_teletypeConversion.setChecked( parent.preferences['teletype']) self.checkBox_lineNumbers.setChecked(parent.preferences['lineNumbers']) self.checkBox_showAllMessages.setChecked( parent.preferences['showAllMessages']) self.checkBox_showHiddenFiles.setChecked( parent.preferences['showHiddenFiles']) self.checkBox_autoCompleteAddressBar.setChecked( parent.preferences['autoCompleteAddressBar']) self.useSpacesCheckBox.setChecked(parent.preferences['useSpaces']) self.useSpacesSpinBox.setValue(parent.preferences['tabSpaces']) self.lineEditTextEditor.setText(parent.preferences['textEditor']) self.lineEditDiffTool.setText(parent.preferences['diffTool']) self.updateFontLabel() # ----- Programs tab ----- self.progLayout = QVBoxLayout() self.extLayout = QVBoxLayout() # Extensions can only be: <optional .><alphanumeric><optional comma><optional space> #self.progValidator = QRegExpValidator(QRegExp("[\w,. ]+"), self) self.extValidator = QRegExpValidator(QRegExp(r"(?:\.?\w*,?\s*)+"), self) self.lineEdit.setValidator(self.extValidator) # Create the fields for programs and extensions. self.populateProgsAndExts(parent.programs)
def main(): import sys app = QApplication(sys.argv) layout = QVBoxLayout() infos = QSerialPortInfo.availablePorts() for info in infos: s = ( f"Port: {info.portName()}", f"Location: {info.systemLocation()}", f"Description: {info.description()}", f"Manufacturer: {info.manufacturer()}", f"Serial number: {info.serialNumber()}", "Vendor Identifier: " + f"{info.vendorIdentifier():x}" if info.hasVendorIdentifier() else "", "Product Identifier: " + f"{info.productIdentifier():x}" if info.hasProductIdentifier() else "", ) label = QLabel("\n".join(s)) layout.addWidget(label) workPage = QWidget() workPage.setLayout(layout) area = QScrollArea() area.setWindowTitle("Info about all available serial ports.") area.setWidget(workPage) area.show() sys.exit(app.exec_())
def __init__(self, parent=None): super().__init__(parent) self.m_icon = QLabel() self.m_title = QLabel() self.m_message = QLabel() self.notification = None self.setWindowFlags(Qt.ToolTip) rootLayout = QHBoxLayout(self) rootLayout.addWidget(self.m_icon) bodyLayout = QVBoxLayout() rootLayout.addLayout(bodyLayout) titleLayout = QHBoxLayout() bodyLayout.addLayout(titleLayout) titleLayout.addWidget(self.m_title) titleLayout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding)) close = QPushButton(self.tr("Close")) titleLayout.addWidget(close) close.clicked.connect(self.onClosed) bodyLayout.addWidget(self.m_message) self.adjustSize()
def __init__(self, url: QUrl) -> None: super().__init__() self.setupUi(self) self.m_cookies = [] self.m_urlLineEdit.setText(url.toString()) self.m_layout = QVBoxLayout() self.m_layout.addItem( QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)) self.m_layout.setContentsMargins(0, 0, 0, 0) self.m_layout.setSpacing(0) w = QWidget() p = w.palette() p.setColor(self.widget.backgroundRole(), Qt.white) w.setPalette(p) w.setLayout(self.m_layout) self.m_scrollArea.setWidget(w) self.m_scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.m_scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.m_urlButton.clicked.connect(self.handleUrlClicked) self.m_deleteAllButton.clicked.connect(self.handleDeleteAllClicked) self.m_newButton.clicked.connect(self.handleNewClicked) self.m_store: QWebEngineCookieStore = self.m_webview.page().profile( ).cookieStore() self.m_store.cookieAdded.connect(self.handleCookieAdded) self.m_store.loadAllCookies() self.m_webview.load(url)
def __init__(self, page, parent=None): super(HelpForm, self).__init__(parent) self.setAttribute(Qt.WA_DeleteOnClose) self.setAttribute(Qt.WA_GroupLeader) backAction = QAction(QIcon(":/back.png"), "&Back", self) backAction.setShortcut(QKeySequence.Back) homeAction = QAction(QIcon(":/home.png"), "&Home", self) homeAction.setShortcut("Home") self.pageLabel = QLabel() toolBar = QToolBar() toolBar.addAction(backAction) toolBar.addAction(homeAction) toolBar.addWidget(self.pageLabel) self.textBrowser = QTextBrowser() layout = QVBoxLayout() layout.addWidget(toolBar) layout.addWidget(self.textBrowser, 1) self.setLayout(layout) backAction.triggered.connect(self.tbackward) homeAction.triggered.connect(self.thome) self.textBrowser.sourceChanged.connect(self.updatePageTitle) self.textBrowser.setSearchPaths([":/help"]) self.textBrowser.setSource(QUrl(page)) self.resize(400, 600) self.setWindowTitle("{0} Help".format(QApplication.applicationName()))
def _build_ui(self): fields = self._entity.fields() fields = [ x for x in fields if x.name not in ('id', 'timestamp', 'username') ] lyt_buttons = QHBoxLayout() lyt_buttons.addWidget(self._btn_create) lyt_buttons.addWidget(self._btn_cancel) r = 0 lyt_grid = QGridLayout() for field in fields: editor = QLineEdit() if field.type == int: editor = QSpinBox() editor.setRange(-1000000, 1000000) self._wdg_map[field] = editor lyt_grid.addWidget(QLabel(field.name), r, 0) lyt_grid.addWidget(editor, r, 1) r += 1 lyt_main = QVBoxLayout() lyt_main.addLayout(lyt_grid) lyt_main.addLayout(lyt_buttons) self.setLayout(lyt_main)
def __init__(self, parent=None): super(QLineNumberArea, self).__init__(parent) self.fixWidth = 10 self.paintLineNum = -1 self.current_line = -1 self.editor = parent layout = QVBoxLayout() self.setLayout(layout)
def __init__(self): super(VariablesTool, self).__init__() self.setMinimumSize(QtCore.QSize(200, 50)) self.content = QWidget() self.content.setObjectName("VariablesToolContent") self.verticalLayout = QVBoxLayout(self.content) self.verticalLayout.setSpacing(0) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setObjectName("verticalLayout") self.setWidget(self.content)
def __init__(self): super().__init__() if separate_colorbars: if rescale_colorbars: self.vmins = tuple(np.min(u[0]) for u in U) self.vmaxs = tuple(np.max(u[0]) for u in U) else: self.vmins = tuple(np.min(u) for u in U) self.vmaxs = tuple(np.max(u) for u in U) else: if rescale_colorbars: self.vmins = (min(np.min(u[0]) for u in U),) * len(U) self.vmaxs = (max(np.max(u[0]) for u in U),) * len(U) else: self.vmins = (min(np.min(u) for u in U),) * len(U) self.vmaxs = (max(np.max(u) for u in U),) * len(U) layout = QHBoxLayout() plot_layout = QGridLayout() self.colorbarwidgets = [cbar_widget(self, vmin=vmin, vmax=vmax) if cbar_widget else None for vmin, vmax in zip(self.vmins, self.vmaxs)] plots = [widget(self, grid, vmin=vmin, vmax=vmax, bounding_box=bounding_box, codim=codim) for vmin, vmax in zip(self.vmins, self.vmaxs)] if legend: for i, plot, colorbar, l in zip(range(len(plots)), plots, self.colorbarwidgets, legend): subplot_layout = QVBoxLayout() caption = QLabel(l) caption.setAlignment(Qt.AlignHCenter) subplot_layout.addWidget(caption) if not separate_colorbars or backend == 'matplotlib': subplot_layout.addWidget(plot) else: hlayout = QHBoxLayout() hlayout.addWidget(plot) if colorbar: hlayout.addWidget(colorbar) subplot_layout.addLayout(hlayout) plot_layout.addLayout(subplot_layout, int(i/columns), (i % columns), 1, 1) else: for i, plot, colorbar in zip(range(len(plots)), plots, self.colorbarwidgets): if not separate_colorbars or backend == 'matplotlib': plot_layout.addWidget(plot, int(i/columns), (i % columns), 1, 1) else: hlayout = QHBoxLayout() hlayout.addWidget(plot) if colorbar: hlayout.addWidget(colorbar) plot_layout.addLayout(hlayout, int(i/columns), (i % columns), 1, 1) layout.addLayout(plot_layout) if not separate_colorbars: layout.addWidget(self.colorbarwidgets[0]) for w in self.colorbarwidgets[1:]: w.setVisible(False) self.setLayout(layout) self.plots = plots
def showSystemSettings(system): from brigks.gui.systemSettingsWidget import SystemSettingsWidget widget = SystemSettingsWidget(system) dialog = QDialog() layout = QVBoxLayout() layout.addWidget(widget) dialog.setLayout(layout) if not dialog.exec_(): return
def DDTree(): tree = TreeWidget() dialog = QDialog() layout = QVBoxLayout() layout.addWidget(tree) dialog.setLayout(layout) if not dialog.exec_(): return
def _build_ui(self): layout = QVBoxLayout() self.results = QTextBrowser() font = QFontDatabase.systemFont(QFontDatabase.FixedFont) self.results.setFont(font) layout.insertWidget(0, self.results, 1) self.ui_area.setLayout(layout) self.manage(None)
def __init__(self, parent: QWidget = None): super().__init__(parent) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.server = QLocalServer(self) if not self.server.listen("fortune"): QMessageBox.critical( self, self.tr("Local Fortune Server"), self.tr("Unable to start the server: %s." % (self.server.errorString())), ) QTimer.singleShot(0, self.close) return statusLabel = QLabel() statusLabel.setWordWrap(True) statusLabel.setText( self. tr("The server is running.\nRun the Local Fortune Client example now." )) self.fortunes = ( self.tr( "You've been leading a dog's life. Stay off the furniture."), self.tr("You've got to think about tomorrow."), self.tr("You will be surprised by a loud noise."), self.tr("You will feel hungry again in another hour."), self.tr("You might have mail."), self.tr("You cannot kill time without injuring eternity."), self.tr( "Computers are not intelligent. They only think they are."), ) quitButton = QPushButton(self.tr("Quit")) quitButton.setAutoDefault(False) quitButton.clicked.connect(self.close) self.server.newConnection.connect(self.sendFortune) buttonLayout = QHBoxLayout() buttonLayout.addStretch(1) buttonLayout.addWidget(quitButton) buttonLayout.addStretch(1) mainLayout = QVBoxLayout(self) mainLayout.addWidget(statusLabel) mainLayout.addLayout(buttonLayout) self.setWindowTitle(QGuiApplication.applicationDisplayName())
def __init__(self): super(HistoryTool, self).__init__() self.setMinimumSize(QtCore.QSize(200, 50)) self.content = QWidget() self.content.setObjectName("historyToolContent") self.verticalLayout = QVBoxLayout(self.content) self.verticalLayout.setSpacing(0) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setObjectName("verticalLayout") self.undoStackView = QUndoView(self) self.undoStackView.setObjectName("undoStackView") self.verticalLayout.addWidget(self.undoStackView) self.setWidget(self.content)
def get_horizontal_separator(): v_div_w = QWidget() v_div_l = QVBoxLayout() v_div_l.setAlignment(Qt.AlignLeft) v_div_l.setContentsMargins(0, 0, 0, 0) v_div_l.setSpacing(0) v_div_w.setLayout(v_div_l) v_div = QFrame() v_div.setMinimumHeight(30) v_div.setFrameShape(QFrame.VLine) v_div.setFrameShadow(QFrame.Sunken) v_div_l.addWidget(v_div) return v_div_w
def setupUI(self): self.setWindowTitle("浏览窗口") self.ui = loadUi(file_path + "\\res\\UI\\CenterWidget.ui") self.ui.setParent(self) self.setLayout(QVBoxLayout()) self.layout().addWidget(self.ui) self.layout().setContentsMargins(0,0,0,0) self.child_widget = self.ui.findChild(QWidget, "widget") # 设置选择窗口 self.widget = SelWidget() layout = QVBoxLayout() self.child_widget.setLayout(layout) self.child_widget.layout().addWidget(self.widget) self.flowLayout = layouitflow.FlowLayout() self.widget.setLayout(self.flowLayout) #瀑布流布局 self.widget.layout().setSpacing(0) #设置间距
def __init__(self, parent): self.figure = Figure() self.canvas = FigureCanvas(self.figure) self.canvas.setParent(parent) self.mpl_toolbar = NavigationToolbar(self.canvas, parent) self.axes = self.figure.add_subplot(111) self.grid_layout = QVBoxLayout() self.grid_layout.addWidget(self.canvas) self.grid_layout.addWidget(self.mpl_toolbar) parent.setLayout(self.grid_layout) self.clear()
def _build_ui(self): self._tree.setRootIsDecorated(False) self._tree.setSelectionMode(QTreeWidget.ExtendedSelection) lyt_main = QVBoxLayout() if self._allow_create: lyt_top = QHBoxLayout() lyt_top.setContentsMargins(0, 0, 0, 0) lyt_top.setSpacing(0) lyt_top.addWidget(self._btn_add) lyt_top.addStretch() lyt_main.addLayout(lyt_top) lyt_main.addWidget(self._tree) self.setLayout(lyt_main)
def setUI(self): """设置界面""" #加载ui #self.ui = loadUi(btnWin_ui) self.ui = loadUi(btnWin_ui) self.ui.setParent(self) #设置布局 self.setLayout(QVBoxLayout()) self.layout().setContentsMargins(1.5, 1.5, 1.5, 1.5) self.layout().addWidget(self.ui)
def get_column_layout(*widgets): """ Returns a QVBoxLayout with all given widgets added to it :param widgets: list<QWidget> :return: QVBoxLayout """ layout = QVBoxLayout() for w in widgets: if isinstance(w, QWidget): layout.addWidget(w) elif isinstance(w, QLayout): layout.addLayout(w) return layout
def __init__(self, parent, canvas=None): super(NodesBox, self).__init__(parent) self.canvasRef = weakref.ref(canvas) self.verticalLayout = QVBoxLayout(self) self.verticalLayout.setObjectName("verticalLayout") self.verticalLayout.setContentsMargins(4, 4, 4, 4) self.lineEdit = NodeBoxLineEdit(self) self.lineEdit.setObjectName("lineEdit") self.verticalLayout.addWidget(self.lineEdit) self.treeWidget = NodeBoxTreeWidget(self) self.treeWidget.setObjectName("treeWidget") self.treeWidget.headerItem().setText(0, "1") self.verticalLayout.addWidget(self.treeWidget) self.lineEdit.textChanged.connect(self.leTextChanged) self.treeWidget.refresh()
def __init__(self, parent=None): QScrollArea.__init__(self, parent) self.setWidgetResizable(True) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self._layout = QVBoxLayout() self._layout.setContentsMargins(0, 0, 0, 0) self._layout.setSpacing(Counters.SPACING) widget = QWidget() widget.setLayout(self._layout) self.setWidget(widget) self.setFixedWidth(200) self.checked_buttons = dict()
def _setup_login_dialog(dialog, account_input, password_input): dialog.setWindowTitle('登录CGTeamWork') account_input.setPlaceholderText('CGTeamwork账号名') password_input.setPlaceholderText('密码') password_input.setEchoMode(QLineEdit.Password) ok_button = QPushButton('登录') ok_button.setDefault(True) ok_button.clicked.connect(dialog.accept) layout = QVBoxLayout(dialog) layout.addWidget(QLabel('帐号')) layout.addWidget(account_input) layout.addWidget(QLabel('密码')) layout.addWidget(password_input) layout.addWidget(ok_button) dialog.setLayout(layout)
def __init__(self, font, textColor, parent=None): super(TextEditDialog, self).__init__(parent) self.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint) self.resize(QtCore.QSize(400, 300)) self.layout = QVBoxLayout(self) self.layout.setContentsMargins(2, 2, 2, 2) self.te = TextEditingField() self.te.accepted.connect(self.onAccept) self._font = QtGui.QFont(font) self.te.setTextColor(textColor) self.layout.addWidget(self.te) self.buttons = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self) self.buttons.accepted.connect(self.onAccept) self.buttons.rejected.connect(self.onReject) self.layout.addWidget(self.buttons) self._result = None
def _build_ui(self): self._lyt_grid.setContentsMargins(0, 0, 0, 0) self._lyt_grid.setSpacing(10) self._lyt_grid.setAlignment(Qt.AlignTop | Qt.AlignLeft) scroll_area = QScrollArea() scroll_area.setFrameStyle(0) scroll_area.setWidget(QWidget()) scroll_area.widget().setLayout(self._lyt_grid) scroll_area.setWidgetResizable(True) lyt_main = QVBoxLayout() lyt_main.setContentsMargins(0, 0, 0, 0) lyt_main.setSpacing(0) lyt_main.addWidget(scroll_area) lyt_main.addWidget(self._toolbar) self.setLayout(lyt_main)
def setupUI(self): self.setMinimumSize(Data.getWindowWidth() / 4.7, Data.getWindowHeight() / 2) self.setMaximumSize(Data.getWindowWidth() / 4.7, Data.getWindowHeight() / 2) self.setWindowModality(Qt.ApplicationModal) Data.setWindowCenter(self) self.setLayout(QVBoxLayout()) btn = MPushButton("SIGNAL IN") btn.setIcon(QIcon(file_path + r"\res\ZeusDesign\a.png")) self.layout().addWidget(btn) self.layout().addWidget(MDivider()) self.line_edit_name = MLineEdit() self.line_edit_name.setPlaceholderText('username') self.line_edit_name.set_prefix_widget( MToolButton().svg('user_line.svg').icon_only()) self.line_edit_password = MLineEdit() self.line_edit_password.setPlaceholderText('password') self.line_edit_password.setEchoMode(QLineEdit.Password) self.line_edit_password.set_prefix_widget( MToolButton().svg('confirm_line.svg').icon_only()) self.layout().addWidget(self.line_edit_name) self.layout().addWidget(self.line_edit_password) self.layout().addWidget(MDivider()) self.btn_sign_in = MPushButton(u'登录').large().primary() self.layout().addWidget(self.btn_sign_in) self.btn_sign_up = MPushButton(u'注册').large().primary() self.layout().addWidget(self.btn_sign_up) dayu_theme.background_color = "#262626" dayu_theme.apply(self) self.layout().setContentsMargins(20, 40, 20, 40) self.btn_sign_up.clicked.connect(self.on_sigin_up_click) self.btn_sign_in.clicked.connect(self.on_sigin_in_click) self.setWindowTitle(u"登录界面")
def __init__(self, id_, items, parent=None): super().__init__(parent) itemLabel = QLabel(self.tr("Item: ")) descriptionLabel = QLabel(self.tr("Description: ")) imageFileLabel = QLabel(self.tr("Image file: ")) self.createButtons() self.itemText = QLabel() self.descriptionEditor = QTextEdit() self.imageFileEditor = QComboBox() self.imageFileEditor.setModel(items.relationModel(1)) self.imageFileEditor.setModelColumn( items.relationModel(1).fieldIndex("file")) self.mapper = QDataWidgetMapper(self) self.mapper.setModel(items) self.mapper.setSubmitPolicy(QDataWidgetMapper.ManualSubmit) self.mapper.setItemDelegate(QSqlRelationalDelegate(self.mapper)) self.mapper.addMapping(self.imageFileEditor, 1) self.mapper.addMapping(self.itemText, 2, b"text") self.mapper.addMapping(self.descriptionEditor, 3) self.mapper.setCurrentIndex(id_) self.descriptionEditor.textChanged.connect(self.enableButtons) self.imageFileEditor.currentIndexChanged.connect(self.enableButtons) formLayout = QFormLayout() formLayout.addRow(itemLabel, self.itemText) formLayout.addRow(imageFileLabel, self.imageFileEditor) formLayout.addRow(descriptionLabel, self.descriptionEditor) layout = QVBoxLayout() layout.addLayout(formLayout) layout.addWidget(self.buttonBox) self.setLayout(layout) self.itemId = id_ self.displayedImage = self.imageFileEditor.currentText() self.setWindowFlags(Qt.Window) self.enableButtons(False) self.setWindowTitle(self.itemText.text())
def _setup_login_dialog(dialog, account_input, password_input): # type: (Any, Any, Any) -> None dialog.setWindowTitle("登录CGTeamWork") account_input.setPlaceholderText("CGTeamwork账号名") password_input.setPlaceholderText("密码") password_input.setEchoMode(QLineEdit.Password) ok_button = QPushButton("登录") ok_button.setDefault(True) ok_button.clicked.connect(dialog.accept) layout = QVBoxLayout(dialog) layout.addWidget(QLabel("帐号")) layout.addWidget(account_input) layout.addWidget(QLabel("密码")) layout.addWidget(password_input) layout.addWidget(ok_button) dialog.setLayout(layout)
def __init__(self, name='modelPanelWidget', **kwargs): super(ModelPanelWidget, self).__init__(**kwargs) unique_name = name + str(id(self)) self.setObjectName(unique_name + 'Widget') main_layout = QVBoxLayout(self) main_layout.setContentsMargins(0, 0, 0, 0) main_layout.setObjectName(unique_name + 'Layout') self.setLayout(main_layout) maya.cmds.setParent(main_layout.objectName()) pane_layout_name = maya.cmds.paneLayout() self._model_panel = maya.cmds.modelPanel(unique_name, label="ModelPanel", menuBarVisible=False) pane_layout_widget = gui.to_qt_object(pane_layout_name) main_layout.addWidget(pane_layout_widget) self.set_model_panel_options() self.hide_bar_layout() self.hide_menu_bar()