def qgis_app(): """ Start QGIS application to test against. Based on code from Inasafe plugin. :return: Reference to QGIS application, canvas and parent widget. :rtype:(QgsApplication, QWidget, QgsMapCanvas) """ global QGIS_APP if QGIS_APP is None: gui_flag = True QCoreApplication.setOrganizationName('QGIS') QCoreApplication.setOrganizationDomain('qgis.org') QCoreApplication.setApplicationName('STDM_Testing') QGIS_APP = QgsApplication(sys.argv, gui_flag) QGIS_APP.initQgis() global PARENT if PARENT is None: PARENT = QWidget() global CANVAS if CANVAS is None: CANVAS = QgsMapCanvas(PARENT) CANVAS.resize(QSize(400, 400)) return QGIS_APP, CANVAS, PARENT
def start(): #Init Qt Application app = QApplication(sys.argv) #Set application organization, name and version QCoreApplication.setOrganizationName('lol-server-status') QCoreApplication.setApplicationName(__prj__) QCoreApplication.setApplicationVersion(__version__) #Set icon for application app.setWindowIcon(QIcon(IMAGES['icon_256'])) #Codec for QString QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Add StyleSheet with open(STYLES, 'r') as f: style = f.read() app.setStyleSheet(style) f.close() #Run user interface window = mainWindow() window.show() sys.exit(app.exec_())
def set_up_interface(): """ Sets up a QGIS pseudo-application which enables calling methods as if when calling them from QGIS-console. :return qgis_app: Pseudo QGIS-instance :rtype: QgsApplication :return canvas: The map canvas :rtype: QgsMapCanvas :return iface: A dummy interface, giving access to needed method-calls :rtype: QgisInterface """ gui_flag = True # All test will run qgis in gui mode qgis_app = QgsApplication(sys.argv, gui_flag) prefix_path = config.qgis_prefix_path() qgis_app.setPrefixPath(prefix_path, True) qgis_app.initQgis() QCoreApplication.setOrganizationName('QGIS') QCoreApplication.setApplicationName('QGIS2') # parent = QWidget() # canvas = QgsMapCanvas(parent) # canvas.resize(QSize(400, 400)) canvas = MyMapCanvas() iface = QgisInterface(canvas) return qgis_app, canvas, iface
def start_app(gui_flag=False): """ Will start a QgsApplication and call all initialization code like registering the providers and other infrastructure. It will not load any plugins. You can always get the reference to a running app by calling `QgsApplication.instance()`. The initialization will only happen once, so it is safe to call this method repeatedly. Returns ------- QgsApplication A QgsApplication singleton """ global QGISAPP QCoreApplication.setOrganizationName('QGIS') QCoreApplication.setApplicationName('QGIS2') QgsApplication.setPrefixPath("/usr/share/", True) # Note: QGIS_PREFIX_PATH is evaluated in QgsApplication - # no need to mess with it here. QGISAPP = QgsApplication(sys.argv, gui_flag) QGISAPP.initQgis() if len(QgsProviderRegistry.instance().providerList()) == 0: raise RuntimeError('No data providers available.') return QGISAPP
def setUpClass(cls): # to see how to setup a qgis app in pyqgis # https://hub.qgis.org/issues/13494#note-19 os.environ["QGIS_DEBUG"] = str(-1) QCoreApplication.setOrganizationName('QGIS') QCoreApplication.setApplicationName('QGIS2') QgsApplication.setPrefixPath(os.getenv("QGIS_PREFIX_PATH"), True) QgsApplication.setAuthDbDirPath('/home/richard/.qgis2/')
def main(args): QCoreApplication.setApplicationName("2D Scan Post Processor") QCoreApplication.setApplicationVersion("0.2") QCoreApplication.setOrganizationName("Phoseon Technology") QCoreApplication.setOrganizationDomain("phoseon.com") app = QApplication([]) form = MainDialog() # form.show() # app.exec_() sys.exit(app.exec_())
def main(): from PyQt4.QtCore import QCoreApplication import logging logging.basicConfig(level=logging.DEBUG) app = QApplication(sys.argv) # share settings with QGIS plugin QCoreApplication.setOrganizationName( "QuantumGIS" ) QCoreApplication.setOrganizationDomain( "qgis.org" ) QCoreApplication.setApplicationName( "QGIS" ) nldas() sys.exit(app.exec_())
def start(): app = QApplication(sys.argv) QCoreApplication.setApplicationName(__prj__) QCoreApplication.setApplicationVersion(__version__) #Set Application icon app.setWindowIcon(QIcon(IMAGES['minebackup_icon'])) #Codec for QString QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Create configuration configuration.config() minebackup = main_window() minebackup.show() sys.exit(app.exec_())
def main(): """Function to test functionality.""" import sys from PyQt4.QtCore import QCoreApplication conf = """ p1 = 1 [mysection] p2 = 2 [[mysubsection]] p3 = 3.14 """ app = QCoreApplication(sys.argv) app.setApplicationName('configtest') app.setOrganizationName('foo') config = configobj.ConfigObj(conf.split('\n')) settings = to_QSettings(config) config2 = from_QSettings(settings) print config == config2
def main(): """Function to test functionality.""" import sys from PyQt4.QtCore import QCoreApplication conf = """ p1 = 1 [mysection] p2 = 2 [[mysubsection]] p3 = 3.14 """ app = QCoreApplication(sys.argv) app.setApplicationName('configtest') app.setOrganizationName('foo') config = configobj.ConfigObj(conf.split('\n')) settings = to_QSettings(config) config2 = from_QSettings(settings) print(config == config2)
def __init__(self, parent=None): """ Konstruktor """ self.translator_app = QTranslator() self.translator_qt = QTranslator() QApplication.installTranslator( self.translator_app ) QApplication.installTranslator( self.translator_qt ) QWidget.__init__(self, parent) QCoreApplication.setOrganizationName("Caern") QCoreApplication.setOrganizationDomain("www.caern.de") QCoreApplication.setApplicationName("DiceRoller WoD") QCoreApplication.setApplicationVersion(QString.number(PROGRAM_VERSION_MAJOR) + "." + QString.number(PROGRAM_VERSION_MINOR) + "." + QString.number(PROGRAM_VERSION_CHANGE) ) QApplication.setWindowIcon(QIcon(":/icons/logo/WoD.png")) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.createInfo() #self.createLanguageMenu() self.instantRoll = InstantRoll() self.extendedRoll = ExtendedRoll() # Dieser Zähler bestimmt, wie der rollende Würfel angezeigt wird. self.timerDice = QTimer() # Verzögert die tatsächliche Ausführung des Würfelwurfs. self.timerRoll = QTimer() self.populateUi() self.createConnections() self.initializing() self.setWindowTitle(QCoreApplication.applicationName())
def init_qgis(): """Set up a global QGIS instance. :returns: A QGIS application (for global use). :rtype: QgsApplication """ print 'Instantiating QGIS' QCoreApplication.setOrganizationName('InaSAFE') QCoreApplication.setOrganizationDomain('inasafe.org') QCoreApplication.setApplicationName('InaSAFEWeb') #noinspection PyPep8Naming gui_flag = True # app = QApplication([], gui_flag) app = QgsApplication(sys.argv, gui_flag) # Make sure QGIS_PREFIX_PATH is set in your env if needed! app.initQgis() return app
def calculate(request): """Calculates the buildings affected by flood. """ QCoreApplication.setOrganizationName('QGIS') QCoreApplication.setOrganizationDomain('qgis.org') QCoreApplication.setApplicationName('QGIS2InaSAFETesting') #noinspection PyPep8Naming gui_flag = False qgis_app = QgsApplication([], gui_flag) # Make sure QGIS_PREFIX_PATH is set in your env if needed! qgis_app.initQgis() output = os.path.join(settings.MEDIA_ROOT, 'layers', 'impact.json') roads = get_layer_data('Roads') flood = get_layer_data('Flood') impact_function = FloodVectorRoadsExperimentalFunction xmin, ymin, xmax, ymax = 121, 14.54, 121.05, 14.56 impact_file = calculate_safe_impact(layers=[roads, flood], function=impact_function, extent=[xmin, ymin, xmax, ymax], check_integrity=False) os.remove(impact_geojson) call(['ogr2ogr', '-f', 'GeoJSON', output, impact_file.filename]) impact_geojson = os.path.join(settings.MEDIA_URL, 'layers', 'impact.json') os.remove(impact_geojson) context = impact_file.keywords context = {} context['geojson'] = impact_geojson context['user'] = request.user return render(request, 'layers/calculate.html', context)
def main(): gc.set_debug(gc.DEBUG_UNCOLLECTABLE | gc.DEBUG_SAVEALL| gc.DEBUG_INSTANCES | gc.DEBUG_OBJECTS) qtTranslator = QTranslator() qtTranslator.load("qt_" + QLocale.system().name()) appTranslator = QTranslator() appTranslator.load("translations/boincgui_" + QLocale.system().name()) QCoreApplication.setOrganizationName("LinuxOS.sk") QCoreApplication.setOrganizationDomain("linuxos.sk") QCoreApplication.setApplicationName("pyboincgui") cm = ConnectionManager() app = QApplication(sys.argv) app.installTranslator(qtTranslator) app.installTranslator(appTranslator) win = MainWindow(cm) win.show() ret = app.exec_() del win del cm
def __init__(self): super().__init__() self.setupUi(self) # set python environment if getattr(sys, 'frozen', False): bundle_dir = sys._MEIPASS # pylint: disable=no-member else: # we are running in a normal Python environment bundle_dir = os.path.dirname(os.path.abspath(__file__)) # load environmental variables load_dotenv(dotenv_path = Path(bundle_dir) / ".env") # set program icon self.setWindowIcon(QtGui.QIcon(os.path.join(bundle_dir, "pickle.ico"))) # work in INI File Stuff here QCoreApplication.setOrganizationName("NRB") QCoreApplication.setOrganizationDomain("northriverboats.com") QCoreApplication.setApplicationName("Options Boat Pickler") self.settings = QSettings() # set variables self.background_thread = None self.exit_flag = False self.dir = self.settings.value("dir", os.getenv("DIR")) self.pickle_name = os.getenv("PICKLE") # set ui state self.actionCancel.setEnabled(False) self.btnCancel.hide() self.lePath.setText(self.dir) # set slots and signals self.actionExit.triggered.connect(self.closeEvent) self.actionAbout.triggered.connect(self.doAbout) self.btnBrowse.clicked.connect(self.browseEvent) self.btnRun.clicked.connect(self.startBackgroundTask)
def init(): """ Initialize the QCoreApplication.organizationDomain, applicationName, applicationVersion and the default settings format. Will only run once. .. note:: This should not be run before QApplication has been initialized. Otherwise it can break Qt's plugin search paths. """ dist = pkg_resources.get_distribution("Orange3") version = dist.version # Use only major.minor version = ".".join(version.split(".", 2)[:2]) QCoreApplication.setOrganizationDomain("biolab.si") QCoreApplication.setApplicationName("Orange Canvas") QCoreApplication.setApplicationVersion(version) QSettings.setDefaultFormat(QSettings.IniFormat) # Make it a null op. global init init = lambda: None
def main(args=sys.argv, logger=None): parser = option_parser() opts, args = parser.parse_args(args) if hasattr(opts, 'help'): parser.print_help() return 1 pid = os.fork() if (islinux or isbsd) else -1 if pid <= 0: override = 'calibre-lrf-viewer' if islinux else None app = Application(args, override_program_name=override) app.setWindowIcon(QIcon(I('viewer.png'))) QCoreApplication.setOrganizationName(ORG_NAME) QCoreApplication.setApplicationName(APP_UID) opts = normalize_settings(parser, opts) stream = open(args[1], 'rb') if len(args) > 1 else None main = file_renderer(stream, opts, logger=logger) sys.excepthook = main.unhandled_exception main.show() main.render() main.activateWindow() main.raise_() return app.exec_() return 0
def run(): #Change process name only GNU/Linux change_pro_name() #Set global var global app app = QApplication(sys.argv) #Set application parameters QCoreApplication.setOrganizationName(__prj__) QCoreApplication.setApplicationName(__prj__) QCoreApplication.setApplicationVersion(__version__) #Add style sheet with open(style_file, 'r') as f: style = f.read() app.setStyleSheet(style) app.setWindowIcon(QIcon(main_icon)) window = divergenceMeterWindow() window.show() sys.exit(app.exec_())
self.show_message("Server message", message) def show_error_from_socket(self, message): self.show_message("Server error", message, QSystemTrayIcon.Critical) def show_message_from_mod_manager(self, message): self.show_message("ModManager message", message) def show_error_from_mod_manager(self, message): self.show_message("ModManager error", message, QSystemTrayIcon.Critical) def show_message(self, title, message, icon = QSystemTrayIcon.Information): self.tray.showMessage(title, message, icon) if __name__ == '__main__': app = SingleApplication(sys.argv) app.setQuitOnLastWindowClosed(False); if app.is_running(): log.DEBUG("[main] d2mp is already running!") else: QCoreApplication.setOrganizationName("D2Modd"); QCoreApplication.setOrganizationDomain("d2modd.in"); QCoreApplication.setApplicationName("D2ModdInClient"); log.DEBUG("[main] ready to close") r = app.exec_() log.DEBUG("[main] exiting with status %d" %r)
def start(listener, filenames=None, projects_path=None, extra_plugins=None): app = QApplication(sys.argv) QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('NINJA-IDE') QCoreApplication.setApplicationName('NINJA-IDE') app.setWindowIcon(QIcon(resources.IMAGES['icon'])) # Create and display the splash screen splash_pix = QPixmap(resources.IMAGES['splash']) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking app.setCursorFlashTime(0) #Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Translator qsettings = QSettings() language = QLocale.system().language() lang = unicode(qsettings.value( 'preferences/interface/language', language).toString()) + '.qm' lang_path = file_manager.create_path(resources.LANGS, unicode(lang)) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path elif file_manager.file_exists(file_manager.create_path( resources.LANGS_DOWNLOAD, unicode(lang))): settings.LANGUAGE = file_manager.create_path( resources.LANGS_DOWNLOAD, unicode(lang)) translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) #Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() #Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() #Loading Themes splash.showMessage("Loading Themes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = unicode(qsettings.value('preferences/editor/scheme', "default").toString()) if scheme != 'default': scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + '.color') if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) #Loading Shortcuts resources.load_shortcuts() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ide = IDE() #Showing GUI ide.show() #Connect listener signals ide.connect(listener, SIGNAL("fileOpenRequested(QString)"), ide.open_file) ide.connect(listener, SIGNAL("projectOpenRequested(QString)"), ide.open_project) #Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) #Files in Main Tab mainFiles = qsettings.value('openFiles/mainTab', []).toList() tempFiles = [] for file_ in mainFiles: fileData = file_.toList() tempFiles.append((unicode(fileData[0].toString()), fileData[1].toInt()[0])) mainFiles = tempFiles #Files in Secondary Tab secondaryFiles = qsettings.value('openFiles/secondaryTab', []).toList() tempFiles = [] for file_ in secondaryFiles: fileData = file_.toList() tempFiles.append((unicode(fileData[0].toString()), fileData[1].toInt()[0])) secondaryFiles = tempFiles #Projects projects = qsettings.value('openFiles/projects', []).toList() projects = [unicode(project.toString()) for project in projects] #Include files received from console args if filenames: mainFiles += [(f, 0) for f in filenames] #Include projects received from console args if projects_path: projects += projects_path ide.load_session_files_projects(mainFiles, secondaryFiles, projects) #Load external plugins if extra_plugins: ide.load_external_plugins(extra_plugins) splash.finish(ide) ide.notify_plugin_errors() sys.exit(app.exec_())
#!/usr/bin/python # -*- coding: utf-8 -*- from __future__ import print_function, division, absolute_import """ GAUDInspect =========== A full GUI for launching GAUDI jobs, analyze their progress and examine the results. """ from .version import __version_info__, __version__ # noqa import sip sip.setapi(u'QDate', 2) sip.setapi(u'QDateTime', 2) sip.setapi(u'QString', 2) sip.setapi(u'QTextStream', 2) sip.setapi(u'QTime', 2) sip.setapi(u'QUrl', 2) sip.setapi(u'QVariant', 2) from PyQt4.QtCore import QSettings, QCoreApplication QSettings.setDefaultFormat(QSettings.IniFormat) QCoreApplication.setOrganizationName("GAUDI") QCoreApplication.setApplicationName("GAUDInspect")
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Importe este módulo para registrar ao PyQt detalhes desta aplicação, tais como nome, organização e domínio. Revision history: $Log: register_application.py,v $ Revision 1.2 2012/10/16 18:50:17 diogenes-silva First version ''' from PyQt4.QtCore import QCoreApplication, QSettings QCoreApplication.setOrganizationDomain( 'fis.unb.br' ) QCoreApplication.setOrganizationName( 'labfis2' ) QCoreApplication.setApplicationName( 'DrDaq' ) QSettings.setDefaultFormat( QSettings.IniFormat ) del QCoreApplication del QSettings
def start(filenames=None, projects_path=None, extra_plugins=None, linenos=None): app = QApplication(sys.argv) QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('NINJA-IDE') QCoreApplication.setApplicationName('NINJA-IDE') app.setWindowIcon(QIcon(resources.IMAGES['icon'])) # Check if there is another session of ninja-ide opened # and in that case send the filenames and projects to that session running = ipc.is_running() start_server = not running[0] if running[0] and (filenames or projects_path): sended = ipc.send_data(running[1], filenames, projects_path, linenos) running[1].close() if sended: sys.exit() else: running[1].close() # Create and display the splash screen splash_pix = QPixmap(resources.IMAGES['splash']) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking global cursor_flash_time cursor_flash_time = app.cursorFlashTime() app.setCursorFlashTime(0) #Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Translator qsettings = QSettings() language = QLocale.system().name() lang = qsettings.value('preferences/interface/language', language) + '.qm' lang_path = file_manager.create_path(resources.LANGS, lang) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path elif file_manager.file_exists(file_manager.create_path( resources.LANGS_DOWNLOAD, lang)): settings.LANGUAGE = file_manager.create_path( resources.LANGS_DOWNLOAD, lang) translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) #Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() #Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() #Set Stylesheet style_applied = False if settings.NINJA_SKIN not in ('Default', 'Classic Theme'): file_name = ("%s.qss" % settings.NINJA_SKIN) qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD, file_name) if file_manager.file_exists(qss_file): with open(qss_file) as f: qss = f.read() app.setStyleSheet(qss) style_applied = True if not style_applied: if settings.NINJA_SKIN == 'Default': with open(resources.NINJA_THEME) as f: qss = f.read() else: with open(resources.NINJA__THEME_CLASSIC) as f: qss = f.read() app.setStyleSheet(qss) #Loading Schemes splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = qsettings.value('preferences/editor/scheme', "default") if scheme != 'default': scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + '.color') if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) #Loading Shortcuts resources.load_shortcuts() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ide = IDE(start_server) #Showing GUI ide.show() #Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) #Files in Main Tab main_files = qsettings.value('openFiles/mainTab', []) if main_files is not None: mainFiles = list(main_files) else: mainFiles = list() tempFiles = [] for file_ in mainFiles: fileData = list(file_) tempFiles.append((fileData[0], int(fileData[1]))) mainFiles = tempFiles #Files in Secondary Tab sec_files = qsettings.value('openFiles/secondaryTab', []) if sec_files is not None: secondaryFiles = list(sec_files) else: secondaryFiles = list() tempFiles = [] for file_ in secondaryFiles: fileData = list(file_) tempFiles.append((fileData[0], int(fileData[1]))) secondaryFiles = tempFiles # Recent Files recent = qsettings.value('openFiles/recentFiles', []) if recent is not None: recent_files = list(recent) else: recent_files = list() recent_files = [file_ for file_ in recent_files] #Current File current_file = qsettings.value('openFiles/currentFile', '') #Projects projects_list = qsettings.value('openFiles/projects', []) if projects_list is not None: projects = list(projects_list) else: projects = list() projects = [project for project in projects] #Include files received from console args file_with_nro = list(map(lambda f: (f[0], f[1] - 1), zip(filenames, linenos))) file_without_nro = list(map(lambda f: (f, 0), filenames[len(linenos):])) mainFiles += file_with_nro + file_without_nro #Include projects received from console args if projects_path: projects += projects_path ide.load_session_files_projects(mainFiles, secondaryFiles, projects, current_file, recent_files) #Load external plugins if extra_plugins: ide.load_external_plugins(extra_plugins) splash.finish(ide) ide.notify_plugin_errors() sys.exit(app.exec_())
def get_qgis_app(): """ Start one QGIS application to test against. :returns: Handle to QGIS app, canvas, iface and parent. If there are any errors the tuple members will be returned as None. :rtype: (QgsApplication, CANVAS, IFACE, PARENT) If QGIS is already running the handle to that app will be returned. """ try: from qgis.core import QgsApplication from qgis.gui import QgsMapCanvas # pylint: disable=no-name-in-module # noinspection PyPackageRequirements from PyQt4 import QtGui, QtCore # pylint: disable=W0621 # noinspection PyPackageRequirements from PyQt4.QtCore import QCoreApplication, QSettings from safe.gis.qgis_interface import QgisInterface except ImportError: return None, None, None, None global QGIS_APP # pylint: disable=W0603 if QGIS_APP is None: gui_flag = True # All test will run qgis in gui mode # AG: For testing purposes, we use our own configuration file instead # of using the QGIS apps conf of the host # noinspection PyCallByClass,PyArgumentList QCoreApplication.setOrganizationName('QGIS') # noinspection PyCallByClass,PyArgumentList QCoreApplication.setOrganizationDomain('qgis.org') # noinspection PyCallByClass,PyArgumentList QCoreApplication.setApplicationName('QGIS2InaSAFETesting') # noinspection PyPep8Naming QGIS_APP = QgsApplication(sys.argv, gui_flag) # Make sure QGIS_PREFIX_PATH is set in your env if needed! QGIS_APP.initQgis() s = QGIS_APP.showSettings() LOGGER.debug(s) # Save some settings settings = QSettings() settings.setValue('locale/overrideFlag', True) settings.setValue('locale/userLocale', 'en_US') # We disabled message bars for now for extent selector as # we don't have a main window to show them in TS - version 3.2 settings.setValue('inasafe/show_extent_confirmations', False) settings.setValue('inasafe/show_extent_warnings', False) settings.setValue('inasafe/showRubberBands', True) settings.setValue('inasafe/analysis_extents_mode', 'HazardExposure') global PARENT # pylint: disable=W0603 if PARENT is None: # noinspection PyPep8Naming PARENT = QtGui.QWidget() global CANVAS # pylint: disable=W0603 if CANVAS is None: # noinspection PyPep8Naming CANVAS = QgsMapCanvas(PARENT) CANVAS.resize(QtCore.QSize(400, 400)) global IFACE # pylint: disable=W0603 if IFACE is None: # QgisInterface is a stub implementation of the QGIS plugin interface # noinspection PyPep8Naming IFACE = QgisInterface(CANVAS) register_impact_functions() return QGIS_APP, CANVAS, IFACE, PARENT
import sip sip.setapi('QString', 2) import sys, os from PyQt4.QtCore import QCoreApplication # VERY important, importing this module monkey patches Win32 os routines to have super-powers (like; can detect symlinks) from lib.platform import Platform import logging # TIP: its important that the imports DO NOT happen before the Org/App name has been set up, otherwise the QSettings # can potentially be instantiated *before* its defaults are ready a = QCoreApplication(sys.argv) a.setOrganizationName("FileWave") a.setApplicationName("UnitTest") #from test_build_tree_model import * from test_directory_scanner import * from test_document_storage import * from test_path_info import * from test_persistent_scanning_state import * from test_exclusion_rules import * from test_plugins import * from tests.utils import start_figleaf, close_figleaf if __name__ == '__main__': logging.basicConfig(format='%(asctime)s, %(levelname)s: %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.DEBUG) #fig_started = start_figleaf()
def __init__(self, fileName=None, exportPath=None, parent=None): debug_timing_start = Debug.timehook() super(MainWindow, self).__init__(parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) QCoreApplication.setOrganizationName( Config.ORGANIZATION ) QCoreApplication.setApplicationName( Config.PROGRAM_NAME ) QCoreApplication.setApplicationVersion( Config.version() ) #Debug.debug(QApplication.style()) self.setWindowTitle( "" ) self.setWindowIcon( QIcon( ":/icons/images/WoD.png" ) ) self.__storage = StorageTemplate( self ) self.storeTemplateData() self.__character = StorageCharacter(self.__storage) ## Später sollte ich mich für einen entscheiden!! self.__readCharacter = ReadXmlCharacter(self.__character) self.__writeCharacter = WriteXmlCharacter(self.__character) self.ui.pushButton_next.clicked.connect(self.ui.selectWidget_select.selectNext) self.ui.pushButton_previous.clicked.connect(self.ui.selectWidget_select.selectPrevious) self.ui.selectWidget_select.currentRowChanged.connect(self.ui.stackedWidget_traits.setCurrentIndex) self.ui.selectWidget_select.currentRowChanged.connect(self.setTabButtonState) #self.ui.selectWidget_select.currentRowChanged.connect(self.pageChanged.emit) self.__character.speciesChanged.connect(self.ui.selectWidget_select.changeIcons) self.__readCharacter.exception_raised.connect(self.showExceptionMessage) # Laden der Konfiguration self.readSettings() self.populateUi() Debug.timesince( debug_timing_start, "Time neccessary to populate the UI." ) debug_timing_between_start = Debug.timehook() self.activate() Debug.timesince( debug_timing_between_start, "Time neccessary to activate the UI." ) debug_timing_between_start = Debug.timehook() self.ui.selectWidget_select.currentRowChanged.connect(self.showCreationPoints) self.ui.actionSettings.triggered.connect(self.showSettingsDialog) self.ui.actionNew.triggered.connect(self.newCharacter) self.ui.actionOpen.triggered.connect(self.openCharacter) self.ui.actionSave.triggered.connect(self.saveCharacter) self.ui.actionExport.triggered.connect(self.exportCharacter) self.ui.actionPrint.triggered.connect(self.printCharacter) self.ui.actionAbout.triggered.connect(self.aboutApp) self.reset() Debug.timesince( debug_timing_between_start, "Time neccessary to set all initial values." ) debug_timing_between_start = Debug.timehook() ## Wird ein Dateiname angegeben, soll dieser sofort geladen werden. if fileName: if os.path.exists(fileName): if GlobalState.is_verbose: print("Opening file {}.".format(fileName)) self.openCharacter(fileName) elif fileName.lower() in [ species.lower() for species in self.__storage.species.keys() ]: if GlobalState.is_verbose: print("Empty Charactersheet of species {} will be created.".format(fileName.lower())) self.__character.species = fileName[0].upper() + fileName[1:].lower() self.__character.setModified(False) else: Shell.print_warning("A file named \"{}\" does not exist.".format(fileName)) Debug.timesince( debug_timing_between_start, "Time neccessary to load a file at startup." ) if exportPath: if GlobalState.is_verbose: print("Creating PDF {}".format(exportPath[0])) # exportPath ist eine Liste mit einem einzigen Element als Inhalt (argparse) self.__createPdf(exportPath[0]) # Damit das Programm ordentlich geschlossen werden kann, muß auf das Starten der Event-Loop gewartet werden. dies geht am einfachsten mit einem QTimer. QTimer.singleShot(0, self.close) Debug.timesince( debug_timing_start, "The full time span neccessary to prepare the application for user input." )
def get_qgis_app(): """ Start one QGIS application to test against. :returns: Handle to QGIS app, canvas, iface and parent. If there are any errors the tuple members will be returned as None. :rtype: (QgsApplication, CANVAS, IFACE, PARENT) If QGIS is already running the handle to that app will be returned. """ try: from PyQt4 import QtGui, QtCore from PyQt4.QtCore import QCoreApplication, QSettings from qgis.core import QgsApplication from qgis.gui import QgsMapCanvas from safe.common.qgis_interface import QgisInterface except ImportError: return None, None, None, None global QGIS_APP # pylint: disable=W0603 if QGIS_APP is None: gui_flag = True # All test will run qgis in gui mode # AG: For testing purposes, we use our own configuration file instead # of using the QGIS apps conf of the host QCoreApplication.setOrganizationName('QGIS') QCoreApplication.setOrganizationDomain('qgis.org') QCoreApplication.setApplicationName('QGIS2InaSAFETesting') # noinspection PyPep8Naming QGIS_APP = QgsApplication(sys.argv, gui_flag) # Make sure QGIS_PREFIX_PATH is set in your env if needed! QGIS_APP.initQgis() s = QGIS_APP.showSettings() LOGGER.debug(s) # Save some settings settings = QSettings() settings.setValue('locale/overrideFlag', True) settings.setValue('locale/userLocale', 'en_US') global PARENT # pylint: disable=W0603 if PARENT is None: # noinspection PyPep8Naming PARENT = QtGui.QWidget() global CANVAS # pylint: disable=W0603 if CANVAS is None: # noinspection PyPep8Naming CANVAS = QgsMapCanvas(PARENT) CANVAS.resize(QtCore.QSize(400, 400)) global IFACE # pylint: disable=W0603 if IFACE is None: # QgisInterface is a stub implementation of the QGIS plugin interface # noinspection PyPep8Naming IFACE = QgisInterface(CANVAS) return QGIS_APP, CANVAS, IFACE, PARENT
def __init__(self, fileName=None, exportPath=None, parent=None): debug_timing_start = Debug.timehook() super(MainWindow, self).__init__(parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) QCoreApplication.setOrganizationName(Config.ORGANIZATION) QCoreApplication.setApplicationName(Config.PROGRAM_NAME) QCoreApplication.setApplicationVersion(Config.version()) #Debug.debug(QApplication.style()) self.setWindowTitle("") self.setWindowIcon(QIcon(":/icons/images/WoD.png")) self.__storage = StorageTemplate(self) self.storeTemplateData() self.__character = StorageCharacter(self.__storage) ## Später sollte ich mich für einen entscheiden!! self.__readCharacter = ReadXmlCharacter(self.__character) self.__writeCharacter = WriteXmlCharacter(self.__character) self.ui.pushButton_next.clicked.connect( self.ui.selectWidget_select.selectNext) self.ui.pushButton_previous.clicked.connect( self.ui.selectWidget_select.selectPrevious) self.ui.selectWidget_select.currentRowChanged.connect( self.ui.stackedWidget_traits.setCurrentIndex) self.ui.selectWidget_select.currentRowChanged.connect( self.setTabButtonState) #self.ui.selectWidget_select.currentRowChanged.connect(self.pageChanged.emit) self.__character.speciesChanged.connect( self.ui.selectWidget_select.changeIcons) self.__readCharacter.exception_raised.connect( self.showExceptionMessage) # Laden der Konfiguration self.readSettings() self.populateUi() Debug.timesince(debug_timing_start, "Time neccessary to populate the UI.") debug_timing_between_start = Debug.timehook() self.activate() Debug.timesince(debug_timing_between_start, "Time neccessary to activate the UI.") debug_timing_between_start = Debug.timehook() self.ui.selectWidget_select.currentRowChanged.connect( self.showCreationPoints) self.ui.actionSettings.triggered.connect(self.showSettingsDialog) self.ui.actionNew.triggered.connect(self.newCharacter) self.ui.actionOpen.triggered.connect(self.openCharacter) self.ui.actionSave.triggered.connect(self.saveCharacter) self.ui.actionExport.triggered.connect(self.exportCharacter) self.ui.actionPrint.triggered.connect(self.printCharacter) self.ui.actionAbout.triggered.connect(self.aboutApp) self.reset() Debug.timesince(debug_timing_between_start, "Time neccessary to set all initial values.") debug_timing_between_start = Debug.timehook() ## Wird ein Dateiname angegeben, soll dieser sofort geladen werden. if fileName: if os.path.exists(fileName): if GlobalState.is_verbose: print("Opening file {}.".format(fileName)) self.openCharacter(fileName) elif fileName.lower() in [ species.lower() for species in self.__storage.species.keys() ]: if GlobalState.is_verbose: print( "Empty Charactersheet of species {} will be created.". format(fileName.lower())) self.__character.species = fileName[0].upper( ) + fileName[1:].lower() self.__character.setModified(False) else: Shell.print_warning( "A file named \"{}\" does not exist.".format(fileName)) Debug.timesince(debug_timing_between_start, "Time neccessary to load a file at startup.") if exportPath: if GlobalState.is_verbose: print("Creating PDF {}".format(exportPath[0])) # exportPath ist eine Liste mit einem einzigen Element als Inhalt (argparse) self.__createPdf(exportPath[0]) # Damit das Programm ordentlich geschlossen werden kann, muß auf das Starten der Event-Loop gewartet werden. dies geht am einfachsten mit einem QTimer. QTimer.singleShot(0, self.close) Debug.timesince( debug_timing_start, "The full time span neccessary to prepare the application for user input." )
def __init__(self): QCoreApplication.setOrganizationName("DLC") QCoreApplication.setApplicationName("AFS") self.settings = QSettings("settings.ini", QSettings.IniFormat)
from PyQt4.QtCore import QCoreApplication, QSettings def chunks(l, n): for i in xrange(0, len(l), n): yield l[i:i + n] QCoreApplication.setOrganizationName("QGIS") QCoreApplication.setOrganizationDomain("qgis.org") QCoreApplication.setApplicationName("QGIS2") s = QSettings() ba = s.value("/UI/geometry").toByteArray() f = open("src/app/ui_defaults.h", "w") f.write( "#ifndef UI_DEFAULTS_H\n#define UI_DEFAULTS_H\n\nstatic const unsigned char defaultUIgeometry[] =\n{\n" ) for chunk in chunks(ba, 16): f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % ord(x), chunk))) f.write("};\n\nstatic const unsigned char defaultUIstate[] =\n{\n") ba = s.value("/UI/state").toByteArray() for chunk in chunks(ba, 16): f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % ord(x), chunk)))
def start_ide(app, filenames, projects_path, extra_plugins, linenos): """Load all the settings necessary before loading the UI, and start IDE.""" QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('NINJA-IDE') QCoreApplication.setApplicationName('NINJA-IDE') app.setWindowIcon(QIcon(":img/icon")) # Check if there is another session of ninja-ide opened # and in that case send the filenames and projects to that session running = ipc.is_running() start_server = not running[0] if running[0] and (filenames or projects_path): sended = ipc.send_data(running[1], filenames, projects_path, linenos) running[1].close() if sended: sys.exit() else: running[1].close() # Create and display the splash screen splash_pix = QPixmap(":img/splash") splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking #if not settings.IS_WINDOWS: #app.setCursorFlashTime(0) #Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Translator qsettings = ide.IDE.ninja_settings() data_qsettings = ide.IDE.data_settings() language = QLocale.system().name() lang = qsettings.value('preferences/interface/language', defaultValue=language, type='QString') + '.qm' lang_path = file_manager.create_path(resources.LANGS, lang) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) qtTranslator = QTranslator() qtTranslator.load("qt_" + language, QLibraryInfo.location(QLibraryInfo.TranslationsPath)) app.installTranslator(qtTranslator) #Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() #Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) #Set Stylesheet style_applied = False print(settings.NINJA_SKIN) if settings.NINJA_SKIN not in ('Default'): file_name = ("%s.qss" % settings.NINJA_SKIN) qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD, file_name) if file_manager.file_exists(qss_file): with open(qss_file) as fileaccess: qss = fileaccess.read() app.setStyleSheet(qss) style_applied = True if not style_applied: if settings.NINJA_SKIN == 'Default': with open(resources.NINJA_THEME) as fileaccess: qss = fileaccess.read() app.setStyleSheet(qss) #Loading Schemes splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = qsettings.value('preferences/editor/scheme', "default", type='QString') if scheme != 'default': scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + '.color') if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) #Loading Shortcuts resources.load_shortcuts() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ninjaide = ide.IDE(start_server) #Showing GUI ninjaide.show() #OSX workaround for ninja window not in front try: ninjaide.raise_() except: pass # I really dont mind if this fails in any form #Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) #First check if we need to load last session files if qsettings.value('preferences/general/loadFiles', True, type=bool): #Files in Main Tab files = data_qsettings.value('lastSession/openedFiles', []) tempFiles = [] if files: for file_ in files: fileData = tuple(file_) if fileData: tempFiles.append(fileData) files = tempFiles # Recent Files recent_files = data_qsettings.value('lastSession/recentFiles', []) #Current File current_file = data_qsettings.value('lastSession/currentFile', '', type='QString') #Projects projects = data_qsettings.value('lastSession/projects', []) else: files = [] recent_files = [] current_file = '' projects = [] #Include files received from console args file_with_nro = list([(f[0], (f[1] - 1, 0), 0) for f in zip(filenames, linenos)]) file_without_nro = list([(f, (0, 0), 0) for f in filenames[len(linenos):]]) files += file_with_nro + file_without_nro #Include projects received from console args if projects_path: projects += projects_path #FIXME: IMPROVE THIS WITH THE NEW WAY OF DO IT ninjaide.load_session_files_projects(files, projects, current_file, recent_files) #Load external plugins #if extra_plugins: #ninjaide.load_external_plugins(extra_plugins) splash.finish(ninjaide) ninjaide.notify_plugin_errors() ninjaide.show_python_detection()
def start(filenames=None, projects_path=None, extra_plugins=None, linenos=None): app = QApplication(sys.argv) QCoreApplication.setOrganizationName("NINJA-IDE") QCoreApplication.setOrganizationDomain("NINJA-IDE") QCoreApplication.setApplicationName("NINJA-IDE") app.setWindowIcon(QIcon(resources.IMAGES["icon"])) # Check if there is another session of ninja-ide opened # and in that case send the filenames and projects to that session running = ipc.is_running() start_server = not running[0] if running[0] and (filenames or projects_path): sended = ipc.send_data(running[1], filenames, projects_path, linenos) running[1].close() if sended: sys.exit() else: running[1].close() # Create and display the splash screen splash_pix = QPixmap(resources.IMAGES["splash"]) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking global cursor_flash_time cursor_flash_time = app.cursorFlashTime() app.setCursorFlashTime(0) # Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName("utf-8")) # Translator qsettings = QSettings() language = QLocale.system().language() lang = unicode(qsettings.value("preferences/interface/language", language).toString()) + ".qm" lang_path = file_manager.create_path(resources.LANGS, unicode(lang)) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path elif file_manager.file_exists(file_manager.create_path(resources.LANGS_DOWNLOAD, unicode(lang))): settings.LANGUAGE = file_manager.create_path(resources.LANGS_DOWNLOAD, unicode(lang)) translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) # Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() # Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() # Set Stylesheet if settings.USE_STYLESHEET: with open(resources.NINJA_THEME) as f: qss = f.read() app.setStyleSheet(qss) # Loading Themes splash.showMessage("Loading Themes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = unicode(qsettings.value("preferences/editor/scheme", "default").toString()) if scheme != "default": scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + ".color") if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) # Loading Shortcuts resources.load_shortcuts() # Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ide = IDE(start_server) # Showing GUI ide.show() # Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) # Files in Main Tab mainFiles = qsettings.value("openFiles/mainTab", []).toList() tempFiles = [] for file_ in mainFiles: fileData = file_.toList() tempFiles.append((unicode(fileData[0].toString()), fileData[1].toInt()[0])) mainFiles = tempFiles # Files in Secondary Tab secondaryFiles = qsettings.value("openFiles/secondaryTab", []).toList() tempFiles = [] for file_ in secondaryFiles: fileData = file_.toList() tempFiles.append((unicode(fileData[0].toString()), fileData[1].toInt()[0])) secondaryFiles = tempFiles # Current File current_file = unicode(qsettings.value("openFiles/currentFile", "").toString()) # Projects projects = qsettings.value("openFiles/projects", []).toList() projects = [unicode(project.toString()) for project in projects] # Include files received from console args file_with_nro = map(lambda f: (f[0], f[1] - 1), zip(filenames, linenos)) file_without_nro = map(lambda f: (f, 0), filenames[len(linenos) :]) mainFiles += file_with_nro + file_without_nro # Include projects received from console args if projects_path: projects += projects_path mainFiles.reverse() secondaryFiles.reverse() ide.load_session_files_projects(mainFiles, secondaryFiles, projects, current_file) # Load external plugins if extra_plugins: ide.load_external_plugins(extra_plugins) splash.finish(ide) ide.notify_plugin_errors() sys.exit(app.exec_())
def __init__(self): QMainWindow.__init__(self) # for QSettings QCoreApplication.setOrganizationName("Autodrill") QCoreApplication.setApplicationName("Autodrill") self.updateTimer=QTimer() self.updateTimer.start(50) # set up the user interface from Designer. self.setupUi(self) self.setFocusPolicy(QtCore.Qt.StrongFocus) self.installEventFilter(self) self.boardDrillsWidget = BoardDrillsWidget() self.gridLayout.addWidget(self.boardDrillsWidget, 0, 0, 2, 1) self.cameraWidget = DrillCam() self.gridLayout.addWidget(self.cameraWidget, 0, 1, 1, 1) self.dialogDrills=DialogDrills(self) self.dialogDrillParameter=DialogDrillParameter(self) self.dialogCamera=DialogCamera(self) # init local variables self.rawHoles = {} # dictionary: holes sorted by diameter (from drill file) self.fitHoles = {} # dictionary: dia -> set of holes, holes fitted to available drill diameters self.selectedHoles=list() # list of selected holes self.trafoPoints=list() # points used for transformation (file coordinates) self.trafoMachinePoints=list() # corresponding machine coordinates # load settings (and set default values) self.settings=QSettings() self.drills={} diaList=self.settings.value("drillsDia", "").toList() toolNrList=self.settings.value("drillsToolNr", "").toList() for i in range(len(diaList)): self.drills[diaList[i].toDouble()[0]] = toolNrList[i].toInt()[0] self.diaTol=self.settings.value("diaTol", 0.05).toDouble()[0] self.cameraZoom=self.settings.value("cameraZoom", 1.0).toDouble()[0] self.cameraOffset=(self.settings.value("cameraOffsetX", 0.0).toDouble()[0], self.settings.value("cameraOffsetY", 0.0).toDouble()[0]) self.feedrate=self.settings.value("feedrate", 10.0).toDouble()[0] self.drillDepth=self.settings.value("drillDepth", 2.0).toDouble()[0] self.drillSpacing=self.settings.value("drillSpacing", 5.0).toDouble()[0] self.currentFile=self.settings.value("currentFile", "").toString() # connect signals and slots self.action_loadDrillFile.triggered.connect(self.action_loadDrillFile_triggered) self.action_dialogDrills.triggered.connect(self.action_dialogDrills_triggered) self.action_dialogDrillParameter.triggered.connect(self.action_dialogDrillParameter_triggered) self.action_dialogCamera.triggered.connect(self.action_dialogCamera_triggered) self.action_writeGCode.triggered.connect(self.action_writeGCode_triggered) self.treeWidget_holes.currentItemChanged.connect(self.treeNodeSelected) self.boardDrillsWidget.holeSelected.connect(self.holeSelected) self.pushButton_addPoint.clicked.connect(self.addTrafoPoint) self.pushButton_removeLast.clicked.connect(self.removeLastTrafoPoints) self.pushButton_removeAll.clicked.connect(self.removeAllTrafoPoints) self.verticalSlider_cameraZoom.valueChanged.connect(self.zoomChanged) self.updateTimer.timeout.connect(self.updatePositionLabel) # init widgets self.updateHolesTable() self.cameraWidget.setZoom(self.cameraZoom) self.verticalSlider_cameraZoom.setValue(self.cameraZoom*10) if not self.cameraWidget.cameraAvailable(): self.verticalSlider_cameraZoom.setEnabled(False) # check for LinuxCNC if not LinuxCNCInstalled(): QMessageBox.information(self, "LinuxCNC", "Please install LinuxCNC") return if not LinuxCNCRunning(): QMessageBox.information(self, "LinuxCNC", "Please start LinuxCNC now.") # for jogging self.jogSpeed=SLOWJOG self.jogAxes=[0, 0, 0]
def main(argv): path = None first_arg = None second_arg = None config = None apath = None print("QT VERSION %s" % QT_VERSION_STR) try: first_arg = argv[1] second_arg = argv[2] except IndexError: pass if first_arg is not None: if first_arg == "-c": config = True if second_arg is not None: path = second_arg else: path = first_arg try: #app = QApplication(argv) app = MyApp(argv) QCoreApplication.setOrganizationDomain('www.trickplay.com') QCoreApplication.setOrganizationName('Trickplay') QCoreApplication.setApplicationName('Trickplay Debugger') QCoreApplication.setApplicationVersion('0.0.1') s = QProcessEnvironment.systemEnvironment().toStringList() for item in s: k, v = str(item).split("=", 1) if k == 'PWD': apath = v apath = os.path.join(apath, os.path.dirname(str(argv[0]))) main = MainWindow(app, apath) main.config = config main.show() main.raise_() wizard = Wizard() app.main = main path = wizard.start(path) if path: settings = QSettings() settings.setValue('path', path) app.setActiveWindow(main) main.start(path, wizard.filesToOpen()) main.show() sys.exit(app.exec_()) # TODO, better way of doing this for 'clean' exit... except KeyboardInterrupt: exit("Exited")
def main(argv): path = None first_arg = None second_arg = None config = None apath = None print("QT VERSION %s" % QT_VERSION_STR ) try: first_arg = argv[1] second_arg = argv[2] except IndexError: pass if first_arg is not None: if first_arg == "-c": config = True if second_arg is not None: path = second_arg else: path = first_arg try: #app = QApplication(argv) app = MyApp(argv) QCoreApplication.setOrganizationDomain('www.trickplay.com'); QCoreApplication.setOrganizationName('Trickplay'); QCoreApplication.setApplicationName('Trickplay Debugger'); QCoreApplication.setApplicationVersion('0.0.1'); s = QProcessEnvironment.systemEnvironment().toStringList() for item in s: k , v = str( item ).split( "=" , 1 ) if k == 'PWD': apath = v apath = os.path.join(apath, os.path.dirname(str(argv[0]))) main = MainWindow(app, apath) main.config = config main.show() main.raise_() wizard = Wizard() app.main = main path = wizard.start(path) if path: settings = QSettings() settings.setValue('path', path) app.setActiveWindow(main) main.start(path, wizard.filesToOpen()) main.show() sys.exit(app.exec_()) # TODO, better way of doing this for 'clean' exit... except KeyboardInterrupt: exit("Exited")
def start(): app = QApplication(sys.argv) QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('ninja-ide.org.ar') QCoreApplication.setApplicationName('Kunai') # Create and display the splash screen splash_pix = QPixmap(resources.images['splash']) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() loader.load_syntax() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignBottom, Qt.white) settings = QSettings() if not settings.value('preferences/skins/default', True).toBool(): selectedSkin = settings.value('preferences/skins/selectedSkin', '').toString() skins = loader.load_gui_skins() css = skins.get(str(selectedSkin), '') app.setStyleSheet(css) schemeColor = str(settings.value('preferences/editor/scheme', 'default').toString()) if schemeColor != 'default': resources.custom_scheme = loader.load_editor_skins().get(schemeColor, {}) #Editor Configuration EditorGeneric.codeCompletion = settings.value('preferences/editor/codeCompletion', True).toBool() EditorGeneric.indent = settings.value('preferences/editor/indent', 4).toInt()[0] EditorGeneric.findErrors = settings.value('preferences/editor/errors', False).toBool() EditorGeneric.checkStyle = settings.value('preferences/editor/checkStyle', True).toBool() EditorGeneric.highlightVariables = settings.value('preferences/editor/highlightWord', True).toBool() if not settings.value('preferences/editor/parentheses', True).toBool(): del EditorGeneric.braces_strings['('] if not settings.value('preferences/editor/brackets', True).toBool(): del EditorGeneric.braces_strings['['] if not settings.value('preferences/editor/keys', True).toBool(): del EditorGeneric.braces_strings['{'] if not settings.value('preferences/editor/simpleQuotes', True).toBool(): del EditorGeneric.braces_strings["'"] if not settings.value('preferences/editor/doubleQuotes', True).toBool(): del EditorGeneric.braces_strings['"'] ide = IDE() if settings.value('preferences/interface/centralRotate', False).toBool(): ide.main._splitter_central_rotate() if settings.value('preferences/interface/panelsRotate', False).toBool(): ide.main._splitter_main_rotate() if settings.value('preferences/interface/centralOrientation', False).toBool(): ide.main._splitter_central_orientation() #Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignBottom, Qt.white) resources.python_path = str(settings.value('preferences/general/pythonPath', 'python').toString()) if (settings.value('preferences/general/activatePlugins', Qt.Checked) == Qt.Checked): set_plugin_access(ide) ninja_ide.core.load_plugins(ide) resources.workspace = str(settings.value('preferences/general/workspace', '').toString()) supportedExtensions = settings.value('preferences/general/extensions', []).toList() if supportedExtensions: tempExtensions = [] for se in supportedExtensions: tempExtensions.append(str(se.toString())) manage_files.supported_extensions = tuple(tempExtensions) #Load Font preference font = str(settings.value('preferences/editor/font', "Monospace, 11").toString()) EditorGeneric.font_family = font.split(', ')[0] EditorGeneric.font_size = int(font.split(', ')[1]) ide.show() splash.showMessage("Loading Projects", Qt.AlignRight | Qt.AlignBottom, Qt.white) for projectFolder in settings.value('openFiles/projects', []).toStringList(): if os.path.isdir(projectFolder): ide.main.open_project_folder(str(projectFolder), False) if (settings.value('preferences/general/loadFiles', Qt.Checked) == Qt.Checked): for openFile in settings.value('openFiles/tab1', []).toList(): if len(openFile.toList()) > 0: fileList = openFile.toList() fileName = str(fileList[0].toString()) projectPath = str(fileList[1].toString()) if len(projectPath) == 0: projectPath = None cursorPosition = fileList[2].toInt()[0] if os.path.isfile(fileName): ide.main.open_document(fileName, projectPath) ide.main._central.obtain_editor().set_cursor_position(cursorPosition) for openFile2 in settings.value('openFiles/tab2', []).toList(): #ide.main.split_tab(True) if len(openFile2.toList()) > 0: ide.main._central._tabs2.show() ide.main._central._mainTabSelected = False fileList = openFile2.toList() fileName = fileList[0].toString() projectPath = fileList[1].toString() cursorPosition = fileList[2].toInt()[0] if os.path.isfile(fileName): ide.main.open_document(str(fileName), str(projectPath)) ide.main._central.obtain_editor().set_cursor_position(cursorPosition) ide.main._central._mainTabSelected = True filenames, projects_path = ninja_ide.core.cliparser.parse() for filename in filenames: ide.main.open_document(filename) for project_path in projects_path: ide.main.open_project_folder(project_path) splash.finish(ide) sys.exit(app.exec_())
def printHelp(cmd): print("Usage: %s [cmd]" % (cmd)) printArguments() def printVersion(): print("Cadence version %s" % (VERSION)) print("Developed by falkTX and the rest of the KXStudio Team") #--------------- main ------------------ if __name__ == '__main__': # App initialization app = QCoreApplication(sys.argv) app.setApplicationName("Cadence") app.setApplicationVersion(VERSION) app.setOrganizationName("Cadence") # Check arguments cmd = sys.argv[0] if len(app.arguments()) == 1: printHelp(cmd) elif len(app.arguments()) == 2: arg = app.arguments()[1] if arg == "--printLADSPA_PATH": printLADSPA_PATH() elif arg == "--printDSSI_PATH": printDSSI_PATH() elif arg == "--printLV2_PATH":
def start(listener, filenames=None, projects_path=None, extra_plugins=None): app = QApplication(sys.argv) QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('NINJA-IDE') QCoreApplication.setApplicationName('NINJA-IDE') app.setWindowIcon(QIcon(resources.IMAGES['icon'])) # Create and display the splash screen splash_pix = QPixmap(resources.IMAGES['splash']) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking app.setCursorFlashTime(0) #Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Translator qsettings = QSettings() language = QLocale.system().language() lang = unicode( qsettings.value('preferences/interface/language', language).toString()) + '.qm' lang_path = file_manager.create_path(resources.LANGS, unicode(lang)) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path elif file_manager.file_exists( file_manager.create_path(resources.LANGS_DOWNLOAD, unicode(lang))): settings.LANGUAGE = file_manager.create_path(resources.LANGS_DOWNLOAD, unicode(lang)) translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) #Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() #Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() #Loading Themes splash.showMessage("Loading Themes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = unicode( qsettings.value('preferences/editor/scheme', "default").toString()) if scheme != 'default': scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + '.color') if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) #Loading Shortcuts resources.load_shortcuts() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ide = IDE() #Showing GUI ide.show() #Connect listener signals ide.connect(listener, SIGNAL("fileOpenRequested(QString)"), ide.open_file) ide.connect(listener, SIGNAL("projectOpenRequested(QString)"), ide.open_project) #Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) #Files in Main Tab mainFiles = qsettings.value('openFiles/mainTab', []).toList() tempFiles = [] for file_ in mainFiles: fileData = file_.toList() tempFiles.append( (unicode(fileData[0].toString()), fileData[1].toInt()[0])) mainFiles = tempFiles #Files in Secondary Tab secondaryFiles = qsettings.value('openFiles/secondaryTab', []).toList() tempFiles = [] for file_ in secondaryFiles: fileData = file_.toList() tempFiles.append( (unicode(fileData[0].toString()), fileData[1].toInt()[0])) secondaryFiles = tempFiles #Projects projects = qsettings.value('openFiles/projects', []).toList() projects = [unicode(project.toString()) for project in projects] #Include files received from console args if filenames: mainFiles += [(f, 0) for f in filenames] #Include projects received from console args if projects_path: projects += projects_path ide.load_session_files_projects(mainFiles, secondaryFiles, projects) #Load external plugins if extra_plugins: ide.load_external_plugins(extra_plugins) splash.finish(ide) ide.notify_plugin_errors() sys.exit(app.exec_())
self.versionLabel.setText( tr("Version {}").format( QCoreApplication.instance().applicationVersion())) self.verticalLayout.addWidget(self.versionLabel) self.label_3 = QLabel(self) self.verticalLayout.addWidget(self.label_3) self.label_3.setText(tr("Copyright Hardcoded Software 2014")) self.label = QLabel(self) font = QFont() font.setWeight(75) font.setBold(True) self.label.setFont(font) self.verticalLayout.addWidget(self.label) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Ok) self.verticalLayout.addWidget(self.buttonBox) self.horizontalLayout.addLayout(self.verticalLayout) if __name__ == '__main__': import sys app = QApplication([]) QCoreApplication.setOrganizationName('Hardcoded Software') QCoreApplication.setApplicationName('FooApp') QCoreApplication.setApplicationVersion('1.2.3') app.LOGO_NAME = '' dialog = AboutBox(None, app) dialog.show() sys.exit(app.exec_())
from hscommon.plat import ISWINDOWS from hscommon.trans import install_gettext_trans_under_qt from qtlib.error_report_dialog import install_excepthook from qtlib.util import setupQtLogging from qt.base import dg_rc from qt.base.platform import BASE_PATH from core_{edition} import __version__, __appname__ if ISWINDOWS: import qt.base.cxfreeze_fix if __name__ == "__main__": app = QApplication(sys.argv) QCoreApplication.setOrganizationName('Hardcoded Software') QCoreApplication.setApplicationName(__appname__) QCoreApplication.setApplicationVersion(__version__) setupQtLogging() settings = QSettings() lang = settings.value('Language') locale_folder = op.join(BASE_PATH, 'locale') install_gettext_trans_under_qt(locale_folder, lang) # Many strings are translated at import time, so this is why we only import after the translator # has been installed from qt.{edition}.app import DupeGuru app.setWindowIcon(QIcon(QPixmap(":/{0}".format(DupeGuru.LOGO_NAME)))) dgapp = DupeGuru() if not ISWINDOWS: dgapp.model.registered = True install_excepthook() sys.exit(app.exec_())
def start_ide(app, filenames, projects_path, extra_plugins, linenos): """Load all the settings necessary before loading the UI, and start IDE.""" QCoreApplication.setOrganizationName("NINJA-IDE") QCoreApplication.setOrganizationDomain("NINJA-IDE") QCoreApplication.setApplicationName("NINJA-IDE") app.setWindowIcon(QIcon(resources.IMAGES["icon"])) # Check if there is another session of ninja-ide opened # and in that case send the filenames and projects to that session running = ipc.is_running() start_server = not running[0] if running[0] and (filenames or projects_path): sended = ipc.send_data(running[1], filenames, projects_path, linenos) running[1].close() if sended: sys.exit() else: running[1].close() # Create and display the splash screen splash_pix = QPixmap(resources.IMAGES["splash"]) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking if not settings.IS_WINDOWS: app.setCursorFlashTime(0) # Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName("utf-8")) # Translator qsettings = QSettings(resources.SETTINGS_PATH, QSettings.IniFormat) language = QLocale.system().name() lang = qsettings.value("preferences/interface/language", defaultValue=language, type="QString") + ".qm" lang_path = file_manager.create_path(resources.LANGS, lang) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) qtTranslator = QTranslator() qtTranslator.load("qt_" + language, QLibraryInfo.location(QLibraryInfo.TranslationsPath)) app.installTranslator(qtTranslator) # Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() # Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() # Set Stylesheet style_applied = False if settings.NINJA_SKIN not in ("Default", "Classic Theme"): file_name = "%s.qss" % settings.NINJA_SKIN qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD, file_name) if file_manager.file_exists(qss_file): with open(qss_file) as f: qss = f.read() app.setStyleSheet(qss) style_applied = True if not style_applied: if settings.NINJA_SKIN == "Default": with open(resources.NINJA_THEME) as f: qss = f.read() else: with open(resources.NINJA_THEME_CLASSIC) as f: qss = f.read() app.setStyleSheet(qss) # Loading Schemes splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = qsettings.value("preferences/editor/scheme", "default", type="QString") if scheme != "default": scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + ".color") if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) # Loading Shortcuts resources.load_shortcuts() # Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ninjaide = ide.IDE(start_server) # Showing GUI ninjaide.show() # Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) # First check if we need to load last session files if qsettings.value("preferences/general/loadFiles", True, type=bool): # Files in Main Tab main_files = qsettings.value("openFiles/mainTab", []) tempFiles = [] if main_files: for file_ in main_files: fileData = list(file_) if fileData: lineno = fileData[1] tempFiles.append((fileData[0], lineno)) main_files = tempFiles # Files in Secondary Tab sec_files = qsettings.value("openFiles/secondaryTab", []) tempFiles = [] if sec_files: for file_ in sec_files: fileData = list(file_) if fileData: lineno = fileData[1] tempFiles.append((fileData[0], lineno)) sec_files = tempFiles # Recent Files recent_files = qsettings.value("openFiles/recentFiles", []) # Current File current_file = qsettings.value("openFiles/currentFile", "", type="QString") # Projects projects = qsettings.value("openFiles/projects", []) else: main_files = [] sec_files = [] recent_files = [] current_file = "" projects = [] # Include files received from console args file_with_nro = list([(f[0], f[1] - 1) for f in zip(filenames, linenos)]) file_without_nro = list([(f, 0) for f in filenames[len(linenos) :]]) main_files += file_with_nro + file_without_nro # Include projects received from console args if projects_path: projects += projects_path # FIXME: IMPROVE THIS WITH THE NEW WAY OF DO IT # ninjaide.load_session_files_projects(main_files, sec_files, # projects, current_file, recent_files) # Load external plugins # if extra_plugins: # ninjaide.load_external_plugins(extra_plugins) splash.finish(ninjaide) ninjaide.notify_plugin_errors() ninjaide.show_python_detection()
def start_ide(app, filenames, projects_path, extra_plugins, linenos): """Load all the settings necessary before loading the UI, and start IDE.""" QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('NINJA-IDE') QCoreApplication.setApplicationName('NINJA-IDE') app.setWindowIcon(QIcon(":img/icon")) # Check if there is another session of ninja-ide opened # and in that case send the filenames and projects to that session running = ipc.is_running() start_server = not running[0] if running[0] and (filenames or projects_path): sended = ipc.send_data(running[1], filenames, projects_path, linenos) running[1].close() if sended: sys.exit() else: running[1].close() # Create and display the splash screen splash_pix = QPixmap(":img/splash") splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking if not settings.IS_WINDOWS: app.setCursorFlashTime(0) #Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Translator qsettings = ide.IDE.ninja_settings() data_qsettings = ide.IDE.data_settings() language = QLocale.system().name() lang = qsettings.value('preferences/interface/language', defaultValue=language, type='QString') + '.qm' lang_path = file_manager.create_path(resources.LANGS, lang) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) qtTranslator = QTranslator() qtTranslator.load("qt_" + language, QLibraryInfo.location(QLibraryInfo.TranslationsPath)) app.installTranslator(qtTranslator) #Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() #Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() #Set Stylesheet style_applied = False if settings.NINJA_SKIN not in ('Default', 'Classic Theme'): file_name = ("%s.qss" % settings.NINJA_SKIN) qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD, file_name) if file_manager.file_exists(qss_file): with open(qss_file) as f: qss = f.read() app.setStyleSheet(qss) style_applied = True if not style_applied: if settings.NINJA_SKIN == 'Default': with open(resources.NINJA_THEME) as f: qss = f.read() else: with open(resources.NINJA_THEME_CLASSIC) as f: qss = f.read() app.setStyleSheet(qss) #Loading Schemes splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = qsettings.value('preferences/editor/scheme', "default", type='QString') if scheme != 'default': scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + '.color') if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) #Loading Shortcuts resources.load_shortcuts() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ninjaide = ide.IDE(start_server) #Showing GUI ninjaide.show() #OSX workaround for ninja window not in front try: ninjaide.raise_() except: pass # I really dont mind if this fails in any form #Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) #First check if we need to load last session files if qsettings.value('preferences/general/loadFiles', True, type=bool): #Files in Main Tab files = data_qsettings.value('lastSession/openedFiles', []) tempFiles = [] if files: for file_ in files: fileData = tuple(file_) if fileData: tempFiles.append(fileData) files = tempFiles # Recent Files recent_files = data_qsettings.value('lastSession/recentFiles', []) #Current File current_file = data_qsettings.value( 'lastSession/currentFile', '', type='QString') #Projects projects = data_qsettings.value('lastSession/projects', []) else: files = [] recent_files = [] current_file = '' projects = [] #Include files received from console args file_with_nro = list([(f[0], f[1] - 1) for f in zip(filenames, linenos)]) file_without_nro = list([(f, 0) for f in filenames[len(linenos):]]) files += file_with_nro + file_without_nro #Include projects received from console args if projects_path: projects += projects_path #FIXME: IMPROVE THIS WITH THE NEW WAY OF DO IT ninjaide.load_session_files_projects(files, projects, current_file, recent_files) #Load external plugins #if extra_plugins: #ninjaide.load_external_plugins(extra_plugins) splash.finish(ninjaide) ninjaide.notify_plugin_errors() ninjaide.show_python_detection()
print("Invalid arguments") print("Run '%s -h' for help" % (cmd)) def printHelp(cmd): print("Usage: %s [cmd]" % (cmd)) printArguments() def printVersion(): print("Cadence version %s" % (VERSION)) print("Developed by falkTX and the rest of the KXStudio Team") #--------------- main ------------------ if __name__ == '__main__': # App initialization app = QCoreApplication(sys.argv) app.setApplicationName("Cadence") app.setApplicationVersion(VERSION) app.setOrganizationName("Cadence") # Check arguments cmd = sys.argv[0] if len(app.arguments()) == 1: printHelp(cmd) elif len(app.arguments()) == 2: arg = app.arguments()[1] if arg == "--printLADSPA_PATH": printLADSPA_PATH() elif arg == "--printDSSI_PATH": printDSSI_PATH() elif arg == "--printLV2_PATH":
def get_qgis_app(): """ Start one QGIS application to test against. :returns: Handle to QGIS app, canvas, iface and parent. If there are any errors the tuple members will be returned as None. :rtype: (QgsApplication, CANVAS, IFACE, PARENT) If QGIS is already running the handle to that app will be returned. """ global QGIS_APP, PARENT, IFACE, CANVAS # pylint: disable=W0603 if iface: from qgis.core import QgsApplication QGIS_APP = QgsApplication CANVAS = iface.mapCanvas() PARENT = iface.mainWindow() IFACE = iface return QGIS_APP, CANVAS, IFACE, PARENT try: from qgis.core import QgsApplication from qgis.gui import QgsMapCanvas # pylint: disable=no-name-in-module # noinspection PyPackageRequirements from PyQt4 import QtGui, QtCore # pylint: disable=W0621 # noinspection PyPackageRequirements from PyQt4.QtCore import QCoreApplication, QSettings from safe.test.qgis_interface import QgisInterface except ImportError: return None, None, None, None if QGIS_APP is None: gui_flag = True # All test will run qgis in gui mode # AG: For testing purposes, we use our own configuration file instead # of using the QGIS apps conf of the host # noinspection PyCallByClass,PyArgumentList QCoreApplication.setOrganizationName('QGIS') # noinspection PyCallByClass,PyArgumentList QCoreApplication.setOrganizationDomain('qgis.org') # noinspection PyCallByClass,PyArgumentList QCoreApplication.setApplicationName('QGIS2InaSAFETesting') # noinspection PyPep8Naming if 'argv' in dir(sys): QGIS_APP = QgsApplication(sys.argv, gui_flag) else: QGIS_APP = QgsApplication([], gui_flag) # Make sure QGIS_PREFIX_PATH is set in your env if needed! QGIS_APP.initQgis() s = QGIS_APP.showSettings() LOGGER.debug(s) # Save some settings settings = QSettings() settings.setValue('locale/overrideFlag', True) settings.setValue('locale/userLocale', 'en_US') # We disabled message bars for now for extent selector as # we don't have a main window to show them in TS - version 3.2 settings.setValue('inasafe/show_extent_confirmations', False) settings.setValue('inasafe/show_extent_warnings', False) settings.setValue('inasafe/showRubberBands', True) settings.setValue('inasafe/analysis_extents_mode', HAZARD_EXPOSURE) if PARENT is None: # noinspection PyPep8Naming PARENT = QtGui.QWidget() if CANVAS is None: # noinspection PyPep8Naming CANVAS = QgsMapCanvas(PARENT) CANVAS.resize(QtCore.QSize(400, 400)) if IFACE is None: # QgisInterface is a stub implementation of the QGIS plugin interface # noinspection PyPep8Naming IFACE = QgisInterface(CANVAS) return QGIS_APP, CANVAS, IFACE, PARENT
def testSmewtDaemon(self): # we need to remove traces of previous test runs, even though we're supposed to have cleaned it after the test, # a previous run of the test that failed might not have done that os.system('rm -fr ~/.config/Falafelton_tmp') os.system('rm -fr /tmp/smewt_test_daemon') import smewt orgname = smewt.ORG_NAME appname = smewt.APP_NAME smewt.ORG_NAME = 'Falafelton_tmp' smewt.APP_NAME = 'Smewt_tmp' from PyQt4.QtCore import QCoreApplication app = QCoreApplication([]) app.setOrganizationName(smewt.ORG_NAME) app.setOrganizationDomain('smewt.com') app.setApplicationName(smewt.APP_NAME) smewtd = SmewtDaemon() # create fake database cmds = '''mkdir -p /tmp/smewt_test_daemon/Monk touch /tmp/smewt_test_daemon/Monk/Monk.2x05.Mr.Monk.And.The.Very,.Very.Old.Man.DVDRip.XviD-MEDiEVAL.[tvu.org.ru].avi touch /tmp/smewt_test_daemon/Monk/Monk.2x05.Mr.Monk.And.The.Very,.Very.Old.Man.DVDRip.XviD-MEDiEVAL.[tvu.org.ru].English.srt ''' for cmd in cmds.split('\n'): os.system(cmd.strip()) smewtd.episodeCollection.folders = { '/tmp/smewt_test_daemon': True } # make sure we don't have a residual collection from previous test runs self.assertEqual(len(list(smewtd.database.nodes())), 0) # initial import of the collection smewtd.episodeCollection.rescan() smewtd.taskManager.queue.join() # wait for all import tasks to finish #smewtd.database.display_graph() self.collectionTestIncomplete(smewtd.database) # update collection, as we haven't changed anything it should be the same smewtd.episodeCollection.update() smewtd.taskManager.queue.join() # wait for all import tasks to finish #smewtd.database.display_graph() self.collectionTestIncomplete(smewtd.database) # fully rescan collection, should still be the same smewtd.episodeCollection.rescan() smewtd.taskManager.queue.join() # wait for all import tasks to finish #smewtd.database.display_graph() self.collectionTestIncomplete(smewtd.database) # add some more files cmds = '''mkdir -p /tmp/smewt_test_daemon/Monk touch /tmp/smewt_test_daemon/Monk/Monk.2x06.Mr.Monk.Goes.To.The.Theater.DVDRip.XviD-MEDiEVAL.[tvu.org.ru].avi touch /tmp/smewt_test_daemon/Monk/Monk.2x06.Mr.Monk.Goes.To.The.Theater.DVDRip.XviD-MEDiEVAL.[tvu.org.ru].English.srt ''' for cmd in cmds.split('\n'): os.system(cmd.strip()) # update collection smewtd.episodeCollection.update() smewtd.taskManager.queue.join() # wait for all import tasks to finish #smewtd.database.display_graph() self.collectionTest(smewtd.database) # clean up our mess before we exit os.system('rm -fr ~/.config/Falafelton_tmp') os.system('rm -fr /tmp/smewt_test_daemon') smewt.ORG_NAME = orgname smewt.APP_NAME = appname
self.verticalLayout.addWidget(self.nameLabel) self.versionLabel = QLabel(self) self.versionLabel.setText(tr("Version {}").format(QCoreApplication.instance().applicationVersion())) self.verticalLayout.addWidget(self.versionLabel) self.label_3 = QLabel(self) self.verticalLayout.addWidget(self.label_3) self.label_3.setText(tr("Copyright Hardcoded Software 2014")) self.label = QLabel(self) font = QFont() font.setWeight(75) font.setBold(True) self.label.setFont(font) self.verticalLayout.addWidget(self.label) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Ok) self.verticalLayout.addWidget(self.buttonBox) self.horizontalLayout.addLayout(self.verticalLayout) if __name__ == '__main__': import sys app = QApplication([]) QCoreApplication.setOrganizationName('Hardcoded Software') QCoreApplication.setApplicationName('FooApp') QCoreApplication.setApplicationVersion('1.2.3') app.LOGO_NAME = '' dialog = AboutBox(None, app) dialog.show() sys.exit(app.exec_())
def get_qgis_app(): """ Start one QGIS application to test against. :returns: Handle to QGIS app, canvas, iface and parent. If there are any errors the tuple members will be returned as None. :rtype: (QgsApplication, CANVAS, IFload_standard_layersACE, PARENT) If QGIS is already running the handle to that app will be returned. """ try: from qgis.core import QgsApplication from qgis.gui import QgsMapCanvas # pylint: disable=no-name-in-module # noinspection PyPackageRequirements from PyQt4 import QtGui, QtCore # pylint: disable=W0621 # noinspection PyPackageRequirements from PyQt4.QtCore import QCoreApplication, QSettings from qgis.gui import QgisInterface except ImportError: return None, None, None, None global QGIS_APP # pylint: disable=W0603 if QGIS_APP is None: gui_flag = True # All test will run qgis in gui mode # AG: For testing purposes, we use our own configuration file instead # of using the QGIS apps conf of the host # noinspection PyCallByClass,PyArgumentList QCoreApplication.setOrganizationName('QGIS') # noinspection PyCallByClass,PyArgumentList QCoreApplication.setOrganizationDomain('qgis.org') # noinspection PyCallByClass,PyArgumentList QCoreApplication.setApplicationName('IsochronesTesting') # noinspection PyPep8Naming QGIS_APP = QgsApplication(sys.argv, gui_flag) # Make sure QGIS_PREFIX_PATH is set in your env if needed! QGIS_APP.initQgis() s = QGIS_APP.showSettings() # Save some settings settings = QSettings() settings.setValue('locale/overrideFlag', True) settings.setValue('locale/userLocale', 'en_US') # We disabled message bars for now for extent selector as # we don't have a main window to show them in TS - version 3.2 global PARENT # pylint: disable=W0603 if PARENT is None: # noinspection PyPep8Naming PARENT = QtGui.QWidget() global CANVAS # pylint: disable=W0603 if CANVAS is None: # noinspection PyPep8Naming CANVAS = QgsMapCanvas(PARENT) CANVAS.resize(QtCore.QSize(400, 400)) global IFACE # pylint: disable=W0603 if IFACE is None: # QgisInterface is a stub implementation of the QGIS plugin interface # noinspection PyPep8Naming IFACE = QgisInterface(CANVAS) return QGIS_APP, CANVAS, IFACE, PARENT
def start(filenames=None, projects_path=None, extra_plugins=None, linenos=None): app = QApplication(sys.argv) QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('NINJA-IDE') QCoreApplication.setApplicationName('NINJA-IDE') app.setWindowIcon(QIcon(resources.IMAGES['icon'])) # Check if there is another session of ninja-ide opened # and in that case send the filenames and projects to that session running = ipc.is_running() start_server = not running[0] if running[0] and (filenames or projects_path): sended = ipc.send_data(running[1], filenames, projects_path, linenos) running[1].close() if sended: sys.exit() else: running[1].close() # Create and display the splash screen splash_pix = QPixmap(resources.IMAGES['splash']) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking global cursor_flash_time cursor_flash_time = app.cursorFlashTime() app.setCursorFlashTime(0) #Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Translator qsettings = QSettings() language = QLocale.system().name() lang = qsettings.value('preferences/interface/language', language) + '.qm' lang_path = file_manager.create_path(resources.LANGS, lang) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path elif file_manager.file_exists( file_manager.create_path(resources.LANGS_DOWNLOAD, lang)): settings.LANGUAGE = file_manager.create_path(resources.LANGS_DOWNLOAD, lang) translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) #Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() #Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() #Set Stylesheet style_applied = False if settings.NINJA_SKIN not in ('Default', 'Classic Theme'): file_name = ("%s.qss" % settings.NINJA_SKIN) qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD, file_name) if file_manager.file_exists(qss_file): with open(qss_file) as f: qss = f.read() app.setStyleSheet(qss) style_applied = True if not style_applied: if settings.NINJA_SKIN == 'Default': with open(resources.NINJA_THEME) as f: qss = f.read() else: with open(resources.NINJA__THEME_CLASSIC) as f: qss = f.read() app.setStyleSheet(qss) #Loading Schemes splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = qsettings.value('preferences/editor/scheme', "default") if scheme != 'default': scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + '.color') if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) #Loading Shortcuts resources.load_shortcuts() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ide = IDE(start_server) #Showing GUI ide.show() #Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) #Files in Main Tab main_files = qsettings.value('openFiles/mainTab', []) if main_files is not None: mainFiles = list(main_files) else: mainFiles = list() tempFiles = [] for file_ in mainFiles: fileData = list(file_) tempFiles.append((fileData[0], int(fileData[1]))) mainFiles = tempFiles #Files in Secondary Tab sec_files = qsettings.value('openFiles/secondaryTab', []) if sec_files is not None: secondaryFiles = list(sec_files) else: secondaryFiles = list() tempFiles = [] for file_ in secondaryFiles: fileData = list(file_) tempFiles.append((fileData[0], int(fileData[1]))) secondaryFiles = tempFiles # Recent Files recent = qsettings.value('openFiles/recentFiles', []) if recent is not None: recent_files = list(recent) else: recent_files = list() recent_files = [file_ for file_ in recent_files] #Current File current_file = qsettings.value('openFiles/currentFile', '') #Projects projects_list = qsettings.value('openFiles/projects', []) if projects_list is not None: projects = list(projects_list) else: projects = list() projects = [project for project in projects] #Include files received from console args file_with_nro = list( map(lambda f: (f[0], f[1] - 1), zip(filenames, linenos))) file_without_nro = list(map(lambda f: (f, 0), filenames[len(linenos):])) mainFiles += file_with_nro + file_without_nro #Include projects received from console args if projects_path: projects += projects_path ide.load_session_files_projects(mainFiles, secondaryFiles, projects, current_file, recent_files) #Load external plugins if extra_plugins: ide.load_external_plugins(extra_plugins) splash.finish(ide) ide.notify_plugin_errors() sys.exit(app.exec_())
from PyQt4.QtGui import QApplication, QIcon, QPixmap import mg_rc from hscommon.trans import install_qt_trans from app import MusicGuru if sys.platform == 'win32': # cx_Freeze workarounds import hsfs.tree import os os.environ['QT_PLUGIN_PATH'] = 'qt4_plugins' if __name__ == "__main__": app = QApplication(sys.argv) app.setWindowIcon(QIcon(QPixmap(":/mg_logo"))) QCoreApplication.setOrganizationName('Hardcoded Software') QCoreApplication.setApplicationName('musicGuru') QCoreApplication.setApplicationVersion(MusicGuru.VERSION) install_qt_trans('en') mgapp = MusicGuru() exec_result = app.exec_() del mgapp # Since PyQt 4.7.2, I had crashes on exit, and from reading the mailing list, it seems to be # caused by some weird crap about C++ instance being deleted with python instance still living. # The worst part is that Phil seems to say this is expected behavior. So, whatever, this # gc.collect() below is required to avoid a crash. gc.collect() del app sys.exit(exec_result)