-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Qt widget wrapper #480
base: master
Are you sure you want to change the base?
Qt widget wrapper #480
Conversation
With the Widgets one can build a standalone application like (maybe the setting of the asyncio-eventloop is required) from PyQt5.QtGui import QApplication
from concert.devices.samplechangers.dummy import SampleChanger
from concert.gui.parameterizable import ParameterizableWidget
if __name__ == '__main__':
app = QApplication([]) # or args etc.
changer = SampleChanger()
changer_widget = ParameterizableWidget(changer)
changer_widget.show() # or an arbitrary combination in layouts etc.
app.exec() I also wanted to have the possibility to open a Widget from a running concert session. Therefore, I added this manual "qt event loop". The possibility to open a widget in a running session is required, if devices do not allow access from multiple connections (or when parameters/state is handled in concert -> that's why I don't like the So far I wrapped all async slots that qt sees only non-asyncio blocking functions. I didn't test qt-asyncio compatible event loops like asyncqt or quamash with tango etc. But changing the event loop within a running concert session (not a standalone python program) does not work. |
Before we continue here this will require a discussion with the others, we could try to chat in the week after Easter. |
Sure. I just wanted to dump everything from my mind here, otherwise I can not remember until the next discussions 😉 I just played with it in the lab and it feels quite nice and responsive. |
4a1d46a
to
ec653a4
Compare
When I exit |
self.read_button.clicked.connect(self.read) | ||
self.write_button.clicked.connect(self.write) | ||
|
||
# TODO: in standalone the run_in_loop is not working -> fix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be history after #482 if we manage to have the widget like this:
class ParameterWidget(QWidget, AsyncObject):
def __ainit__(self, param):
super().__init__()
await super().__ainit__()
I'm quite satisfied in this state, that I only get this when exiting... I already think to know the cause. When the full-async stuff is working I will fix it. |
d19ed5e
to
e0966ee
Compare
e0966ee
to
18c9ca1
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #480 +/- ##
==========================================
- Coverage 88.36% 85.41% -2.96%
==========================================
Files 120 117 -3
Lines 8306 8151 -155
==========================================
- Hits 7340 6962 -378
- Misses 966 1189 +223
☔ View full report in Codecov by Sentry. |
So far I'm quite happy with the functionality and interface. We should discuss how to proceed. |
ba5d6a3
to
07b7ba0
Compare
First attempt to write a qt-widget-wrapper that can be applied to a
Parameterizable
.The code is still quite chaotic but in the first tests it did what it should be.
An example session:
Then
lin_motor_widget.show()
opens the widget. Can be also used as a general widget in qt layouts etc.TODOs / Questions:
Properties
with arbitrary data types? Maybe add a string-to-property function to the property?-> I will add a string-to-property function to the Property-Widget
This would require a subclass for each device and would lead to a bridge like implementation (if seen from the gui side).
Maybe a simple way to add buttons connected to functions and a factory that sets this for the most common devices/experiments would be a more clean solution (also with less work...)
In
concert.gui.parameterizable
there isParameterWidget
(+StateWidget
QuantityWidget
SelectionWidget
that inherit fromParameterWidget
). This widget implements a Widget for a (async) setter/getter for a Parameter (Quantitiy....). The setting/getting runs detatched (with theqasynv.asyncSlot
). It also features the signalsthat are emitted when a setter/getter is called, finished and when an Exception is raised within.
The ParameterizableWidget adds all parameter (etc.) widgets to a new Widget. The paramter-widgets are in the dictionary params. This allows to connect the setter/getter signals to any arbitrary function.
(E.g. in the example session above)
All widgets are "functional" and there are many options to make the look more appealing.