def __init__(self): # Initialize app = QApplication(sys.argv) app.setApplicationName("eKalappai") app.setApplicationVersion("4.0.0") shared = QSharedMemory("59698760-43bb-44d9-8121-181ecbb70e4d") # Check if already another instance of app is running and quit if it is if not shared.create(512, QSharedMemory.ReadWrite): qWarning("Cannot start more than one instance of eKalappai any time.") exit(0) # Splash Screen init splashImage = QPixmap(':intro/splash_screen') splashScreen = QSplashScreen(splashImage) splashScreen.show() # Time wait for splash screen to be shown time.sleep(2) splashScreen.hide() # Main application starting QApplication.setQuitOnLastWindowClosed(False) ekWindow = EKWindow(app) # EK Engine start ekWindow.engine.start() sys.exit(app.exec_())
def __init__(self): app = QApplication(sys.argv) app.setApplicationName("eKalappai") app.setApplicationVersion("4.0.0") shared = QSharedMemory("59698760-43bb-44d9-8121-181ecbb70e4d") if not shared.create(512, QSharedMemory.ReadWrite): qWarning("Cannot start more than one instance of eKalappai any time.") exit(0) splashImage = QPixmap(':intro/splash_screen') splashScreen = QSplashScreen(splashImage) splashScreen.show() time.sleep(2) splashScreen.hide() QApplication.setQuitOnLastWindowClosed(False) ekWindow = EKWindow() ekWindow.engine.start() sys.exit(app.exec_())
class MemoryCondition: def __init__(self, key='memory_condition_key'): self._shm = QSharedMemory(key) if not self._shm.attach(): if not self._shm.create(1): raise RuntimeError('error creating shared memory: %s' % self._shm.errorString()) self.condition = False def __enter__(self): self._shm.lock() if self._shm.data()[0] == b'\x00': self.condition = True self._shm.data()[0] = b'\x01' self._shm.unlock() return self.condition def __exit__(self, exc_type, exc_value, traceback): if self.condition: self._shm.lock() self._shm.data()[0] = b'\x00' self._shm.unlock()
elif self.iniSettings.value("shortcut_modifier") == "CTRL": self.engine.event_queue.register_event([['Lcontrol', self.shortcutKey], self.icon_activated, QSystemTrayIcon.Trigger]) self.engine.event_queue.register_event([['Rcontrol', self.shortcutKey], self.icon_activated, QSystemTrayIcon.Trigger]) elif self.iniSettings.value("shortcut_modifier") == "ALT": self.engine.event_queue.register_event([['LMenu', self.shortcutKey], self.icon_activated, QSystemTrayIcon.Trigger]) self.engine.event_queue.register_event([['RMenu', self.shortcutKey], self.icon_activated, QSystemTrayIcon.Trigger]) return True if __name__ == "__main__": """ Main Function which will initialize the app """ app = QApplication(sys.argv) app.setApplicationName("eKalappai") app.setApplicationVersion("4.0.0") shared = QSharedMemory("59698760-43bb-44d9-8121-181ecbb70e4d") if not shared.create(512, QSharedMemory.ReadWrite): qWarning("Cannot start more than one instance of eKalappai any time.") exit(0) splashImage = QPixmap(':/images/intro.png') splashScreen = QSplashScreen(splashImage) splashScreen.show() time.sleep(2) splashScreen.hide() QApplication.setQuitOnLastWindowClosed(False) ekWindow = EKWindow() ekWindow.engine.start() sys.exit(app.exec_())