multiple inputs dialog

996 views
Skip to first unread message

wxxxx

unread,
Mar 18, 2012, 1:47:40 PM3/18/12
to wxpytho...@googlegroups.com
Hello,
 
what is the right way to do a pop-up dialog with multiple input fields (firstname, lastname, age) and get user data. As wxpython beginner I can't figure it out. Is there any example for it?
 
Thanks!

werner

unread,
Mar 18, 2012, 2:19:40 PM3/18/12
to wxpytho...@googlegroups.com
Maybe the sample app Mike and I did might help you.

https://bitbucket.org/driscollis/medialocker

In this we used validators to get data to/from database to controls.

Mike did a few posts on his blog about it.

http://www.blog.pythonlibrary.org/tag/medialocker/

If you just need something simpler then you could do something along
these lines.

with yourDialog(....) as dlg:
if dlg.ShowModal() == wx.ID_OK:
fn = dlg.firstName.GetValue()
....

Try to code as much as you can and come back with your questions. If
the code is not too large you can even attach it, if you do follows as
much as possible - http://wiki.wxpython.org/MakingSampleApps

Werner

wxxxx

unread,
Mar 18, 2012, 3:45:07 PM3/18/12
to wxpytho...@googlegroups.com

On Sunday, March 18, 2012 7:19:40 PM UTC+1, werner wrote:
On 18/03/2012 18:47, wxxxx wrote:
> Hello,
> what is the right way to do a pop-up dialog with multiple input fields
> (firstname, lastname, age) and get user data. As wxpython beginner I
> can't figure it out. Is there any example for it?
Maybe the sample app Mike and I did might help you.

https://bitbucket.org/driscollis/medialocker

In this we used validators to get data to/from database to controls.

Mike did a few posts on his blog about it.

http://www.blog.pythonlibrary.org/tag/medialocker/

If you just need something simpler then you could do something along
these lines.

with yourDialog(....) as dlg:
     if dlg.ShowModal() == wx.ID_OK:
         fn = dlg.firstName.GetValue()
         ....

 

 
thanks for quick reply. Medialocker is pretty big app for learning from it. Will do my best.
 
Basically, I just want to know how to create dlg.firstName and dlg.lastName inputs for dlg. What objects should they be?

grunculus

unread,
Mar 18, 2012, 6:58:14 PM3/18/12
to wxpytho...@googlegroups.com
Hi,

On Sun, Mar 18, 2012 at 3:45 PM, wxxxx <fredga...@googlemail.com> wrote:
>
> On Sunday, March 18, 2012 7:19:40 PM UTC+1, werner wrote:
>>
>> On 18/03/2012 18:47, wxxxx wrote:
>> > Hello,
>> > what is the right way to do a pop-up dialog with multiple input fields
>> > (firstname, lastname, age) and get user data. As wxpython beginner I
>> > can't figure it out. Is there any example for it?
>> Maybe the sample app Mike and I did might help you.
>>
>> https://bitbucket.org/driscollis/medialocker

[...]

> thanks for quick reply. Medialocker is pretty big app for learning from it.
> Will do my best.
>
> Basically, I just want to know how to create dlg.firstName and dlg.lastName
> inputs for dlg. What objects should they be?

You're mixing up your terminology, I think. It sounds like you need
to start with something simpler.

Take a look at the examples at Zetcode. Maybe they'll help you get on
the right track.

http://zetcode.com/wxpython/dialogs/

>> Try to code as much as you can and come back with your questions.  If
>> the code is not too large you can even attach it, if you do follows as
>> much as possible - http://wiki.wxpython.org/MakingSampleApps

That's good advice too.

>> Werner

HTH.

Cheers,
Scott.

werner

unread,
Mar 19, 2012, 4:26:13 AM3/19/12
to wxpytho...@googlegroups.com
Hi,

On 18/03/2012 20:45, wxxxx wrote:
...
> thanks for quick reply. Medialocker is pretty big app for learning
> from it. Will do my best.
> Basically, I just want to know how to create dlg.firstName and
> dlg.lastName inputs for dlg. What objects should they be?

The wxPython demo is a good place to look for answers for this type of
question, check out wx.TextCtrl and wx.lib.masked.TextCtrl (search for
'masked' in the demo).

In the tutorial Scott pointed you too there is another one which might
be of interest to you:

http://zetcode.com/wxpython/databases/

Werner

Robin Dunn

unread,
Mar 20, 2012, 2:35:52 PM3/20/12
to wxpytho...@googlegroups.com


Also the Dialog sample in the demo has a fairly good example of a simple
dialog with labels, textctrls and buttons. It also shows a few extra
things, but the golden nuggets are in there too.


--
Robin Dunn
Software Craftsman
http://wxPython.org

werner

unread,
Mar 20, 2012, 3:14:20 PM3/20/12
to wxpytho...@googlegroups.com
Robin,

On 20/03/2012 19:35, Robin Dunn wrote:
...


> Also the Dialog sample in the demo has a fairly good example of a
> simple dialog with labels, textctrls and buttons. It also shows a few
> extra things, but the golden nuggets

Where are they hidden, didn't find them;-) .

Werner

Mike Driscoll

unread,
Mar 21, 2012, 2:04:10 PM3/21/12
to wxpytho...@googlegroups.com
Hi,

I would recommend subclassing wx.Dialog. That's the easiest way. You can also read up on the various standard dialogs here: http://www.blog.pythonlibrary.org/2010/06/26/the-dialogs-of-wxpython-part-1-of-2/ or http://www.blog.pythonlibrary.org/2010/07/10/the-dialogs-of-wxpython-part-2-of-2/

Using wx.Dialog is the most flexible though and it's pretty straight-forward too.

- Mike
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages