473,765 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

wxpython dialog - do something after ShowModal()?

Hi. I have a modal dialog whcih has a "Browse..." button which pops
up a file selector. This all works fine, but the first thing the user
has to do when they open the dialog is select a file, so I would like
the dialog to automatically call the onBrowse function as soon as the
dialog opens. However, I don't know how to do this.

dlg.ShowModal()
onBrowse()

obviously doesn't work, and neither does the reverse. I was hoping
that the dialog would throw some kind of "I have been shown" event,
but it doesn't (as far as I can tell). How do I make the dialog do
something as soon as it's been shown?

Iain
Jun 27 '08 #1
6 3717
Iain King wrote:
Hi. I have a modal dialog whcih has a "Browse..." button which pops
up a file selector. This all works fine, but the first thing the user
has to do when they open the dialog is select a file, so I would like
the dialog to automatically call the onBrowse function as soon as the
dialog opens. However, I don't know how to do this.

dlg.ShowModal()
onBrowse()

obviously doesn't work, and neither does the reverse. I was hoping
that the dialog would throw some kind of "I have been shown" event,
but it doesn't (as far as I can tell). How do I make the dialog do
something as soon as it's been shown?

Iain
If the only things on your modal dialog are Browse and cancel, just call the
wx.FileDialog directly and eliminate the intermediate modal dialog. If not
don't bind the FileDialog to a button, just create an instance of it as the last
you do in the __init__ method of the modal dialog code.

If this doesn't help, you will have better luck posting to wxpython newsgroup.

-Larry
Jun 27 '08 #2
On May 13, 2:20 pm, Larry Bates <larry.ba...@we bsafe.com`wrote :
Iain King wrote:
Hi. I have a modal dialog whcih has a "Browse..." button which pops
up a file selector. This all works fine, but the first thing the user
has to do when they open the dialog is select a file, so I would like
the dialog to automatically call the onBrowse function as soon as the
dialog opens. However, I don't know how to do this.
dlg.ShowModal()
onBrowse()
obviously doesn't work, and neither does the reverse. I was hoping
that the dialog would throw some kind of "I have been shown" event,
but it doesn't (as far as I can tell). How do I make the dialog do
something as soon as it's been shown?
Iain

If the only things on your modal dialog are Browse and cancel, just call the
wx.FileDialog directly and eliminate the intermediate modal dialog. If not
don't bind the FileDialog to a button, just create an instance of it as the last
you do in the __init__ method of the modal dialog code.

If this doesn't help, you will have better luck posting to wxpython newsgroup.

-Larry
The dialog doesn't only let you call the file dialog, it does other
stuff too. Your suggestion of __init__ sounded promising, but neither
giving the dialog an __init__() method nor an OnInit() method worked.
Thanks anyway.

Iain
Jun 27 '08 #3
On May 13, 2:43 pm, Iain King <iaink...@gmail .comwrote:
On May 13, 2:20 pm, Larry Bates <larry.ba...@we bsafe.com`wrote :
Iain King wrote:
Hi. I have a modal dialog whcih has a "Browse..." button which pops
up a file selector. This all works fine, but the first thing the user
has to do when they open the dialog is select a file, so I would like
the dialog to automatically call the onBrowse function as soon as the
dialog opens. However, I don't know how to do this.
dlg.ShowModal()
onBrowse()
obviously doesn't work, and neither does the reverse. I was hoping
that the dialog would throw some kind of "I have been shown" event,
but it doesn't (as far as I can tell). How do I make the dialog do
something as soon as it's been shown?
Iain
If the only things on your modal dialog are Browse and cancel, just call the
wx.FileDialog directly and eliminate the intermediate modal dialog. If not
don't bind the FileDialog to a button, just create an instance of it as the last
you do in the __init__ method of the modal dialog code.
If this doesn't help, you will have better luck posting to wxpython newsgroup.
-Larry

The dialog doesn't only let you call the file dialog, it does other
stuff too. Your suggestion of __init__ sounded promising, but neither
giving the dialog an __init__() method nor an OnInit() method worked.
Thanks anyway.

Iain
After having a hunt through the wxpython mailing list archives I found
the answer: the event is EVT_INIT_DIALOG :

dlg.Bind(wx.EVT _INIT_DIALOG, onInit, dlg)

work. Thanks for the pointer.

Iain
Jun 27 '08 #4
En Tue, 13 May 2008 09:41:25 -0300, Iain King <ia******@gmail .com>
escribió:
Hi. I have a modal dialog whcih has a "Browse..." button which pops
up a file selector. This all works fine, but the first thing the user
has to do when they open the dialog is select a file, so I would like
the dialog to automatically call the onBrowse function as soon as the
dialog opens. However, I don't know how to do this.
I've seen you already answered your question. But are you sure that doing
this is a good thing? If you try to be too clever or too helpful the
interfase may become annoying at some times. You can't guess the user's
intention or read his mind.
By example, what if I already have the desired file name copied in the
clipboard? I don't want the file selector to pop up.

I completely *hate* Windows programs with a "Browse for folder" button
that don't let me paste a name, neither start opened at the currently
selected folder.

--
Gabriel Genellina

Jun 27 '08 #5
In article
<a1************ *************** *******@m44g200 0hsc.googlegrou ps.com>,
Iain King <ia******@gmail .comwrote:
Hi. I have a modal dialog whcih has a "Browse..." button which pops
up a file selector. This all works fine, but the first thing the user
has to do when they open the dialog is select a file, so I would like
the dialog to automatically call the onBrowse function as soon as the
dialog opens. However, I don't know how to do this.

dlg.ShowModal()
onBrowse()

obviously doesn't work, and neither does the reverse. I was hoping
that the dialog would throw some kind of "I have been shown" event,
but it doesn't (as far as I can tell). How do I make the dialog do
something as soon as it's been shown?
It's too bad that you found an answer. You _shouldn't_ have your
dialog pop up a file-selection box as soon as it's shown! That's
not the way dialogs usually work, so you're going to confuse
people.

Instead, first pop up the file-selection box, and then pop up
the dialog (without the Browse button) to do whatever else it
does after you've got the filename.
Iain
Jun 27 '08 #6
On May 14, 9:37 pm, "David C. Ullrich" <dullr...@spryn et.comwrote:
In article
<a14c2400-e88b-4d90-80bb-a5fe27fed...@m4 4g2000hsc.googl egroups.com>,
Iain King <iaink...@gmail .comwrote:
Hi. I have a modal dialog whcih has a "Browse..." button which pops
up a file selector. This all works fine, but the first thing the user
has to do when they open the dialog is select a file, so I would like
the dialog to automatically call the onBrowse function as soon as the
dialog opens. However, I don't know how to do this.
dlg.ShowModal()
onBrowse()
obviously doesn't work, and neither does the reverse. I was hoping
that the dialog would throw some kind of "I have been shown" event,
but it doesn't (as far as I can tell). How do I make the dialog do
something as soon as it's been shown?

It's too bad that you found an answer. You _shouldn't_ have your
dialog pop up a file-selection box as soon as it's shown! That's
not the way dialogs usually work, so you're going to confuse
people.

Instead, first pop up the file-selection box, and then pop up
the dialog (without the Browse button) to do whatever else it
does after you've got the filename.
That's actually what happens - the dialog throws EVT_INIT_DIALOG
before it displays itself. Not that I really agree with you. I don't
think that a "do such-and-such dialog" appearing with a "Select file
for such-and-such" file selector on top of it, the file selector being
in focus, is confusing for the user. Actually, I think it'd be
friendlier - the user can see where the data from the file is going,
so has an immediate reminder of what the (generic) file selector is
for.
Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2544
by: Anand | last post by:
I am calling a python script from LabVIEW. This is achieved by making a dll call to python22.dll. It works perfectly well for most of my code. I now want to throwup dialog boxes from python. It works just fine if i run the code once. but when i call the same piece of code the second time, wxPython.wx.miscc does not exist for some reason. I dont know how this gets deleted. I guess this happens during some kind of clean up. The code that...
1
2068
by: flupke | last post by:
Hi, i'm trying to convert my java console app to a python gui. Now, the only problem i seem to have at the moment are the resizers for the layout. It seems that for the purpose of what i'm trying to do, specifying the coordinates is easier that fighting with the layout resizers. 1) I have a screen split in 2. Left side is a textcontrol where logging will end up. All text will be appended to the textcontrol. Ideally this should allow...
2
1712
by: rodmc | last post by:
I am totally new to Python and WxPython and need to write an application which can open up an external windows from a plug-in within GAIM (using pyGAIM). I have managed to hack some code together from what little I have covered so far, however GAIM refuses to open until I have closed the extra window. I appreciate this is probably a simple point but I would be grateful for any advice people can offer on how I can make them both appear so...
2
2203
by: John Salerno | last post by:
I'm not exactly sure how to call the method ShowModal(). This is what I have so far: -------------- import wx class InputForm(wx.Frame):
9
4446
by: Tyler | last post by:
Hello All: I am currently working on a project to create an FEM model for school. I was thinking about using wxPython to gather the 12 input variables from the user, then, after pressing the "Run" button, the GUI would close, and the 12 input variables would then be available for the rest of the program. So far, what I have been able to do is mostly a reverse engineering job to get the frame to look right and return the text variable...
4
1212
by: Daniel Gee | last post by:
I'm trying to learn WxPython with the tutorial: http://wiki.wxpython.org/Getting_Started But I can't seem to get the example for events to work. I pasted the code they had directly into an interpreter and it got a dialog to appear and the program was able to close itself, but my own copy won't work. As far as I can see, it isn't at all different except for the name of the main frame, and so I differ to you for help. my own code:
4
1874
by: Marcpp | last post by:
Hi I need to call a widget from a button in WXPYTHON. I've tried to this from a function like this, but when push the button, the program opens a window and do error. Any idea? ...... def DialogRRHH(self,event): prog = wx.PySimpleApp(0) wx.InitAllImageHandlers() DialogRRHH = MTRRHH(None, -1, "")
5
7806
by: SMALLp | last post by:
How can i select folder either with wx.FileDialog or with any other. I managed to fine only how to open files but I need to select folder to get files from all sub folders..... Thanks in advance!
3
2118
by: dp_pearce | last post by:
Hi All, Apologies if this should be seriously obvious. But I am quite new to Python and it is not quite so obvious yet. I have a GUI which will eventually load and display database information. I want the user to be able to browse for a database and then load it. My problem relates to how I set the value of a TextCtrl once the user has selected the database they wish to load.
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9951
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.