Skip to content

Instantly share code, notes, and snippets.

@cryzed
Created October 1, 2018 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cryzed/89a4f43e13853946282f83021a945a7e to your computer and use it in GitHub Desktop.
Save cryzed/89a4f43e13853946282f83021a945a7e to your computer and use it in GitHub Desktop.
import argparse
import os
import enaml
from enaml.qt.qt_application import QtApplication
from enaml.widgets.api import Action
from folder_model import ImageFolder
argument_parser = argparse.ArgumentParser()
argument_parser.add_argument('source', nargs='?', default=os.getcwd())
def qt_bind_child_actions(parent):
for action in (child for child in parent.children if isinstance(child, Action)):
parent.proxy.widget.addAction(action.proxy.widget)
def main(arguments):
with enaml.imports():
from main_view import MainWindow
app = QtApplication()
view = MainWindow(folder=ImageFolder(path=os.path.abspath(arguments.source)))
view.show()
# Bind Action elements that are not part of a Menu/Toolbar to the MainWindow, so they can be triggered even if the
# status- & menubar are hidden (hack)
qt_bind_child_actions(view)
app.start()
if __name__ == '__main__':
arguments = argument_parser.parse_args()
argument_parser.exit(main(arguments))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment