def setupUi(self, widget): """ Creates and lays out the widgets defined in the ui file. :Parameters: widget : `QtWidgets.QWidget` Base widget """ super(FindDialog, self).setupUi(widget) self.statusBar = QStatusBar(self) self.verticalLayout.addWidget(self.statusBar) self.findBtn.setIcon(QIcon.fromTheme("edit-find")) self.replaceBtn.setIcon(QIcon.fromTheme("edit-find-replace"))
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 updateForEditMode(self, edit): """ Show/Hide text replacement options based on if we are editing or not. If editing, allow replacement of the found text. :Parameters: edit : `bool` If in edit mode or not """ self.replaceLabel.setVisible(edit) self.replaceLineEdit.setVisible(edit) self.replaceBtn.setVisible(edit) self.replaceFindBtn.setVisible(edit) self.replaceAllBtn.setVisible(edit) self.replaceAllOpenBtn.setVisible(edit) self.buttonBox.setVisible(edit) self.buttonBox2.setVisible(not edit) if edit: self.setWindowTitle("Find/Replace") self.setWindowIcon(QIcon.fromTheme("edit-find-replace")) else: self.setWindowTitle("Find") self.setWindowIcon(QIcon.fromTheme("edit-find"))
def __init__(self, path="", filter="", selectedFilter="", parent=None): """ Initialize the panel. :Parameters: path : `str` default path to look in when creating or choosing the file. filter : `list` A list of strings denoting filename match filters. These strings are displayed in a user-selectable combobox. When selected, the file list is filtered by the pattern The format must follow: ["Descriptive text (pattern1 pattern2 ...)", ...] The glob matching pattern is in parens, and the entire string is displayed for the user. selectedFilter : `str` Set the current filename filter. Needs to be one of the entries specified in the "filter" parameter. parent : `QObject` Parent for this widget. """ super(IncludePanel, self).__init__(parent) # Setup UI. self.lookInCombo = QtWidgets.QComboBox(self) self.toParentButton = QtWidgets.QToolButton(self) self.buttonHome = QtWidgets.QToolButton(self) self.buttonOriginal = QtWidgets.QPushButton("Original", self) self.fileNameEdit = QtWidgets.QLineEdit(self) self.fileNameLabel = QtWidgets.QLabel("File:", self) self.fileTypeCombo = QtWidgets.QComboBox(self) self.fileTypeLabel = QtWidgets.QLabel("Type:", self) self.stackedWidget = QtWidgets.QStackedWidget(self) self.listView = QtWidgets.QListView(self) self.fileTypeLabelFiller = QtWidgets.QLabel(self) self.fileTypeComboFiller = QtWidgets.QLabel(self) self.buttonOpen = QtWidgets.QPushButton( QIcon.fromTheme("document-open"), "Open", self) # Item settings. self.buttonHome.setIcon(self.style().standardIcon( QtWidgets.QStyle.SP_DirHomeIcon)) self.buttonHome.setToolTip("User's home directory") self.buttonHome.setAutoRaise(True) self.buttonOriginal.setToolTip("Original directory") self.lookInCombo.setMinimumSize(50, 0) self.toParentButton.setIcon(self.style().standardIcon( QtWidgets.QStyle.SP_FileDialogToParent)) self.toParentButton.setAutoRaise(True) self.toParentButton.setToolTip("Parent directory") self.listView.setDragEnabled(True) self.fileNameLabel.setToolTip("Selected file or directory") self.fileTypeLabel.setBuddy(self.fileTypeCombo) self.fileTypeLabel.setToolTip("File type filter") self.buttonOpen.setToolTip("Open selected file") # Focus policies. self.lookInCombo.setFocusPolicy(QtCore.Qt.NoFocus) self.toParentButton.setFocusPolicy(QtCore.Qt.NoFocus) self.buttonHome.setFocusPolicy(QtCore.Qt.NoFocus) self.buttonOriginal.setFocusPolicy(QtCore.Qt.NoFocus) self.buttonOpen.setFocusPolicy(QtCore.Qt.NoFocus) # Item size policies. self.lookInCombo.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Fixed) self.toParentButton.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self.buttonHome.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self.buttonOriginal.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self.fileNameLabel.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) self.fileTypeCombo.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Fixed) self.fileTypeLabel.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) self.buttonOpen.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) # Layouts. self.include1Layout = QtWidgets.QHBoxLayout() self.include1Layout.setContentsMargins(0, 0, 0, 0) self.include1Layout.setSpacing(5) self.include1Layout.addWidget(self.buttonHome) self.include1Layout.addWidget(self.lookInCombo) self.include1Layout.addWidget(self.toParentButton) self.include2Layout = QtWidgets.QHBoxLayout() self.include2Layout.setContentsMargins(0, 0, 0, 0) self.include2Layout.setSpacing(5) self.include2Layout.addWidget(self.stackedWidget) self.include4Layout = QtWidgets.QGridLayout() self.include4Layout.setContentsMargins(0, 0, 0, 0) self.include4Layout.setSpacing(5) self.include4Layout.addWidget( self.fileNameLabel, 0, 0, QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.include4Layout.addWidget(self.fileNameEdit, 0, 1) self.include4Layout.addWidget( self.fileTypeLabel, 1, 0, QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.include4Layout.addWidget(self.fileTypeCombo, 1, 1) self.include4Layout.addWidget(self.fileTypeLabelFiller, 2, 0) self.include4Layout.addWidget(self.fileTypeComboFiller, 2, 1) self.include5Layout = QtWidgets.QHBoxLayout() self.include5Layout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.include5Layout.setContentsMargins(0, 0, 0, 0) self.include5Layout.setSpacing(5) self.include5Layout.addWidget(self.buttonOriginal) spacer = QtWidgets.QSpacerItem(5, 0, QtWidgets.QSizePolicy.MinimumExpanding) self.include5Layout.addSpacerItem(spacer) self.include5Layout.addWidget(self.buttonOpen) self.includeLayout = QtWidgets.QVBoxLayout() self.includeLayout.setContentsMargins(0, 0, 0, 0) self.includeLayout.setSpacing(5) self.includeLayout.addLayout(self.include1Layout) self.includeLayout.addLayout(self.include2Layout) self.includeLayout.addLayout(self.include4Layout) line1 = QtWidgets.QFrame() line1.setFrameStyle(QtWidgets.QFrame.HLine | QtWidgets.QFrame.Sunken) self.includeLayout.addWidget(line1) self.includeLayout.addLayout(self.include5Layout) self.setLayout(self.includeLayout) self.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.buttonHome.clicked.connect(self.onHome) self.buttonOriginal.clicked.connect(self.onOriginal) self.lookInCombo.activated[int].connect(self.onPathComboChanged) self.fileTypeCombo.activated[int].connect(self._useNameFilter) self.fileModel = QtWidgets.QFileSystemModel(parent) self.fileModel.setReadOnly(True) self.fileModel.setNameFilterDisables(False) self.fileModel.setResolveSymlinks(True) self.fileModel.rootPathChanged.connect(self.pathChanged) self.listView.setModel(self.fileModel) self.listView.activated[QtCore.QModelIndex].connect( self.enterDirectory) # Set selection mode and behavior. self.listView.setSelectionBehavior( QtWidgets.QAbstractItemView.SelectRows) self.listView.setWrapping(False) self.listView.setResizeMode(QtWidgets.QListView.Adjust) selectionMode = QtWidgets.QAbstractItemView.SingleSelection self.listView.setSelectionMode(selectionMode) # Setup the completer. completer = QtWidgets.QCompleter(self.fileModel, self.fileNameEdit) completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) self.fileNameEdit.setCompleter(completer) self.fileNameEdit.textChanged.connect(self.autoCompleteFileName) self.fileNameEdit.returnPressed.connect(self.accept) pathFile = None if not path: self.__path = os.getcwd() elif os.path.isfile(path): self.__path, pathFile = os.path.split(path) else: self.__path = path self.setPath(self.__path) if filter: self.setNameFilters(filter) if selectedFilter: self.selectNameFilter(selectedFilter) self.listPage = QtWidgets.QWidget(self.stackedWidget) self.stackedWidget.addWidget(self.listPage) listLayout = QtWidgets.QGridLayout(self.listPage) #listLayout.setMargin(0) listLayout.setContentsMargins(0, 0, 0, 0) listLayout.addWidget(self.listView, 0, 0, 1, 1) self.fileTypeLabelFiller.hide() self.fileTypeComboFiller.hide() # Selections selections = self.listView.selectionModel() selections.selectionChanged.connect(self.fileSelectionChanged) if pathFile is not None: idx = self.fileModel.index(self.fileModel.rootPath() + QtCore.QDir.separator() + pathFile) self.select(idx) self.fileNameEdit.setText(pathFile) # Connect signals. self.toParentButton.clicked.connect(self.onUp) self.buttonOpen.clicked.connect(self.accept) self.listView.scheduleDelayedItemsLayout() self.stackedWidget.setCurrentWidget(self.listPage) self.fileNameEdit.setFocus()
def setupUi(self, Hypnotoad): if not Hypnotoad.objectName(): Hypnotoad.setObjectName(u"Hypnotoad") Hypnotoad.resize(1215, 863) self.action_New = QAction(Hypnotoad) self.action_New.setObjectName(u"action_New") icon = QIcon() iconThemeName = u"document-new" if QIcon.hasThemeIcon(iconThemeName): icon = QIcon.fromTheme(iconThemeName) else: icon.addFile(u".", QSize(), QIcon.Normal, QIcon.Off) self.action_New.setIcon(icon) self.action_Open = QAction(Hypnotoad) self.action_Open.setObjectName(u"action_Open") icon1 = QIcon() iconThemeName = u"document-open" if QIcon.hasThemeIcon(iconThemeName): icon1 = QIcon.fromTheme(iconThemeName) else: icon1.addFile(u".", QSize(), QIcon.Normal, QIcon.Off) self.action_Open.setIcon(icon1) self.action_Save = QAction(Hypnotoad) self.action_Save.setObjectName(u"action_Save") icon2 = QIcon() iconThemeName = u"document-save" if QIcon.hasThemeIcon(iconThemeName): icon2 = QIcon.fromTheme(iconThemeName) else: icon2.addFile(u".", QSize(), QIcon.Normal, QIcon.Off) self.action_Save.setIcon(icon2) self.action_Save_as = QAction(Hypnotoad) self.action_Save_as.setObjectName(u"action_Save_as") icon3 = QIcon() iconThemeName = u"document-save-as" if QIcon.hasThemeIcon(iconThemeName): icon3 = QIcon.fromTheme(iconThemeName) else: icon3.addFile(u".", QSize(), QIcon.Normal, QIcon.Off) self.action_Save_as.setIcon(icon3) self.action_Quit = QAction(Hypnotoad) self.action_Quit.setObjectName(u"action_Quit") icon4 = QIcon() iconThemeName = u"application-exit" if QIcon.hasThemeIcon(iconThemeName): icon4 = QIcon.fromTheme(iconThemeName) else: icon4.addFile(u".", QSize(), QIcon.Normal, QIcon.Off) self.action_Quit.setIcon(icon4) self.action_About = QAction(Hypnotoad) self.action_About.setObjectName(u"action_About") icon5 = QIcon() iconThemeName = u"help-about" if QIcon.hasThemeIcon(iconThemeName): icon5 = QIcon.fromTheme(iconThemeName) else: icon5.addFile(u".", QSize(), QIcon.Normal, QIcon.Off) self.action_About.setIcon(icon5) self.action_Run = QAction(Hypnotoad) self.action_Run.setObjectName(u"action_Run") icon6 = QIcon() iconThemeName = u"system-run" if QIcon.hasThemeIcon(iconThemeName): icon6 = QIcon.fromTheme(iconThemeName) else: icon6.addFile(u".", QSize(), QIcon.Normal, QIcon.Off) self.action_Run.setIcon(icon6) self.action_Write_grid = QAction(Hypnotoad) self.action_Write_grid.setObjectName(u"action_Write_grid") icon7 = QIcon() iconThemeName = u"document-print" if QIcon.hasThemeIcon(iconThemeName): icon7 = QIcon.fromTheme(iconThemeName) else: icon7.addFile(u".", QSize(), QIcon.Normal, QIcon.Off) self.action_Write_grid.setIcon(icon7) self.action_Revert = QAction(Hypnotoad) self.action_Revert.setObjectName(u"action_Revert") icon8 = QIcon() iconThemeName = u"document-revert" if QIcon.hasThemeIcon(iconThemeName): icon8 = QIcon.fromTheme(iconThemeName) else: icon8.addFile(u".", QSize(), QIcon.Normal, QIcon.Off) self.action_Revert.setIcon(icon8) self.action_Preferences = QAction(Hypnotoad) self.action_Preferences.setObjectName(u"action_Preferences") icon9 = QIcon(QIcon.fromTheme(u"document-properties")) self.action_Preferences.setIcon(icon9) self.action_Regrid = QAction(Hypnotoad) self.action_Regrid.setObjectName(u"action_Regrid") self.action_Regrid.setEnabled(False) self.action_Regrid.setIcon(icon6) self.centralwidget = QWidget(Hypnotoad) self.centralwidget.setObjectName(u"centralwidget") self.horizontalLayout_2 = QHBoxLayout(self.centralwidget) self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") self.horizontalLayout = QHBoxLayout() self.horizontalLayout.setObjectName(u"horizontalLayout") self.verticalLayout_2 = QVBoxLayout() self.verticalLayout_2.setObjectName(u"verticalLayout_2") self.search_bar = QLineEdit(self.centralwidget) self.search_bar.setObjectName(u"search_bar") self.verticalLayout_2.addWidget(self.search_bar) self.options_form = QTableWidget(self.centralwidget) if (self.options_form.columnCount() < 2): self.options_form.setColumnCount(2) __qtablewidgetitem = QTableWidgetItem() self.options_form.setHorizontalHeaderItem(0, __qtablewidgetitem) __qtablewidgetitem1 = QTableWidgetItem() self.options_form.setHorizontalHeaderItem(1, __qtablewidgetitem1) self.options_form.setObjectName(u"options_form") self.verticalLayout_2.addWidget(self.options_form) self.gridLayout_2 = QGridLayout() self.gridLayout_2.setObjectName(u"gridLayout_2") self.options_file_browse_button = QPushButton(self.centralwidget) self.options_file_browse_button.setObjectName( u"options_file_browse_button") self.gridLayout_2.addWidget(self.options_file_browse_button, 0, 2, 1, 1) self.geqdsk_file_browse_button = QPushButton(self.centralwidget) self.geqdsk_file_browse_button.setObjectName( u"geqdsk_file_browse_button") self.gridLayout_2.addWidget(self.geqdsk_file_browse_button, 0, 6, 1, 1) self.options_file_line_edit = QLineEdit(self.centralwidget) self.options_file_line_edit.setObjectName(u"options_file_line_edit") self.gridLayout_2.addWidget(self.options_file_line_edit, 0, 1, 1, 1) self.run_button = QPushButton(self.centralwidget) self.run_button.setObjectName(u"run_button") self.gridLayout_2.addWidget(self.run_button, 0, 7, 1, 1) self.write_grid_button = QPushButton(self.centralwidget) self.write_grid_button.setObjectName(u"write_grid_button") self.gridLayout_2.addWidget(self.write_grid_button, 0, 9, 1, 1) self.geqdsk_file_line_edit = QLineEdit(self.centralwidget) self.geqdsk_file_line_edit.setObjectName(u"geqdsk_file_line_edit") self.gridLayout_2.addWidget(self.geqdsk_file_line_edit, 0, 4, 1, 1) self.geqdsk_file_label = QLabel(self.centralwidget) self.geqdsk_file_label.setObjectName(u"geqdsk_file_label") self.gridLayout_2.addWidget(self.geqdsk_file_label, 0, 3, 1, 1) self.options_file_label = QLabel(self.centralwidget) self.options_file_label.setObjectName(u"options_file_label") self.gridLayout_2.addWidget(self.options_file_label, 0, 0, 1, 1) self.regrid_button = QPushButton(self.centralwidget) self.regrid_button.setObjectName(u"regrid_button") self.regrid_button.setEnabled(False) self.gridLayout_2.addWidget(self.regrid_button, 1, 7, 1, 1) self.nonorthogonal_box = QCheckBox(self.centralwidget) self.nonorthogonal_box.setObjectName(u"nonorthogonal_box") self.nonorthogonal_box.setEnabled(True) self.gridLayout_2.addWidget(self.nonorthogonal_box, 1, 6, 1, 1) self.verticalLayout_2.addLayout(self.gridLayout_2) self.horizontalLayout_4 = QHBoxLayout() self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") self.verticalLayout_2.addLayout(self.horizontalLayout_4) self.gridLayout = QGridLayout() self.gridLayout.setObjectName(u"gridLayout") self.verticalLayout_2.addLayout(self.gridLayout) self.horizontalLayout.addLayout(self.verticalLayout_2) self.plottingArea = QWidget(self.centralwidget) self.plottingArea.setObjectName(u"plottingArea") self.horizontalLayout.addWidget(self.plottingArea) self.horizontalLayout_2.addLayout(self.horizontalLayout) Hypnotoad.setCentralWidget(self.centralwidget) self.menubar = QMenuBar(Hypnotoad) self.menubar.setObjectName(u"menubar") self.menubar.setGeometry(QRect(0, 0, 1215, 22)) self.menu_File = QMenu(self.menubar) self.menu_File.setObjectName(u"menu_File") self.menu_Help = QMenu(self.menubar) self.menu_Help.setObjectName(u"menu_Help") self.menu_Mesh = QMenu(self.menubar) self.menu_Mesh.setObjectName(u"menu_Mesh") Hypnotoad.setMenuBar(self.menubar) self.statusbar = QStatusBar(Hypnotoad) self.statusbar.setObjectName(u"statusbar") Hypnotoad.setStatusBar(self.statusbar) self.toolBar = QToolBar(Hypnotoad) self.toolBar.setObjectName(u"toolBar") Hypnotoad.addToolBar(Qt.TopToolBarArea, self.toolBar) self.toolBar_2 = QToolBar(Hypnotoad) self.toolBar_2.setObjectName(u"toolBar_2") Hypnotoad.addToolBar(Qt.TopToolBarArea, self.toolBar_2) self.toolBar_3 = QToolBar(Hypnotoad) self.toolBar_3.setObjectName(u"toolBar_3") Hypnotoad.addToolBar(Qt.TopToolBarArea, self.toolBar_3) self.menubar.addAction(self.menu_File.menuAction()) self.menubar.addAction(self.menu_Mesh.menuAction()) self.menubar.addAction(self.menu_Help.menuAction()) self.menu_File.addAction(self.action_New) self.menu_File.addAction(self.action_Open) self.menu_File.addAction(self.action_Save) self.menu_File.addAction(self.action_Save_as) self.menu_File.addAction(self.action_Revert) self.menu_File.addSeparator() self.menu_File.addAction(self.action_Preferences) self.menu_File.addAction(self.action_Quit) self.menu_Help.addAction(self.action_About) self.menu_Mesh.addAction(self.action_Run) self.menu_Mesh.addAction(self.action_Regrid) self.menu_Mesh.addAction(self.action_Write_grid) self.toolBar.addAction(self.action_New) self.toolBar.addAction(self.action_Open) self.toolBar.addAction(self.action_Save) self.toolBar.addAction(self.action_Save_as) self.toolBar.addAction(self.action_Run) self.toolBar.addAction(self.action_Write_grid) self.retranslateUi(Hypnotoad) QMetaObject.connectSlotsByName(Hypnotoad)