hephy-dd / comet

COMET - Control and Measurement Toolkit
GNU General Public License v3.0
2 stars 2 forks source link

Custom UI #3

Closed arnobaer closed 4 years ago

arnobaer commented 4 years ago

Create simple custom UI classes to wrap PyQt5 widgets to provide an easy way to create COMET dashboards.

A bit like a simplified version of Plotly's Dash Python framework.

import comet

app = comet.Application(name='sample')
app.layout = comet.Row(
    comet.Plot(id='plot'),
    comet.Column(
        comet.Button(id='reset', text='Reset'),
        comet.Button(id='clear', text='Clear')
    )
)

@comet.event('refresh', 'clicked')
def refresh(event):
    app.get('plot').reset()
@comet.event('clear', 'clicked')
def clear(event):
    app.get('plot').clear()

app.run()
arnobaer commented 4 years ago

refactored UI components cc63b3054ca6eab299d2abbd384a9f220daf67e5

arnobaer commented 4 years ago

Updated event handling approach by callbacks for UI elements.

import comet

app = comet.Application()
app.title = "Sample"
app.layout = comet.Row(
    comet.Plot(id="plot", axes={...}, series={...}),
    comet.Column(
        comet.Button(id="refresh", text="Refresh", click=lambda e: app.get("plot").reset()),
        comet.Button(id="clear", text="Clear", click=lambda e: app.get("plot").clear())
    )
)
app.run()