Previous Thread  Next Thread

chat icon Using Tkinter in Blender Python

demolishun

Posted: Tue Feb 18, 2003 6:42 am
Joined: 17 Feb 2003
Posts: 6
I am trying to use Tkinter in the Blender Python interface.

from Tkinter import * # this works

root = Tk() # this complains about "argv" not being part of "sys" ie:

Traceback (most recent call last):
File "Text", line 11, in ?
File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 1483, in __init__
baseName = os.path.basename(sys.argv[0])
AttributeError: 'module' object has no attribute 'argv'

I can run the same stuff under a python shell with no errors even though both Blender and the shell are using "/usr/bin/python".

I also noticed Blender.sys does not have argv. Am I missing something very basic?

Thanks,
Demolishun
Reply with quote


demolishun

Posted: Wed Feb 19, 2003 5:27 am
Joined: 17 Feb 2003
Posts: 6
Well I figured out how to use Tkinter in Blender. It seems that Blender modifies the Python shell so that the "sys" object is not the same as the "sys" object under a regular Python shell. This false sys object does not have a "argv" variable in it. So in order to get it to work I lied to it:

sys.argv = "Some Text' # This is not really correct, but it works.

This has allowed me to execute a Tkinter script and pop up a window on top of Blender. It is not perfect, but it works. I hope to fix some of the scripts that relied on the GUI object to do thier work.

I do have another question:
Is there a way to save the contents of the Text window to another file other than ".blend"? I have looked at all the docs I can find and it does not mention this.

Thanks,
Demolishun
Reply with quote


Schlops

Posted: Wed Feb 19, 2003 2:32 pm
Joined: 16 Oct 2002
Posts: 20
Shift-Alt-F
Reply with quote


levinemartin100

Posted: Sat Mar 09, 2013 3:50 am
Joined: 09 Mar 2013
Posts: 3
tried to do x = tkinter.Tk() after importing and no window appears
please help
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group