def loadPreview(self, item): if item == self.item and not self.dirty: return if item is None: return self._clear() if isinstance(item, Table) and item.type in [Table.VectorType, Table.RasterType]: # update the preview, but first let the manager chance to show the canvas def runPrev(): return self._loadTablePreview(item) QTimer.singleShot(50, runPrev) else: return self.item = item self.item.aboutToChange.connect(self.setDirty)
def show_console(): """ called from QGIS to open the console """ global _console if _console is None: parent = iface.mainWindow() if iface else None _console = PythonConsole(parent) _console.show() # force show even if it was restored as hidden # set focus to the console so the user can start typing # defer the set focus event so it works also whether the console not visible yet QTimer.singleShot(0, _console.activate) else: _console.setVisible(not _console.isVisible()) # set focus to the console so the user can start typing if _console.isVisible(): _console.activate() ## Shows help on first launch of the console settings = QSettings() if settings.value('pythonConsole/contextHelpOnFirstLaunch', True, type=bool): QgsContextHelp.run("PythonConsole") settings.setValue('pythonConsole/contextHelpOnFirstLaunch', False)
def loadPreview(self, item): if item == self.item and not self.dirty: return if item is None: return self._clear() if isinstance(item, Table) and item.type in [ Table.VectorType, Table.RasterType ]: # update the preview, but first let the manager chance to show the canvas def runPrev(): return self._loadTablePreview(item) QTimer.singleShot(50, runPrev) else: return self.item = item self.item.aboutToChange.connect(self.setDirty)