Try calling win.Render() in the callback function... The pipeline is updated, but it renders only when you explicitly say "Render".<div><br></div><div>Shash<br><br><div class="gmail_quote">On Mon, Oct 24, 2011 at 12:42 AM, David Froger <span dir="ltr"><<a href="mailto:david.froger@gmail.com">david.froger@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<br>
<br>
I'm new to vtk. I'm trying to use Vtk+Python+Tkinter to read MultiBlock from<br>
Ensight files, plot unstructrued data that are extracted from the MultiBlock,<br>
and interactively select a time to re-read and re-draw the data.<br>
<br>
Here is what I did:<br>
<br>
import Tkinter as Tk<br>
<br>
import vtk<br>
from vtk.tk.vtkTkRenderWindowInteractor import vtkTkRenderWindowInteractor<br>
<br>
# Read the source file<br>
reader = vtk.vtkGenericEnSightReader()<br>
reader.SetCaseFileName('data.case')<br>
reader.SetTimeValue(0.1)<br>
reader.Update()<br>
<br>
# Extract the block 1<br>
multiBlock = reader.GetOutput()<br>
triangularData = multiBlock.GetBlock(1)<br>
<br>
# Create the Mapper<br>
mapper = vtk.vtkDataSetMapper()<br>
mapper.SetInput(triangularData)<br>
<br>
# Create the Actor<br>
actor = vtk.vtkActor()<br>
actor.SetMapper(mapper)<br>
<br>
# Create the Renderer<br>
renderer = vtk.vtkRenderer()<br>
renderer.AddActor(actor)<br>
renderer.SetBackground(1, 1, 1) # Set background to white<br>
<br>
# create root window<br>
root = Tk.Tk()<br>
<br>
# create the WindowInteractor<br>
win = vtkTkRenderWindowInteractor(root, width=300, height=300)<br>
win.Initialize()<br>
win.GetRenderWindow().AddRenderer(renderer)<br>
style = vtk.vtkInteractorStyleTrackballCamera()<br>
win.SetInteractorStyle(style)<br>
win.pack(fill='both', expand=1, side='bottom')<br>
win.Start()<br>
<br>
# Function called when Button "Ok" is pressed.<br>
# Get the time value from the Entry widget, and<br>
# pass it to the vtkGenericEnSightReader<br>
def update():<br>
text = entry.get()<br>
try:<br>
time = float(text)<br>
reader.SetTimeValue(time)<br>
reader.Update()<br>
except ValueError:<br>
print "Float recquired"<br>
<br>
# Create Label, a Entry and a Button where user inputs time value.<br>
Tk.Label(text='time=').pack(side='left')<br>
entry = Tk.Entry()<br>
entry.pack(side='left')<br>
button = Tk.Button(text='Ok',command=update).pack(side='left')<br>
<br>
root.mainloop()<br>
<br>
Inputing a time in the tkinter widget updates the Reader, but not the<br>
vtkTkRenderWindowInteractor. Obviously, the pipe is broken when the block 1 is<br>
extracted. I've tried to use the vtkExtractBlock filter, but it only returns<br>
MultiBlock, and the mapper input has to be a Block.<br>
<br>
How can I do?<br>
<br>
Thanks for reading and for any suggestion that could help me!<br>
<br>
Best,<br>
David.<br>
<font color="#888888">--<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</font></blockquote></div><br></div>