def setLibraryPaths(): """ Module function to set the Qt library paths correctly for windows systems. """ if Utilities.isWindowsPlatform(): libPath = os.path.join(Utilities.getPyQt4ModulesDirectory(), "plugins") if os.path.exists(libPath): libPath = Utilities.fromNativeSeparators(libPath) libraryPaths = QApplication.libraryPaths() if libPath not in libraryPaths: libraryPaths.prepend(libPath) QApplication.setLibraryPaths(libraryPaths)
def start_main(): app = QApplication(sys.argv) icon = QIcon(':/icons/application.png') app.setWindowIcon(icon) # If compiled as a one-file PyInstaller package look for Qt4 Plugins in the TEMP folder. try: extra_path = [os.path.join(sys._MEIPASS, 'qt4_plugins')] app.setLibraryPaths(app.libraryPaths() + extra_path) app.utils_path = os.path.join(sys._MEIPASS, 'utils') except AttributeError: app.utils_path = os.path.join(os.getcwd(), 'utils') # Error handling stuff. if hasattr(sys, 'frozen'): sys.excepthook = except_hook app.setApplicationName('ABBYY Automator') app.setApplicationVersion(VERSION) app.setOrganizationName('Pearl Scan Solutions') print 'AppName: %s' % app.applicationName() print 'AppVersion: %s' % app.applicationVersion() print 'Company Name: %s' % app.organizationName() app.setStyle(QStyleFactory.create('Cleanlooks')) app.setPalette(QApplication.style().standardPalette()) if not instance_check(app): message_box_error('Program already running.', 'You can only have one copy of ABBYY Automator running at once.') sys.exit() mainwindow = MainWindow() mainwindow.show() app.exec_() app.closeAllWindows() app.quit()