Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
PyObj-C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PyObj-C



Hi All,

I am starting now in programming python, I choose PyObj-C so I could use my Obj-C and Cocoa previous knowledge.

The point is that I am trying to subclass a NSOpenGL view without success!

When I try to subclass an NSView all is fine, both "initWithFrame_(self, frame):"  and  "drawRect_(self, rect):"
are called.

On the other hand, when instantiating the NSOpenGLView subclass the "initWithFrame_pixelformat_(self, frame, fmt):" method is not called avoiding me any kind of initialization. The crazy ( even for me ) thing is that
the "def drawRect_(self, rect):" is called fine...

Here is the code of my NSOpenGLView subclass:

from objc import YES, NO, IBAction, IBOutlet
from Foundation import *
from AppKit import *
from OpenGL.GL import *

class PiiOpenGLView(NSOpenGLView):
    def initWithFrame_pixelformat_(self, frame, fmt):
        self = super(PiiOpenGLView, self).initWithFrame_pixelformat_(frame, fmt)
        if self:
            # initialization code here
    #pass
    self.col = NSColor.blueColor()
    self.b = self.bounds()
        return self
    
    def drawRect_(self, rect):
        # drawing code here
#self.col = NSColor.redColor()
        #self.b = self.bounds()
        self.col.set()
        NSBezierPath.fillRect_(self.b)

Here is the code of my "main.py" main class:

#import modules required by application
import objc
import Foundation
import AppKit
import OpenGL.GL

from PyObjCTools import AppHelper

# import modules containing classes required to start application and load MainMenu.nib
import PiInteractionAppDelegate
import PiiView
import PiiOpenGLView

# pass control to AppKit
AppHelper.runEventLoop()


subclass Thanks All :)

Adriano
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Student-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.