1. Ronald Oussoren
  2. pyobjc


Ronald Oussoren  committed 6bf6f7a

- runEventloop -> runEventLoop
- fix NibClassBuilder breakage that was introduced during the move to
- NibClassBuilder generates a default main block

Changes have not yet been tested, but do compile

  • Participants
  • Parent commits 2bb0343
  • Branches default

Comments (0)

Files changed (2)

File pyobjc/Lib/PyObjCTools/AppHelper.py

View file
 Currently only a single function is exported: runEventloop
 from AppKit import NSApplicationMain, NSApp, NSRunAlertPanel
+import traceback
 def unexpectedErrorAlert():
     exceptionInfo = traceback.format_exception_only(
             "Continue", "Quit", None)
-def runEventloop(argv, unexpectedErrorAlert = unexpectedErrorAlert):
+def runEventLoop(argv, unexpectedErrorAlert = unexpectedErrorAlert):
-    Run the eventloop, ask the user if we should continue when 
+    Run the event loop, ask the user if we should continue when 
     catching exceptions. Use this function instead of NSApplicationMain
     mainFunc = NSApplicationMain

File pyobjc/Lib/PyObjCTools/NibClassBuilder.py

View file
 				writer.writeln("# *** base class not found: %s" % clsInfo.super)
 				self._printClass(writer, clsInfo)
+                self._printTemplateFooter(self, writer)
 	def _printTemplateHeader(self, writer):
 		frameworks = {}
 			for framework, classes in items:
 				writer.writeln("from %s import %s" % (framework, ", ".join(classes)))
-		writer.writeln("from AppKit import NibClassBuilder")
-		writer.writeln("from AppKit.NibClassBuilder import AutoBaseClass")
+		writer.writeln("from PyObjCTools import NibClassBuilder, AppHelper")
 		nibs = nibs.keys()
+	def _printTemplateHeader(self, writer):
+            writer.writeln()
+            writer.writeln('if __name__ == "__main__":')
+            writer.indent()
+            writer.writeln('AppHelper.runEventLoop()')
+            writer.dedent()
 	def _printClass(self, writer, clsInfo):
 			nibs = clsInfo.nibs
 			if len(nibs) > 1:
 				del nibs[-1]
 			nibs = ", ".join(nibs)
 			writer.writeln("# class defined in %s" % nibs)
-			writer.writeln("class %s(AutoBaseClass):" % clsInfo.name)
+			writer.writeln("class %s(NibClassBuilder.AutoBaseClass):" % clsInfo.name)
 			writer.writeln("# the actual base class is %s" % clsInfo.super)
 			outlets = clsInfo.outlets