Esempio n. 1
0
 def welcome(self):
     # the overall frame
     frame = lc.frame(title='my application')
     # a document in the frame
     doc = frame.document(title='Hello world!', id='doc1')
     # a button in the document
     b = lc.button(label='click me to show an alert'); doc.add(b)
     b.onclick = lc.alert('clicked!')
     # another button
     b2 = lc.button(label='click me to add a new paragraph'); doc.add(b2)
     b2.onclick = lc.load(routine='onbutton2')
     # weave to produce html
     return self.weaver.weave(frame)
Esempio n. 2
0
def qedialog(title, text, Class="qe-dialog-output"):
    "Returns the dialog widget"
    dialog = lc.dialog(title=title, autoopen=True, Class=Class)
    dialog.add(text)  # Text
    okbutton = lc.button(label='OK', onclick=select(element=dialog).destroy())
    dialog.add(okbutton)
    return dialog
Esempio n. 3
0
def configuration_wizard(experiment):
    doc = lc.document(
        title='Configuration wizard for ARCS_beam',
        id='instrument-configuration-wizard',
    )

    # button to skip this wizard
    from . import load_manual_instrument_configuration
    load_manual_configuration = load_manual_instrument_configuration(
        experiment.id)
    skip_button = lc.button(
        label='skip this wizard',
        onclick=select(element=doc).replaceBy(load_manual_configuration),
    )
    doc.add(skip_button)

    # wizard
    form = doc.form(id='arcs-beam-wizard')
    form.text(name='fermi_nu', label='Fermi chopper frequency (Hz)', value=600)
    # form.text(name='fermi_bladeradius', label = 'Fermi choipper blade radius (meter)', value=0.060364)
    form.text(name='T0_nu', label='T0 chopper frequency (Hz)', value=120)
    form.text(name='E', label='Desired incident energy (meV)', value=100)
    form.text(name='emission_time',
              label='Emission time (microsecond)',
              value=10)
    form.submitbutton()
    form.onsubmit = select(element=form).submit(
        actor='neutronexperiment/edit/ARCS_beam_wizard',
        experiment_id=experiment.id)

    return doc
def configuration_wizard(experiment):
    doc = lc.document(
        title='Configuration wizard for ARCS_beam',
        id='instrument-configuration-wizard',
        )

    # button to skip this wizard
    from . import load_manual_instrument_configuration
    load_manual_configuration = load_manual_instrument_configuration(experiment.id)
    skip_button = lc.button(
        label='skip this wizard',
        onclick=select(element=doc).replaceBy(load_manual_configuration),
        )
    doc.add(skip_button)

    # wizard
    form = doc.form(id='arcs-beam-wizard')
    form.text(name='fermi_nu', label = 'Fermi chopper frequency (Hz)', value=600)
    # form.text(name='fermi_bladeradius', label = 'Fermi choipper blade radius (meter)', value=0.060364)
    form.text(name='T0_nu', label = 'T0 chopper frequency (Hz)', value=120)
    form.text(name='E', label = 'Desired incident energy (meV)', value=100)
    form.text(name='emission_time', label = 'Emission time (microsecond)', value=10)
    form.submitbutton()
    form.onsubmit = select(element=form).submit(
        actor='neutronexperiment/edit/ARCS_beam_withmonitor2_wizard',
        experiment_id = experiment.id)
    
    return doc
Esempio n. 5
0
def qedialog(title, text, Class="qe-dialog-output"):
    "Returns the dialog widget"
    dialog  = lc.dialog(title=title, autoopen=True, Class=Class)
    dialog.add(text)   # Text
    okbutton = lc.button( label     = 'OK',
                          onclick   = select(element=dialog).destroy())
    dialog.add(okbutton)
    return dialog
Esempio n. 6
0
def visual(
    instrument=None,
    components=[], refresh_component_configuration_panel=None, component_in_focus=None,
    actorname = None,
    db = None,
    director = None,
    ):
    """
    instrument: id of the instrument which has the component chain
    components: list of component instances
    refresh_component_configuration_panel: action factory that creates an action to refresh component configuration panel give the component. sth like lambda component: ... some action ...
    component_in_focus: the component that is now being focused
    actorname: the actor to deal with events for this visual
    db: db manager
    """
    
    doc = lc.document(id='component-chain-container', title='Component chain')
    sp = doc.splitter(id='component-chain')

    # ids of components
    ids = [c.id for c in components]

    # ids of buttons for components
    buttonids = [button_id_formatter_for_component % id for id in ids]

    # ids of insert buttons for components
    insertbuttonids = [button_id_formatter_for_insert_before % id for id in ids]
        
    for component in components:
        compuid = db.getUniqueIdentifierStr(component)
            
        # button to insert before a component
        insertbuttoncontainer = sp.section()
        insertbutton = lc.button(id=button_id_formatter_for_insert_before%component.id)
        insertbuttoncontainer.add(insertbutton)
        insertbutton.Class='component-chain-insert-button'
        insertbutton.label = '==>'
        insertbutton.tip = 'click to insert component'
        insertbutton.onclick = load(
            actor=actorname, routine='onInsertComponent',
            id = instrument, before=compuid)

        # "button" of a comonent
        infocus = component_in_focus.id == component.id
        refresh_config_panel = refresh_component_configuration_panel(component)
        button = createComponentButton(
            component, 
            infocus=infocus, 
            buttonids = buttonids,
            refresh_config_panel = refresh_config_panel,
            )
        sp.section().add(button)
        continue

    # button to append before a component
    appendbuttoncontainer = sp.section()
    appendbutton = lc.button(id='append-component')
    appendbuttoncontainer.add(appendbutton)
    appendbutton.Class='component-chain-insert-button'
    appendbutton.label = '==>'
    appendbutton.tip = 'click to append component'
    appendbutton.onclick = load(
        actor=actorname, routine='onAppendComponent',
        id = instrument)

    return doc