Example #1
0
def ask_a_question():
    app = QtWidgets.QApplication(sys.argv)
    resources.init()

    if dialogs.ask('Are you okay?', 'seriously', 'AYO'):
        print('YAY!')
    sys.exit()
Example #2
0
def show_action_forms():
    # configure bands
    import bands

    class LoggingDispatcher(bands.Dispatcher):
        def __init__(self, name):
            self.name = name

        def dispatch(self, identifier, receiver, *args, **kwargs):
            print(self.name + '> Sending %s to %s' % (identifier, receiver))
            return receiver(*args, **kwargs)

    bands.get_band().dispatcher = LoggingDispatcher('bands')

    # configure construct
    construct.init()
    workspace = construct.search(tags=['workspace']).one()
    construct.set_context_from_entry(workspace)

    # configure qapp with dynamic stylesheet
    app = QtWidgets.QApplication(sys.argv)
    resources.init()
    apply_style(app, ':/styles/dark')

    # Show some forms
    form = form_for_action('file.open')
    apply_style(form, ':/styles/dark')
    form.exec_()

    form = form_for_action('file.save')
    apply_style(form, ':/styles/dark')
    form.show()

    # Wait for app loop to finish and exit
    sys.exit(app.exec_())
Example #3
0
def show_frameless_dialog():
    app = QtWidgets.QApplication(sys.argv)
    resources.init()

    dialog = dialogs.FramelessDialog('Hello World')
    apply_style(dialog, ':/styles/dark')

    sys.exit(dialog.exec_())
Example #4
0
def show_collapsable_list():
    app = QtWidgets.QApplication(sys.argv)
    resources.init()

    ls = widgets.CollapsableList('Projects')
    ls.list_widget.addItems(['Project ' + char for char in 'ABCDEFGH'])
    apply_style(ls, ':/styles/dark')
    ls.show()

    sys.exit(app.exec_())
Example #5
0
def get_form(action_identifier, action=None, ctx=None, parent=None):
    '''Return a form instance for an action_identifier.'''

    from construct_ui import resources
    resources.init()

    action = action or actions.get(action_identifier)
    parent = parent or get_host().get_qt_parent()
    ctx = ctx or get_context()

    form_cls = get_form_cls(action_identifier)
    if not form_cls:
        return

    form = form_cls(action, ctx, parent)
    form.setStyleSheet(resources.style(config['STYLE']))
    return form
Example #6
0
def show_header():
    def null():
        print('Action')

    app = QtWidgets.QApplication(sys.argv)
    resources.init()

    dialog = QtWidgets.QDialog()
    apply_style(dialog, ':/styles/dark')

    header = widgets.Header('Hello World!')
    header.add_menu_item('Item 1', null)
    header.add_menu_item('Item 2', null)
    header.add_menu_item('Item 3', null)
    header.add_menu_item('Item 4', null)
    layout = QtWidgets.QVBoxLayout()
    layout.setContentsMargins(0, 0, 0, 0)
    layout.setSpacing(0)
    layout.addWidget(header)
    layout.setAlignment(QtCore.Qt.AlignTop)
    dialog.setLayout(layout)

    sys.exit(dialog.exec_())
def setup():
    _log.debug('Configuring Construct for Maya!')
    construct.init()
    resources.init()

    ctx = construct.get_context()
    host = construct.get_host()
    if ctx.workspace:
        _log.debug('Setting workspace to ' + ctx.workspace.path)
        host.set_workspace(ctx.workspace.path)

    _log.debug('Registering callbacks...')
    callbacks.register()

    _log.debug('Creating Construct menu...')
    menus.ConstructMenu.setup()

    if ctx.workspace and not host.get_filename():
        if ctx.workspace.get_work_files():
            action_identifier = 'file.open'
        else:
            action_identifier = 'file.save'

        construct.show_form(action_identifier)
Example #8
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import logging

import construct
from construct_hou import callbacks, utils
from construct_ui import resources

_log = logging.getLogger('construct.hou.pythonrc')
construct.init()
resources.init()
ctx = construct.get_context()
host = construct.get_host()

_log.debug('Setting workspace: %s' % ctx.workspace.path)
host.set_workspace(ctx.workspace.path)

_log.debug('Registering callbacks')
callbacks.register()

_log.debug('Creating Construct menu...')
# TODO

if utils.show_file_open_at_startup():
    # TODO: Add abstraction around creating ActionForms
    if ctx.workspace and not host.get_filename():
        action = construct.actions.get('file.open')
        parent = host.get_qt_parent()
        form_cls = construct.show_form(action.identifier)