| |||||
HelloWorld PyObjC
Yesterday I finally sat down and got PyObjC working on Panther. I had been having some problems with it earlier until I realized I was installing the Jaguar version on Panther. Doh! If you want to install it, don't download the installer, it doesn't work on Panther. That isn't real clear on the download page. Anyway, I put together my first program with it. So here's my PyObjC version of a first program.
Yep, that's a very, very rudimentary web browser. That's how simple Cocoa makes this stuff. Doing that was just as easy as throwing up a simple text area to say "hello world". Of course it helps that I already know Cocoa, but ... anyway, here's the Python code for creating a very, very simple web browser using WebKit and PyObjC.
from PyObjCTools import NibClassBuilder, AppHelper
import WebKit
from Foundation import *
from AppKit import *
NibClassBuilder.extractClasses("MainMenu")
# class defined in MainMenu.nib
class MyObject(NibClassBuilder.AutoBaseClass):
# the actual base class is NSObject
# The following outlets are added to the class:
# url
# webview
def loadURL_(self, sender):
urlString = self.url.stringValue()
url = NSURL.URLWithString_(urlString)
request = NSURLRequest.requestWithURL_(url)
self.webview.mainFrame().loadRequest_(request)
if __name__ == "__main__":
AppHelper.runEventLoop()
Posted by Kimbro Staken Monday Dec 15, 2003 at 2:49 PM | Recommended Sites JumpBox Virtual Appliances Virtualization Daily Grid7 Venturecast Inspirational Technology Scrollin on Dubs MC Ping - Microcontent Notfications
Archives
XML --
subscribe
Music -- subscribe Programming -- subscribe Python -- subscribe Syncato -- subscribe Photography -- subscribe Mac OS X -- subscribe General -- subscribe Canon EOS 1D -- subscribe Canon EOS 10D -- subscribe Canon EOS Digital Rebel -- subscribe Samsung Digimax V50 -- subscribe | ||||
Copyright 2002, 2003 Kimbro Staken
Powered By: Syncato 0.8 | |||||