Last active
December 6, 2018 16:51
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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