1

I had tried to create a simple mouse event to see if it would work in a test Python code and now I'm trying it in my actual code. Is there a way for me to create a mouse event that logs the x and y points of the windows in a paraview widget? If so how would I do it? I am creating a program that takes a png and displays it in 3d using paraview widget.

4
  • could you please provide a minimal code snippet to illustrate what you want to do? Sep 22 at 4:33
  • Sure this is what i'm currently working with. class MainWindow(QMainWindow): def init__(self, parent=None): super().__init__(parent) self.setWindowTitle('ParaView in Qt Widget') self.setGeometry(100, 100, 800, 600) self.pv_widget = ParaViewWidget(self) self.setCentralWidget(self.pv_widget) if __name == 'main': app = QApplication(sys.argv) window = MainWindow() window.show() sys.exit(app.exec_())
    – Exac23
    Sep 23 at 23:11
  • def load_sample_dataset(self): # Load a sample dataset (replace with your own data loading code) dataset = pv.read('Example.PNG') # Add the dataset to the ParaView render window self.interactor.add_mesh(dataset, show_edges=True) # Reset the camera position self.interactor.reset_camera() self.interactor.update() def update_mouse_position(self, x, y): # Update the mouse position label with the current coordinates self.mouse_position_label.setText(f"Mouse Position: ({x}, {y})")
    – Exac23
    Sep 23 at 23:12
  • def show(self, *args, **kwargs): if self.is_updated is False: super(ParaViewWidget, self).show(*args, **kwargs) def build_ui(self): """Grunt work to make the UI NOTE THIS IS FIRST TIME ONLY, call update_ui if data changes TODO lots to do. """ return def update_ui(self): """ required for TRI standard practice called by parent widget :return: """ return
    – Exac23
    Sep 23 at 23:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.