def main(): """ Starts the Main Window Interface """ app = QApplication(sys.argv) app.setWindowIcon(QIcon(os.path.join(RESOURCE_PATH, "manager.ico"))) start = time.time() # Start timer for splash screen splashImage = os.path.join(RESOURCE_PATH, "splash.jpg") # Define splash image pixmap = QPixmap(splashImage) # Create a pixmap object splash = QSplashScreen(pixmap) # Create a splash screen object # This "splash.setMask()" is usefull if the splashscreen is not a regular # ractangle. This is also the reason we created a separate object of type # pixmap. # splash.setMask(pixmap.mask()) # Accomodate odd shapes splash.show() # Show splash screen splash.showMessage((u'%s, Version %s Starting...' %(ME, VERSION)), Qt.AlignLeft | Qt.AlignBottom, Qt.black) # make sure Qt really display the splash screen while time.time() - start < 3: # \ time.sleep(0.001) # > Timer for splash screen. app.processEvents() # / mainWin = MainWindow() # Create object of type "MainWindow" splash.finish(mainWin) # kill the splashscreen mainWin.setGeometry(100, 100, 1000, 700) # Initial window position and size mainWin.setWindowTitle(ME) # Initial Window title mainWin.show() # Abracadabra "POOF!" sys.exit(app.exec_()) # Handles all clean exits
def main(argv=None): '''Entry point if executing as standalone''' if argv is None: argv = sys.argv app = QApplication(argv) app.processEvents() pixmap = QPixmap(os.path.abspath(os.path.join("res", "CLEED_logo.png"))) splash = QSplashScreen(pixmap, QtCore.Qt.WindowStaysOnTopHint) splash.setMask(pixmap.mask()) # this is useful if splash isn't a rectangle splash.showMessage((u'Starting %s...' % __APP_NAME__), QtCore.Qt.AlignRight | QtCore.Qt.AlignBottom, QtCore.Qt.yellow) splash.show() # make sure Qt really display the splash screen app.processEvents() app.setQuitOnLastWindowClosed(False) window = MainWindow() if not QtGui.QSystemTrayIcon.isSystemTrayAvailable(): window.logger.warning("Unable to create a Systray on this system") # now kill the splash screen splash.finish(window) splash.close() window.show() sys.exit(app.exec_())
def start(): app = QApplication(sys.argv) # 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() ide = IDE() #Settings settings = QSettings('NINJA-IDE', 'Kunai') if (settings.value('Preferences/General/activate_plugins', 2) == 2): set_plugin_access(ide) core.load_plugins(ide) ide.show() for projectFolder in settings.value('Open_Files/projects', []).toStringList(): ide.main.open_project_folder(str(projectFolder)) for openFile in settings.value('Open_Files/tab1', []).toStringList(): ide.main.open_document(str(openFile)) for openFile2 in settings.value('Open_Files/tab2', []).toStringList(): ide.main.split_tab(True) ide.main.open_document(str(openFile2)) splash.finish(ide) sys.exit(app.exec_())
def showSplashScreen(): splash_path = os.path.join(os.path.split(ilastik.__file__)[0], 'ilastik-splash.png') splashImage = QPixmap(splash_path) global splashScreen splashScreen = QSplashScreen(splashImage) splashScreen.showMessage( ilastik.__version__, Qt.AlignBottom | Qt.AlignRight ) splashScreen.show()
class SplashScreen: def __init__(self, image_resource=":/images/splash_wait.png", text=None): pixmap = QPixmap(image_resource) self.splash = QSplashScreen(pixmap) self.splash.setMask(QRegion(pixmap.mask())); self.splash.setPixmap(pixmap); flags = self.splash.windowFlags() flags |= Qt.WindowStaysOnTopHint self.splash.setWindowFlags(flags) self._text = None if text is not None: self.setText(text) def show(self): self.splash.show() def hide(self): self.splash.hide() def setText(self, text): self._text = text self.splash.showMessage(text, Qt.AlignBottom | Qt.AlignHCenter); def getText(self): return self._text
def main(): print 'Starting Central Access Reader...' import sys import os from PyQt4.QtGui import QApplication, QPixmap, QSplashScreen app = QApplication(sys.argv) # Create a splash screen from forms import resource_rc pixmap = QPixmap(':/icons/icons/CAR Splash.png') splash = QSplashScreen(pixmap) splash.show() app.processEvents() # Check to see if my folders in my paths exist. If they don't, make them from misc import program_path, app_data_path, temp_path if not os.path.exists(os.path.dirname(program_path('test.txt'))): os.makedirs(os.path.dirname(program_path('test.txt'))) if not os.path.exists(os.path.dirname(app_data_path('test.txt'))): os.makedirs(os.path.dirname(app_data_path('test.txt'))) if not os.path.exists(os.path.dirname(temp_path('test.txt'))): os.makedirs(os.path.dirname(temp_path('test.txt'))) from gui.main_window import MainWindow window = MainWindow(app) window.show() splash.finish(window) sys.exit(app.exec_())
def launchShell(workflowClass, testFunc = None, windowTitle="ilastikShell", workflowKwargs=None): """ Start the ilastik shell GUI with the given workflow type. Note: A QApplication must already exist, and you must call this function from its event loop. workflowClass - the type of workflow to instantiate for the shell. """ if workflowKwargs is None: workflowKwargs = dict() # Splash Screen splashImage = QPixmap("../ilastik-splash.png") splashScreen = QSplashScreen(splashImage) splashScreen.show() # Create workflow workflow = workflowClass(**workflowKwargs) # Create the shell and populate it shell = IlastikShell(workflow=workflow, sideSplitterSizePolicy=SideSplitterSizePolicy.Manual) shell.setWindowTitle(windowTitle) shell.setImageNameListSlot( workflow.imageNameListSlot ) # Start the shell GUI. shell.show() # Hide the splash screen splashScreen.finish(shell) # Run a test (if given) if testFunc: QTimer.singleShot(0, functools.partial(testFunc, shell, workflow) )
def showSplashScreen(): splash_path = os.path.join( os.path.split(ilastik.__file__)[0], 'ilastik-splash.png') splashImage = QPixmap(splash_path) global splashScreen splashScreen = QSplashScreen(splashImage) splashScreen.show()
def show_splash(): """Show the splash screen""" splashImage = QPixmap( "images/splash.png" ) splashScreen = QSplashScreen( splashImage ) splashScreen.showMessage( "Loading . . . " ) splashScreen.show() return splashScreen
def show(): message = "{0} {1} ".format(appinfo.appname, appinfo.version) pixmap = QPixmap(os.path.join(__path__[0], 'splash.png')) if QApplication.desktop().screenGeometry().height() < 640: fontsize = 23 pixmap = pixmap.scaledToHeight(240, Qt.SmoothTransformation) else: fontsize = 40 splash = QSplashScreen(pixmap, Qt.SplashScreen) font = splash.font() font.setPixelSize(fontsize) font.setWeight(QFont.Bold) splash.setFont(font) splash.showMessage(message, Qt.AlignRight | Qt.AlignTop, Qt.white) splash.show() splash.repaint() def hide(): splash.deleteLater() app.appStarted.disconnect(hide) app.appStarted.connect(hide)
def show_splash(): """Show the splash screen""" splashImage = QPixmap("images/splash.png") splashScreen = QSplashScreen(splashImage) splashScreen.showMessage("Loading . . . ") splashScreen.show() return splashScreen
def start(): app = QApplication(sys.argv) # 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() ide = IDE() #Settings settings = QSettings('NINJA-IDE','Kunai') if (settings.value('Preferences/General/activate_plugins', 2)==2): set_plugin_access(ide) core.load_plugins(ide) ide.show() for projectFolder in settings.value('Open_Files/projects',[]).toStringList(): ide.main.open_project_folder(str(projectFolder)) for openFile in settings.value('Open_Files/tab1', []).toStringList(): ide.main.open_document(str(openFile)) for openFile2 in settings.value('Open_Files/tab2', []).toStringList(): ide.main.split_tab(True) ide.main.open_document(str(openFile2)) splash.finish(ide) sys.exit(app.exec_())
def main(): app = QApplication(sys.argv) # Show SplashScreen splash_pixmap = QPixmap(':/cover.png') splash_screen = QSplashScreen(splash_pixmap, Qt.WindowStaysOnTopHint) splash_screen.show() app.processEvents() # Runtime imports import Valves_Main import time app.processEvents() app.setOrganizationName('Gatituz PK') app.setOrganizationDomain('http://gatituzmes-server.duckdns.org/') app.setApplicationName('VAL 518') app.processEvents() window = Valves_Main.MainWindowStart() app.setWindowIcon(QIcon(":/logo.png")) app.processEvents() app.processEvents() time.sleep(2) app.processEvents() time.sleep(1) app.processEvents() time.sleep(1) window.showMaximized() splash_screen.close() # Execute app app.exec_()
def launchShell(workflowClass=None, *testFuncs): """ Start the ilastik shell GUI with the given workflow type. Note: A QApplication must already exist, and you must call this function from its event loop. workflowClass - the type of workflow to instantiate for the shell. """ # Splash Screen splashImage = QPixmap("../ilastik-splash.png") splashScreen = QSplashScreen(splashImage) splashScreen.show() # Create the shell and populate it global shell shell = IlastikShell(workflowClass=workflowClass, sideSplitterSizePolicy=SideSplitterSizePolicy.Manual) assert QApplication.instance().thread() == shell.thread() # Start the shell GUI. shell.show() # Hide the splash screen splashScreen.finish(shell) # Run a test (if given) for testFunc in testFuncs: QTimer.singleShot(0, functools.partial(testFunc, shell))
def splash(path): u"Create and display the splash screen. Credits: Eli Bendersky ([email protected])" splash_pix = QPixmap(path) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) ##splash.setAttribute(Qt.WA_TranslucentBackground) # XXX: Doesn't work currently: https://bugreports.qt.nokia.com//browse/QTBUG-12820 # See also http://developer.qt.nokia.com/wiki/QSplashScreen_replacement_for_semitransparent_images splash.show() return splash
def main(): splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # app.setStyle('Plastique') frame = MainWindow() frame.showMaximized() splash.finish(frame) frame.init() app.exec_()
def main(): from guidata import qapplication app = qapplication() splash = QSplashScreen(QPixmap('test/splash.png')) splash.show() app.processEvents() win = MainWindow() win.show() splash.finish(win) gl.progressManager.startNewProgress('Loading Modules', progressTest, [0, 0, 0]) app.exec()
def get_splash(): """Instantiate a splash screen""" from PyQt4.QtGui import QSplashScreen, QPixmap from PyQt4.QtCore import Qt import os pth = os.path.join(os.path.dirname(__file__), 'logo.png') pm = QPixmap(pth) splash = QSplashScreen(pm, Qt.WindowStaysOnTopHint) splash.show() return splash
def main(): app = QApplication(sys.argv) start = time() splash = QSplashScreen(QPixmap("images/login.png")) splash.show() while time() - start < 1: sleep(0.001) app.processEvents() win = MainWindow() splash.finish(win) win.show() app.exec_()
class QtUserInterface(): """ Class for Qt User Interface .. versionadded:: 0.9 """ def __init__(self, application): """ Default constructor """ super().__init__() self.application = application self.splash_screen = None self.qt_app = QApplication([]) self.qt_app.setOverrideCursor(QCursor(Qt.BlankCursor)) def show_splash_screen(self): """ Show splash screen """ file = QFile(':herculeum.qss') file.open(QFile.ReadOnly) styleSheet = str(file.readAll().data(), 'ascii') self.qt_app.setStyleSheet(styleSheet) pixmap = QPixmap(':splash.png') self.splash_screen = QSplashScreen(pixmap) self.splash_screen.show() def show_main_window(self): """ Show main window """ main_window = MainWindow(self.application, self.application.surface_manager, self.qt_app, None, Qt.FramelessWindowHint, StartGameController(self.application.level_generator_factory, self.application.creature_generator, self.application.item_generator, self.application.config.start_level)) self.splash_screen.finish(main_window) main_window.show_new_game() self.qt_app.exec_()
def main(): app = QtGui.QApplication(sys.argv) splash_pix = QPixmap(':/splash/3dlp_slicer_splash.png') splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() window = Main() window.show() splash.finish(window) # It's exec_ because exec is a reserved word in Python sys.exit(app.exec_())
class QtUserInterface(): """ Class for Qt User Interface .. versionadded:: 0.9 """ def __init__(self, application): """ Default constructor """ super().__init__() self.application = application self.splash_screen = None self.qt_app = QApplication([]) # self.qt_app.setOverrideCursor(QCursor(Qt.BlankCursor)) def show_splash_screen(self): """ Show splash screen """ file = QFile(':herculeum.qss') file.open(QFile.ReadOnly) styleSheet = str(file.readAll().data(), 'ascii') self.qt_app.setStyleSheet(styleSheet) pixmap = QPixmap(':splash.png') self.splash_screen = QSplashScreen(pixmap) self.splash_screen.show() def show_main_window(self): """ Show main window """ main_window = MainWindow( self.application, self.application.surface_manager, self.qt_app, None, Qt.FramelessWindowHint, StartGameController(self.application.level_generator_factory, self.application.creature_generator, self.application.item_generator, self.application.config.start_level)) self.splash_screen.finish(main_window) main_window.show_new_game() self.qt_app.exec_()
def _run(argv=[]): app = QApplication(argv) splash = QSplashScreen(QPixmap(u':/General/logo_refl_hq.png')) splash.showMessage(u"""<html> <div style="margin-bottom: 420;"> </div> <div style="font-size: 12pt; margin-bottom: 15;"> <b>RefRed</b> Version %s </div> <div>Starting up...</div> </html>""" % version.str_version, alignment=Qt.AlignBottom | Qt.AlignHCenter) splash.show() QApplication.processEvents() window = MainGui(argv) window.show() splash.finish(window) return app.exec_()
def main(): """ Main runtine to run software. """ workpath = os.path.dirname(os.path.join(os.getcwd(), __file__)) # print workpath workpath = workpath.split("\\") workpath.append("icon") iconDir = "\\".join(workpath) # print iconDir app = QApplication(sys.argv) splash = QSplashScreen(QPixmap(os.path.join(iconDir, "tm.png"))) splash.show() app.processEvents() sleep(1) TMWindows = TMMainWidget() splash.finish(TMWindows) sys.exit(app.exec_())
class gui(): def __init__(self): """Launch GUI""" #translator = DFF_Translator() self.app = QApplication(sys.argv) #app.installTranslator(translator) pixmap = QPixmap(":splash.png") self.splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint) self.splash.setMask(pixmap.mask()) def launch(self, modPath): self.splash.show() self.loader = loader() self.loader.do_load(modPath, self.splash.showMessage) mainWindow = DFF_MainWindow(self.app) mainWindow.show() self.splash.finish(mainWindow) sys.exit(self.app.exec_())
def start_eas(host, client, app): multisite_client = MultisiteClient(host, client) # Add splash screen pixmap = QPixmap(":/images/splash_start.png") splash = QSplashScreen(pixmap) splash.setMask(QRegion(pixmap.mask())) splash.setPixmap(pixmap) splash.show() app.splash = splash splash.showMessage(tr("Loading application"), Qt.AlignBottom | Qt.AlignRight) app.processEvents() # Load the main window from console_edenwall import MainWindow window = MainWindow(app, multisite_client) window.show() splash.finish(window)
def run_pygobstones(): app = QtGui.QApplication(sys.argv) #Get the locale settings locale = str(QtCore.QLocale.system().name()) # This is to make Qt use locale configuration; i.e. Standard Buttons # in your system's language. qtTranslator = QtCore.QTranslator() qtTranslator.load( "qt_" + locale, QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)) app.installTranslator(qtTranslator) path = os.path.join(root_path(), 'commons') f = QtGui.QFontDatabase.addApplicationFont(os.path.join( path, 'ubuntu.ttf')) font = QtGui.QFont('Ubuntu Titling') font.setBold(True) font.setPixelSize(16) app.setFont(font) start = time() if 'huayra' in platform.uname(): img = QPixmap(os.path.join(path, 'gobstones_huayra.png')) else: img = QPixmap(os.path.join(path, 'gobstones.png')) splash = QSplashScreen(img) splash.show() while time() - start < 1: app.processEvents() w = MainWindow() icon = QtGui.QIcon(os.path.join(path, 'logo.png')) w.setWindowIcon(icon) splash.finish(w) w.showMaximized() sys.exit(app.exec_())
def run_pygobstones(): app = QtGui.QApplication(sys.argv) #Get the locale settings locale = unicode(QtCore.QLocale.system().name()) # This is to make Qt use locale configuration; i.e. Standard Buttons # in your system's language. qtTranslator=QtCore.QTranslator() qtTranslator.load("qt_" + locale, QtCore.QLibraryInfo.location( QtCore.QLibraryInfo.TranslationsPath) ) app.installTranslator(qtTranslator) path = os.path.join(root_path(), 'commons') f = QtGui.QFontDatabase.addApplicationFont(os.path.join(path, 'ubuntu.ttf')) font = QtGui.QFont('Ubuntu Titling') font.setBold(True) font.setPixelSize(16) app.setFont(font) start = time() if 'huayra' in platform.uname(): img = QPixmap(os.path.join(path, 'gobstones_huayra.png')) else: img = QPixmap(os.path.join(path, 'gobstones.png')) splash = QSplashScreen(img) splash.show() while time() - start < 1: app.processEvents() w = MainWindow() icon = QtGui.QIcon(os.path.join(path, 'logo.png')) w.setWindowIcon(icon) splash.finish(w) w.showMaximized() sys.exit(app.exec_())
class SplashScreen(object): """Displays a splash screen until the main window is ready""" def __init__(self): splash_pix = QPixmap(':/splash.png') self.splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) self.splash.setMask(splash_pix.mask()) def show(self): """Displays the splash screen""" self.splash.show() self.splash.showMessage('Loading...', Qt.AlignBottom | Qt.AlignHCenter, Qt.white) # ensure at least its visible one second time.sleep(1) def finish(self, window): """Hides and destroy the splash screen, ensure the """ self.splash.finish(window)
def show(): message = "{0} {1} ".format(info.appname, info.version) pixmap = QPixmap(os.path.join(__path__[0], 'splash.png')) if QApplication.desktop().screenGeometry().height() < 640: fontsize = 23 pixmap = pixmap.scaledToHeight(240, Qt.SmoothTransformation) else: fontsize = 40 splash = QSplashScreen(pixmap, Qt.SplashScreen | Qt.WindowStaysOnTopHint) font = splash.font() font.setPixelSize(fontsize) font.setWeight(QFont.Bold) splash.setFont(font) splash.showMessage(message, Qt.AlignRight | Qt.AlignTop, Qt.white) splash.show() app.qApp.processEvents() splash.deleteLater()
def main(argv): """The main function.""" wavy = QApplication(argv) wavy.setStyle('Cleanlooks') wavy.setApplicationVersion(__version__) wavy.setApplicationName(__app_name__) wavy.setOrganizationName("Sao Carlos Institute of Physics - University of Sao Paulo") wavy.setOrganizationDomain("www.ifsc.usp.br") pixmap = QPixmap("images/symbol.png") splash = QSplashScreen(pixmap) splash.show() splash.repaint() splash.showMessage("Loading...") wavy.processEvents() splash.showMessage("Starting...") wavy.processEvents() window = MainWindow() window.showMaximized() time.sleep(0) splash.finish(window) return wavy.exec_()
def launchShell(workflowClass, testFunc=None, windowTitle="ilastikShell", workflowKwargs=None): """ Start the ilastik shell GUI with the given workflow type. Note: A QApplication must already exist, and you must call this function from its event loop. workflowClass - the type of workflow to instantiate for the shell. """ if workflowKwargs is None: workflowKwargs = dict() # Splash Screen splashImage = QPixmap("../ilastik-splash.png") splashScreen = QSplashScreen(splashImage) splashScreen.show() # Create workflow workflow = workflowClass(**workflowKwargs) # Create the shell and populate it shell = IlastikShell(sideSplitterSizePolicy=SideSplitterSizePolicy.Manual) shell.setWindowTitle(windowTitle) for app in workflow.applets: shell.addApplet(app) shell.setImageNameListSlot(workflow.imageNameListSlot) # Start the shell GUI. shell.show() # Hide the splash screen splashScreen.finish(shell) # Run a test (if given) if testFunc: QTimer.singleShot(0, functools.partial(testFunc, shell, workflow))
def main(args): App = QApplication(args) splash = QSplashScreen(QPixmap("./view/winView/imgs/splash.png")) splash.show() # 启动动画 App.processEvents() QTextCodec.setCodecForCStrings(QTextCodec.codecForName("UTF-8")) initProperty() # 初始化 app.Music.play() # 开机音乐 app.MainWin.show() # 主窗口显示 splash.finish(app.MainWin) createTray() # 创建托盘 # 调试状态不连线上接服务器 if app.Debug: host = '114.215.209.164' # host = 'localhost' thread = Worker(None, host, 1234, app.AppUser, app.MainWin) # 子进程 thread.start() server = Server(None) # 子进程 server.start() # else: # # 打开工具箱 # app._tool_.show() App.exec_()
def showSplash(app): # splash pixmap logo = QPixmap(RES + ICONS + SPLASH) splash = QSplashScreen(logo, Qt.WindowStaysOnTopHint) splash.setWindowFlags(Qt.WindowStaysOnTopHint) # alpha mask splash.show() splash.setMask(logo.mask()) # status message labelAlignment = Qt.Alignment(Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute) newline = '<br/>' family = FONTS_DICT['splash'][0] size = str(FONTS_DICT['splash'][2]) font = "<font style='font-family: " + family + "; font-size: " + size + "pt; color: white;'>" info = newline * 10 + font + 'Loading...<br/>' + __name__ + ' ' + __version__ + '</font' splash.showMessage(info, labelAlignment) #NB: html tags completely break alignment and color settings # checking for mouse click app.processEvents() return splash
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()
class MainWindow(QMainWindow): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.dirty = False self.isLoaded = False self.calibration_enabled = False self.aggregate_enabled = False self.setObjectName("MainWindow") self.resize(800, 600) self.setWindowTitle("OpenFisca") app_icon = get_icon('OpenFisca22.png') self.setWindowIcon(app_icon) self.setLocale(QLocale(QLocale.French, QLocale.France)) self.setDockOptions(QMainWindow.AllowNestedDocks | QMainWindow.AllowTabbedDocks | QMainWindow.AnimatedDocks) self.centralwidget = QWidget(self) self.gridLayout = QGridLayout(self.centralwidget) self.setCentralWidget(self.centralwidget) self.centralwidget.hide() self.statusbar = QStatusBar(self) self.statusbar.setObjectName("statusbar") self.setStatusBar(self.statusbar) # Showing splash screen pixmap = QPixmap(':/images/splash.png', 'png') self.splash = QSplashScreen(pixmap) font = self.splash.font() font.setPixelSize(10) self.splash.setFont(font) self.splash.show() self.splash.showMessage( "Initialisation...", Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.black)) # if CONF.get('main', 'current_version', '') != __version__: # CONF.set('main', 'current_version', __version__) # Execute here the actions to be performed only once after # each update (there is nothing there for now, but it could # be useful some day... self.scenario = Scenario() # Preferences self.general_prefs = [SimConfigPage, PathConfigPage, CalConfigPage] self.oldXAXIS = 'sal' self.reforme = False self.apply_settings() # Dockwidgets creation self.splash.showMessage( "Creating widgets...", Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.black)) self.create_dockwidgets() self.populate_mainwidow() ################################################################# ## Menu initialization ################################################################# self.splash.showMessage( "Creating menubar...", Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.black)) # Menu Fichier self.file_menu = self.menuBar().addMenu("Fichier") action_export_png = create_action(self, 'Exporter le graphique', icon='document-save png.png', triggered=self._graph.save_figure) action_export_csv = create_action(self, 'Exporter la table', icon='document-save csv.png', triggered=self._table.saveCsv) action_pref = create_action(self, u'Préférences', QKeySequence.Preferences, icon='preferences-desktop.png', triggered=self.edit_preferences) action_quit = create_action(self, 'Quitter', QKeySequence.Quit, icon='process-stop.png', triggered=SLOT('close()')) file_actions = [ action_export_png, action_export_csv, None, action_pref, None, action_quit ] add_actions(self.file_menu, file_actions) # Menu Edit self.edit_menu = self.menuBar().addMenu(u"Édition") action_copy = create_action(self, 'Copier', QKeySequence.Copy, triggered=self.global_callback, data='copy') edit_actions = [None, action_copy] add_actions(self.edit_menu, edit_actions) # Menu Simulation self.simulation_menu = self.menuBar().addMenu(u"Simulation") self.action_refresh_bareme = create_action( self, u'Calculer barèmes', shortcut='F9', icon='calculator_green.png', triggered=self.refresh_bareme) self.action_refresh_aggregate = create_action( self, u'Calculer aggrégats', shortcut='F10', icon='calculator_blue.png', triggered=self.refresh_aggregate) self.action_calibrate = create_action(self, u'Caler les poids', shortcut='CTRL+K', icon='scale22.png', triggered=self.calibrate) action_bareme = create_action(self, u'Barème', icon='bareme22.png', toggled=self.modeBareme) action_cas_type = create_action(self, u'Cas type', icon='castype22.png', toggled=self.modeCasType) action_mode_reforme = create_action( self, u'Réforme', icon='comparison22.png', toggled=self.modeReforme, tip= u"Différence entre la situation simulée et la situation actuelle") mode_group = QActionGroup(self) mode_group.addAction(action_bareme) mode_group.addAction(action_cas_type) self.mode = 'bareme' action_bareme.trigger() simulation_actions = [ self.action_refresh_bareme, self.action_refresh_aggregate, None, self.action_calibrate, None, action_bareme, action_cas_type, None, action_mode_reforme ] add_actions(self.simulation_menu, simulation_actions) # Menu Help help_menu = self.menuBar().addMenu("&Aide") action_about = create_action(self, u"&About OpenFisca", triggered=self.helpAbout) action_help = create_action(self, "&Aide", QKeySequence.HelpContents, triggered=self.helpHelp) help_actions = [action_about, action_help] add_actions(help_menu, help_actions) # Display Menu view_menu = self.createPopupMenu() view_menu.setTitle("&Affichage") self.menuBar().insertMenu(help_menu.menuAction(), view_menu) # Toolbar self.main_toolbar = self.create_toolbar(u"Barre d'outil", 'main_toolbar') toolbar_actions = [ action_export_png, action_export_csv, None, self.action_refresh_bareme, self.action_refresh_aggregate, None, self.action_calibrate, None, action_bareme, action_cas_type, None, action_mode_reforme ] add_actions(self.main_toolbar, toolbar_actions) self.connect(self._menage, SIGNAL('changed()'), self.changed_bareme) self.connect(self._parametres, SIGNAL('changed()'), self.changed_param) self.connect(self._aggregate_output, SIGNAL('calculated()'), self.calculated) self.connect(self, SIGNAL('weights_changed()'), self.refresh_aggregate) self.connect(self, SIGNAL('bareme_only()'), self.switch_bareme_only) # Window settings self.splash.showMessage( "Restoring settings...", Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.black)) settings = QSettings() size = settings.value('MainWindow/Size', QVariant(QSize(800, 600))).toSize() self.resize(size) position = settings.value('MainWindow/Position', QVariant(QPoint(0, 0))).toPoint() self.move(position) self.restoreState(settings.value("MainWindow/State").toByteArray()) self.splash.showMessage( "Loading survey data...", Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.black)) self.enable_aggregate(True) self.refresh_bareme() self.isLoaded = True self.splash.hide() def create_toolbar(self, title, object_name, iconsize=24): toolbar = self.addToolBar(title) toolbar.setObjectName(object_name) toolbar.setIconSize(QSize(iconsize, iconsize)) return toolbar def create_dockwidgets(self): # Création des dockwidgets self._parametres = ParamWidget('data/param.xml', self) self._menage = ScenarioWidget(self.scenario, self) self._graph = Graph(self) self._table = OutTable(self) self._aggregate_output = AggregateOutputWidget(self) self._dataframe_widget = ExploreDataWidget(self) def populate_mainwidow(self): ''' Creates all dockwidgets ''' self.addDockWidget(Qt.RightDockWidgetArea, self._parametres) self.addDockWidget(Qt.RightDockWidgetArea, self._menage) self.addDockWidget(Qt.LeftDockWidgetArea, self._graph) self.addDockWidget(Qt.LeftDockWidgetArea, self._table) self.addDockWidget(Qt.LeftDockWidgetArea, self._aggregate_output) self.addDockWidget(Qt.LeftDockWidgetArea, self._dataframe_widget) self.tabifyDockWidget(self._dataframe_widget, self._aggregate_output) self.tabifyDockWidget(self._aggregate_output, self._table) self.tabifyDockWidget(self._table, self._graph) def global_callback(self): """Global callback""" widget = QApplication.focusWidget() action = self.sender() callback = unicode(action.data().toString()) if hasattr(widget, callback): getattr(widget, callback)() def load_survey_data(self): QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) try: # liberate some memory before loading new data self.reset_aggregate() gc.collect() fname = CONF.get('paths', 'survey_data/file') self.survey = DataTable(InputTable, survey_data=fname) self._dataframe_widget.set_dataframe(self.survey.table) return True except Exception, e: self.aggregate_enabled = False QMessageBox.warning( self, u"Impossible de lire les données", u"OpenFisca n'a pas réussi à lire les données d'enquête et passe en mode barème. L'erreur suivante a été renvoyé:\n%s\n\nVous pouvez charger des nouvelles données d'enquête dans Fichier>Paramètres>Chemins>Données d'enquête" % e) self.emit(SIGNAL('baremeOnly()')) return False finally:
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_())
class MainWindow(QMainWindow): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.dirty = False self.setObjectName("MainWindow") self.resize(800, 600) self.setWindowTitle("GA") # TODO # TODO app_icon = get_icon('OpenFisca22.png') # self.setWindowIcon(app_icon) self.setLocale(QLocale(QLocale.French, QLocale.France)) self.setDockOptions(QMainWindow.AllowNestedDocks | QMainWindow.AllowTabbedDocks | QMainWindow.AnimatedDocks) self.centralwidget = QWidget(self) self.gridLayout = QGridLayout(self.centralwidget) self.setCentralWidget(self.centralwidget) self.centralwidget.hide() self.statusbar = QStatusBar(self) self.statusbar.setObjectName("statusbar") self.setStatusBar(self.statusbar) # Showing splash screen pixmap = QPixmap(':/images/splash.png', 'png') self.splash = QSplashScreen(pixmap) font = self.splash.font() font.setPixelSize(10) self.splash.setFont(font) self.splash.show() self.splash.showMessage( "Initialisation...", Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.black)) # if CONF.get('main', 'current_version', '') != __version__: # CONF.set('main', 'current_version', __version__) # Execute here the actions to be performed only once after # each update (there is nothing there for now, but it could # be useful some day... self.start() def start(self, restart=False): ''' Starts main process ''' # Preferences self.general_prefs = [PathConfigPage] self.apply_settings() # Dockwidgets creation self.splash.showMessage( "Creating widgets...", Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.black)) self.create_dockwidgets() self.populate_mainwidow() ################################################################# ## Menu initialization ################################################################# self.splash.showMessage( "Creating menubar...", Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.black)) # Menu Fichier self.file_menu = self.menuBar().addMenu("Fichier") action_export_png = create_action( self, 'Exporter le graphique', icon='document-save png.png') #, triggered = None) action_export_csv = create_action( self, 'Exporter la table', icon='document-save csv.png') #, triggered = None) action_pref = create_action(self, u'Préférences', QKeySequence.Preferences, icon='preferences-desktop.png', triggered=self.edit_preferences) action_quit = create_action(self, 'Quitter', QKeySequence.Quit, icon='process-stop.png', triggered=SLOT('close()')) file_actions = [ action_export_png, action_export_csv, None, action_pref, None, action_quit ] add_actions(self.file_menu, file_actions) # Menu Edit self.edit_menu = self.menuBar().addMenu(u"Édition") action_copy = create_action(self, 'Copier', QKeySequence.Copy, triggered=self.global_callback, data='copy') edit_actions = [None, action_copy] add_actions(self.edit_menu, edit_actions) # Menu Projection self.projection_menu = self.menuBar().addMenu(u"Projection") # self.action_refresh_project_population = create_action( self, u'Calculer les projections de population', shortcut='F9', icon='calculator_green.png', triggered=self.project_population) projection_actions = [self.action_refresh_project_population, None] add_actions(self.projection_menu, projection_actions) # Menu Help help_menu = self.menuBar().addMenu("&Aide") action_about = create_action(self, u"&About GA", triggered=self.helpAbout) action_help = create_action(self, "&Aide", QKeySequence.HelpContents, triggered=self.helpHelp) help_actions = [action_about, action_help] add_actions(help_menu, help_actions) # Display Menu view_menu = self.createPopupMenu() view_menu.setTitle("&Affichage") self.menuBar().insertMenu(help_menu.menuAction(), view_menu) # Toolbar self.main_toolbar = self.create_toolbar(u"Barre d'outil", 'main_toolbar') toolbar_actions = [ action_export_png, action_export_csv, None, self.action_refresh_project_population, ] add_actions(self.main_toolbar, toolbar_actions) # Window settings self.splash.showMessage( "Restoring settings...", Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.black)) settings = QSettings() size = settings.value('MainWindow/Size', QVariant(QSize(800, 600))).toSize() self.resize(size) position = settings.value('MainWindow/Position', QVariant(QPoint(0, 0))).toPoint() self.move(position) self.restoreState(settings.value("MainWindow/State").toByteArray()) # Connectors self.connect(self._param_widget, SIGNAL('population_changed()'), self.refresh_population) # self.connect(self._param_widget, SIGNAL('rates_changed()'), self.refresh_cohorts) self.connect(self._param_widget, SIGNAL('state_proj_changed()'), self.refresh_cohorts) self.refresh_population() self.load_data() self.splash.showMessage( "Loading survey data...", Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.black)) self.splash.hide() return def create_toolbar(self, title, object_name, iconsize=24): toolbar = self.addToolBar(title) toolbar.setObjectName(object_name) toolbar.setIconSize(QSize(iconsize, iconsize)) return toolbar def create_dockwidgets(self): ''' Creates dockwidgets ''' self._population_widget = PopulationDataWidget(self) self._cohorts_widget = PopulationDataWidget(self) self._profiles_widget = ProfilesDataWidget(self) self._param_widget = ParametersWidget(self) self._plot_widget = PlotWidget(self) # TODO # plot population pyramides/expenses pyramides # générational flow def populate_mainwidow(self): ''' Creates all dockwidgets ''' left_widgets = [ self._profiles_widget, self._population_widget, self._cohorts_widget, self._plot_widget ] first_left_widget = None for widget in left_widgets: self.addDockWidget(Qt.LeftDockWidgetArea, widget) if first_left_widget is None: first_left_widget = widget else: self.tabifyDockWidget(first_left_widget, widget) def global_callback(self): """Global callback""" widget = QApplication.focusWidget() action = self.sender() callback = unicode(action.data().toString()) if hasattr(widget, callback): getattr(widget, callback)() def load_data(self): ''' Loads population and profiles data ''' QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) try: profiles_file = CONF.get('paths', 'profiles_file') store = HDFStore(profiles_file, 'r') profiles = store['profiles'] except Exception, e: self.population_loaded = False QMessageBox.warning( self, u"Impossible de lire les données de population", u"GA n'a pas réussi à lire les données de population. L'erreur suivante a été renvoyée:\n%s\n\nVous pouvez configuer le chemin vers le fichier de données Fichier>Paramètres>Chemins>Fichier données population" % e) return False finally:
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_())
import platform if platform.system() == 'Darwin': #os.environ['R_HOME']='/opt/local/Library/Frameworks/R.framework/Versions/3.2/Resources' #os.environ["R_USER"]='******' Options.setFontSize(13) elif platform.system() == 'Windows': Options.setFontSize(10) import sys #import win32api from PyQt4.QtGui import QApplication from PyQt4.QtGui import QSplashScreen from Main import mainWindow if __name__ == '__main__': app = QApplication(sys.argv) app.addLibraryPath("./") mainwin = mainWindow() # Trick to enable the Toolbar dummy = QSplashScreen() dummy.show() dummy.finish(mainwin) mainwin.show() mainwin.raise_() sys.exit(app.exec_())
from GmGui import GmApp from PyQt4.QtGui import QApplication, QSplashScreen, QPixmap from sys import argv from time import sleep if __name__=="__main__": app=QApplication(argv) splash=QSplashScreen(QPixmap("g-square.png")) splash.show() GuloMail=GmApp() #sleep(3) splash.finish(GuloMail) GuloMail.show() app.exec_()
class Application(QApplication, Singleton): """ GNS3 Application instance Used for containing global app variable, windows are other global objects. """ def __init__(self): """ Initilize the application instance and register GApp variable to ourself """ # call parent contructor QApplication.__init__(self, sys.argv) self.__mainWindow = None self.__workspace = None self.__scene = None self.__topology = None self.__dynagen = None self.__HypervisorManager = None self.__QemuManager = None self.__VBoxManager = None # Dict for storing config self.__systconf = {} self.__projconf = {} self.__iosimages = {} self.__hypervisors = {} self.__libraries = {} self.__qemuimages = {} self.__vboximages = {} self.__piximages = {} self.__junosimages = {} self.__asaimages = {} self.__awprouterimages = {} self.__idsimages = {} self.__recentfiles = [] self.iosimages_ids = 0 self.hypervisors_ids = 0 self.qemuimages_ids = 0 self.vboximages_ids = 0 self.piximages_ids = 0 self.junosimages_ids = 0 self.asaimages_ids = 0 self.awprouterimages_ids = 0 self.idsimages_ids = 0 # set global app to ourself globals.GApp = self # Force SystemScope init file to Defaults.SysConfigDir if not sys.platform.startswith('win'): QSettings.setPath(QSettings.IniFormat, QSettings.SystemScope, Defaults.SysConfigDir) QSettings.setPath(QSettings.IniFormat, QSettings.UserScope, os.path.expanduser(Defaults.UsrConfigDir)) #self.setStyle(QStyleFactory.create("cleanlooks")) def __setMainWindow(self, mw): """ register the MainWindow instance """ self.__mainWindow = mw def __getMainWindow(self): """ return the MainWindow instance """ return self.__mainWindow mainWindow = property(__getMainWindow, __setMainWindow, doc='MainWindow instance') def __setWorkspace(self, wkspc): """ register the Workspace instance """ self.__workspace = wkspc def __getWorkspace(self): """ return the Workspace instance """ return self.__workspace workspace = property(__getWorkspace, __setWorkspace, doc='Workspace instance') def __setScene(self, scene): """ register the Scene instance """ self.__scene = scene def __getScene(self): """ return the Scene instance """ return self.__scene scene = property(__getScene, __setScene, doc='Scene instance') def __setTopology(self, topology): """ register the Topology instance """ self.__topology = topology def __getTopology(self): """ return the Topology instance """ return self.__topology topology = property(__getTopology, __setTopology, doc='Topology instance') def __setSystConf(self, systconf): """ register the systconf instance """ self.__systconf = systconf def __getSystConf(self): """ return the systconf instance """ return self.__systconf systconf = property(__getSystConf, __setSystConf, doc='System config instance') def __setIOSImages(self, iosimages): """ register the sysconf instance """ self.__iosimages = iosimages def __getIOSImages(self): """ return the sysconf instance """ return self.__iosimages iosimages = property(__getIOSImages, __setIOSImages, doc='IOS images dictionnary') def __setQemuImages(self, qemuimages): """ register the sysconf instance """ self.__qemuimages = qemuimages def __getQemuImages(self): """ return the sysconf instance """ return self.__qemuimages qemuimages = property(__getQemuImages, __setQemuImages, doc='Qemu images dictionnary') def __setVBoxImages(self, vboximages): """ register the sysconf instance """ self.__vboximages = vboximages def __getVBoxImages(self): """ return the sysconf instance """ return self.__vboximages vboximages = property(__getVBoxImages, __setVBoxImages, doc='VBox images dictionnary') def __setPIXImages(self, piximages): """ register the sysconf instance """ self.__piximages = piximages def __getPIXImages(self): """ return the sysconf instance """ return self.__piximages piximages = property(__getPIXImages, __setPIXImages, doc='PIX images dictionnary') def __setJunOSImages(self, junosimages): """ register the sysconf instance """ self.__junosimages = junosimages def __getJunOSImages(self): """ return the sysconf instance """ return self.__junosimages junosimages = property(__getJunOSImages, __setJunOSImages, doc='JunOS images dictionnary') def __setASAImages(self, asaimages): """ register the sysconf instance """ self.__asaimages = asaimages def __getASAImages(self): """ return the sysconf instance """ return self.__asaimages asaimages = property(__getASAImages, __setASAImages, doc='ASA images dictionnary') def __setAWPImages(self, awprouterimages): """ register the sysconf instance """ self.__awprouterimages = awprouterimages def __getAWPImages(self): """ return the sysconf instance """ return self.__awprouterimages awprouterimages = property(__getAWPImages, __setAWPImages, doc='AWP images dictionary') def __setIDSImages(self, idsimages): """ register the sysconf instance """ self.__idsimages = idsimages def __getIDSImages(self): """ return the sysconf instance """ return self.__idsimages idsimages = property(__getIDSImages, __setIDSImages, doc='IDS images dictionnary') def __setLibraries(self, libraries): """ register the sysconf instance """ self.__libraries = libraries def __getLibraries(self): """ return the sysconf instance """ return self.__libraries libraries = property(__getLibraries, __setLibraries, doc='Libraries dictionnary') def __setRecentFiles(self, recentfiles): """ register the sysconf instance """ self.__recentfiles = recentfiles def __getRecentFiles(self): """ return the sysconf instance """ return self.__recentfiles recentfiles = property(__getRecentFiles, __setRecentFiles, doc='Recent files array') def __setHypervisors(self, hypervisors): """ register the sysconf instance """ self.__hypervisors = hypervisors def __getHypervisors(self): """ return the sysconf instance """ return self.__hypervisors hypervisors = property(__getHypervisors, __setHypervisors, doc='Hypervisors dictionnary') def __setDynagen(self, dynagen): """ register the dynagen instance """ self.__dynagen = dynagen def __getDynagen(self): """ return the systconf instance """ return self.__dynagen dynagen = property(__getDynagen, __setDynagen, doc='Dynagen instance') def __setHypervisorManager(self, HypervisorManager): """ register the HypervisorManager instance """ self.__HypervisorManager = HypervisorManager def __getHypervisorManager(self): """ return the HypervisorManager instance """ return self.__HypervisorManager HypervisorManager = property(__getHypervisorManager, __setHypervisorManager, doc='HypervisorManager instance') def __setQemuManager(self, QemuManager): """ register the QemuManager instance """ self.__QemuManager = QemuManager def __getQemuManager(self): """ return the QemuManager instance """ return self.__QemuManager QemuManager = property(__getQemuManager, __setQemuManager, doc='QemuManager instance') def __setVBoxManager(self, VBoxManager): """ register the VBoxManager instance """ self.__VBoxManager = VBoxManager def __getVBoxManager(self): """ return the VBoxManager instance """ return self.__VBoxManager VBoxManager = property(__getVBoxManager, __setVBoxManager, doc='VBoxManager instance') def processSplashScreen(self): """ Processes the splash screen, Prints a loading picture before entering the application """ self.splashMessage = translate("Application", "Starting Graphical Network Simulator...") self.splashSleepTime = 1 self.splashPath = ':/images/logo_gns3_splash.png' pixmap = QPixmap(self.splashPath) self.splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint) self.splash.show() self.splash.showMessage(self.splashMessage, Qt.AlignRight | Qt.AlignTop, Qt.black) # make sure Qt really display the splash screen and message self.processEvents(QEventLoop.AllEvents, 500) time.sleep(self.splashSleepTime) self.splash.finish(self.__mainWindow) return def showTipsDialog(self): self.mainWindow.tips_dialog.setModal(True) self.mainWindow.tips_dialog.show() self.mainWindow.tips_dialog.loadWebPage() self.mainWindow.tips_dialog.raise_() self.mainWindow.tips_dialog.activateWindow() self.mainWindow.raise_() self.mainWindow.tips_dialog.raise_() def run(self, file): self._file = file # Display splash screen while waiting for the application to open self.processSplashScreen() # Instantiation of Dynagen self.__dynagen = DynagenSub() self.systconf['dynamips'] = systemDynamipsConf() confo = self.systconf['dynamips'] confo.path = ConfDB().get('Dynamips/hypervisor_path', Defaults.DYNAMIPS_DEFAULT_PATH) confo.port = int(ConfDB().get('Dynamips/hypervisor_port', 7200)) confo.baseUDP = int(ConfDB().get('Dynamips/hypervisor_baseUDP', 10001)) confo.baseConsole = int(ConfDB().get('Dynamips/hypervisor_baseConsole', 2101)) confo.baseAUX = int(ConfDB().get('Dynamips/hypervisor_baseAUX', 2501)) confo.workdir = ConfDB().get('Dynamips/hypervisor_working_directory', Defaults.DYNAMIPS_DEFAULT_WORKDIR) confo.clean_workdir = ConfDB().value("Dynamips/clean_working_directory", QVariant(True)).toBool() confo.ghosting = ConfDB().value("Dynamips/dynamips_ghosting", QVariant(True)).toBool() confo.mmap = ConfDB().value("Dynamips/dynamips_mmap", QVariant(True)).toBool() confo.sparsemem = ConfDB().value("Dynamips/dynamips_sparsemem", QVariant(True)).toBool() confo.jitsharing = ConfDB().value("Dynamips/dynamips_jitsharing", QVariant(False)).toBool() if sys.platform.startswith('win'): confo.memory_limit = int(ConfDB().get("Dynamips/hypervisor_memory_usage_limit", 512)) else: confo.memory_limit = int(ConfDB().get("Dynamips/hypervisor_memory_usage_limit", 1024)) confo.udp_incrementation = int(ConfDB().get("Dynamips/hypervisor_udp_incrementation", 100)) confo.detected_version = ConfDB().get('Dynamips/detected_version', unicode('')) confo.import_use_HypervisorManager = ConfDB().value("Dynamips/hypervisor_manager_import", QVariant(True)).toBool() confo.HypervisorManager_binding = ConfDB().get('Dynamips/hypervisor_manager_binding', unicode('127.0.0.1')) confo.allocateHypervisorPerIOS = ConfDB().value("Dynamips/allocate_hypervisor_per_IOS", QVariant(True)).toBool() # Expand user home dir and environment variables confo.path = os.path.expandvars(os.path.expanduser(confo.path)) confo.workdir = os.path.expandvars(os.path.expanduser(confo.workdir)) # Qemu config self.systconf['qemu'] = systemQemuConf() confo = self.systconf['qemu'] confo.qemuwrapper_path = ConfDB().get('Qemu/qemuwrapper_path', Defaults.QEMUWRAPPER_DEFAULT_PATH) confo.qemuwrapper_workdir = ConfDB().get('Qemu/qemuwrapper_working_directory', Defaults.QEMUWRAPPER_DEFAULT_WORKDIR) confo.qemu_path = ConfDB().get('Qemu/qemu_path', Defaults.QEMU_DEFAULT_PATH) confo.qemu_img_path = ConfDB().get('Qemu/qemu_img_path', Defaults.QEMU_IMG_DEFAULT_PATH) confo.external_hosts = ConfDB().get('Qemu/external_hosts', unicode('127.0.0.1:10525')).split(',') confo.enable_QemuWrapperAdvOptions = ConfDB().value("Qemu/enable_QemuWrapperAdvOptions", QVariant(False)).toBool() confo.enable_QemuManager = ConfDB().value("Qemu/enable_QemuManager", QVariant(True)).toBool() confo.import_use_QemuManager = ConfDB().value("Qemu/qemu_manager_import", QVariant(True)).toBool() confo.send_path_external_QemuWrapper = ConfDB().value("Qemu/send_paths_external_Qemuwrapper", QVariant(False)).toBool() confo.QemuManager_binding = ConfDB().get('Qemu/qemu_manager_binding', unicode('127.0.0.1')) confo.qemuwrapper_port = int(ConfDB().get('Qemu/qemuwrapper_port', 10525)) confo.qemuwrapper_baseUDP = int(ConfDB().get('Qemu/qemuwrapper_baseUDP', 40000)) confo.qemuwrapper_baseConsole = int(ConfDB().get('Qemu/qemuwrapper_baseConsole', 3001)) # Expand user home dir and environment variables confo.qemuwrapper_path = os.path.expandvars(os.path.expanduser(confo.qemuwrapper_path)) confo.qemuwrapper_workdir = os.path.expandvars(os.path.expanduser(confo.qemuwrapper_workdir)) # VBox config self.systconf['vbox'] = systemVBoxConf() confo = self.systconf['vbox'] confo.vboxwrapper_path = ConfDB().get('VBox/vboxwrapper_path', Defaults.VBOXWRAPPER_DEFAULT_PATH) confo.vboxwrapper_workdir = ConfDB().get('VBox/vboxwrapper_working_directory', Defaults.VBOXWRAPPER_DEFAULT_WORKDIR) confo.external_hosts = ConfDB().get('VBox/external_hosts', unicode('127.0.0.1:11525')).split(',') confo.use_VBoxVmnames = ConfDB().value("VBox/use_VBoxVmnames", QVariant(True)).toBool() confo.enable_VBoxWrapperAdvOptions = ConfDB().value("VBox/enable_VBoxWrapperAdvOptions", QVariant(False)).toBool() confo.enable_VBoxAdvOptions = ConfDB().value("VBox/enable_VBoxAdvOptions", QVariant(False)).toBool() confo.enable_GuestControl = ConfDB().value("VBox/enable_GuestControl", QVariant(False)).toBool() confo.enable_VBoxManager = ConfDB().value("VBox/enable_VBoxManager", QVariant(True)).toBool() confo.import_use_VBoxManager = ConfDB().value("VBox/vbox_manager_import", QVariant(True)).toBool() confo.VBoxManager_binding = ConfDB().get('VBox/vbox_manager_binding', unicode('127.0.0.1')) confo.vboxwrapper_port = int(ConfDB().get('VBox/vboxwrapper_port', 11525)) confo.vboxwrapper_baseUDP = int(ConfDB().get('VBox/vboxwrapper_baseUDP', 20900)) confo.vboxwrapper_baseConsole = int(ConfDB().get('VBox/vboxwrapper_baseConsole', 3501)) # Expand user home dir and environment variables confo.vboxwrapper_path = os.path.expandvars(os.path.expanduser(confo.vboxwrapper_path)) confo.vboxwrapper_workdir = os.path.expandvars(os.path.expanduser(confo.vboxwrapper_workdir)) # Capture config self.systconf['capture'] = systemCaptureConf() confo = self.systconf['capture'] confo.workdir = ConfDB().get('Capture/working_directory', Defaults.CAPTURE_DEFAULT_WORKDIR) confo.cap_cmd = ConfDB().get('Capture/capture_reader_cmd', Defaults.CAPTURE_DEFAULT_CMD) confo.auto_start = ConfDB().value('Capture/auto_start_cmd', QVariant(False)).toBool() # Expand user home dir and environment variables confo.cap_cmd = os.path.expandvars(os.path.expanduser(confo.cap_cmd)) confo.workdir = os.path.expandvars(os.path.expanduser(confo.workdir)) # Deployement Wizard config self.systconf['deployement wizard'] = systemDeployementWizardConf() confo = self.systconf['deployement wizard'] confo.deployementwizard_path = ConfDB().get('DeployementWizard/deployementwizard_path', Defaults.DEPLOYEMENTWIZARD_DEFAULT_PATH) confo.deployementwizard_filename = ConfDB().get('DeployementWizard/deployementwizard_filename', unicode('Topology.pdf')) # Expand user home dir and environement variable confo.deployementwizard_path = os.path.expandvars(os.path.expanduser(confo.deployementwizard_path)) confo.deployementwizard_filename = os.path.expandvars(os.path.expanduser(confo.deployementwizard_filename)) # System general config self.systconf['general'] = systemGeneralConf() confo = self.systconf['general'] confo.lang = ConfDB().get('GNS3/lang', unicode('en')) confo.slow_start = int(ConfDB().get('GNS3/slow_start', 1)) confo.autosave = int(ConfDB().get('GNS3/autosave', 0)) confo.project_startup = ConfDB().value("GNS3/project_startup", QVariant(True)).toBool() confo.relative_paths = ConfDB().value("GNS3/relative_paths", QVariant(True)).toBool() confo.auto_screenshot = ConfDB().value("GNS3/auto_screenshot", QVariant(True)).toBool() if sys.platform.startswith('win'): confo.use_shell = ConfDB().value("GNS3/use_shell", QVariant(False)).toBool() else: confo.use_shell = ConfDB().value("GNS3/use_shell", QVariant(True)).toBool() confo.bring_console_to_front = ConfDB().value("GNS3/bring_console_to_front", QVariant(False)).toBool() confo.term_cmd = ConfDB().get('GNS3/console', Defaults.TERMINAL_DEFAULT_CMD) confo.term_serial_cmd = ConfDB().get('GNS3/serial_console', Defaults.TERMINAL_SERIAL_DEFAULT_CMD) confo.term_close_on_delete = ConfDB().value("GNS3/term_close_on_delete", QVariant(True)).toBool() confo.project_path = ConfDB().get('GNS3/project_directory', Defaults.PROJECT_DEFAULT_DIR) confo.ios_path = ConfDB().get('GNS3/ios_directory', Defaults.IOS_DEFAULT_DIR) confo.status_points = ConfDB().value("GNS3/gui_show_status_points", QVariant(True)).toBool() confo.manual_connection = ConfDB().value("GNS3/gui_use_manual_connection", QVariant(True)).toBool() confo.draw_selected_rectangle = ConfDB().value("GNS3/gui_draw_selected_rectangle", QVariant(False)).toBool() confo.scene_width = int(ConfDB().get('GNS3/scene_width', 2000)) confo.scene_height = int(ConfDB().get('GNS3/scene_height', 1000)) confo.console_delay = float(ConfDB().get('GNS3/console_delay', 1)) if sys.platform.startswith('win') or sys.platform.startswith('darwin'): # by default auto check for update only on Windows or OSX confo.auto_check_for_update = ConfDB().value("GNS3/auto_check_for_update", QVariant(True)).toBool() else: confo.auto_check_for_update = ConfDB().value("GNS3/auto_check_for_update", QVariant(False)).toBool() confo.last_check_for_update = int(ConfDB().get('GNS3/last_check_for_update', 0)) # Expand user home dir and environment variables confo.term_cmd = os.path.expandvars(os.path.expanduser(confo.term_cmd)) confo.project_path = os.path.expandvars(os.path.expanduser(confo.project_path)) confo.ios_path = os.path.expandvars(os.path.expanduser(confo.ios_path)) # Restore debug level globals.debugLevel = int(ConfDB().get('GNS3/debug_level', 0)) if globals.debugLevel == 1 or globals.debugLevel == 3: lib.setdebug(True) tracker.setdebug(True) # Now systGeneral settings are loaded, load the translator self.translator = Translator() self.translator.switchLangTo(self.systconf['general'].lang) # HypervisorManager if globals.GApp.systconf['dynamips'].path: self.__HypervisorManager = HypervisorManager() # QemuManager self.__QemuManager = QemuManager() # VBoxManager self.__VBoxManager = VBoxManager() GNS_Conf().VBOX_images() GNS_Conf().IOS_images() GNS_Conf().IOS_hypervisors() GNS_Conf().QEMU_images() GNS_Conf().PIX_images() GNS_Conf().JUNOS_images() GNS_Conf().ASA_images() GNS_Conf().AWP_images() GNS_Conf().IDS_images() GNS_Conf().Libraries() GNS_Conf().Symbols() GNS_Conf().RecentFiles() # Workspace create a ` Scene' object, # so it also set self.__topology self.__workspace = Workspace() # seems strange to have mainWindow = Workspace, but actually, # we don't use MDI style, so there not so much difference. self.__mainWindow = self.__workspace # In GNS3, the `scene' represent the widget where all graphical stuff # are done (drawing Node, Animation), and in Qt, it's the QGraphicsView # which handle all this stuff. self.__scene = self.__mainWindow.graphicsView # Restore the geometry & state of the GUI self.mainWindow.restoreGeometry(ConfDB().value("GUIState/Geometry").toByteArray()) self.mainWindow.restoreState(ConfDB().value("GUIState/State").toByteArray()) self.mainWindow.action_DisableMouseWheel.setChecked(ConfDB().value("GUIState/DisableMouseWheel", QVariant(False)).toBool()) self.mainWindow.action_ZoomUsingMouseWheel.setChecked(ConfDB().value("GUIState/ZoomUsingMouseWheel", QVariant(False)).toBool()) if self.mainWindow.tips_dialog: self.mainWindow.tips_dialog.checkBoxDontShowAgain.setChecked(ConfDB().value("GUIState/DoNotShowTipsDialog", QVariant(False)).toBool()) # load initial stuff once the event loop isn't busy QtCore.QTimer.singleShot(0, self._startupLoading) # By default, don't show the NodeTypes dock self.mainWindow.dockWidget_NodeTypes.setVisible(False) self.mainWindow.show() retcode = QApplication.exec_() self.__HypervisorManager = None self.__QemuManager = None self.__VBoxManager = None if globals.recordConfiguration: # Save the geometry & state of the GUI ConfDB().set("GUIState/Geometry", self.mainWindow.saveGeometry()) ConfDB().set("GUIState/State", self.mainWindow.saveState()) ConfDB().set("GUIState/DisableMouseWheel", self.mainWindow.action_DisableMouseWheel.isChecked()) ConfDB().set("GUIState/ZoomUsingMouseWheel", self.mainWindow.action_ZoomUsingMouseWheel.isChecked()) if self.mainWindow.tips_dialog: ConfDB().set("GUIState/DoNotShowTipsDialog", self.mainWindow.tips_dialog.checkBoxDontShowAgain.isChecked()) self.syncConf() self.deleteLater() sys.exit(retcode) def _startupLoading(self): confo = self.systconf['general'] force_clear_configuration = True version = ConfDB().get('GNS3/version', '0.0.1') try: # trick to test old version format (integer), before 0.8.2.1 release int(version) except ValueError: force_clear_configuration = False #for future releases if LooseVersion(VERSION) > str(version): # reset the tips dialog if self.mainWindow.tips_dialog: self.mainWindow.tips_dialog.checkBoxDontShowAgain.setChecked(False) if force_clear_configuration: self.mainWindow.raise_() reply = QMessageBox.question(self.mainWindow, translate("Application", "GNS3 configuration file"), translate("Application", "You have installed a new GNS3 version.\nIt is recommended to clear your old configuration, do you want to proceed?"), QMessageBox.Yes, QMessageBox.No) if reply == QMessageBox.Yes: ConfDB().clear() c = ConfDB() c.set('GNS3/version', VERSION) c.sync() globals.recordConfiguration = False QMessageBox.information(self.mainWindow, translate("Application", "GNS3 configuration file"), translate("Application", "Configuration cleared!\nPlease restart GNS3")) else: # if we cannot find our config file, we start the Wizard dialog configFile = unicode(ConfDB().fileName(), 'utf-8', errors='replace') if not os.access(configFile, os.F_OK): dialog = Wizard(parent=self.mainWindow) dialog.setModal(True) dialog.show() else: if self._file: self.mainWindow.load_netfile(self._file, load_instructions=True) elif confo.project_startup and os.access(configFile, os.F_OK): dialog = ProjectDialog(parent=self.mainWindow, newProject=True) dialog.setModal(True) dialog.show() if self.mainWindow.tips_dialog and self.mainWindow.tips_dialog.checkBoxDontShowAgain.isChecked() == False: self.showTipsDialog() else: self.mainWindow.createProject((None, None, None, False, False)) self.mainWindow.raise_() if self.mainWindow.tips_dialog and self.mainWindow.tips_dialog.checkBoxDontShowAgain.isChecked() == False: self.showTipsDialog() def syncConf(self): """ Sync current application config with config file (gns3.{ini,conf}) """ c = ConfDB() c.set('GNS3/version', VERSION) # Apply general settings confo = self.systconf['general'] c.set('GNS3/lang', confo.lang) c.set('GNS3/project_startup', confo.project_startup) c.set('GNS3/relative_paths', confo.relative_paths) c.set('GNS3/auto_screenshot', confo.auto_screenshot) c.set('GNS3/slow_start', confo.slow_start) c.set('GNS3/autosave', confo.autosave) c.set('GNS3/console', confo.term_cmd) c.set('GNS3/serial_console', confo.term_serial_cmd) c.set('GNS3/term_close_on_delete', confo.term_close_on_delete) c.set('GNS3/use_shell', confo.use_shell) c.set('GNS3/bring_console_to_front', confo.bring_console_to_front) c.set('GNS3/gui_show_status_points', confo.status_points) c.set('GNS3/gui_use_manual_connection', confo.manual_connection) c.set('GNS3/gui_draw_selected_rectangle', confo.draw_selected_rectangle) c.set('GNS3/project_directory', confo.project_path) c.set('GNS3/ios_directory', confo.ios_path) c.set('GNS3/scene_width', confo.scene_width) c.set('GNS3/scene_height', confo.scene_height) c.set('GNS3/auto_check_for_update', confo.auto_check_for_update) c.set('GNS3/last_check_for_update', confo.last_check_for_update) c.set('GNS3/console_delay', confo.console_delay) c.set('GNS3/debug_level', globals.debugLevel) # Dynamips settings confo = self.systconf['dynamips'] c.set('Dynamips/hypervisor_path', confo.path) c.set('Dynamips/hypervisor_port', confo.port) c.set('Dynamips/hypervisor_baseUDP', confo.baseUDP) c.set('Dynamips/hypervisor_baseConsole', confo.baseConsole) c.set('Dynamips/hypervisor_baseAUX', confo.baseAUX) c.set('Dynamips/hypervisor_working_directory', confo.workdir) c.set('Dynamips/clean_working_directory', confo.clean_workdir) c.set('Dynamips/dynamips_ghosting', confo.ghosting) c.set('Dynamips/dynamips_sparsemem', confo.sparsemem) c.set('Dynamips/dynamips_jitsharing', confo.jitsharing) c.set('Dynamips/dynamips_mmap', confo.mmap) c.set('Dynamips/hypervisor_memory_usage_limit', confo.memory_limit) c.set('Dynamips/detected_version', confo.detected_version) c.set('Dynamips/hypervisor_udp_incrementation', confo.udp_incrementation) c.set('Dynamips/hypervisor_manager_import', confo.import_use_HypervisorManager) c.set('Dynamips/allocate_hypervisor_per_IOS', confo.allocateHypervisorPerIOS) c.set('Dynamips/hypervisor_manager_binding', confo.HypervisorManager_binding) # Qemu config confo = self.systconf['qemu'] c.set('Qemu/qemuwrapper_path', confo.qemuwrapper_path) c.set('Qemu/qemuwrapper_working_directory', confo.qemuwrapper_workdir) c.set('Qemu/qemu_path', confo.qemu_path) c.set('Qemu/qemu_img_path', confo.qemu_img_path) external_hosts = ','.join(confo.external_hosts) c.set('Qemu/external_hosts', external_hosts) c.set('Qemu/enable_QemuWrapperAdvOptions', confo.enable_QemuWrapperAdvOptions) c.set('Qemu/enable_QemuManager', confo.enable_QemuManager) c.set('Qemu/qemu_manager_import', confo.import_use_QemuManager) c.set('Qemu/qemu_manager_binding', confo.QemuManager_binding) c.set('Qemu/send_paths_external_Qemuwrapper', confo.send_path_external_QemuWrapper) c.set('Qemu/qemuwrapper_port', confo.qemuwrapper_port) c.set('Qemu/qemuwrapper_baseUDP', confo.qemuwrapper_baseUDP) c.set('Qemu/qemuwrapper_baseConsole', confo.qemuwrapper_baseConsole) # VBox config confo = self.systconf['vbox'] c.set('VBox/vboxwrapper_path', confo.vboxwrapper_path) c.set('VBox/vboxwrapper_working_directory', confo.vboxwrapper_workdir) external_hosts = ','.join(confo.external_hosts) c.set('VBox/external_hosts', external_hosts) c.set('VBox/use_VBoxVmnames', confo.use_VBoxVmnames) c.set('VBox/enable_VBoxWrapperAdvOptions', confo.enable_VBoxWrapperAdvOptions) c.set('VBox/enable_VBoxAdvOptions', confo.enable_VBoxAdvOptions) c.set('VBox/enable_GuestControl', confo.enable_GuestControl) c.set('VBox/enable_VBoxManager', confo.enable_VBoxManager) c.set('VBox/vbox_manager_import', confo.import_use_VBoxManager) c.set('VBox/vbox_manager_binding', confo.VBoxManager_binding) c.set('VBox/vboxwrapper_port', confo.vboxwrapper_port) c.set('VBox/vboxwrapper_baseUDP', confo.vboxwrapper_baseUDP) c.set('VBox/vboxwrapper_baseConsole', confo.vboxwrapper_baseConsole) # Capture settings confo = self.systconf['capture'] c.set('Capture/working_directory', confo.workdir) c.set('Capture/capture_reader_cmd', confo.cap_cmd) c.set('Capture/auto_start_cmd', confo.auto_start) # Clear IOS.hypervisors, IOS.images and QEMU.images group c.beginGroup("IOS.images") c.remove("") c.endGroup() c.beginGroup("IOS.hypervisors") c.remove("") c.endGroup() c.beginGroup("QEMU.images") c.remove("") c.endGroup() c.beginGroup("VBOX.images") c.remove("") c.endGroup() c.beginGroup("PIX.images") c.remove("") c.endGroup() c.beginGroup("JUNOS.images") c.remove("") c.endGroup() c.beginGroup("ASA.images") c.remove("") c.endGroup() c.beginGroup("AWP.images") c.remove("") c.endGroup() c.beginGroup("IDS.images") c.remove("") c.endGroup() # Clear Symbol.libraries group c.beginGroup("Symbol.libraries") c.remove("") c.endGroup() # Clear Recent.files group c.beginGroup("Recent.files") c.remove("") c.endGroup() # Clear Symbol.libraries group c.beginGroup("Symbol.settings") c.remove("") c.endGroup() # IOS Images for (key, o) in self.__iosimages.iteritems(): basekey = "IOS.images/" + str(o.id) c.set(basekey + "/filename", o.filename) c.set(basekey + "/chassis", o.chassis) c.set(basekey + "/platform", o.platform) c.set(basekey + "/baseconfig", o.baseconfig) hypervisors = '' for hypervisor in o.hypervisors: hypervisors += hypervisor + ' ' c.set(basekey + "/hypervisors", hypervisors.strip()) c.set(basekey + "/default_ram", o.default_ram) c.set(basekey + "/idlepc", o.idlepc) c.set(basekey + "/idlemax", o.idlemax) c.set(basekey + "/idlesleep", o.idlesleep) c.set(basekey + "/default", o.default) # Hypervisors for (key, o) in self.__hypervisors.iteritems(): basekey = "IOS.hypervisors/" + str(o.id) c.set(basekey + "/host", o.host) c.set(basekey + "/port", o.port) c.set(basekey + "/working_directory", o.workdir) c.set(basekey + "/base_udp", o.baseUDP) c.set(basekey + "/base_console", o.baseConsole) c.set(basekey + "/base_aux", o.baseAUX) # Qemu images for (key, o) in self.__qemuimages.iteritems(): basekey = "QEMU.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/filename", o.filename) c.set(basekey + "/memory", o.memory) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/usermod", o.usermod) c.set(basekey + "/nic", o.nic) c.set(basekey + "/flavor", o.flavor) c.set(basekey + "/options", o.options) c.set(basekey + "/kvm", o.kvm) c.set(basekey + "/monitor", o.monitor) # VBox images for (key, o) in self.__vboximages.iteritems(): basekey = "VBOX.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/filename", o.filename) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/nic", o.nic) c.set(basekey + "/first_nic_managed", o.first_nic_managed) c.set(basekey + "/headless_mode", o.headless_mode) c.set(basekey + "/console_support", o.console_support) c.set(basekey + "/console_telnet_server", o.console_telnet_server) c.set(basekey + "/guestcontrol_user", o.guestcontrol_user) c.set(basekey + "/guestcontrol_password", o.guestcontrol_password) # PIX images for (key, o) in self.__piximages.iteritems(): basekey = "PIX.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/filename", o.filename) c.set(basekey + "/memory", o.memory) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/nic", o.nic) c.set(basekey + "/options", o.options) c.set(basekey + "/key", o.key) c.set(basekey + "/serial", o.serial) # JunOS images for (key, o) in self.__junosimages.iteritems(): basekey = "JUNOS.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/filename", o.filename) c.set(basekey + "/memory", o.memory) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/usermod", o.usermod) c.set(basekey + "/nic", o.nic) c.set(basekey + "/options", o.options) c.set(basekey + "/kvm", o.kvm) c.set(basekey + "/monitor", o.monitor) # ASA images for (key, o) in self.__asaimages.iteritems(): basekey = "ASA.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/memory", o.memory) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/usermod", o.usermod) c.set(basekey + "/nic", o.nic) c.set(basekey + "/options", o.options) c.set(basekey + "/kvm", o.kvm) c.set(basekey + "/monitor", o.monitor) c.set(basekey + "/initrd", o.initrd) c.set(basekey + "/kernel", o.kernel) c.set(basekey + "/kernel_cmdline", o.kernel_cmdline) # AWP images for (key, o) in self.__awprouterimages.iteritems(): basekey = "AWP.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/memory", o.memory) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/nic", o.nic) c.set(basekey + "/options", o.options) c.set(basekey + "/kvm", o.kvm) c.set(basekey + "/initrd", o.initrd) c.set(basekey + "/kernel", o.kernel) c.set(basekey + "/rel", o.rel) c.set(basekey + "/kernel_cmdline", o.kernel_cmdline) # IDS images for (key, o) in self.__idsimages.iteritems(): basekey = "IDS.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/image1", o.image1) c.set(basekey + "/image2", o.image2) c.set(basekey + "/memory", o.memory) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/usermod", o.usermod) c.set(basekey + "/nic", o.nic) c.set(basekey + "/options", o.options) c.set(basekey + "/kvm", o.kvm) c.set(basekey + "/monitor", o.monitor) # Libraries id = 0 for (key, o) in self.__libraries.iteritems(): basekey = "Symbol.libraries/" + str(id) c.set(basekey + "/path", o.path) id += 1 # Recent Files id = 0 for o in self.__recentfiles: basekey = "Recent.files/" + str(id) c.set(basekey + "/path", o.path) id += 1 # Symbols id = 0 for symbol in SYMBOLS: if not symbol['translated']: basekey = "Symbol.settings/" + str(id) c.set(basekey + "/name", symbol['name']) c.set(basekey + "/type", SYMBOL_TYPES[symbol['object']]) c.set(basekey + "/normal_svg_file", symbol['normal_svg_file']) c.set(basekey + "/selected_svg_file", symbol['select_svg_file']) id += 1 c.sync()
* You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. ''' #import sip #sip.setapi('QString', 1) #sip.setapi('QVariant', 1) from PyQt4.QtGui import QApplication, QIcon, QPixmap, QSplashScreen from frame.MainFrame import MainWindow from PyQt4.QtCore import QString import sys import os if __name__ == "__main__": app = QApplication(sys.argv) pixmap = QPixmap("Tests/psycho.jpg") splashcreen = QSplashScreen(pixmap) splashcreen.show() app.setOrganizationName("Laboratoire de Simulation et de Depistage") app.setApplicationName("LSD Simulator Dashboard") app.setWindowIcon(QIcon("../img/icon.png")) app.window = MainWindow() app.window.setWindowTitle("LSD Simulator Dashboard -- version alpha") if sys.argv[0].rpartition("/")[0]: os.chdir(sys.argv[0].rpartition("/")[0]) app.window.loadSettings() splashcreen.finish(app.window) sys.exit(app.exec_())
def main(): if platform.system() == "Windows": print "Running on Windows" # On Windows, redirect stderr to a file import imp, ctypes if (hasattr(sys, "frozen") or # new py2exe hasattr(sys, "importers") or # old py2exe imp.is_frozen("__main__")): # tools/freeze sys.stderr = open(os.path.expanduser("~/friture.exe.log"), "w") # set the App ID for Windows 7 to properly display the icon in the # taskbar. myappid = 'Friture.Friture.Friture.current' # arbitrary string try: ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) except: print "Could not set the app model ID. If the plaftorm is older than Windows 7, this is normal." app = QApplication(sys.argv) # Splash screen pixmap = QPixmap(":/images/splash.png") splash = QSplashScreen(pixmap) splash.show() splash.showMessage("Initializing the audio subsystem") app.processEvents() # Set the separator stylesheet here # As of Qt 4.6, separator width is not handled correctly # when the stylesheet is applied directly to the QMainWindow instance. # QtCreator workarounds it with a "minisplitter" special class app.setStyleSheet(STYLESHEET) # Logger class logger = Logger() window = Friture(logger) window.show() splash.finish(window) profile = "no" # "python" or "kcachegrind" or anything else to disable if len(sys.argv) > 1: if sys.argv[1] == "--python": profile = "python" #elif sys.argv[1] == "--kcachegrind": #profile = "kcachegrind" elif sys.argv[1] == "--no": profile = "no" else: print "command-line arguments (%s) not recognized" %sys.argv[1:] if profile == "python": import cProfile import pstats cProfile.runctx('app.exec_()', globals(), locals(), filename="friture.cprof") stats = pstats.Stats("friture.cprof") stats.strip_dirs().sort_stats('time').print_stats(20) stats.strip_dirs().sort_stats('cumulative').print_stats(20) sys.exit(0) #elif profile == "kcachegrind": #import cProfile #import lsprofcalltree #p = cProfile.Profile() #p.run('app.exec_()') #k = lsprofcalltree.KCacheGrind(p) #data = open('cachegrind.out.00000', 'wb') #k.output(data) #data.close() ## alternative code with pyprof2calltree instead of lsprofcalltree ##import pyprof2calltree ##pyprof2calltree.convert(p.getstats(), "cachegrind.out.00000") # save #sys.exit(0) else: sys.exit(app.exec_())
def run_edis(app): """ Se carga la interfáz """ DEBUG("Running Edis...") qsettings = QSettings(paths.CONFIGURACION, QSettings.IniFormat) # Ícono app.setWindowIcon(QIcon(":image/edis")) # Lenguaje local = QLocale.system().name() DEBUG("Loading language...") language = settings.get_setting('general/language') if language: edis_translator = QTranslator() edis_translator.load( os.path.join(paths.PATH, "extras", "i18n", language)) app.installTranslator(edis_translator) # Qt translator qtranslator = QTranslator() qtranslator.load("qt_" + local, QLibraryInfo.location(QLibraryInfo.TranslationsPath)) app.installTranslator(qtranslator) pixmap = QPixmap(":image/splash") # Splash screen show_splash = False if settings.get_setting('general/show-splash'): DEBUG("Showing splash...") splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint) splash.setMask(pixmap.mask()) splash.show() app.processEvents() show_splash = True # Style Sheet style = settings.get_setting('window/style-sheet') path_style = None style_sheet = None if style == 'Edark': path_style = os.path.join(paths.PATH, 'extras', 'theme', 'edark.qss') elif style != 'Default': path_style = os.path.join(paths.EDIS, style + '.qss') if path_style is not None: with open(path_style, mode='r') as f: style_sheet = f.read() app.setStyleSheet(style_sheet) # Fuente en Tooltips QToolTip.setFont(QFont(settings.DEFAULT_FONT, 9)) # GUI if show_splash: alignment = Qt.AlignBottom | Qt.AlignLeft splash.showMessage("Loading UI...", alignment, Qt.white) DEBUG("Loading GUI...") edis = Edis() edis.show() # Archivos de última sesión files, recents_files, projects = [], [], [] projects = qsettings.value('general/projects') #FIXME: if projects is None: projects = [] if settings.get_setting('general/load-files'): DEBUG("Loading files and projects...") if show_splash: splash.showMessage("Loading files...", alignment, Qt.white) files = qsettings.value('general/files') if files is None: files = [] # Archivos recientes recents_files = qsettings.value('general/recents-files') if recents_files is None: recents_files = [] # Archivos desde línea de comandos files += cmd_parser.parse() edis.load_files_and_projects(files, recents_files, projects) if show_splash: splash.finish(edis) DEBUG("Edis is Ready!") sys.exit(app.exec_())
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_())
def main(argv): app = QApplication(argv) #Early so that QT is initialized before other imports app.setWindowIcon(util.resourceIcon("application/window_icon_cutout")) splash = QSplashScreen(resourceImage("newsplash"), Qt.WindowStaysOnTopHint) splash.show() splash.showMessage("Starting up...", Qt.AlignLeft, Qt.white) app.processEvents() help_center = HelpCenter("ERT") help_center.setHelpLinkPrefix(os.getenv("ERT_SHARE_PATH") + "/gui/help/") help_center.setHelpMessageLink("welcome_to_ert") splash.showMessage("Bootstrapping...", Qt.AlignLeft, Qt.white) app.processEvents() strict = True site_config = os.getenv("ERT_SITE_CONFIG") if len(argv) == 1: print("-----------------------------------------------------------------") print("-- You must supply the name of configuration file as the first --") print("-- commandline argument: --") print("-- --") print("-- bash% gert <config_file> --") print("-- --") print("-- If the configuration file does not exist, gert will create --") print("-- create a new configuration file. --") print("-----------------------------------------------------------------") else: enkf_config = argv[1] if not os.path.exists(enkf_config): print("Trying to start new config") new_configuration_dialog = NewConfigurationDialog(enkf_config) success = new_configuration_dialog.exec_() if not success: print("Can not run without a configuration file.") sys.exit(1) else: enkf_config = new_configuration_dialog.getConfigurationPath() first_case_name = new_configuration_dialog.getCaseName() dbase_type = new_configuration_dialog.getDBaseType() num_realizations = new_configuration_dialog.getNumberOfRealizations() storage_path = new_configuration_dialog.getStoragePath() EnKFMain.createNewConfig(enkf_config, storage_path, first_case_name, dbase_type, num_realizations) strict = False ert = Ert(EnKFMain(enkf_config, site_config=site_config, strict=strict)) ErtConnector.setErt(ert.ert()) splash.showMessage("Creating GUI...", Qt.AlignLeft, Qt.white) app.processEvents() window = GertMainWindow() window.setWidget(SimulationPanel()) help_tool = HelpTool("ERT", window) window.addDock("Configuration Summary", SummaryPanel(), area=Qt.BottomDockWidgetArea) window.addTool(IdeTool(os.path.basename(enkf_config), ert.reloadERT, help_tool)) window.addTool(PlotTool()) window.addTool(ExportTool()) window.addTool(WorkflowsTool()) window.addTool(ManageCasesTool()) window.addTool(help_tool) splash.showMessage("Communicating with ERT...", Qt.AlignLeft, Qt.white) app.processEvents() window.show() splash.finish(window) 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(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_())
class MainWindow(QMainWindow): def __init__(self, parent = None): super(MainWindow, self).__init__(parent) self.dirty = False self.isLoaded = False self.calibration_enabled = False self.aggregate_enabled = False self.setObjectName("MainWindow") self.resize(800, 600) self.setWindowTitle("OpenFisca") app_icon = get_icon('OpenFisca22.png') self.setWindowIcon(app_icon) self.setLocale(QLocale(QLocale.French, QLocale.France)) self.setDockOptions(QMainWindow.AllowNestedDocks|QMainWindow.AllowTabbedDocks|QMainWindow.AnimatedDocks) self.centralwidget = QWidget(self) self.gridLayout = QGridLayout(self.centralwidget) self.setCentralWidget(self.centralwidget) self.centralwidget.hide() self.statusbar = QStatusBar(self) self.statusbar.setObjectName("statusbar") self.setStatusBar(self.statusbar) # Showing splash screen pixmap = QPixmap(':/images/splash.png', 'png') self.splash = QSplashScreen(pixmap) font = self.splash.font() font.setPixelSize(10) self.splash.setFont(font) self.splash.show() self.splash.showMessage("Initialisation...", Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.black)) # if CONF.get('main', 'current_version', '') != __version__: # CONF.set('main', 'current_version', __version__) # Execute here the actions to be performed only once after # each update (there is nothing there for now, but it could # be useful some day... self.scenario = Scenario() # Preferences self.general_prefs = [SimConfigPage, PathConfigPage, CalConfigPage] self.oldXAXIS = 'sal' self.reforme = False self.apply_settings() # Dockwidgets creation self.splash.showMessage("Creating widgets...", Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.black)) self.create_dockwidgets() self.populate_mainwidow() ################################################################# ## Menu initialization ################################################################# self.splash.showMessage("Creating menubar...", Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.black)) # Menu Fichier self.file_menu = self.menuBar().addMenu("Fichier") action_export_png = create_action(self, 'Exporter le graphique', icon = 'document-save png.png', triggered = self._graph.save_figure) action_export_csv = create_action(self, 'Exporter la table', icon = 'document-save csv.png', triggered = self._table.saveCsv) action_pref = create_action(self, u'Préférences', QKeySequence.Preferences, icon = 'preferences-desktop.png', triggered = self.edit_preferences) action_quit = create_action(self, 'Quitter', QKeySequence.Quit, icon = 'process-stop.png', triggered = SLOT('close()')) file_actions = [action_export_png, action_export_csv,None, action_pref, None, action_quit] add_actions(self.file_menu, file_actions) # Menu Edit self.edit_menu = self.menuBar().addMenu(u"Édition") action_copy = create_action(self, 'Copier', QKeySequence.Copy, triggered = self.global_callback, data = 'copy') edit_actions = [None, action_copy] add_actions(self.edit_menu, edit_actions) # Menu Simulation self.simulation_menu = self.menuBar().addMenu(u"Simulation") self.action_refresh_bareme = create_action(self, u'Calculer barèmes', shortcut = 'F8', icon = 'view-refresh.png', triggered = self.refresh_bareme) self.action_refresh_calibration = create_action(self, u'Calibrer', shortcut = 'F9', icon = 'view-refresh.png', triggered = self.refresh_calibration) self.action_refresh_aggregate = create_action(self, u'Calculer aggrégats', shortcut = 'F10', icon = 'view-refresh.png', triggered = self.refresh_aggregate) action_bareme = create_action(self, u'Barème', icon = 'bareme22.png', toggled = self.modeBareme) action_cas_type = create_action(self, u'Cas type', icon = 'castype22.png', toggled = self.modeCasType) action_mode_reforme = create_action(self, u'Réforme', icon = 'comparison22.png', toggled = self.modeReforme, tip = u"Différence entre la situation simulée et la situation actuelle") mode_group = QActionGroup(self) mode_group.addAction(action_bareme) mode_group.addAction(action_cas_type) self.mode = 'bareme' action_bareme.trigger() simulation_actions = [self.action_refresh_bareme, self.action_refresh_calibration, self.action_refresh_aggregate , None, action_bareme, action_cas_type, None, action_mode_reforme] add_actions(self.simulation_menu, simulation_actions) # Menu Help help_menu = self.menuBar().addMenu("&Aide") action_about = create_action(self, u"&About OpenFisca", triggered = self.helpAbout) action_help = create_action(self, "&Aide", QKeySequence.HelpContents, triggered = self.helpHelp) help_actions = [action_about, action_help] add_actions(help_menu, help_actions) # Display Menu view_menu = self.createPopupMenu() view_menu.setTitle("&Affichage") self.menuBar().insertMenu(help_menu.menuAction(), view_menu) # Toolbar self.main_toolbar = self.create_toolbar(u"Barre d'outil", 'main_toolbar') toolbar_actions = [action_export_png, action_export_csv, None, self.action_refresh_bareme, self.action_refresh_calibration, self.action_refresh_aggregate, None, action_bareme, action_cas_type, None, action_mode_reforme] add_actions(self.main_toolbar, toolbar_actions) self.connect(self._menage, SIGNAL('changed()'), self.changed_bareme) self.connect(self._parametres, SIGNAL('changed()'), self.changed_param) self.connect(self._aggregate_output, SIGNAL('calculated()'), self.calculated) self.connect(self._calibration, SIGNAL('param_or_margins_changed()'), self.param_or_margins_changed) self.connect(self._calibration, SIGNAL('calibrated()'), self.calibrated) # Window settings self.splash.showMessage("Restoring settings...", Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.black)) settings = QSettings() size = settings.value('MainWindow/Size', QVariant(QSize(800,600))).toSize() self.resize(size) position = settings.value('MainWindow/Position', QVariant(QPoint(0,0))).toPoint() self.move(position) self.restoreState(settings.value("MainWindow/State").toByteArray()) self.splash.showMessage("Loading survey data...", Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.black)) self.enable_aggregate(True) self.enable_calibration(True) self.refresh_bareme() self.isLoaded = True self.splash.hide() def create_toolbar(self, title, object_name, iconsize=24): toolbar = self.addToolBar(title) toolbar.setObjectName(object_name) toolbar.setIconSize( QSize(iconsize, iconsize) ) return toolbar def create_dockwidgets(self): # Création des dockwidgets self._parametres = ParamWidget('data/param.xml', self) self._menage = ScenarioWidget(self.scenario, self) self._graph = Graph(self) self._table = OutTable(self) self._aggregate_output = AggregateOutputWidget(self) self._calibration = CalibrationWidget(self) self._dataframe_widget = DataFrameDock(self) def populate_mainwidow(self): self.addDockWidget(Qt.RightDockWidgetArea, self._parametres) self.addDockWidget(Qt.RightDockWidgetArea, self._menage) self.addDockWidget(Qt.LeftDockWidgetArea, self._graph) self.addDockWidget(Qt.LeftDockWidgetArea, self._table) self.addDockWidget(Qt.LeftDockWidgetArea, self._aggregate_output) self.addDockWidget(Qt.LeftDockWidgetArea, self._calibration) self.addDockWidget(Qt.LeftDockWidgetArea, self._dataframe_widget) self.tabifyDockWidget(self._dataframe_widget, self._aggregate_output) self.tabifyDockWidget(self._aggregate_output, self._calibration) self.tabifyDockWidget(self._calibration, self._table) self.tabifyDockWidget(self._table, self._graph) def global_callback(self): """Global callback""" widget = QApplication.focusWidget() action = self.sender() callback = unicode(action.data().toString()) if hasattr(widget, callback): getattr(widget, callback)() def load_survey_data(self): QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) try: # liberate some memory before loading new data self.reset_aggregate() gc.collect() fname = CONF.get('paths', 'survey_data_file') self.survey = DataTable(InputTable, survey_data = fname) self._dataframe_widget.set_dataframe(self.survey.table) return True except Exception, e: self.aggregate_enabled = False QMessageBox.warning(self, u"Impossible de lire les données", u"OpenFisca n'a pas réussi à lire les données d'enquête et passe en mode barème. L'erreur suivante a été renvoyé:\n%s\n\nVous pouvez charger des nouvelles données d'enquête dans Fichier>Paramètres>Chemins>Données d'enquête"%e) return False finally:
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 main(): if platform.system() == "Windows": print "Running on Windows" # On Windows, redirect stderr to a file import imp, ctypes if (hasattr(sys, "frozen") or # new py2exe hasattr(sys, "importers") or # old py2exe imp.is_frozen("__main__")): # tools/freeze sys.stderr = open(os.path.expanduser("~/friture.exe.log"), "w") # set the App ID for Windows 7 to properly display the icon in the # taskbar. myappid = 'Friture.Friture.Friture.current' # arbitrary string try: ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID( myappid) except: print "Could not set the app model ID. If the plaftorm is older than Windows 7, this is normal." app = QApplication(sys.argv) # Splash screen pixmap = QPixmap(":/images/splash.png") splash = QSplashScreen(pixmap) splash.show() splash.showMessage("Initializing the audio subsystem") app.processEvents() # Set the separator stylesheet here # As of Qt 4.6, separator width is not handled correctly # when the stylesheet is applied directly to the QMainWindow instance. # QtCreator workarounds it with a "minisplitter" special class app.setStyleSheet(STYLESHEET) # Logger class logger = Logger() window = Friture(logger) window.show() splash.finish(window) profile = "no" # "python" or "kcachegrind" or anything else to disable if len(sys.argv) > 1: if sys.argv[1] == "--python": profile = "python" #elif sys.argv[1] == "--kcachegrind": #profile = "kcachegrind" elif sys.argv[1] == "--no": profile = "no" else: print "command-line arguments (%s) not recognized" % sys.argv[1:] if profile == "python": import cProfile import pstats cProfile.runctx('app.exec_()', globals(), locals(), filename="friture.cprof") stats = pstats.Stats("friture.cprof") stats.strip_dirs().sort_stats('time').print_stats(20) stats.strip_dirs().sort_stats('cumulative').print_stats(20) sys.exit(0) #elif profile == "kcachegrind": #import cProfile #import lsprofcalltree #p = cProfile.Profile() #p.run('app.exec_()') #k = lsprofcalltree.KCacheGrind(p) #data = open('cachegrind.out.00000', 'wb') #k.output(data) #data.close() ## alternative code with pyprof2calltree instead of lsprofcalltree ##import pyprof2calltree ##pyprof2calltree.convert(p.getstats(), "cachegrind.out.00000") # save #sys.exit(0) else: sys.exit(app.exec_())
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 GmGui import GmApp from PyQt4.QtGui import QApplication, QSplashScreen, QPixmap from sys import argv from time import sleep if __name__ == "__main__": app = QApplication(argv) splash = QSplashScreen(QPixmap("g-square.png")) splash.show() GuloMail = GmApp() #sleep(3) splash.finish(GuloMail) GuloMail.show() app.exec_()