-
Notifications
You must be signed in to change notification settings - Fork 77
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
Stretchable layout with MEDM-style widgets #857
Comments
Looking at the the caQtDM repository does not reveal any Qt custom layout manager. Instead, the application likely responds to resize events of the windows directly. To co-exist with use of the standard Qt layout managers, a custom layout manager seems the right way to proceed. |
A basic version of the new custom layout (name to be adjusted per agreement): class MedmLayout(QLayout):
"""
Layout Manager for MEDM widgets.
Widgets are added to this layout with absolute coordinates (x,y,height,width).
When the layout is resized, the manager will resize each of the
widgets in the layout.
""" shows up in designer by following the patterns in MedmLayoutPlugin = qtplugin_factory(MedmLayout,
group='PyDM Layouts',
is_container=True,
extensions=BASE_EXTENSIONS) but there are problems: (dev-pydm) zorinvm@zorin22:~/.../slaclab/pydm$ designer
Loading PyDM Widgets
Exception occurred while running Qt Designer.
Traceback (most recent call last):
File "/home/zorinvm/Documents/projects/slaclab/pydm/pydm/widgets/qtplugin_base.py", line 119, in createWidget
w = self.cls(parent=parent)
TypeError: 'parent' is an unknown keyword argument
Designer: The custom widget factory registered for widgets of class MedmLayout returned 0.
** WARNING Factory failed to create "MedmLayout" https://stackoverflow.com/questions/5659875/custom-layout-in-qt-designer Advice is to write a custom container (QWidget, QFrame, ...) which can be interfaced as a designer plugin. |
Now called |
Drat!. Even with the custom layout called from the custom widget, the custom widget is not designable in the sense that child widgets can be dragged into it. Unless the window is based on the custom widget. In either case, widgets added will not be part of the custom layout. Rethink itA QWidget can have widget children. It can manipulate the geometry of each child during a |
What's the problem this feature will solve?
MEDM widgets are placed by absolute positioning. MEDM users are accustomed to changing the screen size and the widgets will stretch accordingly. In Qt, the stretchable feature is provided by a layout manager which re-positions its widgets as the layout changes size.
The widgets from the
adl2pydm
converter are not stretchable and this is a popular feature that is missed in MEDM screens converted for use in PyDM.Describe the solution you'd like
Internal widgets proportionally should stretch as the window changes size. (note: These example screens are rendered with caQtDM, a C++/Qt application, showing the idea is possible in Qt.)
original size
stretched
Additional context
After some research, it seems a good candidate case for a Qt Custom Layout Manager. The new custom layout would accept widgets placed in absolute coordinates and then adjust the geometry (x,y,h,w) of each to fit the containing QFrame.
The PyDM project already has an existing custom layout manager (
FlowLayout()
) that would be a good example for a new layout manager for this feature:pydm/pydm/widgets/template_repeater.py
Lines 17 to 112 in 5740b1a
The
adl2pydm
converter would use this new layout for each of the MEDM screens it converts.The text was updated successfully, but these errors were encountered: