Hi Russell,
 
This may be quite different but if I understand the requirements, you can try this:
 
from Tkinter import *
import tkFileDialog
class app:
    def __init__(self, master):
        master.title('Hello')
        Button(master, text='Button').pack()
       
        tkFileDialog.askopenfilename()
       
       
if __name__ == '__main__':
    root = Tk()
    app = app(root)
    root.mainloop()
 
Harlin Seritt

[EMAIL PROTECTED] wrote:
Send Tkinter-discuss mailing list submissions to
[email protected]

To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/tkinter-discuss
or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]

You can reach the person managing the list at
[EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tkinter-discuss digest..."


Today's Topics:

1. How to launch a dialog when app is started? (Russell Blau)
2. Re: How to launch a dialog when app is started?
([EMAIL PROTECTED])


----------------------------------------------------------------------

Message: 1
Date: Thu, 2 Mar 2006 16:14:54 -0500
From: "Russell Blau" <[EMAIL PROTECTED]>
Subject: [Tkinter-discuss] How to launch a dialog when app is started?
To: [email protected]
Message-ID: <[EMAIL PROTECTED]>

I am trying to write a Tkinter application that will automatically display a
particular dialog box on top of the application when it is initialized.
(Like a word processor opening a "File Open" dialog as the first thing that
happens when you enter the application.) How do I do this? I have a method
that invokes the dialog box, but I cannot call it until after my app's
mainloop has started; but once the mainloop has started, I can't call it
from the program, either!

I'm sure I'm overlooking something obvious here.

Example (skeleton) code:

from Tkinter import *

class NewPageDialog(tkSimpleDialog.Dialog):
def body(self, master, title="Select Target"):
Label(master, text="Target page:").grid(row=0)
self.targetpage = Entry(master)
self.targetpage.grid(row=0, column=1)
return self.targetpage

def validate(self):
return True

def apply(self):
pass

class GuiApplication(Frame):

def __init__(self, master):
Frame.__init__(self, master)

def newpage(self):
n = NewPageDialog(self)
self.targetpage = n.targetpage.get()


if __name__ == "__main__":
app = GuiApplication(Tk())
# do something here to cause GuiApplication to invoke newpage() method
when it starts
app.mainloop()






------------------------------

Message: 2
Date: Thu, 2 Mar 2006 15:43:00 -0600
From: [EMAIL PROTECTED]
Subject: Re: [Tkinter-discuss] How to launch a dialog when app is
started?
To: Russell Blau <[EMAIL PROTECTED]>
Cc: [email protected]
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=us-ascii

You might try writing
app.after_idle(app.newpage)
or simply:
app = GuiApplication(Tk())
app.newpage()
app.mainloop()
except that this will always enter main! loop after newpage is called,
which may not be what you desire.

Jeff


------------------------------

_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss


End of Tkinter-discuss Digest, Vol 25, Issue 1
**********************************************


Yahoo! Mail
Bring photos to life! New PhotoMail makes sharing a breeze.
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to