Commits

Bob Ippolito committed 76e5740

ScreenSaver example, contributed by Jason Toffaletti <catalyst@mac.com>

Comments (0)

Files changed (7)

pyobjc/Examples/SillyBallsSaver/English.lproj/InfoPlist.strings

+/* Localized versions of Info.plist keys */
+
+CFBundleName = "Silly Balls";
+CFBundleShortVersionString = "Silly Balls version 0.0.1d1";
+CFBundleGetInfoString = "Silly Balls version 0.0.1d1, Copyright 2000, MyGreatSoftware.";
+NSHumanReadableCopyright = "Copyright 2000, MyGreatSoftware.";

pyobjc/Examples/SillyBallsSaver/English.lproj/SillyBalls.nib/classes.nib

+{
+    IBClasses = (
+        {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 
+        {CLASS = ScreenSaverView; LANGUAGE = ObjC; SUPERCLASS = NSView; }, 
+        {CLASS = SillyBalls; LANGUAGE = ObjC; SUPERCLASS = ScreenSaverView; }
+    ); 
+    IBVersion = 1; 
+}

pyobjc/Examples/SillyBallsSaver/English.lproj/SillyBalls.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>IBDocumentLocation</key>
+	<string>192 23 356 240 0 0 1152 746 </string>
+	<key>IBFramework Version</key>
+	<string>349.0</string>
+	<key>IBSystem Version</key>
+	<string>7B85</string>
+</dict>
+</plist>
Add a comment to this file

pyobjc/Examples/SillyBallsSaver/English.lproj/SillyBalls.nib/keyedobjects.nib

Binary file added.

pyobjc/Examples/SillyBallsSaver/README.txt

+SillyBallsSaver
+
+Example showing screen saver in Python
+
+Based on "Silly Balls.saver" by Eric Peyton <epeyton@epicware.com>
+    
+
+See:    http://www.epicware.com/macosxsavers.html
+        http://developer.apple.com/documentation/UserExperience/Reference/ScreenSaver/ObjC_classic/Classes/ScreenSaverView.html
+        http://www.cocoadev.com/index.pl?ScreenSaver
+
+The source of this application demonstrates
+- Writing a ScreenSaver in PyObjC
+- Building plug-in bundles in PyObjC
+
+Jason Toffaletti <catalyst@mac.com>

pyobjc/Examples/SillyBallsSaver/SillyBalls.py

+"""
+Example showing screen saver in PyObjC
+
+Based on "Silly Balls.saver" by Eric Peyton <epeyton@epicware.com>
+    http://www.epicware.com/macosxsavers.html
+"""
+import objc
+from AppKit import NSBezierPath, NSColor
+from ScreenSaver import *
+from random import random, randrange
+from PyObjCTools import NibClassBuilder
+
+# NibClassBuilder needs to read our Nib files to do its work,
+# we need to specify the optional second argument to extractClasses
+# because we're not in the main bundle.
+NibClassBuilder.extractClasses("SillyBalls", objc.pluginBundle("SillyBalls"))
+
+class SillyBalls (NibClassBuilder.AutoBaseClass):
+    def animateOneFrame(self):
+        # choose a random point. 
+        (x, y), (fw, fh) = self.frame()
+        x, y = randrange(0.0, fw), randrange(0.0, fw)
+        ballSize = randrange(10.0, 90.0)
+        
+        path = NSBezierPath.bezierPathWithOvalInRect_(((x, y), (ballSize, ballSize)))
+        
+        # make a random color.
+        randomColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(random(), random(), random(), random())
+        
+        # set it.
+        randomColor.set()
+        
+        # draw a new ball.
+        path.fill()

pyobjc/Examples/SillyBallsSaver/buildplugin.py

+from PyObjCTools.pluginbuilder import buildplugin
+
+buildplugin(
+    name = "SillyBalls",
+    mainmodule = "SillyBalls.py",
+    nibname = "SillyBalls",
+    principalClass = "SillyBalls",
+    resources = ["English.lproj"],
+    bundlesuffix = ".saver",
+)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.