def test_show_console(self): if os.name == 'nt': QCoreApplication.setOrganizationName("QGIS") QCoreApplication.setOrganizationDomain("qgis.org") QCoreApplication.setApplicationName("QGIS-TEST") my_console = console.show_console() my_console_widget = my_console.console
def test_show_console(self): if os.name == 'nt': QCoreApplication.setOrganizationName("QGIS") QCoreApplication.setOrganizationDomain("qgis.org") QCoreApplication.setApplicationName("QGIS-TEST") QSettings().setValue('pythonConsole/contextHelpOnFirstLaunch', False) my_console = console.show_console() my_console_widget = my_console.console
def test_show_console(self): if os.name == 'nt': QCoreApplication.setOrganizationName("QGIS") QCoreApplication.setOrganizationDomain("qgis.org") QCoreApplication.setApplicationName("QGIS-TEST") QSettings().setValue('pythonConsole/contextHelpOnFirstLaunch', False) my_console = console.show_console() my_console_widget = my_console.console for action in my_console_widget.classMenu.actions(): action.trigger()
def test_show_console(self): my_console = console.show_console() my_console_widget = my_console.console for action in my_console_widget.classMenu.actions(): action.trigger()
def open_dock(self): """ This method will be called when you click the toolbar button or select the plugin menu item. """ # Try to catch every Exception and show it in a graphical window. try: # Show the output of the plugin: #console.show_console() # works but better: pythonConsole = self.iface.mainWindow().findChild( QDockWidget, 'PythonConsole') try: if not pythonConsole.isVisible(): pythonConsole.setVisible(True) except AttributeError: # can be 'None' above console.show_console() self.out("PythonConsole Error catched", False) self.out("open_dock()") # Test for catching a exception and show this to the user by a window: #raise RuntimeWarning("manual exception raised") # Create the dialog with elements (after translation) and keep reference # Only create GUI ONCE in callback, so that it will only load when the plugin is started # dockwidget may not exist if: # first run of plugin # removed on close (see self.onClosePlugin method) # Close dock via toolbar button: if self.dock: if self.dock.isVisible(): self.dock.close() return # if first start else: """ Detect first start after installation. There seems to be a problem with plugin reloading, so after (re)install there occur errors. So we handle this issue manually with a one time check file (deleted after the following message). """ if self._model.check_file.exists(): msg = "After reinstalling the plugin QGIS should be restarted now,\n"\ " otherwise plugin errors are to be expected!" QMessageBox.warning(self.iface.mainWindow(), 'initialize plugin', msg) # Message should only appear one time, so the # check file must be removed now: self._model.check_file.unlink() self.out( "check file '{}' removed, message doesn't appear again." .format(self._model.check_file)) msg = "It's recommended to exit QGIS now.\n\nExit QGIS?" reply = QMessageBox.question(self.iface.mainWindow(), 'Continue?', msg, QMessageBox.Yes, QMessageBox.No) if reply == QMessageBox.Yes: self.iface.actionExit().trigger() return # maybe unnecessary # if self._init_dock() news_file = self._model.news_file try: with news_file.open() as f: l_text = [f.read()] if l_text: l_text.append( "\nThis info window won't be displayed again!\n") l_text.append( "You can view the change history at any time here:" ) l_text.append( "=> https://plugins.qgis.org/plugins/radolan2map/#plugin-versions" ) text = '\n'.join(l_text) QMessageBox.information(self.iface.mainWindow(), "New changes", text) except FileNotFoundError: pass else: news_file.unlink() self.out( "news file '{}' removed, message doesn't appear again." .format(news_file)) # else self._settings_tab.update_projection_based_on_current_project() """ DockWidget exists but maybe it's invisible Bring DockWidget to front (maybe it's minimized elsewhere...) """ width = self.dock.frameGeometry().width() height = self.dock.frameGeometry().height() # that's fine - if necessary, get the initialized values from the .ui: self.dock.setMinimumSize(QSize(width, height)) # width, height # -> prevents a too small Widget # show the dockwidget self.iface.addDockWidget(Qt.RightDockWidgetArea, self.dock) self.dock.show() # Ohne diese Anweisung wurde das Fenster ab QGIS3 im Hintergrund geöffnet. #self.dock.setWindowFlags(Qt.WindowStaysOnTopHint) except Exception as e: l_msg = ["{}\n\n".format(e)] l_msg.append( "If this error persists - even after restarting QGIS - it may be" ) l_msg.append(" helpful to update your QGIS / Python installation") l_msg.append(" and working with a new QGIS user profile.") l_msg.append("\nIf nothing helps, please write a bug report.") msg = "".join(l_msg) self.out(msg, False) QMessageBox.critical(self.iface.mainWindow(), 'Exception catched', msg)