Tk additional window (again)

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?

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

root.withdraw()

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

yes, thats it! :smiley:

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! :laughing:

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!? ) :laughing:

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.

Ok, thanks.

Can I ask if this could be added to the Particle Panel sample program?

you forgot the magic word.

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.

I cant find the tkRoot variable in showBase,
ex:

base.tkRoot.withdraw()
base.TkGlobal.tkRoot.withdraw()

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