Modifying Context Menu

51 views
Skip to first unread message

RC

unread,
Apr 18, 2017, 8:26:09 AM4/18/17
to pyqtgraph


I guys, I hope someone can help me out with this one.


I have a pyqtgraph context menu and want to add my own Z-Axis. I can create a qlineedit widget but I am not able to create multiple widget on the same line in the context menu as show below (e.g. radio button and 2 text boxes on same line)

enter image description here

As a minimum I would like to achieve:-

Z Axis -> [input value], string, [input value] all on the same line

I've had a look in qmenu but couldn't find what I needed. Anyone know how to achieve this? I think i am missing something

Also if anyone knows how to change the size of the X Axis qlineedit boxes and make them bigger it would be great as they are a bit squashed as you can see. This may be due to the resolution of my screen being very high.


Thanks for any help you can provide on this.

Sebastian Höfer

unread,
Apr 19, 2017, 9:15:26 AM4/19/17
to pyqtgraph
Hi RC,

have a look at the code in pyqtgraph/graphicsItems/ViewBox/.
The submenu on the right is created in the axisCtrlTemplate_*.py files. At the top you can find a Form.resize(..,..) with hard-coded values. A bigger size might solve the issue with the weird scaling of the fonts in your UI. You can also see that the menu is actually defined via a QGridLayout. You can arange and add widgets to your liking within that.
The menu to the left is instantiated in ViewBoxMenu.py. I just had a quick look at the code, but it looks like you can add a z-axis menu by extending the loop (for axis in 'XY':) in the constructor and adding the corresponding functions for event handling down in this file.

Hope this helps a bit.

Cheers
Sebastian

RC

unread,
Apr 20, 2017, 7:54:58 AM4/20/17
to pyqtgraph
Thank you so very much Sebastian, you really helped me

I went into the axisCtrlTemplate_*.py files and modified the appropriate line. Turns out it was the below the one you suggested which controlled the width so I just increase it as shown below and its now appears as it should.
Form.setMaximumSize(QtCore.QSize(450, 16777215))

And thanks for the clue on the z-axis. I am not going to modify this file at the moment, however I am going to use the code in there as an example to add my menu someone else in the context menu which better suits my purpose.

Thanks again Sebastian

Kind Regards

RC
Reply all
Reply to author
Forward
0 new messages