Skip to content

Instantly share code, notes, and snippets.

@eirenik0
Last active December 6, 2018 16:51
Show Gist options
  • Save eirenik0/c1fd2198f6c63586782f0d36854aa7ba to your computer and use it in GitHub Desktop.
Save eirenik0/c1fd2198f6c63586782f0d36854aa7ba to your computer and use it in GitHub Desktop.
Combine https://github.com/mherrmann/fbs/ build tool with https://github.com/nucleic/enaml/ for building Desktop applications smoothly
import sys
import enaml
from enaml.qt.qt_application import QtApplication
from fbs_runtime.application_context import ApplicationContext, cached_property
from hstatus import ModemInfoUpdater
class CustomQtApplication(QtApplication):
"""Redirect from Enaml QtApplication to origin one.
Required by ApplicationContext"""
def __getattr__(self, item):
return getattr(self._qapp, item)
class AppContext(ApplicationContext):
@cached_property
def app(self):
return CustomQtApplication()
def run(self): # 2. Implement run()
with enaml.imports():
from views import ModemInfoView
mi_updater = ModemInfoUpdater().build()
view = ModemInfoView(mi_updater=mi_updater)
view.show()
return self.app.exec_()
if __name__ == '__main__':
appctxt = AppContext()
exit_code = appctxt.run()
sys.exit(exit_code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment