Created
October 1, 2018 22:02
-
-
Save cryzed/89a4f43e13853946282f83021a945a7e to your computer and use it in GitHub Desktop.
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 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