I have a program that is written in Python. GUI uses GTK. I plot something by using VTK and it works. But main GUI freezes and other buttons, etc do not work. I have tried multithreading but it still freezes. Maybe Python’s main loop and/or VTK’s loop have problems with working other.
EDIT: When program encounters an error at the end of the plotting codes (before
iren.Start()), both plot window and main GUI works. (For example, when
x=y code is placed without defining
y it gives error.) But there is an error. There may be another solution for that.
What is the solution?
Windows 10 (x64)
Here is the code:
import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk import vtk builder = Gtk.Builder() builder.add_from_file('test.glade') builder.get_objects() window1 = builder.get_object('window1') class Signals: def on_window1_destroy(self, widget): Gtk.main_quit() def on_button1_clicked(self, widget): cylinder = vtk.vtkCylinderSource() cylinderMapper = vtk.vtkPolyDataMapper() cylinderMapper.SetInputConnection(cylinder.GetOutputPort()) cylinderActor = vtk.vtkActor() cylinderActor.SetMapper(cylinderMapper) ren = vtk.vtkRenderer() renWin = vtk.vtkRenderWindow() renWin.AddRenderer(ren) iren = vtk.vtkRenderWindowInteractor() iren.SetRenderWindow(renWin) ren.AddActor(cylinderActor) renWin.Render() iren.Initialize() iren.Start() builder.connect_signals(Signals()) window1.show_all() Gtk.main()