When the socket times out just call Dialog.Destroy() to destroy the
dialog. (or are you stuck on something else?)
Cody
A bit cleaner way to handle it would be to call
dialog.EndModal(someValue), then the code that called ShowModal can get
someVlaue instead of the button ID and will be able to tell why the
modal dialog was ended.
--
Robin Dunn
Software Craftsman
http://wxPython.org
On Tue, Jul 13, 2010 at 8:57 AM, dubiboy <david...@gmail.com> wrote:
> Thanks all for the suggestions, however nothing is really working, as
> below:
>
> The (major relevant) steps I am doing are:
>
> 1. From within my notebook page class I create a MessageDialog (call
> it self.dlg)
> 2. Then create a thread object and pass it self.dlg as a parameter.
> 3. do "print self.dlg" from within my notebook page class (main gui
> app) and also
> from within the thread just to confirm that both reference the same
> object.
> They do!
> 4. do ShowModal() from within main gui - the dialog is now shown.
> 5. within thread and after a few seconds do
> self.dlg.EndModal(wx.CANCEL) but get error message
> to the effect that the dialog is not modal.
> 6. Alternatively to step 5, from within thread do self.dlg.Destroy()
> with NO effect.
>
> Any ideas???
First please read this http://www.caliburn.nl/topposting.html
You can't make direct GUI calls from a background thread. You need to
post a message back to the main GUI thread and handle the UI changes
in the context of the main thread.
If that doesn't solve the issue then will probably need to see some
sample code that is giving you the problem
(http://wiki.wxpython.org/MakingSampleApps)
Cody
On Tue, Jul 13, 2010 at 10:38 AM, dubiboy <david...@gmail.com> wrote:
> Hi,
>>
>> You can't make direct GUI calls from a background thread. You need to
>> post a message back to the main GUI thread and handle the UI changes
>> in the context of the main thread.
>>
>> If that doesn't solve the issue then will probably need to see some
>> sample code that is giving you the problem
>> (http://wiki.wxpython.org/MakingSampleApps)
>>
>> Cody
>
> I would like to attach a sample file, but after having spent 1/2 hour
> trying (including viewing google groups help)
> I have almost given up. Any easy way to attach file? I cannot find any
> buttons with Link or Attach File, in addition
> the PAGES pages does not seem to have a way to make a new page.
> Thanks for any help.
This is an mailing list you can send email to it, no need to use the
web interface.
Cody
Probably not obvious enough but it is mentioned on the main group page:
http://groups.google.com/group/wxpython-users
"""However if you would like to send sample source code along with your
questions please use email and attach the code to the message instead of
just pasting the code into the message box in the web interface."""
Two problems:
1. When you use pubsub to send messages from a worker thread the message
is received in the context of the worker thread, not the GUI thread. So
you'll still need to do something to pass control over to the GUI thread
in order to operate on the dialog. wx.CallAfter works well.
2. Since wx.MessageDialog is not a real wx.Dialog (it's just a wwrapper
around the system's stock message dialog APIs) it doesn't respond to
EndZModal or Destroy like you would expect. If you want to
programatically close it you'll need to derive your own class from
wx.Dialog to do it.
3. Once you do #2 then using EndModal will be the correct method to use.
steven@dm-steven:~$ python
Python 2.6.4 (r264:75706, Dec 7 2009, 18:43:55)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> wx.ID_CANCEL
5101
>>>
It's the value passed to EndModal, and by common convention the ID of
the button used to close the dialog is the value that is used. Support
for handling wx.ID_OK and wx.ID_CANCEL buttons in dialogs is built-in.