[Tkinter-discuss] How to launch a dialog when app is started?

Harlin Seritt harlinseritt at yahoo.com
Fri Mar 3 13:53:04 CET 2006

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):
        Button(master, text='Button').pack()
if __name__ == '__main__':
    root = Tk()
    app = app(root)
  Harlin Seritt

tkinter-discuss-request at python.org wrote:
  Send Tkinter-discuss mailing list submissions to
tkinter-discuss at python.org

To subscribe or unsubscribe via the World Wide Web, visit
or, via email, send a message with subject or body 'help' to
tkinter-discuss-request at python.org

You can reach the person managing the list at
tkinter-discuss-owner at python.org

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?
(jepler at unpythonic.net)


Message: 1
Date: Thu, 2 Mar 2006 16:14:54 -0500
From: "Russell Blau" 
Subject: [Tkinter-discuss] How to launch a dialog when app is started?
To: tkinter-discuss at python.org

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):

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


Message: 2
Date: Thu, 2 Mar 2006 15:43:00 -0600
From: jepler at unpythonic.net
Subject: Re: [Tkinter-discuss] How to launch a dialog when app is
To: Russell Blau 
Cc: tkinter-discuss at python.org
Message-ID: <20060302214300.GC16093 at unpythonic.net>
Content-Type: text/plain; charset=us-ascii

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



Tkinter-discuss mailing list
Tkinter-discuss at python.org

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

Yahoo! Mail
Bring photos to life! New PhotoMail  makes sharing a breeze. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20060303/29975abc/attachment.htm 

More information about the Tkinter-discuss mailing list