本文整理汇总了Python中enki.widgets.dockwidget.DockWidget类的典型用法代码示例。如果您正苦于以下问题:Python DockWidget类的具体用法?Python DockWidget怎么用?Python DockWidget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DockWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parent):
DockWidget.__init__( self, parent, "&Search Results", QIcon(":/enkiicons/search.png"), "Alt+S")
# actions
widget = QWidget( self )
self._model = searchresultsmodel.SearchResultsModel(self)
self.onResultsHandledByReplaceThread.connect(self._model.onResultsHandledByReplaceThread)
self._view = QTreeView( self )
self._view.setHeaderHidden( True )
self._view.setUniformRowHeights( True )
self._view.setModel( self._model )
self._delegate = HTMLDelegate()
self._view.setItemDelegate(self._delegate)
self._layout = QHBoxLayout( widget )
self._layout.setMargin( 5 )
self._layout.setSpacing( 5 )
self._layout.addWidget( self._view )
self.setWidget( widget )
self.setFocusProxy(self._view)
# connections
self._model.firstResultsAvailable.connect(self.show)
self._view.activated.connect(self._onResultActivated)
core.actionManager().addAction("mView/aSearchResults", self.showAction())
self._expandCollapseAll = ExpandCollapseAllButton(self.titleBarWidget(), self._view, self._model)
self._checkUncheckAll = None
示例2: __init__
def __init__(self):
DockWidget.__init__(self, core.mainWindow(), "&Preview", QIcon(':/enkiicons/internet.png'), "Alt+P")
from PyQt4.QtWebKit import QWebView # delayed import, startup performance optimization
self._view = QWebView(self)
self._view.page().mainFrame().titleChanged.connect(self._updateTitle)
self.setWidget(self._view)
self.setFocusProxy(self._view)
core.workspace().currentDocumentChanged.connect(self._onDocumentChanged)
core.workspace().textChanged.connect(self._onTextChanged)
self._scrollPos = {}
self._vAtEnd = {}
self._hAtEnd = {}
self._thread = ConverterThread()
self._thread.htmlReady.connect(self._setHtml)
self._visiblePath = None
# If we update Preview on every key pressing, freezes are sensible (GUI thread draws preview too slowly
# This timer is used for drawing Preview 300 ms After user has stopped typing text
self._typingTimer = QTimer()
self._typingTimer.setInterval(300)
self._typingTimer.timeout.connect(self._scheduleDocumentProcessing)
self._scheduleDocumentProcessing()
示例3: __init__
def __init__(self, workspace):
DockWidget.__init__(self, workspace, "&Opened Files", QIcon(":/enkiicons/filtered.png"), "Alt+O")
self._workspace = workspace
self.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
self.tvFiles = QTreeView(self)
self.tvFiles.setHeaderHidden(True)
self.tvFiles.setEditTriggers(QAbstractItemView.SelectedClicked)
self.tvFiles.setContextMenuPolicy(Qt.CustomContextMenu)
self.tvFiles.setDragEnabled(True)
self.tvFiles.setDragDropMode(QAbstractItemView.InternalMove)
self.tvFiles.setRootIsDecorated(False)
self.tvFiles.setTextElideMode(Qt.ElideMiddle)
self.tvFiles.setUniformRowHeights(True)
self.tvFiles.customContextMenuRequested.connect(self._onTvFilesCustomContextMenuRequested)
self.setWidget(self.tvFiles)
self.setFocusProxy(self.tvFiles)
self.model = _OpenedFileModel(self) # Not protected, because used by Configurator
self.tvFiles.setModel(self.model)
self.tvFiles.setAttribute(Qt.WA_MacShowFocusRect, False)
self.tvFiles.setAttribute(Qt.WA_MacSmallSize)
self._workspace.currentDocumentChanged.connect(self._onCurrentDocumentChanged)
# disconnected by startModifyModel()
self.tvFiles.selectionModel().selectionChanged.connect(self._onSelectionModelSelectionChanged)
self.tvFiles.activated.connect(self._workspace.focusCurrentDocument)
core.actionManager().addAction("mView/aOpenedFiles", self.showAction())
示例4: __init__
def __init__(self, *args):
DockWidget.__init__(self, *args)
self.setObjectName("PreviewDock")
self.setWindowTitle(self.tr( "&Preview" ))
self.setWindowIcon(QIcon(':/enkiicons/internet.png'))
self.showAction().setShortcut("Alt+P")
from PyQt4.QtWebKit import QWebView # delayed import, startup performance optimization
self._view = QWebView(self)
self._view.page().mainFrame().titleChanged.connect(self._updateTitle)
self.setWidget(self._view)
self.setFocusProxy(self._view)
core.workspace().currentDocumentChanged.connect(self._onDocumentChanged)
core.workspace().textChanged.connect(self._onTextChanged)
self._scrollPos = {}
self._vAtEnd = {}
self._hAtEnd = {}
self._thread = ConverterThread()
self._thread.htmlReady.connect(self._setHtml)
self._visiblePath = None
self._onDocumentChanged(None, core.workspace().currentDocument())
示例5: __init__
def __init__(self):
DockWidget.__init__(self, core.mainWindow(), "Previe&w", QIcon(':/enkiicons/internet.png'), "Alt+W")
self._widget = QLabel("Qt5 Webkit not found. Preview is not available.<br/>"
"Install <i>python3-pyqt5.qtwebkit</i> package on Debian based distributions,"
"<i>python3-qt5-webkit</i> on Fedora")
self.setFocusProxy(self._widget)
self.setWidget(self._widget)
示例6: __init__
def __init__(self, widget, title, icon):
DockWidget.__init__(self, core.mainWindow(), title, icon, "Alt+I")
self.setObjectName(title)
self.setAllowedAreas(Qt.BottomDockWidgetArea | Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
self.setWidget(widget)
self.setFocusProxy(widget)
示例7: __init__
def __init__(self, widget):
DockWidget.__init__(self, core.mainWindow(), "&MIT Scheme", QIcon(':/enkiicons/languages/scheme.png'), "Alt+M")
self.setAllowedAreas( Qt.BottomDockWidgetArea)
core.actionManager().addAction("mView/aMitScheme", self.showAction())
self.setWidget(widget)
self.setFocusProxy(widget)
widget.installEventFilter(self)
示例8: __init__
def __init__(self, widget, replName, title, icon):
DockWidget.__init__(self, core.mainWindow(), title, icon, "Alt+M")
self.setAllowedAreas( Qt.BottomDockWidgetArea | Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
self._action = core.actionManager().addAction("mView/a%s" % replName, self.showAction())
self.setWidget(widget)
self.setFocusProxy(widget)
widget.installEventFilter(self)
示例9: eventFilter
def eventFilter(self, object_, event):
if object_ is self._tree:
if event.type() == QEvent.KeyPress:
if event.key() == Qt.Key_Backspace:
if event.modifiers() == Qt.ControlModifier:
self._onTreeCtrlBackspace()
else:
self._onTreeBackspace()
return True
elif event.text() and \
(event.text().isalnum() or event.text() == '_'):
self._onTreeTextTyped(event.text())
return True
elif object_ is self._filterEdit:
if event.type() == QEvent.KeyPress:
if event.key() in (Qt.Key_Up, Qt.Key_Down):
self._tree.setFocus()
self._tree.event(event)
return True
elif event.key() in (Qt.Key_Enter, Qt.Key_Return):
currIndex = self._tree.currentIndex()
if currIndex.isValid():
self._tagModel.onActivated(currIndex)
return DockWidget.eventFilter(self, object_, event)
示例10: __init__
def __init__(self, parent):
DockWidget.__init__(self, parent, "&File Browser", QIcon(':/enkiicons/open.png'), "Alt+F")
self._comboBox = None
self._tree = None
self._smartRecents = None
self._smartHistory = None
# restrict areas
self.setAllowedAreas( Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea )
core.actionManager().addAction("mView/aFileBrowser", self.showAction())
core.mainWindow().directoryDropt.connect(self._onDirectoryDropt)
self.visibilityChanged.connect(self._onVisibilityChanged)
示例11: __init__
def __init__(self):
DockWidget.__init__(self, core.mainWindow(), "&Preview", QIcon(':/enkiicons/internet.png'), "Alt+P")
self._widget = QWidget(self)
uic.loadUi(os.path.join(os.path.dirname(__file__), 'Preview.ui'), self._widget)
self._loadTemplates()
self._widget.webView.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
self._widget.webView.page().linkClicked.connect(self._onLinkClicked)
self._widget.webView.page().mainFrame().titleChanged.connect(self._updateTitle)
self.setWidget(self._widget)
self.setFocusProxy(self._widget.webView )
self._widget.cbEnableJavascript.clicked.connect(self._onJavaScriptEnabledCheckbox)
core.workspace().currentDocumentChanged.connect(self._onDocumentChanged)
core.workspace().textChanged.connect(self._onTextChanged)
self._scrollPos = {}
self._vAtEnd = {}
self._hAtEnd = {}
self._thread = ConverterThread()
self._thread.htmlReady.connect(self._setHtml)
self._visiblePath = None
# If we update Preview on every key pressing, freezes are sensible (GUI thread draws preview too slowly
# This timer is used for drawing Preview 300 ms After user has stopped typing text
self._typingTimer = QTimer()
self._typingTimer.setInterval(300)
self._typingTimer.timeout.connect(self._scheduleDocumentProcessing)
self._widget.cbTemplate.currentIndexChanged.connect(self._onCurrentTemplateChanged)
self._scheduleDocumentProcessing()
self._applyJavaScriptEnabled(self._isJavaScriptEnabled())
self._widget.tbSave.clicked.connect(self.onSave)
# Only set up sync if TRE is installed.
if findApproxTextInTarget:
self._initPreviewToTextSync()
self._initTextToPreviewSync()
示例12: eventFilter
def eventFilter(self, obj, event):
"""Event filter for the widget. Catches Esc pressings. It is necessary, because QScintilla eats it
"""
if (event.type() == QEvent.KeyPress or event.type() == QEvent.ShortcutOverride) and \
event.key() == Qt.Key_Escape and \
event.modifiers() == Qt.NoModifier:
self.hide()
return True
return DockWidget.eventFilter(self, obj, event)
示例13: __init__
def __init__(self):
DockWidget.__init__(self, core.mainWindow(), '&Navigator', QIcon(':/enkiicons/goto.png'), "Alt+N")
self._tags = []
self._tree = QTreeView(self)
self._tree.installEventFilter(self)
self._tree.setHeaderHidden(True)
self.setFocusProxy(self._tree)
self._filterEdit = LineEdit(self)
self._filterEdit.setClearButtonVisible(True)
self._filterEdit.textEdited.connect(self._applyFilter)
self._filterEdit.clearButtonClicked.connect(self._applyFilter)
self._filterEdit.clearButtonClicked.connect(self._tree.setFocus)
self._filterEdit.clearButtonClicked.connect(self._hideFilter)
self._filterEdit.installEventFilter(self)
self._displayWidget = QWidget(self)
layout = QVBoxLayout(self._displayWidget)
layout.addWidget(self._tree)
layout.addWidget(self._filterEdit)
layout.setContentsMargins(0, 0, 0, 0)
self.setWidget(self._displayWidget)
self._tagModel = _TagModel(self._tree)
self._tagModel.jumpToTagDone.connect(self._hideFilter)
self._tree.setModel(self._tagModel)
self._tree.activated.connect(self._tagModel.onActivated)
self._tree.clicked.connect(self._tagModel.onActivated)
self._tagModel.modelAboutToBeReset.connect(self._onModelAboutToBeReset)
self._tagModel.modelReset.connect(self._onModelReset)
self._showAction.triggered.connect(self._onShowTriggered)
self._currentTagPath = None
self._errorLabel = None
self._installed = False
示例14: eventFilter
def eventFilter(self, obj, ev):
""" Event filter for the web view
Zooms the web view
"""
if isinstance(ev, QWheelEvent) and \
ev.modifiers() == Qt.ControlModifier:
multiplier = 1 + (0.1 * (ev.angleDelta().y() / 120.))
view = self._widget.webView
view.setZoomFactor(view.zoomFactor() * multiplier)
return True
else:
return DockWidget.eventFilter(self, obj, ev)
示例15: __init__
def __init__(self, title, icon):
DockWidget.__init__(self, core.mainWindow(), title, icon, "Alt+I")
self.setObjectName(title)
self.setAllowedAreas(Qt.BottomDockWidgetArea | Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
# Copied from https://github.com/jupyter/qtconsole/blob/master/examples/inprocess_qtconsole.py, then modified based on https://github.com/jupyter/qtconsole/blob/master/qtconsole/qtconsoleapp.py -- the QtInProcessKernelManager is blocking, so infinite loops crash Enki!
kernel_manager = QtKernelManager()
kernel_manager.start_kernel()
kernel_manager.client_factory = QtKernelClient
kernel_manager.kernel.gui = 'qt'
kernel_client = kernel_manager.client()
kernel_client.start_channels()
self.ipython_widget = RichJupyterWidget()
self.ipython_widget.kernel_manager = kernel_manager
self.ipython_widget.kernel_client = kernel_client
# By default, iPython adds a blank line between inputs. Per Monika's request, this eliminates the extra line. See https://qtconsole.readthedocs.io/en/latest/config_options.html#options; this fix was based on info from https://stackoverflow.com/questions/38652671/ipython-5-0-remove-spaces-between-input-lines.
self.ipython_widget.input_sep = ''
self.ipython_widget.show()
self.setWidget(self.ipython_widget)
self.setFocusProxy(self.ipython_widget)