[PyObjC-svn] r2110 - trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher
[email protected] Sun, 22 Mar 2009 12:28:21 -0500
Newsgroups
gmane.comp.python.pyobjc.cvs
Message-ID
<[email protected] >
Author: ronaldoussoren
Date: Sun Mar 22 12:28:21 2009
New Revision: 2110
Log:
Remove NibClassBuilder usage
Modified:
trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/ (props changed)
trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/MyDocument.py
trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/PreferencesWindowController.py
trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/PyObjCLauncher.py
Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/MyDocument.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/MyDocument.py (original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/MyDocument.py Sun Mar 22 12:28:21 2009
@@ -5,7 +5,20 @@
from FileSettings import *
from doscript import doscript
-class MyDocument(NibClassBuilder.AutoBaseClass):
+class MyDocument(NSDocument):
+ commandline = objc.IBOutlet()
+ debug = objc.IBOutlet()
+ honourhashbang = objc.IBOutlet()
+ inspect = objc.IBOutlet()
+ interpreter = objc.IBOutlet()
+ nosite = objc.IBOutlet()
+ optimize = objc.IBOutlet()
+ others = objc.IBOutlet()
+ scriptargs = objc.IBOutlet()
+ tabs = objc.IBOutlet()
+ verbose = objc.IBOutlet()
+ with_terminal = objc.IBOutlet()
+
def init(self):
self = super(MyDocument, self).init()
if self is not None:
@@ -25,7 +38,7 @@
def load_defaults(self):
self.settings = FileSettings.newSettingsForFileType_(self.filetype)
- def update_display(self):
+ def updateDisplay(self):
dct = self.settings.fileSettingsAsDict()
self.interpreter.setStringValue_(dct['interpreter'])
self.honourhashbang.setState_(dct['honourhashbang'])
@@ -57,7 +70,7 @@
def windowControllerDidLoadNib_(self, aController):
super(MyDocument, self).windowControllerDidLoadNib_(aController)
self.load_defaults()
- self.update_display()
+ self.updateDisplay()
def dataRepresentationOfType_(self, aType):
return None
@@ -68,33 +81,37 @@
self.filetype = typ
self.settings = FileSettings.newSettingsForFileType_(typ)
if show_ui:
- self.update_display()
+ self.updateDisplay()
return True
else:
self.run()
self.close()
return False
+ @objc.IBAction
def doRun_(self, sender):
self.update_settings()
- self.update_display()
+ self.updateDisplay()
if self.run():
self.close()
+ @objc.IBAction
def doCancel_(self, sender):
self.close()
+ @objc.IBAction
def doReset_(self, sender):
self.settings.reset()
- self.update_display()
+ self.updateDisplay()
+ @objc.IBAction
def doApply_(self, sender):
self.update_settings()
- self.update_display()
+ self.updateDisplay()
def controlTextDidChange_(self, aNotification):
self.update_settings()
- self.update_display()
+ self.updateDisplay()
def fileSettingsAsDict(self):
return dict(
Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/PreferencesWindowController.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/PreferencesWindowController.py (original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/PreferencesWindowController.py Sun Mar 22 12:28:21 2009
@@ -3,7 +3,19 @@
from PyObjCTools import NibClassBuilder
from FileSettings import *
-class PreferencesWindowController(NibClassBuilder.AutoBaseClass):
+class PreferencesWindowController(NSWindowController):
+ commandline = objc.IBOutlet()
+ debug = objc.IBOutlet()
+ filetype = objc.IBOutlet()
+ honourhashbang = objc.IBOutlet()
+ inspect = objc.IBOutlet()
+ interpreter = objc.IBOutlet()
+ nosite = objc.IBOutlet()
+ optimize = objc.IBOutlet()
+ others = objc.IBOutlet()
+ tabs = objc.IBOutlet()
+ verbose = objc.IBOutlet()
+ with_terminal = objc.IBOutlet()
_singleton = None
settings = None
@@ -21,7 +33,7 @@
title = self.filetype.titleOfSelectedItem()
self.settings = FileSettings.getDefaultsForFileType_(title)
- def update_display(self):
+ def updateDisplay(self):
if self.settings is None:
return
dct = self.settings.fileSettingsAsDict()
@@ -42,27 +54,30 @@
super(PreferencesWindowController, self).windowDidLoad()
try:
self.load_defaults()
- self.update_display()
+ self.updateDisplay()
except:
import traceback
traceback.print_exc()
import pdb, sys
pdb.post_mortem(sys.exc_info()[2])
- def update_settings(self):
+ def updateSettings(self):
self.settings.updateFromSource_(self)
+ @objc.IBAction
def doFiletype_(self, sender):
self.load_defaults()
- self.update_display()
+ self.updateDisplay()
+ @objc.IBAction
def doReset_(self, sender):
self.settings.reset()
- self.update_display()
+ self.updateDisplay()
+ @objc.IBAction
def doApply_(self, sender):
- self.update_settings()
- self.update_display()
+ self.updateSettings()
+ self.updateDisplay()
def fileSettingsAsDict(self):
return dict(
@@ -80,8 +95,8 @@
)
def controlTextDidChange_(self, aNotification):
- self.update_settings()
- self.update_display()
+ self.updateSettings()
+ self.updateDisplay()
def comboBox_indexOfItemWithStringValue_(self, aComboBox, aString):
if self.settings is None:
Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/PyObjCLauncher.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/PyObjCLauncher.py (original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/PyObjCLauncher.py Sun Mar 22 12:28:21 2009
@@ -1,12 +1,10 @@
+import objc; objc.setVerbose(1)
from AppKit import *
from Foundation import *
-from PyObjCTools import NibClassBuilder, AppHelper
-NibClassBuilder.extractClasses('MainMenu.nib')
-NibClassBuilder.extractClasses('PreferenceWindow.nib')
-NibClassBuilder.extractClasses('MyDocument.nib')
-from PreferencesWindowController import *
+from PyObjCTools import AppHelper
from MyDocument import *
from LaunchServices import *
+from PreferencesWindowController import *
PYTHON_EXTENSIONS = [u'py', 'pyw', u'pyc']
@@ -16,13 +14,14 @@
See "Changing the application that opens a file" in Mac Help for details.
""".strip()
-class MyAppDelegate(NibClassBuilder.AutoBaseClass):
+class MyAppDelegate(NSObject):
def init(self):
self = super(MyAppDelegate, self).init()
self.initial_action_done = False
self.should_terminate = False
return self
+ @objc.IBAction
def showPreferences_(self, sender):
PreferencesWindowController.getPreferencesWindow()
@@ -53,7 +52,7 @@
myURL = NSURL.fileURLWithPath_(bndl.bundlePath())
myName = bndl.infoDictionary()[u'CFBundleName']
for ext in PYTHON_EXTENSIONS:
- err, outRef, outURL = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, u'txt', kLSRolesViewer)
+ err, outRef, outURL = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, u'txt', kLSRolesViewer, None, None)
if (err or myURL != outURL):
res = NSRunAlertPanel(
u'File type binding',
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com