Skip to main content

Thread: Python help


i'm trying call message dialog if try statement returns error exception but, reason dialog not display. tested message dialog , display not when called statement. functions def playmine , def startserv. not sure i'm doing wrong or if possible within try statement.

code:
#!/usr/bin/env python  # -*- coding: utf-8 -*-    import os, sys    try:        import pygtk        pygtk.require("2.0")    except:        pass    try:        import gtk    except:        print("gtk+ not availible...")      sys.exit(1)            class craftygui:        def playmine(self,widget):          try:              os.system("minecraft &")          except oserror:              result = self.msg.run()              self.msg.destroy()        def startserv(self,widget):          try:              os.system("minecraft_server &")          except oserror:              result = self.msg.run()              self.msg.destroy()        def aboutcrafty(self,widget):          result = self.about.run()          self.about.destroy()        def quit(self,widget):          sys.exit(0)        def __init__(self):          builder = gtk.builder()          builder.add_from_file("shrewds-crafty-gui.ui")            self.about = builder.get_object("aboutdialog")          self.msg   = builder.get_object("messagedialog")                    builder.connect_signals(self)            craftygui = craftygui()  gtk.main()
thanks
--
chris

os.system not throw error if minecraft fails, returns minecrafts exit code.
so, instead of using try .. except block use like
code:
if os.system("blah") != 0:      self.msg.run()      self.msg.destroy()


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] Python help


Ubuntu

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support