On Thursday, January 13, 2011, Fars- mo <far...@live.com> wrote: > And I'm replying to myself to add that there are other possibilities too: > > # using a callback > > def main(): > ... > > if __name__=="__main__": > QApplication().execute(main) # or QApplication.execute(main) for short > > > # using a decorator > > @QMainFunction > def main(): > ... > > if __name__=="__main__": > main() > > > The decorator solution looks pretty satisfactory to me, but it requires > either defining a new class like QMainFunction, or adding a static method > decorator such as @QApplication.main.
I'd favor forms that allow you to keep a reference to the app object with the minimum fuss and magic, because for some apps you might need it... the forms in your first e-mail, to be exact. Also, the decorator approach is very Python, but to me gives the impression that there are two main "functions" now, because I've always though of the "if __name__=='__main__'" bit as being the semantic equivalent of the C/C++ main(). -- Ilkka -- Ilkka github.com/ilkka twitter.com/ilkkalaukkanen _______________________________________________ PySide mailing list PySide@lists.openbossa.org http://lists.openbossa.org/listinfo/pyside