Commits

Bill Bumgarner  committed e504dd2

Added a Cocoa-Python template.

  • Participants
  • Parent commits 873fb52

Comments (0)

Files changed (9)

File pyobjc/Project Templates/Cocoa-Python Application/CocoaApp.pbproj/TemplateInfo.plist

+{
+	FilesToMacroExpand = (
+		"English.lproj/InfoPlist.strings",
+		"bin-python-main.m",
+		"Main.py",
+		"MyAppDelegate.py",
+	);
+}

File pyobjc/Project Templates/Cocoa-Python Application/CocoaApp.pbproj/project.pbxproj

+// !$*UTF8*$!
+{
+	archiveVersion = 1;
+	classes = {
+	};
+	objectVersion = 38;
+	objects = {
+		080E96DCFE201CFB7F000001 = {
+			fileRef = 29B97318FDCFA39411CA2CEA;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		080E96DDFE201D6D7F000001 = {
+			children = (
+				F60DD8BC0358A22201C8ED3C,
+				F60DD8BD0358A22201C8ED3C,
+			);
+			isa = PBXGroup;
+			name = Classes;
+			refType = 4;
+		};
+		089C165CFE840E0CC02AAC07 = {
+			children = (
+				089C165DFE840E0CC02AAC07,
+			);
+			isa = PBXVariantGroup;
+			name = InfoPlist.strings;
+			refType = 4;
+		};
+		089C165DFE840E0CC02AAC07 = {
+			fileEncoding = 10;
+			isa = PBXFileReference;
+			name = English;
+			path = English.lproj/InfoPlist.strings;
+			refType = 4;
+		};
+		089C165EFE840E0CC02AAC07 = {
+			fileRef = 089C165CFE840E0CC02AAC07;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+//080
+//081
+//082
+//083
+//084
+//100
+//101
+//102
+//103
+//104
+		1058C7A1FEA54F0111CA2CBB = {
+			isa = PBXFrameworkReference;
+			name = Cocoa.framework;
+			path = /System/Library/Frameworks/Cocoa.framework;
+			refType = 0;
+		};
+//100
+//101
+//102
+//103
+//104
+//170
+//171
+//172
+//173
+//174
+		17587328FF379C6511CA2CBB = {
+			isa = PBXApplicationReference;
+			path = "«PROJECTNAME».app";
+			refType = 3;
+		};
+//170
+//171
+//172
+//173
+//174
+//190
+//191
+//192
+//193
+//194
+		19C28FACFE9D520D11CA2CBB = {
+			children = (
+				17587328FF379C6511CA2CBB,
+			);
+			isa = PBXGroup;
+			name = Products;
+			refType = 4;
+		};
+//190
+//191
+//192
+//193
+//194
+//290
+//291
+//292
+//293
+//294
+		29B97313FDCFA39411CA2CEA = {
+			buildStyles = (
+				4A9504CCFFE6A4B311CA0CBA,
+				4A9504CDFFE6A4B311CA0CBA,
+			);
+			isa = PBXProject;
+			mainGroup = 29B97314FDCFA39411CA2CEA;
+			projectDirPath = "";
+			targets = (
+				29B97326FDCFA39411CA2CEA,
+			);
+		};
+		29B97314FDCFA39411CA2CEA = {
+			children = (
+				080E96DDFE201D6D7F000001,
+				29B97315FDCFA39411CA2CEA,
+				29B97317FDCFA39411CA2CEA,
+				29B97323FDCFA39411CA2CEA,
+				19C28FACFE9D520D11CA2CBB,
+			);
+			isa = PBXGroup;
+			name = "«PROJECTNAMEASXML»";
+			path = "";
+			refType = 4;
+		};
+		29B97315FDCFA39411CA2CEA = {
+			children = (
+				29B97316FDCFA39411CA2CEA,
+			);
+			isa = PBXGroup;
+			name = "Other Sources";
+			path = "";
+			refType = 4;
+		};
+		29B97316FDCFA39411CA2CEA = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			path = "bin-python-main.m";
+			refType = 4;
+		};
+		29B97317FDCFA39411CA2CEA = {
+			children = (
+				29B97318FDCFA39411CA2CEA,
+				089C165CFE840E0CC02AAC07,
+			);
+			isa = PBXGroup;
+			name = Resources;
+			path = "";
+			refType = 4;
+		};
+		29B97318FDCFA39411CA2CEA = {
+			children = (
+				29B97319FDCFA39411CA2CEA,
+			);
+			isa = PBXVariantGroup;
+			name = MainMenu.nib;
+			path = "";
+			refType = 4;
+		};
+		29B97319FDCFA39411CA2CEA = {
+			isa = PBXFileReference;
+			name = English;
+			path = English.lproj/MainMenu.nib;
+			refType = 4;
+		};
+		29B97323FDCFA39411CA2CEA = {
+			children = (
+				F60DD8D00358A5D701C8ED3C,
+				29B97324FDCFA39411CA2CEA,
+				1058C7A1FEA54F0111CA2CBB,
+				29B97325FDCFA39411CA2CEA,
+			);
+			isa = PBXGroup;
+			name = "Frameworks & Modules";
+			path = "";
+			refType = 4;
+		};
+		29B97324FDCFA39411CA2CEA = {
+			isa = PBXFrameworkReference;
+			name = AppKit.framework;
+			path = /System/Library/Frameworks/AppKit.framework;
+			refType = 0;
+		};
+		29B97325FDCFA39411CA2CEA = {
+			isa = PBXFrameworkReference;
+			name = Foundation.framework;
+			path = /System/Library/Frameworks/Foundation.framework;
+			refType = 0;
+		};
+		29B97326FDCFA39411CA2CEA = {
+			buildPhases = (
+				29B97327FDCFA39411CA2CEA,
+				29B97328FDCFA39411CA2CEA,
+				29B9732BFDCFA39411CA2CEA,
+				29B9732DFDCFA39411CA2CEA,
+				F60DD8ED0358A61B01C8ED3C,
+			);
+			buildSettings = {
+				FRAMEWORK_SEARCH_PATHS = "";
+				HEADER_SEARCH_PATHS = "";
+				INSTALL_PATH = "$(HOME)/Applications";
+				LIBRARY_SEARCH_PATHS = "";
+				OTHER_CFLAGS = "";
+				OTHER_LDFLAGS = "";
+				PRODUCT_NAME = "«PROJECTNAME»";
+				SECTORDER_FLAGS = "";
+				WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
+				WRAPPER_EXTENSION = app;
+			};
+			dependencies = (
+			);
+			isa = PBXApplicationTarget;
+			name = "«PROJECTNAME»";
+			productInstallPath = "$(HOME)/Applications";
+			productName = "«PROJECTNAME»";
+			productReference = 17587328FF379C6511CA2CBB;
+			productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
+<plist version=\"1.0\">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleExecutable</key>
+	<string>«PROJECTNAMEASXML»</string>
+	<key>CFBundleIconFile</key>
+	<string></string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundlePackageType</key>
+	<string>APPL</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>0.1</string>
+	<key>NSMainNibFile</key>
+	<string>MainMenu</string>
+	<key>NSPrincipalClass</key>
+	<string>NSApplication</string>
+</dict>
+</plist>
+";
+			shouldUseHeadermap = 1;
+		};
+		29B97327FDCFA39411CA2CEA = {
+			buildActionMask = 2147483647;
+			files = (
+			);
+			isa = PBXHeadersBuildPhase;
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		29B97328FDCFA39411CA2CEA = {
+			buildActionMask = 2147483647;
+			files = (
+				080E96DCFE201CFB7F000001,
+				089C165EFE840E0CC02AAC07,
+				F60DD8BE0358A22201C8ED3C,
+				F60DD8BF0358A22201C8ED3C,
+			);
+			isa = PBXResourcesBuildPhase;
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		29B9732BFDCFA39411CA2CEA = {
+			buildActionMask = 2147483647;
+			files = (
+				29B9732CFDCFA39411CA2CEA,
+			);
+			isa = PBXSourcesBuildPhase;
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		29B9732CFDCFA39411CA2CEA = {
+			fileRef = 29B97316FDCFA39411CA2CEA;
+			isa = PBXBuildFile;
+			settings = {
+				ATTRIBUTES = (
+				);
+			};
+		};
+		29B9732DFDCFA39411CA2CEA = {
+			buildActionMask = 2147483647;
+			files = (
+				F60DD8CF0358A5C101C8ED3C,
+			);
+			isa = PBXFrameworksBuildPhase;
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+//290
+//291
+//292
+//293
+//294
+//4A0
+//4A1
+//4A2
+//4A3
+//4A4
+		4A9504CCFFE6A4B311CA0CBA = {
+			buildRules = (
+			);
+			buildSettings = {
+				COPY_PHASE_STRIP = NO;
+				OPTIMIZATION_CFLAGS = "-O0";
+			};
+			isa = PBXBuildStyle;
+			name = Development;
+		};
+		4A9504CDFFE6A4B311CA0CBA = {
+			buildRules = (
+			);
+			buildSettings = {
+				COPY_PHASE_STRIP = YES;
+			};
+			isa = PBXBuildStyle;
+			name = Deployment;
+		};
+//4A0
+//4A1
+//4A2
+//4A3
+//4A4
+//F60
+//F61
+//F62
+//F63
+//F64
+		F60DD8BC0358A22201C8ED3C = {
+			isa = PBXExecutableFileReference;
+			path = Main.py;
+			refType = 2;
+		};
+		F60DD8BD0358A22201C8ED3C = {
+			isa = PBXFileReference;
+			path = MyAppDelegate.py;
+			refType = 2;
+		};
+		F60DD8BE0358A22201C8ED3C = {
+			fileRef = F60DD8BC0358A22201C8ED3C;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		F60DD8BF0358A22201C8ED3C = {
+			fileRef = F60DD8BD0358A22201C8ED3C;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		F60DD8CF0358A5C101C8ED3C = {
+			fileRef = 29B97325FDCFA39411CA2CEA;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		F60DD8D00358A5D701C8ED3C = {
+			children = (
+				F60DD8D10358A60901C8ED3C,
+				F60DD8D80358A60901C8ED3C,
+				F60DD8DD0358A60901C8ED3C,
+			);
+			isa = PBXGroup;
+			name = pyobjc;
+			refType = 4;
+		};
+		F60DD8D10358A60901C8ED3C = {
+			includeInIndex = 1;
+			isa = PBXFolderReference;
+			name = AppKit;
+			path = "/usr/lib/python2.2/site-packages/AppKit";
+			refType = 0;
+		};
+		F60DD8D80358A60901C8ED3C = {
+			includeInIndex = 1;
+			isa = PBXFolderReference;
+			name = Foundation;
+			path = "/usr/lib/python2.2/site-packages/Foundation";
+			refType = 0;
+		};
+		F60DD8DD0358A60901C8ED3C = {
+			includeInIndex = 1;
+			isa = PBXFolderReference;
+			name = objc;
+			path = "/usr/lib/python2.2/site-packages/objc";
+			refType = 0;
+		};
+		F60DD8ED0358A61B01C8ED3C = {
+			buildActionMask = 8;
+			dstPath = pyobjc;
+			dstSubfolderSpec = 7;
+			files = (
+				F60DD8EE0358A62701C8ED3C,
+				F60DD8EF0358A62701C8ED3C,
+				F60DD8F00358A62701C8ED3C,
+			);
+			isa = PBXCopyFilesBuildPhase;
+			runOnlyForDeploymentPostprocessing = 1;
+		};
+		F60DD8EE0358A62701C8ED3C = {
+			fileRef = F60DD8D10358A60901C8ED3C;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		F60DD8EF0358A62701C8ED3C = {
+			fileRef = F60DD8D80358A60901C8ED3C;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		F60DD8F00358A62701C8ED3C = {
+			fileRef = F60DD8DD0358A60901C8ED3C;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+	};
+	rootObject = 29B97313FDCFA39411CA2CEA;
+}

File pyobjc/Project Templates/Cocoa-Python Application/English.lproj/InfoPlist.strings

Binary file added.

File pyobjc/Project Templates/Cocoa-Python Application/English.lproj/MainMenu.nib/classes.nib

+{
+    IBClasses = (
+        {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 
+        {
+            ACTIONS = {sayHelloAction = id; }; 
+            CLASS = MyAppDelegate; 
+            LANGUAGE = ObjC; 
+            OUTLETS = {messageTextField = NSTextField; }; 
+            SUPERCLASS = NSObject; 
+        }
+    ); 
+    IBVersion = 1; 
+}

File pyobjc/Project Templates/Cocoa-Python Application/English.lproj/MainMenu.nib/info.nib

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IBEditorPositions</key>
+	<dict>
+		<key>29</key>
+		<string>82 252 318 44 0 0 1152 746 </string>
+	</dict>
+	<key>IBFramework Version</key>
+	<string>286.0</string>
+	<key>IBOpenObjects</key>
+	<array>
+		<integer>29</integer>
+		<integer>21</integer>
+	</array>
+	<key>IBSystem Version</key>
+	<string>6D52</string>
+</dict>
+</plist>

File pyobjc/Project Templates/Cocoa-Python Application/English.lproj/MainMenu.nib/keyedobjects.nib

Binary file added.

File pyobjc/Project Templates/Cocoa-Python Application/Main.py

+#
+#  Main.py
+#  �PROJECTNAME�
+#
+#  Created by �FULLUSERNAME� on �DATE�.
+#  Copyright (c) �YEAR� �ORGANIZATIONNAME�. All rights reserved.
+#
+
+# 
+# Upon an installation build, the project copies the PyObjC modules
+# into the 'pyobjc' directory within the Resources directory of
+# the app wrapper.  The following adjusts sys.path to include that
+# directory.
+#
+import sys
+import os.path
+sys.path.insert(0, os.path.join(sys.path[0], "pyobjc"))
+
+#
+# Import the components of the Python<->ObjC bridge.
+#
+import objc
+import Foundation
+import AppKit
+
+#
+# Import application specific componentry.  At the least, all
+# classes necessary to load the main NIB file must be loaded here.
+#
+import MyAppDelegate
+
+#
+# Pass control to the Appkit.
+#
+# From this point on, application intiailization, execution and
+# termination works exactly like any other Cocoa application.
+#
+sys.exit( AppKit.NSApplicationMain(sys.argv) )

File pyobjc/Project Templates/Cocoa-Python Application/MyAppDelegate.py

+#
+#  MyAppDelegate.py
+#  �PROJECTNAME�
+#
+#  Created by �FULLUSERNAME� on �DATE�.
+#  Copyright (c) �YEAR� �ORGANIZATIONNAME�. All rights reserved.
+#
+
+from objc import IBOutlet
+from Foundation import NSObject, NSProcessInfo, NSFullUserName, NSLog
+
+class MyAppDelegate (NSObject):
+  messageTextField = IBOutlet("messageTextField")
+  
+  def sayHelloAction_(self, sender):
+    userName = NSFullUserName()
+    hostName = NSProcessInfo.processInfo().hostName()
+    helloString = "Hello %s @ %s!" % (userName, hostName)
+    
+    self.messageTextField.setStringValue_( helloString )
+    NSLog( "Saying: %s" % helloString )
+    
+  def applicationDidFinishLaunching_(self, aNotification):
+    NSLog( "Application did finish launching." )

File pyobjc/Project Templates/Cocoa-Python Application/bin-python-main.m

+//
+//  bin-python-main.m
+//  �PROJECTNAME�
+//
+//  Created by �FULLUSERNAME� on �DATE�.
+//  Copyright (c) �YEAR� �ORGANIZATIONNAME�. All rights reserved.
+//
+
+/*
+ This main file uses execve() to transfer control of execution to the standard command line python interpreter.   As such, compiled classes in the project will not actually be linked into the runtime as execve() effectively overlays the existing process with the process being called -- in this case the python command line tool.
+
+ To use compiled classes with this main, create a separate bundle target and load the bundle in the Main.py file.
+
+ This style of execution works with the Apple provided version of Python (or with any other build of python that provides a command line executable interpreter and can load bundles).
+ */
+
+#import <Foundation/Foundation.h>
+#import <sys/param.h>
+#import <unistd.h>
+
+int pyobjc_main(int argc, char * const *argv, char *envp[])
+{
+  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+  const char **childArgv = alloca(sizeof(char *) * (argc + 3));
+  const char *pythonBinPathPtr;
+  const char *mainPyPathPtr;
+  int i;
+
+  NSString *pythonBinPath = [[NSUserDefaults standardUserDefaults] stringForKey: @"PythonBinPath"];
+  pythonBinPath = pythonBinPath ? pythonBinPath : @"/usr/bin/python";
+  [pythonBinPath retain];
+  pythonBinPathPtr = [pythonBinPath cString];
+
+  NSString *mainPyFile = [[[NSBundle mainBundle] infoDictionary] objectForKey: @"PrincipalPythonFile"];
+  NSString *mainPyPath = nil;
+
+  if (mainPyFile)
+    mainPyPath = [[NSBundle mainBundle] pathForResource: mainPyFile ofType: nil];
+
+  if ( !mainPyPath )
+    mainPyPath = [[NSBundle mainBundle] pathForResource: @"Main.py" ofType: nil];
+
+  if ( !mainPyPath )
+    [NSException raise: NSInternalInconsistencyException
+                format: @"%s:%d pyobjc_main() Failed to find main python entry point for application.  Exiting.", __FILE__, __LINE__];
+  [mainPyPath retain];
+  mainPyPathPtr = [mainPyPath cString];
+
+  childArgv[0] = argv[0];
+  childArgv[1] = mainPyPathPtr;
+  for (i = 1; i<argc; i++)
+    childArgv[i+2] = argv[i];
+  childArgv[i+2] = NULL;
+
+  [pool release];
+
+  return execve(pythonBinPathPtr, (char **)childArgv, envp);
+}
+
+int main(int argc, char * const *argv, char *envp[])
+{
+  return pyobjc_main(argc, argv, envp);
+}