Russell Blau | 2 Mar 22:14 2006
Picon

How to launch a dialog when app is started?

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):
(Continue reading)

jepler | 2 Mar 22:43 2006
Picon

Re: How to launch a dialog when app is started?

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

Jeff
Harlin Seritt | 3 Mar 13:53 2006
Picon

Re: How to launch a dialog when app is started?

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

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

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
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"
Subj ect: [Tkinter-discuss] How to launch a dialog when app is started?
To: tkinter-discuss <at> python.org
Message-ID:

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: jepler <at> unpythonic.net
Subject: Re: [Tkinter-discuss] How to launch a dialog when app is
started?
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
app.after_idle(app.newpage)
or simply:
app = GuiApplic ation(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
Tkinter-discuss <at> python.org
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
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
rkundu | 3 Mar 18:57 2006
Picon

Accessing tables through Python (ActivePython 2.3)

I am trying to read the field names from a dbf table using python. Is 
there any way to do this? I tried using PyTables and also PyIMAPITable 
but no luck. I also tried sending a dispatch "DAO.DBEngine", but 
failed. Any suggestions will be appreciated. Thank you,
Reema
V H | 7 Mar 15:35 2006
Picon

question on scalable frame

Hello,

I am using Tkinter to create a scalable/expandable frame and using pack() to 
manage it. On the frame there are several dynamically created sub-frames. 
The top level frame is expanded automatically with the increasing number of 
sub-frames. But after I adjust the size of the top-level frame using mouse, 
it cannot expand automatically.  Is it normal? Or how can I resolve it? 
Thanks.

regards,
Weining

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/
Martin Franklin | 7 Mar 15:40 2006
Picon

Re: question on scalable frame

V H wrote:
> Hello,
> 
> I am using Tkinter to create a scalable/expandable frame and using pack() to 
> manage it. On the frame there are several dynamically created sub-frames. 
> The top level frame is expanded automatically with the increasing number of 
> sub-frames. But after I adjust the size of the top-level frame using mouse, 
> it cannot expand automatically.  Is it normal? Or how can I resolve it? 
> Thanks.
> 
> regards,
> Weining
> 

Hi,

Could you post some code that show this... perhaps it is as simple as
the pack expand or fill option..

CHeers
Martin
jepler | 7 Mar 17:24 2006
Picon

Re: question on scalable frame

Once the user has adjusted the size of the window, many window managers
keep the window at the user-requested size, rather than the
application-requested size.

By setting an empty geometry when resizing the window, this behavior
can be avoided, at least on my system.  e.g., in python,
    app.wm_geometry("")

Here's a wish program that demonstrates the solution (and the problem,
if the "wm geo" section is commented out):

#------------------------------------------------------------------------
label .l -width 10 -bg red
button .b -text "<<" -command {width -1}
button .b1 -text ">>" -command {width 1}

proc width arg {
    set w [.l cget -width]
    incr w $arg
    if {$w < 0} { set $w 0 }
    .l configure -width $w

    # Reset window to use application, not user, size
    # Comment this out to show the problem or do something more sophisticated
    # (like check if the new requested size is greater than the current size, so
    # as to grow but not shrink)
    wm geometry . {}
}

pack .l -side top
pack .b -side left
pack .b1 -side left
#------------------------------------------------------------------------

Jeff
hk | 15 Mar 03:20 2006

Tix: binding

I am looking at Tix and I am stuck with what seems to be a simple problem:

I want to bind the cancel buttom of a ExFileSelectBox to a routine in my class, but can not make it work.
I guess the problem is the same for any binding of tix sub-widgets, so if someone could send some sample code.
>>> import Tix
>>> root = Tix.Tk()
>>> box = Tix.ExFileSelectBox(root)
>>> print box.subwidget(name='cancel')
.11827520.bf.cancel                            #so the sub-widget cancel buttom is there

But how to bind it ?

>>> box.cancel(command = lambda a,b : a+b )
Traceback (most recent call last):
  File "<pyshell#12>", line 1, in ?
    box.cancel(command = lambda a,b : a+b )
AttributeError: _dummyButton instance has no __call__ method

Or

>>> box.subwidget(name='cancel' , command = lambda a,b : a+b )
Traceback (most recent call last):
  File "<pyshell#13>", line 1, in ?
    box.subwidget(name='cancel' , command = lambda a,b : a+b )
TypeError: subwidget() got an unexpected keyword argument 'command'

So, it seems I can not bind to command, but what then ?
>From the Tix docu I thought the buttoms are normal Tkinter widgets ?
--

-- 
Harm 
Mohammad Tayseer | 15 Mar 10:37 2006
Picon

Re: Tix: binding

> >>> box.cancel(command = lambda a,b : a+b )
> Traceback (most recent call last):
> File "", line 1, in ?#12>
> box.cancel(command = lambda a,b : a+b )#12>
> AttributeError: _dummyButton instance has no __call__ method

#12>you should use box.cancel.config(command=my_callback) AFAIK

Yahoo! Mail
Use Photomail to share photos without annoying attachments.
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Adam | 15 Mar 18:36 2006
Picon

Re: Tix: binding

On 15/03/06, hk <at> pop.ms <hk <at> pop.ms> wrote:
> I am looking at Tix and I am stuck with what seems to be a simple problem:
>
> I want to bind the cancel buttom of a ExFileSelectBox to a routine in my class, but can not make it work.
> I guess the problem is the same for any binding of tix sub-widgets, so if someone could send some sample code.
> >>> import Tix
> >>> root = Tix.Tk()
> >>> box = Tix.ExFileSelectBox(root)
> >>> print box.subwidget(name='cancel')
> .11827520.bf.cancel                            #so the sub-widget cancel buttom is there
>
> But how to bind it ?
>
> >>> box.cancel(command = lambda a,b : a+b )
> Traceback (most recent call last):
>   File "<pyshell#12>", line 1, in ?
>     box.cancel(command = lambda a,b : a+b )
> AttributeError: _dummyButton instance has no __call__ method
>
> Or
>
> >>> box.subwidget(name='cancel' , command = lambda a,b : a+b )
> Traceback (most recent call last):
>   File "<pyshell#13>", line 1, in ?
>     box.subwidget(name='cancel' , command = lambda a,b : a+b )
> TypeError: subwidget() got an unexpected keyword argument 'command'
>
> So, it seems I can not bind to command, but what then ?
> >From the Tix docu I thought the buttoms are normal Tkinter widgets ?
> --
> Harm

Here's what I got from a little experimentation and print
box.cancel.bind.__doc__.

>>> def bar(action):
...     print action
>>> import Tix
>>> root = Tix.Tk()
>>> box = Tix.ExFileSelectBox(root)
>>> box.pack()
>>> box.cancel.bind("<ButtonPress-1>", bar)
'-1212073588bar'
>>> <Tkinter.Event instance at 0xb779c0ec>
<Tkinter.Event instance at 0xb779c0ec>
<Tkinter.Event instance at 0xb779c0ec>

If you have a look at box.cancel.bind.__doc__ you can find everything
you can put into the SEQUENCE string "<ButtonPress-1>" is left mouse
click.
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor


Gmane