Anon
June 27, 2011, 7:05am
1
Im finally asking this with a sample code
import direct.directbase.DirectStart
from pandac.PandaModules import *
from Tkinter import *
from tkFileDialog import askopenfilename
root = Tk()
filename = askopenfilename(filetypes=[("all files","*"),("EGG models","*.egg")])
model = loader.loadModel(str(filename))
model.reparentTo(render)
run()
Can you get rid of the small additional window created by Tk?
drwr
June 27, 2011, 3:02pm
2
You should perhaps be asking the guys who created Tk, not us. But as far as I know, the answer is no–you can’t get rid of that window, but you can at least add content to it so it doesn’t look quite so silly and empty.
David
yeah, put a vespa in and a snowboard! and do not forget to add some teachers, which are surround by flowers. and in the background do this photo in ->
http://justpic.info/images/eab4/der_landarzt_season_4_4yco.jpg
Anon
June 27, 2011, 3:27pm
5
ynjh_jo:
root.withdraw()
yes, thats it!
PS. Since Panda makes a window, I thought it could interfere with how Tk works, so asking in a Tk forum wouldn’t be the best idea either.
BTW, what’s base.startTk() for? It worked without it and if I use it, withdraw() won’t have any effect anymore.
not really!
your tk seems not to work right, i cant import a model with.
let the window exist and follow my advice!
Anon
June 27, 2011, 4:09pm
7
That has nothing to do with Tk, that returns a unicode string for the file path. I seem to have converted the string incorrectly.
so its your fault!? but anyway, i would never use a tk gui.
and have you followed my advice?? (WHO IS THE ARTIST!? )
Anon
June 27, 2011, 4:17pm
9
um, whatever…
Here
import direct.directbase.DirectStart
from pandac.PandaModules import *
from Tkinter import *
from tkFileDialog import askopenfilename
root = Tk()
root.withdraw()
filename = askopenfilename(filetypes=[("all files","*"),("EGG models","*.egg")])
model = loader.loadModel(Filename.fromOsSpecific(filename))
model.reparentTo(render)
run()
the command
withdraw
(if its to hide a window) doesnt make much sense, like the entire tk.
It’s just an initiator so you don’t have to instantiate Tk class. If you use it, the root is tkroot, defined in showbase/TkGlobal.py, so call withdraw() on it.
Anon
June 28, 2011, 5:41pm
12
Ok, thanks.
Can I ask if this could be added to the Particle Panel sample program?
you forgot the magic word.
Anon
June 28, 2011, 6:50pm
14
If seriously, is there a reason there’s that window there? Maybe it’s required when you have more than one Tk window with Panda.
Anon
July 18, 2011, 7:40am
15
I cant find the tkRoot variable in showBase,
ex:
base.tkRoot.withdraw()
base.TkGlobal.tkRoot.withdraw()
drwr
July 18, 2011, 4:20pm
16
If you had looked in TkGlobal.py, you would have seen the line:
__builtins__["tkroot"] = Pmw.initialise()
This creates tkroot as a builtin, not as a member of ShowBase. So it’s not base.tkRoot, it’s just tkroot. Note the case as well.
David