[PyObjC-svn] r2066 - in trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/DotView: . English.lproj English.lproj/MainMenu.nib

[email protected]
Newsgroups gmane.comp.python.pyobjc.cvs
Message-ID <[email protected]>
Author: ronaldoussoren
Date: Sun Mar  1 16:23:54 2009
New Revision: 2066

Log:
- Remove NibClassBuilder from this example
- Convert nib file to a 3.x style .xib file
  (requires r72 from the py2app repository)


Added:
   trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/DotView/English.lproj/MainMenu.xib
Removed:
   trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/DotView/English.lproj/MainMenu.nib/
Modified:
   trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/DotView/   (props changed)
   trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/DotView/DotView.py

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/DotView/DotView.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/DotView/DotView.py	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/DotView/DotView.py	Sun Mar  1 16:23:54 2009
@@ -20,30 +20,16 @@
 # -> Scroll View), and *no* work in the code. It was too easy, so for kicks
 # I added zoom functionality and a "Show rulers" checkbox.
 
-from AppKit import NSBezierPath, NSColor, NSRectFill
-from AppKit import NSCommandKeyMask
-from PyObjCTools import NibClassBuilder, AppHelper
-
-try:
-    True, False
-except NameError:
-    # True and False are not defined in Python before Python 2.2.1
-    True, False = 1, 0
-
-
-# create ObjC classes as defined in MainMenu.nib
-NibClassBuilder.extractClasses("MainMenu")
-
+from Cocoa import *
+from PyObjCTools import AppHelper
 
 ZOOM = 2.0
 
 
 # class defined in MainMenu.nib
-class DotView(NibClassBuilder.AutoBaseClass):
-    # the actual base class is NSView
-    # The following outlets are added to the class:
-    # colorWell
-    # sizeSlider
+class DotView(NSView):
+    colorWell = objc.IBOutlet()
+    sizeSlider = objc.IBOutlet()
 
     def initWithFrame_(self, frame):
         self.center = (50.0, 50.0)
@@ -59,6 +45,7 @@
         scrollView.setHasHorizontalRuler_(1)
         scrollView.setHasVerticalRuler_(1)
 
+    @objc.IBAction
     def zoomIn_(self, sender):
         (x, y), (bw, bh) = self.bounds()
         (x, y), (fw, fh) = self.frame()
@@ -66,6 +53,7 @@
         self.setFrameSize_((fw * ZOOM, fh * ZOOM))
         self.setNeedsDisplay_(True)
 
+    @objc.IBAction
     def zoomOut_(self, sender):
         (x, y), (bw, bh) = self.bounds()
         (x, y), (fw, fh) = self.frame()
@@ -73,6 +61,7 @@
         self.setFrameSize_((fw / ZOOM, fh / ZOOM))
         self.setNeedsDisplay_(True)
 
+    @objc.IBAction
     def setRulersVisible_(self, button):
         scrollView = self.superview().superview()
         scrollView.setRulersVisible_(button.state())
@@ -114,10 +103,12 @@
         self.color.set()
         NSBezierPath.bezierPathWithOvalInRect_(dotRect).fill()
 
+    @objc.IBAction
     def setRadius_(self, sender):
         self.radius = sender.floatValue()
         self.setNeedsDisplay_(True)
 
+    @objc.IBAction
     def setColor_(self, sender):
         self.color = sender.color()
         self.setNeedsDisplay_(True)

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.