Sorry guys, how do you print a message dialog box if a file doesn't exists in python? I am currently using a program to do segmentation of video file and assembling it the files that I need and excluding those I don't. I have completed the tasks but if I randomly type a file that doesn't exists, it will print an error but what I want is a message Dialog box to appear, is there any way to do this?

Recommended Answers

All 5 Replies

# error redirection=0 to console
# error redirection=1 to dialog window
app = wx.App(1)

you need to put the ode that opens the file in try-except braces.
Then open a wxMessagebox inside the catch(exeption) brace. Its been along time i worked with wx but the style and logic is the same on GUI's.

try{
    open file()
    }
except(msg){
     wxMessageBox(values,message,...)
     }

Vegaseat be nice will you.?
yea i faultered. Its PYTHON. thanks for your tip ))

Let's not forget that WxPython is just the wrapper for WxWindows which is written in C++.
The wrapper seems to ignore the C++ error handling. It could have been done, but wasn't.
I don't think there is any GUI toolkit that is written in pure Python, bummer.

On the other hand Python is very good glue language for other languages. It's easy to make wrappers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.