def __init__(self): super(WebRender, self).__init__() vbox, temporary_directory = QVBoxLayout(self), mkdtemp() # Web Frame self.webFrame = QWebView() # QWebView = QWebFrame + QWebSettings self.webFrame.setStyleSheet( "QWebView{ background:#fff }") # no dark bg settings = self.webFrame.settings() # QWebSettings instance settings.setDefaultTextEncoding("utf-8") settings.setIconDatabasePath(temporary_directory) settings.setLocalStoragePath(temporary_directory) settings.setOfflineStoragePath(temporary_directory) settings.setOfflineWebApplicationCachePath(temporary_directory) settings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True) settings.setAttribute(QWebSettings.LocalStorageEnabled, True) settings.setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True) settings.setAttribute(QWebSettings.PluginsEnabled, True) settings.setAttribute(QWebSettings.DnsPrefetchEnabled, True) settings.setAttribute(QWebSettings.JavascriptCanOpenWindows, True) settings.setAttribute(QWebSettings.JavascriptCanCloseWindows, True) settings.setAttribute(QWebSettings.JavascriptCanAccessClipboard, True) settings.setAttribute(QWebSettings.SpatialNavigationEnabled, True) settings.setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls, True) settings.setAttribute(QWebSettings.OfflineWebApplicationCacheEnabled, True) vbox.addWidget(self.webFrame)
def __init__(self, parent): super(SchemesManagerWidget, self).__init__(parent, Qt.Dialog) self.setWindowTitle(translations.TR_EDITOR_SCHEMES) self.resize(700, 500) vbox = QVBoxLayout(self) self._tabs = QTabWidget() vbox.addWidget(self._tabs) # Footer hbox = QHBoxLayout() btn_close = QPushButton(self.tr('Close')) btnReload = QPushButton(self.tr("Reload")) hbox.addWidget(btn_close) hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) hbox.addWidget(btnReload) vbox.addLayout(hbox) self.overlay = ui_tools.Overlay(self) self.overlay.show() self._schemes = [] self._loading = True self.downloadItems = [] #Load Themes with Thread self.connect(btnReload, SIGNAL("clicked()"), self._reload_themes) self._thread = ui_tools.ThreadExecution(self.execute_thread) self.connect(self._thread, SIGNAL("finished()"), self.load_skins_data) self.connect(btn_close, SIGNAL('clicked()'), self.close) self._reload_themes()
def __init__(self, *args, **kwargs): super(MainWindow, self).__init__(*args, **kwargs) layout = QVBoxLayout() self.editor = QPlainTextEdit() # Could also use a QTextEdit and set self.editor.setAcceptRichText(False) # Setup the QTextEdit editor configuration fixedfont = QFontDatabase.systemFont(QFontDatabase.FixedFont) fixedfont.setPointSize(12) self.editor.setFont(fixedfont) # self.path holds the path of the currently open file. # If none, we haven't got a file open yet (or creating new). self.path = None layout.addWidget(self.editor) container = QWidget() container.setLayout(layout) self.setCentralWidget(container) self.status = QStatusBar() self.setStatusBar(self.status) file_toolbar = QToolBar("File") file_toolbar.setIconSize(QSize(14, 14)) self.addToolBar(file_toolbar) file_menu = self.menuBar().addMenu("&File")
def __init__(self, parent, available): QWidget.__init__(self, parent) self._parent = parent self._available = available vbox = QVBoxLayout(self) self._table = ui_tools.CheckableHeaderTable(1, 2) self._table.setSelectionMode(QTableWidget.SingleSelection) self._table.removeRow(0) vbox.addWidget(self._table) ui_tools.load_table( self._table, (translations.TR_PROJECT_NAME, translations.TR_VERSION), _format_for_table(available)) self._table.setColumnWidth(0, 500) self._table.setSortingEnabled(True) self._table.setAlternatingRowColors(True) hbox = QHBoxLayout() btnInstall = QPushButton(translations.TR_INSTALL) btnInstall.setMaximumWidth(100) hbox.addWidget(btnInstall) hbox.addWidget(QLabel(translations.TR_NINJA_NEEDS_TO_BE_RESTARTED)) vbox.addLayout(hbox) self.connect(btnInstall, SIGNAL("clicked()"), self._install_plugins) self.connect(self._table, SIGNAL("itemSelectionChanged()"), self._show_item_description)
def __init__(self, suggested, parent=None): super(PythonDetectDialog, self).__init__(parent, Qt.Dialog) self.setMaximumSize(QSize(0, 0)) self.setWindowTitle("Configure Python Path") vbox = QVBoxLayout(self) msg_str = ("We have detected that you are using " "Windows,\nplease choose the proper " "Python application for you:") lblMessage = QLabel(self.tr(msg_str)) vbox.addWidget(lblMessage) self.listPaths = QListWidget() self.listPaths.setSelectionMode(QListWidget.SingleSelection) vbox.addWidget(self.listPaths) hbox = QHBoxLayout() hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) btnCancel = QPushButton(self.tr("Cancel")) btnAccept = QPushButton(self.tr("Accept")) hbox.addWidget(btnCancel) hbox.addWidget(btnAccept) vbox.addLayout(hbox) self.connect(btnAccept, SIGNAL("clicked()"), self._set_python_path) self.connect(btnCancel, SIGNAL("clicked()"), self.close) for path in suggested: self.listPaths.addItem(path) self.listPaths.setCurrentRow(0)
def __init__(self, actions, parent=None): QWidget.__init__(self, parent) itab_item.ITabItem.__init__(self) self.actions = actions self.graphicView = QGraphicsView(self) self.scene = QGraphicsScene() self.graphicView.setScene(self.scene) self.graphicView.setViewportUpdateMode( QGraphicsView.BoundingRectViewportUpdate) vLayout = QVBoxLayout(self) self.setLayout(vLayout) vLayout.addWidget(self.graphicView) self.scene.setItemIndexMethod(QGraphicsScene.NoIndex) self.scene.setSceneRect(-200, -200, 400, 400) self.graphicView.setMinimumSize(400, 400) actualProject = self.actions.ide.explorer.get_actual_project() arrClasses = self.actions._locator.get_classes_from_project( actualProject) #FIXME:dirty need to fix self.mX = -400 self.mY = -320 self.hightestY = self.mY filesList = [] for elem in arrClasses: #loking for paths filesList.append(elem[2]) for path in set(filesList): self.create_class(path)
def __init__(self): QWidget.__init__(self) self.plugin_manager = plugin_manager.PluginManager() vbox = QVBoxLayout(self) self._tabs = QTabWidget() vbox.addWidget(self._tabs) #load widgets self._load_widgets()
def __init__(self, parent=None): super(PlotB, self).__init__(parent) self.win = pg.GraphicsWindow() self.p = self.createAxis(self.win) my_layout = QVBoxLayout() my_layout.addWidget(self.win) self.setLayout(my_layout)
def __init__(self, *args, **kwargs): super(NEBDialog, self).__init__(*args, **kwargs) self.nebwgt = NEBWidget(parent=self) vbox = QVBoxLayout() vbox.addWidget(self.nebwgt) # vbox.addWidget(self.mpl_toolbar) self.setLayout(vbox)
def __init__(self, parent): QWidget.__init__(self, parent) vbox = QVBoxLayout(self) self._webInspector = QWebInspector(self) vbox.addWidget(self._webInspector) self.btnDock = QPushButton(translations.TR_UNDOCK) vbox.addWidget(self.btnDock) ExplorerContainer.register_tab(translations.TR_TAB_WEB_INSPECTOR, self) IDE.register_service('web_inspector', self)
def __init__(self, traceback_msg): QWidget.__init__(self) vbox = QVBoxLayout(self) self._editor = QPlainTextEdit() vbox.addWidget(QLabel(translations.TR_TRACEBACK)) vbox.addWidget(self._editor) self._editor.setReadOnly(True) self._editor.setLineWrapMode(0) self._editor.insertPlainText(traceback_msg) self._editor.selectAll()
def __init__(self, parent=None): super(Form, self).__init__(parent) self.browser = QTextBrowser() self.lineedit = QLineEdit("Type an expression and press Enter") self.lineedit.selectAll() layout = QVBoxLayout() layout.addWidget(self.browser) layout.addWidget(self.lineedit) self.setLayout(layout) self.lineedit.setFocus() self.lineedit.returnPressed.connect(self.updateUi) self.setWindowTitle("Calculate")
def __init__(self, scheme, parent): super(EditorSchemeDesigner, self).__init__(parent, Qt.Dialog) self.original_style = copy.copy(resources.CUSTOM_SCHEME) self._avoid_on_loading, self.saved, self._components = True, False, {} self.setWindowTitle(translations.TR_PREFERENCES_EDITOR_SCHEME_DESIGNER) self.setMinimumSize(450, 480) self.setMaximumSize(500, 900) self.resize(450, 600) # all layouts and groupboxes group0 = QGroupBox(translations.TR_PROJECT_NAME) # scheme filename group1 = QGroupBox(translations.TR_PROJECT_PROPERTIES) # properties group2 = QGroupBox(translations.TR_PREVIEW) # quick preview thingy group0_hbox, group1_vbox = QHBoxLayout(group0), QVBoxLayout(group1) this_dialog_vbox, group2_vbox = QVBoxLayout(self), QVBoxLayout(group2) self._grid, scrollArea, frame = QGridLayout(), QScrollArea(), QFrame() # widgets self.line_name, btnSave = QLineEdit(), QPushButton( translations.TR_SAVE) self.line_name.setPlaceholderText(getuser().capitalize() + "s_scheme") group0_hbox.addWidget(self.line_name) group0_hbox.addWidget(btnSave) self.connect(btnSave, SIGNAL("clicked()"), self.save_scheme) _demo = "<center>" + ascii_letters # demo text for preview self.preview_label1, self.preview_label2 = QLabel(_demo), QLabel(_demo) group2_vbox.addWidget(self.preview_label1) group2_vbox.addWidget(self.preview_label2) # rows titles self._grid.addWidget(QLabel("<b>" + translations.TR_PROJECT_NAME), 0, 0) self._grid.addWidget(QLabel("<b>" + translations.TR_CODE), 0, 1) self._grid.addWidget( QLabel("<b>" + translations.TR_EDITOR_SCHEME_PICK_COLOR), 0, 2) # fill rows for key in sorted(tuple(resources.COLOR_SCHEME.keys())): self.add_item(key, scheme) self.preview_label1.setStyleSheet('background:transparent') self.preview_label2.setStyleSheet('color: transparent') # fill the scroll area frame.setLayout(self._grid) scrollArea.setWidget(frame) group1_vbox.addWidget(scrollArea) # put groups on the dialog this_dialog_vbox.addWidget(group1) this_dialog_vbox.addWidget(group2) this_dialog_vbox.addWidget(group0) self._avoid_on_loading = self._modified = False
def __init__(self): QDialog.__init__(self) self.setWindowTitle(translations.TR_PLUGIN_ERROR_REPORT) self.resize(600, 400) vbox = QVBoxLayout(self) label = QLabel(translations.TR_SOME_PLUGINS_REMOVED) vbox.addWidget(label) self._tabs = QTabWidget() vbox.addWidget(self._tabs) hbox = QHBoxLayout() btnAccept = QPushButton(translations.TR_ACCEPT) btnAccept.setMaximumWidth(100) hbox.addWidget(btnAccept) vbox.addLayout(hbox) #signals self.connect(btnAccept, SIGNAL("clicked()"), self.close)
def __init__(self, parent, schemes): QWidget.__init__(self, parent) self._parent = parent self._schemes = schemes vbox = QVBoxLayout(self) self._table = ui_tools.CheckableHeaderTable(1, 2) self._table.removeRow(0) vbox.addWidget(self._table) ui_tools.load_table(self._table, [self.tr('Name'), self.tr('URL')], self._schemes) btnUninstall = QPushButton(self.tr('Download')) btnUninstall.setMaximumWidth(100) vbox.addWidget(btnUninstall) self._table.setColumnWidth(0, 200) self._table.setSortingEnabled(True) self._table.setAlternatingRowColors(True) self.connect(btnUninstall, SIGNAL("clicked()"), self._download_scheme)
def __init__(self, parent=None): super(PluginsStore, self).__init__(parent, Qt.Dialog) self.setWindowTitle(translations.TR_MANAGE_PLUGINS) vbox = QVBoxLayout(self) vbox.setContentsMargins(0, 0, 0, 0) vbox.setSpacing(0) self.view = QDeclarativeView() self.view.setMinimumWidth(800) self.view.setMinimumHeight(600) self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView) self.view.setSource(ui_tools.get_qml_resource("PluginsStore.qml")) self.root = self.view.rootObject() vbox.addWidget(self.view) self._plugins = {} self._plugins_inflate = [] self._plugins_by_tag = collections.defaultdict(list) self._plugins_by_author = collections.defaultdict(list) self._base_color = QColor("white") self._counter = 0 self._counter_callback = None self._inflating_plugins = [] self._categoryTags = True self._search = [] self.status = None self.connect(self.root, SIGNAL("loadPluginsGrid()"), self._load_by_name) self.connect(self.root, SIGNAL("close()"), self.close) self.connect(self.root, SIGNAL("showPluginDetails(int)"), self.show_plugin_details) self.connect(self.root, SIGNAL("loadTagsGrid()"), self._load_tags_grid) self.connect(self.root, SIGNAL("loadAuthorGrid()"), self._load_author_grid) self.connect(self.root, SIGNAL("search(QString)"), self._load_search_results) self.connect(self.root, SIGNAL("loadPluginsForCategory(QString)"), self._load_plugins_for_category) self.connect(self, SIGNAL("processCompleted(PyQt_PyObject)"), self._process_complete) self.nenv = nenvironment.NenvEggSearcher() self.connect(self.nenv, SIGNAL("searchCompleted(PyQt_PyObject)"), self.callback) self.status = self.nenv.do_search()
def __init__(self, parent): super(ThemeEditor, self).__init__(parent, Qt.Dialog) vbox = QVBoxLayout(self) hbox = QHBoxLayout() self.line_name = QLineEdit() self.btn_save = QPushButton(translations.TR_SAVE) self.line_name.setPlaceholderText(getuser().capitalize() + "s_theme") hbox.addWidget(self.line_name) hbox.addWidget(self.btn_save) self.edit_qss = QPlainTextEdit() css = 'QPlainTextEdit {color: %s; background-color: %s;' \ 'selection-color: %s; selection-background-color: %s;}' \ % (resources.CUSTOM_SCHEME.get( 'editor-text', resources.COLOR_SCHEME['Default']), resources.CUSTOM_SCHEME.get( 'EditorBackground', resources.COLOR_SCHEME['EditorBackground']), resources.CUSTOM_SCHEME.get( 'EditorSelectionColor', resources.COLOR_SCHEME['EditorSelectionColor']), resources.CUSTOM_SCHEME.get( 'EditorSelectionBackground', resources.COLOR_SCHEME['EditorSelectionBackground'])) self.edit_qss.setStyleSheet(css) self.btn_apply = QPushButton(self.tr("Apply Style Sheet")) hbox2 = QHBoxLayout() hbox2.addSpacerItem( QSpacerItem(10, 0, QSizePolicy.Expanding, QSizePolicy.Fixed)) hbox2.addWidget(self.btn_apply) hbox2.addSpacerItem( QSpacerItem(10, 0, QSizePolicy.Expanding, QSizePolicy.Fixed)) vbox.addWidget(self.edit_qss) vbox.addLayout(hbox) vbox.addLayout(hbox2) self.connect(self.btn_apply, SIGNAL("clicked()"), self.apply_stylesheet) self.connect(self.btn_save, SIGNAL("clicked()"), self.save_stylesheet)
def __init__(self,parent=None): QWidget.__init__(self,parent) self.__toolBar = QToolBar(self) self.__toolBar.setIconSize(QSize(16,16)) self.__htmlBrowserView = HtmlBrowserView(self) self.__addressinput = QLineEdit(self) self.__loadlabel = QLabel(self) layout=QVBoxLayout(self) layout.setSpacing(0) layout.setMargin(0) layout.addWidget(self.__toolBar) layout.addWidget(self.__htmlBrowserView) self.__setupToolBarAction() QObject.connect(self.__addressinput, SIGNAL("returnPressed ()"),self.__evt_load) QObject.connect(self.__htmlBrowserView, SIGNAL("loadFinished (bool)"),lambda:self.__loadlabel.setMovie(None)) QObject.connect(self.__htmlBrowserView, SIGNAL("loadStarted ()"),self.__evt_loadstarted)
def __init__(self, url, process=None, parent=None): QWidget.__init__(self, parent) self._process = process vbox = QVBoxLayout(self) #Web Frame self.webFrame = QWebView(self) self.webFrame.setAcceptDrops(False) self.webFrame.load(QUrl(url)) vbox.addWidget(self.webFrame) if process is not None: time.sleep(0.5) self.webFrame.load(QUrl(url)) self.webFrame.page().currentFrame().setScrollBarPolicy( Qt.Vertical, Qt.ScrollBarAsNeeded) self.webFrame.page().currentFrame().setScrollBarPolicy( Qt.Horizontal, Qt.ScrollBarAsNeeded)
def __init__(self, requirements_dict): super(DependenciesHelpDialog, self).__init__() self.setWindowTitle(translations.TR_REQUIREMENTS) self.resize(525, 400) vbox = QVBoxLayout(self) label = QLabel(translations.TR_SOME_PLUGINS_NEED_DEPENDENCIES) vbox.addWidget(label) self._editor = QPlainTextEdit() self._editor.setReadOnly(True) vbox.addWidget(self._editor) hbox = QHBoxLayout() btnAccept = QPushButton(translations.TR_ACCEPT) btnAccept.setMaximumWidth(100) hbox.addWidget(btnAccept) vbox.addLayout(hbox) #signals self.connect(btnAccept, SIGNAL("clicked()"), self.close) command_tmpl = "<%s>:\n%s\n" for name, description in list(requirements_dict.items()): self._editor.insertPlainText(command_tmpl % (name, description))
def __init__(self, parent, updates): QWidget.__init__(self, parent) self._parent = parent self._updates = updates vbox = QVBoxLayout(self) self._table = ui_tools.CheckableHeaderTable(1, 2) self._table.removeRow(0) self._table.setSelectionMode(QTableWidget.SingleSelection) self._table.setColumnWidth(0, 500) self._table.setSortingEnabled(True) self._table.setAlternatingRowColors(True) vbox.addWidget(self._table) ui_tools.load_table( self._table, (translations.TR_PROJECT_NAME, translations.TR_VERSION), _format_for_table(updates)) btnUpdate = QPushButton(translations.TR_UPDATE) btnUpdate.setMaximumWidth(100) vbox.addWidget(btnUpdate) self.connect(btnUpdate, SIGNAL("clicked()"), self._update_plugins) self.connect(self._table, SIGNAL("itemSelectionChanged()"), self._show_item_description)
def __init__(self, parent): super(ShortcutDialog, self).__init__() self.keys = 0 #Keyword modifiers! self.keyword_modifiers = (Qt.Key_Control, Qt.Key_Meta, Qt.Key_Shift, Qt.Key_Alt, Qt.Key_Menu) #main layout main_vbox = QVBoxLayout(self) self.line_edit = QLineEdit() self.line_edit.setReadOnly(True) #layout for buttons buttons_layout = QHBoxLayout() ok_button = QPushButton(translations.TR_ACCEPT) cancel_button = QPushButton(translations.TR_CANCEL) #add widgets main_vbox.addWidget(self.line_edit) buttons_layout.addWidget(ok_button) buttons_layout.addWidget(cancel_button) main_vbox.addLayout(buttons_layout) self.line_edit.installEventFilter(self) #buttons signals self.connect(ok_button, SIGNAL("clicked()"), self.save_shortcut) self.connect(cancel_button, SIGNAL("clicked()"), self.close)
def __init__(self, parent): QDialog.__init__(self, parent, Qt.Dialog) self.setWindowTitle(translations.TR_PLUGIN_MANAGER) self.resize(700, 600) vbox = QVBoxLayout(self) self._tabs = QTabWidget() vbox.addWidget(self._tabs) self._txt_data = QTextBrowser() self._txt_data.setOpenLinks(False) vbox.addWidget(QLabel(translations.TR_PROJECT_DESCRIPTION)) vbox.addWidget(self._txt_data) # Footer hbox = QHBoxLayout() btn_close = QPushButton(translations.TR_CLOSE) btnReload = QPushButton(translations.TR_RELOAD) hbox.addWidget(btn_close) hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) hbox.addWidget(btnReload) vbox.addLayout(hbox) self.overlay = ui_tools.Overlay(self) self.overlay.hide() self._oficial_available = [] self._community_available = [] self._locals = [] self._updates = [] self._loading = True self._requirements = {} self.connect(btnReload, SIGNAL("clicked()"), self._reload_plugins) self.thread = ThreadLoadPlugins(self) self.connect(self.thread, SIGNAL("finished()"), self._load_plugins_data) self.connect(self.thread, SIGNAL("plugin_downloaded(PyQt_PyObject)"), self._after_download_plugin) self.connect(self.thread, SIGNAL("plugin_manually_installed(PyQt_PyObject)"), self._after_manual_install_plugin) self.connect(self.thread, SIGNAL("plugin_uninstalled(PyQt_PyObject)"), self._after_uninstall_plugin) self.connect(self._txt_data, SIGNAL("anchorClicked(const QUrl&)"), self._open_link) self.connect(btn_close, SIGNAL('clicked()'), self.close) self.overlay.show() self._reload_plugins()
def __init__(self,parent=None): QTabWidget.__init__(self,parent) #some default value is needed self.setTabPosition(QTabWidget.South) self.setTabShape(QTabWidget.Triangular) self.setDocumentMode(True) self.__toolBar = QToolBar(self) self.__toolBar.setIconSize(QSize(16,16)) self.__htmlEditorArea = HtmlEditView(self) #self.__htmlEditorArea.setBaseUrl(baseURL) self.__sourceView = SouceView(self) self.__searchBarForEditor = SearchWidget(self.__htmlEditorArea,self) self.__searchBarForEditor.setVisible(False) self.__inspector = None self.__inspectorSplitter = QSplitter(self) self.__inspectorSplitter.setOrientation(Qt.Vertical) self.__inspectorSplitter.addWidget(self.__htmlEditorArea) #tab1 layout=QVBoxLayout(self) layout.setSpacing(0) layout.setMargin(0) layout.addWidget(self.__toolBar) layout.addWidget(self.__searchBarForEditor) layout.addWidget(self.__inspectorSplitter) the_editor_tab=QWidget(self) the_editor_tab.setLayout(layout) the_editor_tab.setAutoFillBackground(True) self.addTab(the_editor_tab, "Edit") #tab2 self.addTab(self.__sourceView, "Source") QObject.connect(self, SIGNAL("currentChanged (int)"),self.__evt_currentTabChange) #actions self.__setupToolBarAction()
def test_prop(self): w = QWidget() layout = QVBoxLayout() cb = QCheckBox("Check", w) sp = QSpinBox(w) le = QLineEdit(w) textw = QTextEdit(w, readOnly=True) textw.setProperty("checked_", False) textw.setProperty("spin_", 0) textw.setProperty("line_", "") textexpr = PropertyBindingExpr(r""" ("Check box is {0}\n" "Spin has value {1}\n" "Line contains {2}").format( "checked" if checked else "unchecked", spin, line) """, dict(checked=binding_for(cb, "checked"), spin=binding_for(sp, "value"), line=binding_for(le, "text")), ) layout.addWidget(cb) layout.addWidget(sp) layout.addWidget(le) layout.addWidget(textw) manager = BindingManager(submitPolicy=BindingManager.AutoSubmit) manager.bind(PropertyBinding(textw, "plainText", "textChanged"), textexpr) w.setLayout(layout) w.show() self.app.exec_()
class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) self.resize(1920, 1080) self.status = False self.setAutoFillBackground(False) self.setDocumentMode(False) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.exitAct = QAction(QIcon('exit.png'), '&Exit', self) self.exitAct.setShortcut('Ctrl+Q') self.exitAct.setStatusTip('Exit application') self.exitAct.triggered.connect(qApp.quit) self.loadAct = QAction(QIcon('exit.png'), '&Import Unfolding', self) self.loadAct.setShortcut('Ctrl+L') self.loadAct.setStatusTip('Import Unfolding') self.loadAct.triggered.connect(self.openFileNameDialog) self.exportAct = QAction(QIcon('exit.png'), '&Export Unfolding', self) self.exportAct.setShortcut('Ctrl+E') self.exportAct.setStatusTip('Export Unfolding') self.exportAct.triggered.connect(self.exportUnfolding) self.writeNPAct = QAction(QIcon('exit.png'), '&Write coordinates as np file', self) self.writeNPAct.setShortcut('Ctrl+W') self.writeNPAct.setStatusTip('Write coordinates') self.writeNPAct.triggered.connect(self.writeNP_file) self.loadGeometryAct = QAction(QIcon('exit.png'), '&Load geometry from .log file', self) #self.loadGeometry.setShortcut('Ctrl+W') self.loadGeometryAct.setStatusTip('Load geometry') self.loadGeometryAct.triggered.connect(self.loadGeometry) self.select_directoryAct = QAction( QIcon('exit.png'), '&Select a directory to generate hdf5 files from', self) self.select_directoryAct.setStatusTip('Select directory') self.select_directoryAct.triggered.connect(self.select_directory) self.load_HDF5Act = QAction(QIcon('exit.png'), '&Select a hdf5 files for the DFT data', self) self.load_HDF5Act.setStatusTip('Select HDF5') self.load_HDF5Act.triggered.connect(self.load_hdf5_scan) self.statusBar() self.menubar = self.menuBar() self.fileMenu = self.menubar.addMenu('&File') self.fileMenu.addAction(self.exitAct) self.fileMenu.addAction(self.loadAct) self.fileMenu.addAction(self.exportAct) self.fileMenu.addAction(self.writeNPAct) self.fileMenu.addAction(self.loadGeometryAct) self.fileMenu.addAction(self.select_directoryAct) self.fileMenu.addAction(self.load_HDF5Act) self.horizontalLayout = QHBoxLayout(self.centralwidget) self.horizontalLayout.setSpacing(10) self.verticalLayout = QVBoxLayout() ### Containing the integration buttons self.horizontalLayout_2 = QHBoxLayout() ### Containing the inital/final position show self.finalPositionLayout = QHBoxLayout() self.gl_widget = gl.GLViewWidget() self.gl_widget.setCameraPosition(distance=20, elevation=40) self.gl_widget.setGeometry(0, 110, 1920, 1080) self.energy_Plot = PlotWidget() self.energy_Plot.setObjectName(_fromUtf8("energyPlot")) self.energy_Plot.setBackground('k') # set properties of the label for y axis self.energy_Plot.setLabel('left', 'E(B3LYP)', units='H') # set properties of the label for x axis self.energy_Plot.setLabel('bottom', 'CC-distance', units='A') # adding legend self.energy_Plot.addLegend() self.horizontalLayout.addWidget(self.gl_widget, 4) ### Push button for sinle integration self.btnUp = QPushButton() self.btnUp.setObjectName(_fromUtf8("btnUp")) ### Check box for continous integration self.chkIntegrate = QCheckBox() self.chkIntegrate.setObjectName(_fromUtf8("chkIntegrate")) ### SpinBox to set the size of the integration step self.spinStep = QSpinBox() self.spinStep.setMinimum(0) self.spinStep.setMaximum(10000) self.spinStep.setObjectName(_fromUtf8("spinStep")) ### final position button self.btnFin = QPushButton() self.btnFin.setObjectName(_fromUtf8("btnFin")) ### initial position button self.btnInit = QPushButton() self.btnInit.setObjectName(_fromUtf8("btnPos")) ### select hinges button self.btnSelHinge = QPushButton() self.btnSelHinge.setObjectName(_fromUtf8("btnSelHinge")) ### close unfolding button self.btnClose = QPushButton() self.btnClose.setObjectName(_fromUtf8("btnClose")) ### add the buttons to the integration layout self.horizontalLayout_2.addWidget(self.spinStep) self.horizontalLayout_2.addWidget(self.btnUp) self.horizontalLayout_2.addWidget(self.chkIntegrate) ## add final position button to layout self.finalPositionLayout.addWidget(self.btnInit) self.finalPositionLayout.addWidget(self.btnFin) self.finalPositionLayout.addWidget(self.btnSelHinge) self.finalPositionLayout.addWidget(self.btnClose) ### add integration and final position layout and plot widget to right side layout self.verticalLayout.addLayout(self.horizontalLayout_2, 1) self.verticalLayout.addLayout(self.finalPositionLayout, 1) self.verticalLayout.addWidget(self.energy_Plot, 6) self.horizontalLayout.addLayout(self.verticalLayout, 1) self.widget = QWidget() self.widget.setLayout(self.horizontalLayout) self.setCentralWidget(self.widget) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) self.setWindowTitle('Fullerene Unfolding') def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None)) self.btnUp.setText("Integrate") self.chkIntegrate.setText("Keep integrating") self.btnFin.setText("Final position") self.btnInit.setText("Initial position") self.btnClose.setText("Close unfolding") self.btnSelHinge.setText("Select Hinges")
def __init__(self, parent): super(ShortcutConfiguration, self).__init__() self._preferences = parent self.shortcuts_text = { "Show-Selector": translations.TR_SHOW_SELECTOR, "cut": translations.TR_CUT, "Indent-more": translations.TR_INDENT_MORE, "expand-file-combo": translations.TR_EXPAND_FILE_COMBO, "expand-symbol-combo": translations.TR_EXPAND_SYMBOL_COMBO, "undo": translations.TR_UNDO, "Close-Split": translations.TR_CLOSE_SPLIT, "Split-assistance": translations.TR_SHOW_SPLIT_ASSISTANCE, "copy": translations.TR_COPY, "paste": translations.TR_PASTE, "Duplicate": translations.TR_DUPLICATE_SELECTION, "Remove-line": translations.TR_REMOVE_LINE_SELECTION, "Move-up": translations.TR_MOVE_LINE_SELECTION_UP, "Move-down": translations.TR_MOVE_LINE_SELECTION_DOWN, "Close-file": translations.TR_CLOSE_CURRENT_TAB, "New-file": translations.TR_NEW_TAB, "New-project": translations.TR_NEW_PROJECT, "Open-file": translations.TR_OPEN_A_FILE, "Open-project": translations.TR_OPEN_PROJECT, "Save-file": translations.TR_SAVE_FILE, "Save-project": translations.TR_SAVE_OPENED_FILES, "Print-file": translations.TR_PRINT_FILE, "Redo": translations.TR_REDO, "Comment": translations.TR_COMMENT_SELECTION, "Uncomment": translations.TR_UNCOMMENT_SELECTION, "Horizontal-line": translations.TR_INSERT_HORIZONTAL_LINE, "Title-comment": translations.TR_INSERT_TITLE_COMMENT, "Indent-less": translations.TR_INDENT_LESS, "Hide-misc": translations.TR_HIDE_MISC, "Hide-editor": translations.TR_HIDE_EDITOR, "Hide-explorer": translations.TR_HIDE_EXPLORER, "Toggle-tabs-spaces": translations.TR_TOGGLE_TABS, "Run-file": translations.TR_RUN_FILE, "Run-project": translations.TR_RUN_PROJECT, "Debug": translations.TR_DEBUG, "Switch-Focus": translations.TR_SWITCH_FOCUS, "Stop-execution": translations.TR_STOP_EXECUTION, "Hide-all": translations.TR_HIDE_ALL, "Full-screen": translations.TR_FULLSCREEN, "Find": translations.TR_FIND, "Find-replace": translations.TR_FIND_REPLACE, "Find-with-word": translations.TR_FIND_WORD_UNDER_CURSOR, "Find-next": translations.TR_FIND_NEXT, "Find-previous": translations.TR_FIND_PREVIOUS, "Help": translations.TR_SHOW_PYTHON_HELP, "Split-vertical": translations.TR_SPLIT_TABS_VERTICAL, "Split-horizontal": translations.TR_SPLIT_TABS_HORIZONTAL, "Follow-mode": translations.TR_ACTIVATE_FOLLOW_MODE, "Reload-file": translations.TR_RELOAD_FILE, "Jump": translations.TR_JUMP_TO_LINE, "Find-in-files": translations.TR_FIND_IN_FILES, "Import": translations.TR_IMPORT_FROM_EVERYWHERE, "Go-to-definition": translations.TR_GO_TO_DEFINITION, "Complete-Declarations": translations.TR_COMPLETE_DECLARATIONS, "Code-locator": translations.TR_SHOW_CODE_LOCATOR, "File-Opener": translations.TR_SHOW_FILE_OPENER, "Navigate-back": translations.TR_NAVIGATE_BACK, "Navigate-forward": translations.TR_NAVIGATE_FORWARD, "Open-recent-closed": translations.TR_OPEN_RECENT_CLOSED_FILE, "Change-Tab": translations.TR_CHANGE_TO_NEXT_TAB, "Change-Tab-Reverse": translations.TR_CHANGE_TO_PREVIOUS_TAB, "Move-Tab-to-right": translations.TR_MOVE_TAB_TO_RIGHT, "Move-Tab-to-left": translations.TR_MOVE_TAB_TO_LEFT, "Show-Code-Nav": translations.TR_ACTIVATE_HISTORY_NAVIGATION, "Show-Bookmarks-Nav": translations.TR_ACTIVATE_BOOKMARKS_NAVIGATION, "Show-Breakpoints-Nav": translations.TR_ACTIVATE_BREAKPOINTS_NAVIGATION, "Show-Paste-History": translations.TR_SHOW_COPYPASTE_HISTORY, "History-Copy": translations.TR_COPY_TO_HISTORY, "History-Paste": translations.TR_PASTE_FROM_HISTORY, #"change-split-focus": #translations.TR_CHANGE_KEYBOARD_FOCUS_BETWEEN_SPLITS, "Add-Bookmark-or-Breakpoint": translations.TR_INSERT_BREAKPOINT, "move-tab-to-next-split": translations.TR_MOVE_TAB_TO_NEXT_SPLIT, "change-tab-visibility": translations.TR_SHOW_TABS_IN_EDITOR, "Highlight-Word": translations.TR_HIGHLIGHT_OCCURRENCES } self.shortcut_dialog = ShortcutDialog(self) #main layout main_vbox = QVBoxLayout(self) #layout for buttons buttons_layout = QVBoxLayout() #widgets self.result_widget = TreeResult() load_defaults_button = QPushButton(translations.TR_LOAD_DEFAULTS) #add widgets main_vbox.addWidget(self.result_widget) buttons_layout.addWidget(load_defaults_button) main_vbox.addLayout(buttons_layout) main_vbox.addWidget( QLabel(translations.TR_SHORTCUTS_ARE_GOING_TO_BE_REFRESH)) #load data! self.result_widget.setColumnWidth(0, 400) self._load_shortcuts() #signals #open the set shortcut dialog self.connect(self.result_widget, SIGNAL("itemDoubleClicked(QTreeWidgetItem*, int)"), self._open_shortcut_dialog) #load defaults shortcuts self.connect(load_defaults_button, SIGNAL("clicked()"), self._load_defaults_shortcuts) #one shortcut has changed self.connect(self.shortcut_dialog, SIGNAL('shortcutChanged'), self._shortcut_changed) self.connect(self._preferences, SIGNAL("savePreferences()"), self.save)
def test(self): window = QWidget() layout = QVBoxLayout() window.setLayout(layout) stack = stackedwidget.AnimatedStackedWidget() stack.transitionFinished.connect(self.app.exit) layout.addStretch(2) layout.addWidget(stack) layout.addStretch(2) window.show() widget1 = QLabel("A label " * 10) widget1.setWordWrap(True) widget2 = QGroupBox("Group") widget3 = QListView() self.assertEqual(stack.count(), 0) self.assertEqual(stack.currentIndex(), -1) stack.addWidget(widget1) self.assertEqual(stack.count(), 1) self.assertEqual(stack.currentIndex(), 0) stack.addWidget(widget2) stack.addWidget(widget3) self.assertEqual(stack.count(), 3) self.assertEqual(stack.currentIndex(), 0) def widgets(): return [stack.widget(i) for i in range(stack.count())] self.assertSequenceEqual([widget1, widget2, widget3], widgets()) stack.show() stack.removeWidget(widget2) self.assertEqual(stack.count(), 2) self.assertEqual(stack.currentIndex(), 0) self.assertSequenceEqual([widget1, widget3], widgets()) stack.setCurrentIndex(1) # wait until animation finished self.app.exec_() self.assertEqual(stack.currentIndex(), 1) widget2 = QGroupBox("Group") stack.insertWidget(1, widget2) self.assertEqual(stack.count(), 3) self.assertEqual(stack.currentIndex(), 2) self.assertSequenceEqual([widget1, widget2, widget3], widgets()) stack.transitionFinished.disconnect(self.app.exit) self.singleShot(2000, lambda: stack.setCurrentIndex(0)) self.singleShot(4000, lambda: stack.setCurrentIndex(1)) self.singleShot(6000, lambda: stack.setCurrentIndex(2)) self.app.exec_()
def __init__(self, parent): super(EditorCompletion, self).__init__() self._preferences = parent vbox = QVBoxLayout(self) groupBoxClose = QGroupBox(translations.TR_PREF_EDITOR_COMPLETE) formClose = QGridLayout(groupBoxClose) formClose.setContentsMargins(5, 15, 5, 5) self._checkParentheses = QCheckBox( translations.TR_PREF_EDITOR_PARENTHESES + " ()") self._checkParentheses.setChecked('(' in settings.BRACES) self._checkKeys = QCheckBox(translations.TR_PREF_EDITOR_KEYS + " {}") self._checkKeys.setChecked('{' in settings.BRACES) self._checkBrackets = QCheckBox(translations.TR_PREF_EDITOR_BRACKETS + " []") self._checkBrackets.setChecked('[' in settings.BRACES) self._checkSimpleQuotes = QCheckBox( translations.TR_PREF_EDITOR_SIMPLE_QUOTES) self._checkSimpleQuotes.setChecked("'" in settings.QUOTES) self._checkDoubleQuotes = QCheckBox( translations.TR_PREF_EDITOR_DOUBLE_QUOTES) self._checkDoubleQuotes.setChecked('"' in settings.QUOTES) self._checkCompleteDeclarations = QCheckBox( translations.TR_PREF_EDITOR_COMPLETE_DECLARATIONS.format( resources.get_shortcut("Complete-Declarations").toString( QKeySequence.NativeText))) self._checkCompleteDeclarations.setChecked( settings.COMPLETE_DECLARATIONS) formClose.addWidget(self._checkParentheses, 1, 1, alignment=Qt.AlignTop) formClose.addWidget(self._checkKeys, 1, 2, alignment=Qt.AlignTop) formClose.addWidget(self._checkBrackets, 2, 1, alignment=Qt.AlignTop) formClose.addWidget(self._checkSimpleQuotes, 2, 2, alignment=Qt.AlignTop) formClose.addWidget(self._checkDoubleQuotes, 3, 1, alignment=Qt.AlignTop) vbox.addWidget(groupBoxClose) groupBoxCode = QGroupBox(translations.TR_PREF_EDITOR_CODE_COMPLETION) formCode = QGridLayout(groupBoxCode) formCode.setContentsMargins(5, 15, 5, 5) self._checkCodeDot = QCheckBox( translations.TR_PREF_EDITOR_ACTIVATE_COMPLETION) self._checkCodeDot.setChecked(settings.CODE_COMPLETION) formCode.addWidget(self._checkCompleteDeclarations, 5, 1, alignment=Qt.AlignTop) formCode.addWidget(self._checkCodeDot, 6, 1, alignment=Qt.AlignTop) vbox.addWidget(groupBoxCode) vbox.addItem( QSpacerItem(0, 10, QSizePolicy.Expanding, QSizePolicy.Expanding)) self.connect(self._preferences, SIGNAL("savePreferences()"), self.save)
def __init__(self, *args, **kwargs): super(MainWindow, self).__init__(*args, **kwargs) layout = QVBoxLayout() self.editor = QPlainTextEdit() # Could also use a QTextEdit and set self.editor.setAcceptRichText(False) # Setup the QTextEdit editor configuration fixedfont = QFontDatabase.systemFont(QFontDatabase.FixedFont) fixedfont.setPointSize(12) self.editor.setFont(fixedfont) # self.path holds the path of the currently open file. # If none, we haven't got a file open yet (or creating new). self.path = None layout.addWidget(self.editor) container = QWidget() container.setLayout(layout) self.setCentralWidget(container) self.status = QStatusBar() self.setStatusBar(self.status) file_toolbar = QToolBar("File") file_toolbar.setIconSize(QSize(14, 14)) self.addToolBar(file_toolbar) file_menu = self.menuBar().addMenu("&File") open_file_action = QAction(QIcon(os.path.join('images', 'blue-folder-open-document.png')), 'Open file...', self) open_file_action.setStatusTip("Open file") open_file_action.triggered.connect(self.file_open) file_menu.addAction(open_file_action) file_toolbar.addAction(open_file_action) save_file_action = QAction(QIcon(os.path.join('images', 'disk.png')), "Save", self) save_file_action.setStatusTip("Save current page") save_file_action.triggered.connect(self.file_save) file_menu.addAction(save_file_action) file_toolbar.addAction(save_file_action) saveas_file_action = QAction(QIcon(os.path.join('images', 'disk--pencil.png')), "Save As...", self) saveas_file_action.setStatusTip("Save current page to specified file") saveas_file_action.triggered.connect(self.file_saveas) file_menu.addAction(saveas_file_action) file_toolbar.addAction(saveas_file_action) print_action = QAction(QIcon(os.path.join('images', 'printer.png')), "Print...", self) print_action.setStatusTip("Print current page") print_action.triggered.connect(self.file_print) file_menu.addAction(print_action) file_toolbar.addAction(print_action) edit_toolbar = QToolBar("Edit") edit_toolbar.setIconSize(QSize(16, 16)) self.addToolBar(edit_toolbar) edit_menu = self.menuBar().addMenu("&Edit") undo_action = QAction(QIcon(os.path.join('images', 'arrow-curve-180-left.png')), "Undo", self) undo_action.setStatusTip("Undo last change") undo_action.triggered.connect(self.editor.undo) edit_menu.addAction(undo_action) redo_action = QAction(QIcon(os.path.join('images', 'arrow-curve.png')), "Redo", self) redo_action.setStatusTip("Redo last change") redo_action.triggered.connect(self.editor.redo) edit_toolbar.addAction(redo_action) edit_menu.addAction(redo_action) edit_menu.addSeparator() cut_action = QAction(QIcon(os.path.join('images', 'scissors.png')), "Cut", self) cut_action.setStatusTip("Cut selected text") cut_action.triggered.connect(self.editor.cut) edit_toolbar.addAction(cut_action) edit_menu.addAction(cut_action) copy_action = QAction(QIcon(os.path.join('images', 'document-copy.png')), "Copy", self) copy_action.setStatusTip("Copy selected text") copy_action.triggered.connect(self.editor.copy) edit_toolbar.addAction(copy_action) edit_menu.addAction(copy_action) paste_action = QAction(QIcon(os.path.join('images', 'clipboard-paste-document-text.png')), "Paste", self) paste_action.setStatusTip("Paste from clipboard") paste_action.triggered.connect(self.editor.paste) edit_toolbar.addAction(paste_action) edit_menu.addAction(paste_action) select_action = QAction(QIcon(os.path.join('images', 'selection-input.png')), "Select all", self) select_action.setStatusTip("Select all text") select_action.triggered.connect(self.editor.selectAll) edit_menu.addAction(select_action) edit_menu.addSeparator() wrap_action = QAction(QIcon(os.path.join('images', 'arrow-continue.png')), "Wrap text to window", self) wrap_action.setStatusTip("Toggle wrap text to window") wrap_action.setCheckable(True) wrap_action.setChecked(True) wrap_action.triggered.connect(self.edit_toggle_wrap) edit_menu.addAction(wrap_action) self.update_title() self.show()