wxWidgets possible bug?

I did a little test. I wrote an application in wxPython that has a button in a frame, simple stuff. Clicking on the button executes this piece of code:

wx.LaunchDefaultBrowser(url='http://www.google.si/’)

I have launched this application in a Windows box that has no web browser installed. (Internet Explorer was removed through the Windows Features option in Windows 7.) After clicking on the button, I got an error message from the operating system itself. Also, catching Exception in a try-except clause, no error is caught by the except clause, and so the error message box of the operating system roared at my face again. See the error message here: http://imageshack.us/f/195/pythonerror.png/

Is this a bug in wxLaunchDefaultBrowser in wxWidgets? If yes, please fix it.

Bo�tjan Mejak wrote:

I did a little test. I �wrote
an application in wxPython that has a button in a frame,
simple stuff. Clicking on the button executes this piece of
code:

wx.LaunchDefaultBrowser(url='http://www.google.si/')

      I have launched this application in a Windows box that has no

web browser installed. (Internet Explorer was removed through
the Windows Features option in Windows 7.) After clicking on
the button, I�got an error message from the operating system
itself. Also, catching Exception�in a try-except clause, no
error is caught by the except clause,�and so the error message
box of the operating system roared at my face again. See the
error message here:�http://imageshack.us/f/195/pythonerror.png/

      Is this a bug in

wxLaunchDefaultBrowser in wxWidgets? If yes, please fix it.

What is it that you are complaining about?� That it failed to find a

default browser after you deleted it, or that you see an error
message?� What did you expect this code to do?

···
-- Tim Roberts, Providenza & Boekelheide, Inc.

timr@probo.com

My original code is this:

def OnButton(self, event):

try:

wx.LaunchDefaultBrowser(url=‘http://www.google.si/’)

except Exception, e:

print e

That should output something, but nothing is outputted. Also, having a wx.MessageBox() inside the exception block doesn’t show my message box as well. Only that darn OS error dialog box is shown. Is that a bug or what? I expected at least my own message box, but no such luck. A bug lurking somewhere?

My original code is this:

def OnButton(self, event):
         try:
             wx.LaunchDefaultBrowser(url='http://www.google.si/')
         except Exception, e:
             print e

That should output something, but nothing is outputted. Also, having a
wx.MessageBox() inside the exception block doesn't show my message box
as well. Only that darn OS error dialog box is shown. Is that a bug or
what?

I'd call it more of a missing feature than a bug.

Remember that Microsoft argued in their anti0trust court case that the browser was in integral part of windows -- so s system without a browser is pretty broken.

I expected at least my own message box, but no such luck. A bug
lurking somewhere?

Well, I suspect it's a Windows issue -- IE is kind of integrated (and broken...), so I wouldn't be surprised that when you make a system call to open something in the default browser, Windows pops up a dialog and doesn't return an error to caller -- but that's just guessing.

Anyway, the python standard lib has a similar call, I"d give that try and see if it handles errors any better.

-Chris

···

On 5/5/11 7:20 PM, Bo�tjan Mejak wrote:

I think that the only bug here is in your expectations. The dialog is not shown by wxwWidgets. All we do is fill a structure and call a native API function. (See the end of wxTrac has been migrated to GitHub Issues - wxWidgets) It sounds to me like you've removed the battery from a car and then when you turn the key and nothing happens you complain about a bug in the ignition system.

Oh, wait. There is a bug. We use a flag that is supposed to tell the API to not display any message box when there is an error. So I guess you can submit a bug report to Microsoft. Or just put the battery back in the car or figure out before you turn the key that there isn't any battery there.

···

On 5/5/11 5:23 PM, Bo�tjan Mejak wrote:

I did a little test. I wrote an application in wxPython that has a
button in a frame, simple stuff. Clicking on the button executes this
piece of code:
wx.LaunchDefaultBrowser(url='http://www.google.si/
<http://www.google.si/'>)

I have launched this application in a Windows box that has no web
browser installed. (Internet Explorer was removed through the Windows
Features option in Windows 7.) After clicking on the button, I got an
error message from the operating system itself. Also, catching
Exception in a try-except clause, no error is caught by the except
clause, and so the error message box of the operating system roared at
my face again. See the error message here:
ImageShack - Best place for all of your image hosting and image sharing needs

Is this a bug in wxLaunchDefaultBrowser in wxWidgets? If yes, please fix it.

--
Robin Dunn
Software Craftsman

We didn’t quite understand each other. Look at this code then:

def OnButton(self, event):

try:

wx.LaunchDefaultBrowser(url=‘http://www.google.si/’)

except Exception:

wx.MessageBox(caption=‘MyApp Error Message’,

message=“You don’t have a web browser installed.”,

style=wx.OK | wx.ICON_EXCLAMATION)

We are catching all errors here, but that should catch at least a NotImplementedError or something and display our custom message box. Why does it not do that?

We didn't quite understand each other.

Correct.

def OnButton(self, event):

        try:
            wx.LaunchDefaultBrowser(url='http://www.google.si/')

        except Exception:
            wx.MessageBox(caption='MyApp Error Message',
                                     message="You don't have a web browser
installed.",
                                     style=wx.OK | wx.ICON_EXCLAMATION)

We are catching all errors here, but that should catch at least a
NotImplementedError or something and display our custom message box. Why
does it not do that?

Because there IS NO such error.

Karsten

···

On Fri, May 06, 2011 at 10:46:22AM +0200, Boštjan Mejak wrote:
--
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

And since wx.LaunchDefaultBrowser API description is like this: “Launches the user’s default browser and tells it to open the location at url. Returns True if the application was successfully launched.” I assume that it returns False otherwise, so I code my handler function like this:

def OnButton(self, event):

if wx.LaunchDefaultBrowser(url=‘http://www.google.si/’) == False:

wx.MessageBox(caption=‘MyApp Error Message’,

message=“You don’t have a web browser installed.”,

style=wx.OK | wx.ICON_EXCLAMATION)

This works as expected! :slight_smile: But the operating system’s error message box is still displayed after “MyApp Error Message” box is closed by clicking on its OK button. Is it possible to supress the operating system’s error message somehow? And also, why didn’t the “catch all exceptions” way worked and displayed my error message box?

As it turns out, this does not produce the operating system’s error message box:

import webbrowser

.

.

.

def OnButton(self, event):

if not webbrowser.open(url='http://www.google.si/’):

wx.MessageBox(caption=‘MyApp Error Message’,

message=“You don’t have a web browser installed.”,

style=wx.OK | wx.ICON_EXCLAMATION)

This does not produce the “Python Error” message box at all. The “Python Error” message box is only shown if I use wx.LaunchDefaultBrowser. So I assume there is a bug in wxLaunchDefaultBrowser in wxWidgets. Please fix this.

As it turns out, this does _not_ produce the operating system's error
message box:

import webbrowser
.
def OnButton(self, event):

         if not webbrowser.open(url='http://www.google.si/
<http://www.google.si/'>):
             wx.MessageBox(caption='MyApp Error Message',
                           message="You don't have a web browser
installed.",
                           style=wx.OK | wx.ICON_EXCLAMATION)

This does not produce the "Python Error" message box at all. The "Python
Error" message box is only shown if I use wx.LaunchDefaultBrowser.

So the webbrowser module is doing something differenet than wx.LaunchDefaultBrowser. It would be interesting to see what.

So I
assume there is a bug in wxLaunchDefaultBrowser in wxWidgets. Please fix
this.

A note about open source project etiquette -- despite the please, this really is pretty rude -- who exactly are you asking to fix it? why should any of us do anything because you ask? Bug reports are always welcome, but demands to do something about it are not. A better approach might be :

"What can I do to help get this fixed?"

But anyway, in general, wxPython does not try to re-produce things are are in thepyton standard library, so this isn't really a high priority -- jsut use webbrowser.open()

-Chris

···

On 5/6/11 2:24 AM, Bo�tjan Mejak wrote:

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

wx.LaunchDefaultBrowser is a wxWidgets/wxPython function. The bug in it is not Python related.

Bo�tjan Mejak wrote:

  wx.LaunchDefaultBrowser is a wxWidgets/wxPython function. The bug

in it is not Python related.

I don't understand what you are trying to say here.� The standard

webbrowser.py module happens to use a different Windows API from the
wxWidgets wxLaunchDefaultBrowser function.� If one has the behavior
you want and the other doesn’t, then use the one that works the way
you want.� End of story.

If you want to submit a bug report against wxWidgets, please do so,

but there’s not much they can do about this.� They are calling the
ShellExecuteEx API with a flag that says “suppress error message
boxes”, and the API is ignoring that in this case.� It’s a Windows
bug.

As a general rule, when wx has functions that overlap those built-in

to Python, it’s always better to use built-in Python modules.

···
-- Tim Roberts, Providenza & Boekelheide, Inc.

timr@probo.com

Very well answered. Thank you.