Comments (3)
A bit late but maybe this'll be helpful to others landing here trying to do the same thing.
This can be done with the "Promote to ..." menu when you right click on the placeholder widget. Add a promoted class like this (might be able to use a more specific base class, not sure if it matters):
Then Add, then Promote. Then when you load the UI, it'll have an attribute with the name you give that widget in Designer that is a QtInteractor
you can re-use.
An example - assumes you at least have a QPushButton
named button
and a widget promoted to QtInteractor
named plot
:
from PyQt6 import QtWidgets, uic
import pyvista as pv
class Widget(QtWidgets.QWidget):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
uic.loadUi("example.ui", self)
# self.plot is now a QtInteractor instance
# self.button is a QPushButton
self.x = 0
self.button.clicked.connect(self.add_sphere)
def add_sphere(self):
mesh = pv.Sphere(center=(self.x, 0, 0))
self.plot.add_mesh(mesh)
self.x += 1
if __name__ == "__main__":
app = QtWidgets.QApplication([])
win = Widget()
win.show()
app.exec()
example.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExampleUI</class>
<widget class="QWidget" name="ExampleUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QtInteractor" name="plot" native="true"/>
</item>
<item>
<widget class="QPushButton" name="button">
<property name="text">
<string>Add Mesh</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QtInteractor</class>
<extends>QWidget</extends>
<header>pyvistaqt</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
from pyvistaqt.
Hello @zoner72 sorry for jumping in so late, did you find a solution?
I think I have an idea of you want to accomplish but I am not quite sure I understand the issue. If I understand correctly, you embed the QtInteractor
in a QtDesigner UI and you want to avoid re-creating the interactor everytime you upload a dataset? 🤔
from pyvistaqt.
Ha, yeah its been a wee while, not a problem though. I put this part to the side and started focussing on other parts of the code.
Your description is correct, that was/is indeed what I am after. Somehow I couldn't get it to work.
from pyvistaqt.
Related Issues (20)
- Online documentation not up to date HOT 1
- Lingering references prevent garbage collection
- Segmentation fault on Mac with PyQt5 HOT 2
- Race condition: BackgroundPlotter has no attribute named image HOT 3
- Running pyvistaqt project in Github Action HOT 2
- Inconsistent plotting results with PyVistaQT versus Jupyter (Trame) backends HOT 3
- Issue using pyvistaqt QtInteractor on Windows 10
- MAINT: Deploy docs HOT 7
- solicitud para agregar característica, para guardar los modelos en formato obj
- Stage release for PyVista 0.40 HOT 3
- Update GC testing fixture
- MAINT: Remove Azure
- Make the canvas background transparent HOT 1
- X Error of failed request: BadWindow (invalid Window parameter) HOT 3
- Border glitch during resize HOT 6
- macOS `pvqt.BackgroundPlotter` never opens window HOT 1
- DOC: MultiPlotter vs BackgroundPlotter
- no mouse interactivity with BackgroundPlotter HOT 1
- Consider adding `.git_archival.txt` to include version number in git archive
- QtInteractor CPU usage is based on window size and meshes rendered
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyvistaqt.