-
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
BackgroundPlotter custom menus and buttons #122
Comments
Hi there, we've been working on expanding how users can customize the In the meantime, here is an example of how to add custom menus and a toolbar to the import pyvista as pv
from pyvista import examples
from PyQt5.QtWidgets import QAction
st_helens = examples.download_st_helens().warp_by_scalar()
plotter = pv.BackgroundPlotter()
def add_st_helens():
plotter.add_mesh(st_helens, name="st helens")
# Add a drop down menu
user_menu = plotter.main_menu.addMenu('My Features')
user_menu.addAction('Add St. Helens', add_st_helens)
# Add a toolbar
def add_action(toolbar, key, method, main_window):
action = QAction(key, main_window)
action.triggered.connect(method)
toolbar.addAction(action)
return
user_toolbar = plotter.app_window.addToolBar('User Toolbar')
add_action(user_toolbar, 'Line Widget', plotter.add_line_widget, plotter.app_window) |
Good, thanks! BTW, how do I access properties of the line widget? Particularly coordinates of the end points. Thanks! |
You’d need to pass a callback method when activating the line widget. See https://docs.pyvista.org/plotting/widgets.html#line-widget So in order to have a Qt button handle all that, you’d need a custom function to properly call the Something like def line_callback(a, b):
# do stuff with the two points
pass
def add_line():
plotter.add_line_widget(line_callback)
# put add_line on the Qt button Sent with GitHawk |
Great thanks! |
@bistek, would you please open a new issue about these picking issues? In the meantime, I'll try to find a solution |
Done #133, thanks! |
Is there a way to remove default items from menu bar and toolbar, or we need to disable the default menu and tool bars and then define and add our own menu and tool bars? |
Hello, I was wondering if there is an already tested way to add custom menus and buttons to the BackgroundPlotter. I guess it should be possible since in the end it is a Qt window. I have not been able to find an example.
Thanks!
The text was updated successfully, but these errors were encountered: