If wxPython is not installed

You’d have to use some other GUI toolkit to manage the message box. You could check to see if QT is installed and use that if it is, I suppose.

David

···

On Jun 12, 2015 12:26 PM, “Boštjan Mejak” bostjan.xperia@gmail.com wrote:

Please look at my code snippet here: https://bpaste.net/show/721e8d0044c4. Notice that my code wouldn’t work if the user (that’ll use my app on his/her machine) doesn’t have wxPython installed, because the exception would raise its own exception.

My goal is to tell the user to install wxPython, but tell the user in a message box, not via the exception message string. Got any idea how should I tackle with my challenge?

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Actually it would be smarter to use a GUI toolkit already included in python: Tkinter

def show_no_wx():
import tkMessageBox

# we have to create a main window to be able to hide it
# see http://stackoverflow.com/questions/17280637/tkinter-messagebox-without-window
import Tkinter
root = Tkinter.Tk()
root.withdraw()

tkMessageBox.showerror("No wx", "Error: no wxPython, install it first!")

try:
import _wx
except ImportError:
# wx not installed
show_no_wx()
raise

``

This was actually fun!

···

On Friday, June 12, 2015 at 7:35:18 PM UTC+2, David Woods wrote:

You’d have to use some other GUI toolkit to manage the message box. You could check to see if QT is installed and use that if it is, I suppose.

David

wx was written as _wx so that it could be tested on a machine which has wx, sorry for not fixing that

nepix32 wrote:

Actually it would be smarter to use a GUI toolkit already included in
python: Tkinter

This is a good answer. Tkinter is built-in and will always be available.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Except on Mac…I don’t know why. I had to specifically install ActiveState’s TCL library to use Tkinter on Mac 10.6+ (IDLE and tkinter with Tcl/Tk on macOS | Python.org)…

Mike

···

On Friday, June 12, 2015 at 4:18:33 PM UTC-5, Tim Roberts wrote:

nepix32 wrote:

Actually it would be smarter to use a GUI toolkit already included in

python: Tkinter

This is a good answer. Tkinter is built-in and will always be available.


Tim Roberts, ti...@probo.com

Providenza & Boekelheide, Inc.

Well, it’s there but buggy.

I think this is getting addressed in future, if not the latest, releases.

Cnut there are no other platform independent options.

-Chris

···

On Jun 12, 2015, at 2:25 PM, Mike Driscoll kyosohma@gmail.com wrote:

On Friday, June 12, 2015 at 4:18:33 PM UTC-5, Tim Roberts wrote:

nepix32 wrote:

Actually it would be smarter to use a GUI toolkit already included in

python: Tkinter

This is a good answer. Tkinter is built-in and will always be available.


Tim Roberts, ti...@probo.com

Providenza & Boekelheide, Inc.

Except on Mac…I don’t know why. I had to specifically install ActiveState’s TCL library to use Tkinter on Mac 10.6+ (https://www.python.org/download/mac/tcltk/)…

Mike

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

http://stackoverflow.com/questions/774175/how-can-i-open-a-message-box-in-a-windows-batch-file

Or a more cross-platform way; open a browser with a local HTML file which
is distributed by you.

I googled "popup a message box".

And extremely cross-platform, indeed.

Karsten

···

On Sun, Jun 14, 2015 at 11:49:30AM +0200, Boštjan Mejak wrote:

Found something even better than the batch script solution. ctypes to the
rescue!

import ctypes
ctypes.windll.user32.MessageBoxW(0, "wxPython is missing.", "App Error", 0)

Works like a charm! :wink:

--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

I wasn't aiming for platform independency here.

Then I must have misunderstood. Your first postings to me
seemed to imply as much.

On Windows, you'd just use ctypes for this purpose, but on
Linux I can't say what is there to use. Got a clue?

Not beyond what was already suggested:

- use tkinter
- use webbrowser.open()

Karsten

···

On Sun, Jun 14, 2015 at 02:07:16PM +0200, Boštjan Mejak wrote:
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

Uhm, Chris, what did you mean to say with the word "cnut"? Is it a typo?

typo -- was supposed to be 'but' -- not sure how that happened!

And it turns out I was wrong the browser option is cross platform and would
work well -- even better if the app has a web page to refer to!

note that it is probably possible to use ctypes to do platform-specific
things for other platforms. Though On Linux at least, a regular old console
message would probably be fine.

On OS-X, I note that Apple's built-in Python has a (likely old) version of
wx out of the box.

-Chris

···

On Sat, Jun 13, 2015 at 12:19 AM, Boštjan Mejak <bostjan.xperia@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

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

It won't show a message box but it will enable people to see
a HTML page in a cross platform way regardless of whether
wxPython (or, in fact, any other UI toolkit) is installed.

  import webbrowser
  webbrowser.open('file:://path/to/your/file.html')

Karsten

···

On Sun, Jun 14, 2015 at 10:03:29PM +0200, Boštjan Mejak wrote:

Karsten, you mentioned webbrowser.open() for this purpose and achieve
platform independency, but I have no idea how to show a message box using
the webbrowser module. Can you like express yourself in code?

--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

You would open an HTML page provided by yours truly which
explains what to do and also links to the download.

Karsten

···

On Sun, Jun 14, 2015 at 10:13:48PM +0200, Boštjan Mejak wrote:

I can open Redirecting... in the user's browser
with webbrowser.open("Redirecting...), but the
user would be baffled as to why did his browser open a wxpython.org web
page. I am assuming that my users are very dumb and I am making sure that I
am speaking to them directly via a message box and instructing them exactly
what to do, rather than giving them a hint by opening a web page that they
probably never heard of and expect they'll understand the hint and install
wxPython. I must tell you, some people are really dumb.

--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346