Example #1
0
def start_qt(factory, node):
    """ Start Qt, and open widget of factory, node

    :param factory: todo
    :param node: todo

    """

    from openalea.vpltk.qt import QtGui, QtCore

    app = QtGui.QApplication(sys.argv)

    # CTRL+C binding
    import signal
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    dialog = QtGui.QDialog()
    widget = factory.instantiate_widget(node, autonomous=True)

    dialog.setAttribute(QtCore.Qt.WA_DeleteOnClose)
    widget.setParent(dialog)

    vboxlayout = QtGui.QVBoxLayout(dialog)
    vboxlayout.setContentsMargins(3, 3, 3, 3)
    vboxlayout.setSpacing(5)
    vboxlayout.addWidget(widget)

    dialog.setWindowTitle(factory.name)
    dialog.show()

    app.exec_()
Example #2
0
def main():
    """ editor as an executable program """
    ## sys.argv to load dataset file?
    from optparse import OptionParser

    parser = OptionParser()
    parser.add_option("-d",
                      "--dataset",
                      dest='dataset',
                      help="*.ini dataset file to load")
    parser.add_option("-i",
                      "--image",
                      dest='image',
                      help="image file to import")

    options, args = parser.parse_args()

    qapp = QtGui.QApplication([])
    viewer = RhizoScanEditor()
    viewer.setWindowTitle("RootEditor")

    if options.dataset: viewer.editor.load_dataset(options.dataset)
    if options.image: viewer.editor.import_image(options.image)

    qapp.exec_()
Example #3
0
def main():
    """the main program, here we create a NurbsPatchEditor and make it draw itself"""
    qapp = QtGui.QApplication([])
    viewer = NurbsPatchEditor(None)
    viewer.setWindowTitle("NurbsPatchEditor")
    viewer.show()
    qapp.exec_()
Example #4
0
def main():
    import sys
    from openalea.oalab.shell import get_shell_class
    from openalea.core.service.ipython import interpreter
    from openalea.oalab.editor.highlight import Highlighter
    app = QtGui.QApplication(sys.argv)

    edit = TextEditor()
    Highlighter(edit)
    interp = interpreter()
    shell = get_shell_class()(interp)

    win = QtGui.QMainWindow()
    win.setCentralWidget(edit)

    dock_widget = QtGui.QDockWidget("IPython", win)
    interp.locals['mainwindow'] = win
    interp.locals['editor'] = edit
    interp.locals['shell'] = shell
    interp.locals['interpreter'] = interp

    dock_widget.setWidget(shell)
    win.addDockWidget(QtCore.Qt.BottomDockWidgetArea, dock_widget)

    win.show()
    win.raise_()
    app.exec_()
Example #5
0
def main():
    import sys
    app = QtGui.QApplication(sys.argv)

    from openalea.oalab.world import World

    world = World()
    world["obj1"] = "plop"
    world["obj2"] = "plop2"

    obj1 = world["obj1"]
    obj2 = world["obj2"]

    obj1.set_attribute('a1', 1, 'IInt')
    obj1.set_attribute('a2', True, 'IBool')

    obj2.set_attribute('b1', 2.34, 'IFloat')

    wid1 = WorldControlPanel(style=WorldControlPanel.StylePanel)
    wid1.set_world(world)
    wid1.show()

    wid2 = WorldControlPanel(style=WorldControlPanel.StyleTableView)
    wid2.set_world(world)
    wid2.show()

    app.exec_()
Example #6
0
def main():
    from openalea.vpltk.qt import QtCore, QtGui
    from openalea.core.service.ipython import interpreter as interpreter_
    from openalea.oalab.shell import ShellWidget
    import sys

    app = QtGui.QApplication(sys.argv)

    history = HistoryWidget()
    # Set interpreter
    interpreter = interpreter_()

    interpreter.user_ns['interp'] = interpreter
    interpreter.user_ns['hist'] = history
    # Set Shell Widget
    shellwdgt = ShellWidget(interpreter)

    mainWindow = QtGui.QMainWindow()

    dock_widget = QtGui.QDockWidget("shell", mainWindow)
    dock_widget.setWidget(shellwdgt)

    mainWindow.setCentralWidget(history)
    mainWindow.addDockWidget(QtCore.Qt.BottomDockWidgetArea, dock_widget)
    mainWindow.show()

    app.exec_()
Example #7
0
 def doit(self):
     app = QtGui.QApplication([])
     # self.widget = MyWidget()
     # self.widget.show()
     pgl.Viewer.start()
     self.start()
     app.exec_()
Example #8
0
def main():
    import sys

    app = QtGui.QApplication(sys.argv)
    selector = ProjectExplorer()
    selector.show()
    app.exec_()
Example #9
0
 def run(self):
     app = QtGui.QApplication([])
     while not self.mutex.tryLock():
         pass
     self.mutex.unlock()
     self.waitcondition.wakeAll()
     print 'app.exec()'
     app.exec_()
Example #10
0
def show_plugins(group="oalab.applet"):
    import sys

    app = QtGui.QApplication(sys.argv)

    plugin_selector = PluginExplorer()
    plugin_selector.show()

    app.exec_()
Example #11
0
def main():
    """
    1. Parse command line arguments.
    2. If GUI enabled (session.gui), launch QApplication
    3. Search an extension in "oalab.extension" plugins.
        - If found, launch extension
        - If not found, quit application and shows available extensions
    """
    class Session(object):
        pass

    session = Session()
    cli = CommandLineParser(session=session)
    cli.parse()

    if session.gui:
        from openalea.vpltk.qt import QtGui
        from openalea.core.settings import get_openalea_home_dir
        from openalea.core.path import path as Path

        app = QtGui.QApplication(sys.argv)

        win = None
        # Run all extension matching session.extension
        available_extensions = []

        for plugin_class in plugins('oalab.lab'):
            try:
                ext = plugin_class.name
            except AttributeError:
                continue
            else:
                # register plugin info for user.
                args = dict(EXT=ext,
                            MODULE=plugin_class.__module__,
                            CLASS=plugin_class.__name__)
                text = '  - \033[94m%(EXT)s\033[0m (provided by class %(CLASS)s defined in %(MODULE)s)' % args
                available_extensions.append(text)

            if session.extension == ext:
                win = launch_lab(plugin_class)
                break

        if win is None:
            from openalea.oalab.gui.pluginselector import select_plugin
            plugin_class = select_plugin('oalab.lab',
                                         size=(400, 10),
                                         title='Select a Laboratory')
            if plugin_class:
                win = launch_lab(plugin_class)

        if win:
            app.exec_()
        else:
            print 'Extension %r not found' % session.extension
            print 'Please choose a valid \033[94mextension\033[0m:'
            print '\n'.join(available_extensions)
Example #12
0
def main():
    app = QtGui.QApplication(sys.argv)

    project_manager = ProjectManager()
    project_manager.discover()
    scroll = ProjectSelectorScroll(project_manager.projects)

    # Display
    scroll.show()
    app.exec_()
Example #13
0
    def init(self):
        self._pause = False
        self._duration = 0
        self.instance = QtGui.QApplication.instance()
        if self.instance is None:
            self.app = QtGui.QApplication([])
        else:
            self.app = self.instance

        self.widget = None
Example #14
0
 def run(self):
     app = QtGui.QApplication([])
     while not self.mutex.tryLock():
         pass
     self.mutex.unlock()
     self.waitcondition.wakeAll()
     pgl.Viewer.threaded = False
     pgl.Viewer.start()
     print "execute"
     QtCore.QThread.exec_(self)
     self.endwaitcondition.wakeAll()
Example #15
0
def main():
    import sys
    app = QtGui.QApplication(sys.argv)
    win = PreferenceWidget()
    win.show()

    # PreferenceWidget.hidden_sections = []
    # win2 = PreferenceWidget()
    # win2.show()

    win.raise_()
    app.exec_()
Example #16
0
def main():
    app = QtGui.QApplication(sys.argv)

    a = dict()
    a[""] = None
    a["plop"] = 1
    a["yep"] = 2
    a["test"] = 3
    a["g"] = 4

    wid = InAndOutModel(a)
    wid.show()
    app.exec_()
Example #17
0
def main():
    """
    1. Parse command line arguments.
    2. If GUI enabled (session.gui), launch QApplication
    3. Search an extension in "oalab.extension" plugins.
        - If found, launch extension
        - If not found, quit application and shows available extensions
    """

    create_project_shortcut()
    session = Session()
    cli = CommandLineParser(session=session)
    cli.parse()

    if session.gui:
        from openalea.vpltk.qt import QtGui
        from openalea.oalab.gui.mainwindow import MainWindow

        app = QtGui.QApplication(sys.argv)

        win = None
        # Run all extension matching session.extension
        available_extensions = []

        if session.extension == '':
            session.extension = 'plant'
        for plugin_class in plugins('oalab.lab'):
            try:
                ext = plugin_class.name
            except AttributeError:
                continue
            else:
                # register plugin info for user.
                args = dict(EXT=ext, MODULE=plugin_class.__module__, CLASS=plugin_class.__name__)
                text = '  - \033[94m%(EXT)s\033[0m (provided by class %(CLASS)s defined in %(MODULE)s)' % args
                available_extensions.append(text)

            if session.extension == ext:
                plugin = plugin_class()
                win = MainWindow(session)
                debug_plugin('oalab.lab', func=plugin, func_args=[win])
                win.show()
                win.raise_()
                break

        if win:
            app.exec_()
        else:
            print 'Extension %r not found' % session.extension
            print 'Please choose a valid \033[94mextension\033[0m:'
            print '\n'.join(available_extensions)
Example #18
0
def main():
    import sys

    app = QtGui.QApplication(sys.argv)
#     pm = ProjectManager()
#     pm.discover()
#     proj = pm.load('Koch')
    proj = None
    widg = CreateProjectWidget(proj)
    widg.show()
    app.exec_()
    project = widg.project()
    print project
    for k, v in project.metadata.iteritems():
        print '    - %s: %s' % (k, v)
Example #19
0
def main():
    # Test the widget independently.
    a = QtGui.QApplication(sys.argv)

    # Restore default signal handler for CTRL+C
    import signal; signal.signal(signal.SIGINT, signal.SIG_DFL)

    shellclass = get_shell_class()
    interpreterclass = get_interpreter_class()

    ipyinterpreter = interpreterclass()
    aw = shellclass(ipyinterpreter)

    # static resize
    aw.resize(600, 400)

    aw.show()
    a.exec_()
Example #20
0
def main():
    from openalea.vpltk.qt import QtGui
    import sys

    app = QtGui.QApplication(sys.argv)

    from openalea.core.service.ipython import interpreter
    interpreter = interpreter()

    interpreter.user_ns['interp'] = interpreter
    # Set Shell Widget
    shellwdgt = ShellWidget(interpreter=interpreter)
    interpreter.user_ns['shell'] = shellwdgt

    mainWindow = QtGui.QMainWindow()
    mainWindow.setCentralWidget(shellwdgt)
    mainWindow.show()

    app.exec_()
Example #21
0
def main():
    from openalea.core.project.manager import ProjectManager
    import sys

    app = QtGui.QApplication(sys.argv)

    tabwidget = QtGui.QTabWidget()

    project_manager = ProjectManager()
    project_manager.discover()

    projects = project_manager.projects
    for project in projects:
        # Create widget
        preview_widget = Preview(project)
        tabwidget.addTab(preview_widget, project.name)

    # Display
    tabwidget.show()
    app.exec_()
Example #22
0
def main():
    import sys
    from openalea.vpltk.qt import QtGui
    from openalea.core.service.ipython import interpreter
    from openalea.oalab.shell import ShellWidget

    # Create Window with IPython shell
    app = QtGui.QApplication(sys.argv)
    interp = interpreter()
    shellwdgt = ShellWidget(interp)
    mainWindow = QtGui.QMainWindow()
    mainWindow.setCentralWidget(shellwdgt)
    mainWindow.show()

    # Create Project Manager
    pm = ProjectManager()

    # Create or load project
    name = "project_test"
    pm.load(name)

    app.exec_()
Example #23
0

def disp_controls():
    cm = ControlManager()
    import sys
    for k, v in cm.namespace().items():
        print >> sys.__stdout__, k, v


if __name__ == '__main__':

    from openalea.oalab.gui.splittablewindow import TestMainWin
    instance = QtGui.QApplication.instance()

    if instance is None:
        app = QtGui.QApplication([])
    else:
        app = instance

    tests = [
        test_all_interfaces,
        test_all_lpy_controls,
        disp_controls,
        sample_controls
    ]

    layout = ({0: [1, 2]},
              {0: None, 1: 0, 2: 0},
              {0: {'amount': 0.4619140625, 'splitDirection': 1},
               1: {'widget': {'position': 0, 'applet': [u'ControlManager']}},
               2: {'widget': {'position': 0, 'applet': [u'ShellWidget']}}})
Example #24
0

def out_of_date(original, derived):
    """
    Returns True if derivative is out-of-date wrt original,
    both of which are full file paths.
    """
    return (not os.path.exists(derived)
            or (os.path.exists(original)
                and os.stat(derived).st_mtime < os.stat(original).st_mtime))


from openalea.vpltk.qt import QtCore, QtGui
from openalea.visualea.dataflowview import GraphicalGraph
# create the application only once!
app = QtGui.QApplication.instance() or QtGui.QApplication([])
# start the package manager
pm = PackageManager(verbose=False)
pm.init()


class DataflowRenderer(QtCore.QObject):
    def __init__(self,
                 plot_path,
                 package_name,
                 node_name,
                 basename,
                 tmpdir,
                 destdir,
                 options,
                 parent=None):
Example #25
0
            elif val > max_:
                val = max_
            fix(val)
            return pt

        ##############################
        # Qt Event reimplementations #
        ##############################
        def paintEvent(self, event):
            # -- Required for stylesheets to work. Search for QWidget here:
            # http://doc.qt.nokia.com/latest/stylesheet-reference.html --
            QStyle = QtGui.QStyle
            opt = QtGui.QStyleOption()
            opt.initFrom(self)
            painter = QtGui.QPainter(self)
            self.style().drawPrimitive(QStyle.PE_Widget, opt, painter, self)

    ###################################################################################
    # /end Inner classes not meant to be seen by others - Inner classes not meant to  #
    ###################################################################################


# Small testing example
if __name__ == "__main__":
    app = QtGui.QApplication(["Muahaha"])
    mw = QtGui.QMainWindow()
    splittable = SplittableUI(parent=mw)
    mw.setCentralWidget(splittable)
    mw.show()
    app.exec_()
Example #26
0
def main():
    app = QtGui.QApplication(sys.argv)

    wid = FileBrowser()
    wid.show()
    app.exec_()
Example #27
0
def main(args):
    app = QtGui.QApplication(args)
    QtGui.QApplication.processEvents()
    win = MainWindow()
    win.show()
    return app.exec_()
Example #28
0
    def properties(self):
        return dict(style=0)

    def set_properties(self, properties):
        get = properties.get
        style = get('style', 0)


if __name__ == '__main__':

    import sys
    from openalea.vpltk.qt import QtGui

    instance = QtGui.QApplication.instance()
    if instance is None:
        qapp = QtGui.QApplication(sys.argv)
    else:
        qapp = instance

    # Example: create a panel with one group containing 1 big and 3 small buttons
    menu = PanedMenu()

    act0 = QtGui.QAction(u'Action', menu)
    act1 = QtGui.QAction(u'act 1', menu)
    act2 = QtGui.QAction(u'act 2', menu)
    act3 = QtGui.QAction(u'act 3', menu)

    menu.addBtnByAction('Panel', 'group', act0, PanedMenu.BigButton)
    menu.addBtnByAction('Panel', 'group', act1, PanedMenu.SmallButton)
    menu.addBtnByAction('Panel', 'group', act2, PanedMenu.SmallButton)
    menu.addBtnByAction('Panel', 'group', act3, PanedMenu.SmallButton)
Example #29
0
def main():
    app = QtGui.QApplication(sys.argv)
    view = view3D()
    view.addToScene(Sphere())
    view.start()
    app.exec_()