By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,567 Members | 1,670 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,567 IT Pros & Developers. It's quick & easy.

Fw: Message vtkUser

P: n/a
Hello everyone,

my student had the following problem with a python program featuring
multiple vtkTkRenderWidget calls. See below...

Can anyone suggest a workaround?

Best regards,

Michel

Michel Audette, Ph.D.,
Research Fellow, Surgical Simulation,
Surgical Assist Technology Group,
AIST,
Namiki 1-2,
Tsukuba, Japan,
305-8564.
--------------------------------------------------------
"If you think you can do it, you're right.
If you think you can't do it, you're still right."
- Henry Ford

I have some problems with management of many vtkTkRenderWidget.

I am developing GUI for surgical software in Python Language.
Each window of this GUI have one vtkTkRenderWidget to show 3D Objects
(One of them used the vtksliceWidget develop by Atamai).
I succeed to show one objects in one of these windows.
But if I try to open another one I get this error:

File "/usr/local/lib/python2.2/lib-tk/Tkinter.py", line 1316, in __call__
return apply(self.func, args)
File "selection.py", line 64, in <lambda>
command = lambda:
File "functionclass.py", line 550, in entranceTriplan
self.show2(self.triplan)
File "functionclass.py", line 164, in show2
self.affichageTriplan("exemple.mnc")
File "functionclass.py", line 584, in affichageTriplan
self.viewer1 = vtkSliceWidget.vtkSliceWidget(self.triplan.frame1,
width=256,height=256)
File "/home/athinnes/atamai/examples/vtkSliceWidget.py", line 108, in
__init__
Tkinter.Widget.__init__(self, master, 'vtkTkRenderWidget', cnf, kw)
File "/usr/local/lib/python2.2/lib-tk/Tkinter.py", line 1780, in
__init__
self.tk.call(
TclError: invalid command name "vtkTkRenderWidget"

This following is a simplify version of the software architecture without
using vtkSliceWidget .
Each module corresponding to one part of the interface:

################################################## ####################
#testfunc.py

from Tkinter import *
from vtkTkRenderWidget import *
import triplantest
import bouton
import render

class Functions:

def __init__(self, myParent):
print "functions class created"
# If you comment the self.render line. The button will open the
triplantest window
self.render = render.Render(self, myParent)

self.bouton = bouton.Bouton(self)
self.triplan = triplantest.Triplan(self)

## Procedure: show
# this procedure is call to show on the screen the windows winname
def show(self, winname):
winname.deiconify()
self.affichageTriplan()

## Procedure: affichageTriplan
# This procedure setup the slice image inside triplan interface

def affichageTriplan(self):

self.renderWidget = vtkTkRenderWidget(self.triplan.frame1)
self.renderWidget.pack(expand='true',fill='both')
if __name__ == '__main__':

root = Tk()
function = Functions(root)
function.triplan.withdraw()
root.mainloop()

################################################## #####################
#render.py

from vtkTkRenderWidget import *
from vtkpython import *
from Tkinter import *

class Render:

def __init__(self, myFunctions, myParentFunction):

self.functions = myFunctions
myParentFunction.title("test vtkTkRenderWidget")

self.viewer = Frame(myParentFunction, borderwidth = 2, relief =
"ridge")
self.renderWidget = vtkTkRenderWidget(self.viewer)

self.viewer.pack(expand='true',fill='both')
self.renderWidget.pack(expand='true',fill='both')

################################################## #######################
#
#triplantest.py

from Tkinter import *

class Triplan(Tk):
def __init__(self, myFct):
Tk.__init__(self)

self.functions = myFct
self.title("Frame for vtkSliceWidget")

self.mainframe = Frame(self)
self.frame1 = Frame(self.mainframe, relief="ridge", borderwidth=2)

self.frame1.pack(expand='true',fill='both')
self.mainframe.pack(expand='true',fill='both')

################################################## #############
#bouton.py

from Tkinter import *
class Bouton(Tk):

def __init__(self, myFunctions):
Tk.__init__(self)
self.functions = myFunctions
self.title("Click On Button")
self.frame = Frame(self)
self.bouton = Button(self.frame, text = "click \nhere",
command = lambda:
self.functions.show(self.functions.triplan)
)

self.frame.pack(expand='true',fill='both')
self.bouton.pack(expand='true',fill='both')

################################################## ####################3

If you run "python testfunc.py" you will see the error. It's the same I
have in the full software.

Somebody have any idea why it's not working and how to solve it?
It seams, vtkTkRenderWidget cannot be call twice. But I don't know how to
solve it.

Thank you for your attention
Best regards
Alexandre Thinnes
Je dois avoir un probleme de mail avec l'AIST.
Il semble que l'adresse qui envois les mails ne soit pas celle qui les
recois. >_<

Accédez au courrier électronique de La Poste : www.laposte.net ;
3615 LAPOSTENET (0,34?/mn) ; tél : 08 92 68 13 50 (0,34?/mn)


Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.