Is there a way to block an app under an OS. Like I wanna block an app to run under Mac OS X. Doing if platform.system() == ‘Darwin’: return False in OnInit of wx.App does not work. Any other ideas?
Check either
sys.platform == “darwin” :
or
wx.Platform == ‘WXMAC’
Check this after creating the App, then pop up a wx.MessageBox saying “This app is not supported on MacOS”, and call sys.exit(0) instead of App.MainLoop(). Raising a RuntimeError during OnInit will also take down the program, but ill-advised - if this is something you’re going to distribute, you should at least show the user a more helpful message than a Python traceback.
-Nat
···
On Tue, Dec 7, 2010 at 3:09 PM, Boštjan Mejak bostjan.mejak@gmail.com wrote:
Is there a way to block an app under an OS. Like I wanna block an app to run under Mac OS X. Doing if platform.system() == ‘Darwin’: return False in OnInit of wx.App does not work. Any other ideas?
I have managed to kill the app if the operating system is the Mac OS X. I am returning False in OnInit of wx.App if sys.platform == ‘darwin’. I also show a wx.MessageBox() to the user. And after the button OK is pressed, the app itself returns a string ‘OnInit returned false, exiting…’. However, if I kill the app by sys.exit(0), I get no nagging string. Is it possible to suppress the string ‘OnInit returned false, exiting…’ somehow? As a side note: the string should really say ‘OnInit returned False, exiting…’.
Catch the SystemExit exception that is being raised and do something different.
···
On 12/7/10 5:04 PM, Bo�tjan Mejak wrote:
I have managed to kill the app if the operating system is the Mac OS X.
I am returning False in OnInit of wx.App if sys.platform == 'darwin'. I
also show a wx.MessageBox() to the user. And after the button OK is
pressed, the app itself returns a string 'OnInit returned false,
exiting...'. However, if I kill the app by sys.exit(0), I get no nagging
string. Is it possible to suppress the string 'OnInit returned false,
exiting...' somehow? As a side note: the string should really say
'OnInit returned False, exiting...'.
--
Robin Dunn
Software Craftsman
Robin, please fix the string ‘OnInit returned false, exiting…’ to ‘OnInit returned False, exiting…’. If this string comes from wxWidgets, then please fix it in wxWidgets.