def main(): """ entry point for the pyfda application see http://pyqt.sourceforge.net/Docs/PyQt4/qapplication.html : "For any GUI application using Qt, there is precisely *one* QApplication object, no matter whether the application has 0, 1, 2 or more windows at any given time. ... Since the QApplication object does so much initialization, it must be created *before* any other objects related to the user interface are created." """ # instantiate QApplication object, passing command line arguments if len(rc.qss_rc) > 20: app = QApplication(sys.argv) app.setStyleSheet(rc.qss_rc) # this is a proper style sheet style = "Using 'pyfda' style sheet." else: qstyle = QApplication.setStyle( rc.qss_rc) # no, this is just a name for a system stylesheet app = QApplication(sys.argv) if qstyle: style = 'Using system style "{0}".'.format(rc.qss_rc) else: style = 'Style "{0}" not found, falling back to default style.'.format( rc.qss_rc) app.setWindowIcon(QIcon(':/pyfda_icon.svg')) mainw = pyFDA() logger.info("Logging to {0}".format(dirs.LOG_DIR_FILE)) logger.info(style) # Sets the active window to the active widget in response to a system event. app.setActiveWindow(mainw) mainw.setWindowIcon(QIcon(':/pyfda_icon.svg')) screen_resolution = app.desktop().screenGeometry() screen_h, screen_w = screen_resolution.height(), screen_resolution.width() logger.info("Starting pyfda with screen resolution: %d x %d", screen_w, screen_h) if screen_h < 800: delta = 50 else: delta = 100 # set position + size of main window on desktop mainw.setGeometry(20, 20, screen_w - delta, screen_h - delta) # top L / top R, dx, dy # Give the keyboard input focus to this widget if this widget # or one of its parents is the active window: # mainw.setFocus() mainw.show() #start the application's exec loop, return the exit code to the OS app.exec_() # sys.exit(app.exec_()) and app.exec_() have same behaviour
def main(): """ entry point for the pyfda application see http://pyqt.sourceforge.net/Docs/PyQt4/qapplication.html : "For any GUI application using Qt, there is precisely *one* QApplication object, no matter whether the application has 0, 1, 2 or more windows at any given time. ... Since the QApplication object does so much initialization, it must be created *before* any other objects related to the user interface are created." """ # instantiate QApplication object, passing command line arguments if len(rc.qss_rc) > 20: app = QApplication(sys.argv) app.setStyleSheet(rc.qss_rc) # this is a proper style sheet style = "Using 'pyfda' style sheet." else: qstyle = QApplication.setStyle( rc.qss_rc) # no, this is just a name for a system stylesheet app = QApplication(sys.argv) if qstyle: style = 'Using system style "{0}".'.format(rc.qss_rc) else: style = 'Style "{0}" not found, falling back to default style.'.format( rc.qss_rc) mainw = pyFDA() logger.info("Logging to {0}".format(dirs.LOG_DIR_FILE)) logger.info(style) if dirs.OS.lower() == "windows": # Windows taskbar is not for "Application Windows" but for "Application # User Models", grouping several instances of an application under one # common taskbar icon. Python apps are sometimes grouped under the icon # for Pythonw.exe, sometimes the icon is just blank. The following # instructions tell Windows that pythonw is merely hosting other applications. import ctypes myappid = u'chipmuenk.pyfda.v0.4' ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) # set taskbar icon app.setWindowIcon(QIcon(':/pyfda_icon.svg')) # Sets the active window to the active widget in response to a system event app.setActiveWindow(mainw) # Set default icon for window mainw.setWindowIcon(QIcon(':/pyfda_icon.svg')) screen_resolution = app.desktop().screenGeometry() screen_h, screen_w = screen_resolution.height(), screen_resolution.width() logger.info("Starting pyfda with screen resolution: %d x %d", screen_w, screen_h) if screen_h < 800: delta = 50 else: delta = 100 # set position + size of main window on desktop mainw.setGeometry(20, 20, screen_w - delta, screen_h - delta) # top L / top R, dx, dy # Give the keyboard input focus to this widget if this widget # or one of its parents is the active window: # mainw.setFocus() mainw.show() #start the application's exec loop, return the exit code to the OS app.exec_() # sys.exit(app.exec_()) and app.exec_() have same behaviour