Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Under 2.9.1 Cocoa, trying to get a Panel for VLC rendering
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Kevin Ollivier  
View profile  
 More options Apr 15 2011, 1:50 pm
From: Kevin Ollivier <kevin-li...@theolliviers.com>
Date: Fri, 15 Apr 2011 10:50:09 -0700
Local: Fri, Apr 15 2011 1:50 pm
Subject: Re: [wxPython-mac] Under 2.9.1 Cocoa, trying to get a Panel for VLC rendering
Hi Andy,

On Apr 15, 2011, at 8:37 AM, adwelly wrote:

> I am trying to get wxPython 2.9.1 Cocoa and VLC, via vlc.py to play
> together nicely. I've managed to do this with wxPython 2.8 under
> windows and linux
> but ran into a problem with 2.8 on a Mac.

> The issue is that once a nice UI has been set up with wxPython, vlc
> has to be informed where to start rendering its video. On windows
> under wxPython 2.8
> you get the HWND associated with a wx.Panel with wx.Panel.GetHandle(),
> you can then inform vlc with a call to vlc.MediaPlayer.set_hwnd().

> On linux using X the process is similar. Call wx.Panel.GetHandle() and
> vlc.MediaPlayer.set_xwindow().

> Under wx 2.8 the problem arises that although vlc.MediaPlayer has a
> set_nsobject() function, wx is built for carbon not cocoa so there is
> no nsobject to be had.

> I've now installed wx 2.9.1 for cocoa and python 2.7.1 It builds an
> excellent Cocoa UI and most aspects seem to work. However, I now need
> to get the ns object associated with the panel, and in fact what I'm
> actually looking for is an NS object that meets the export
> addVoutSubview protocol. That's what vlc is expecting and
> unfortunately I can't change it.

> The actual error I'm getting is:

> -[wxNSView addVoutSubview:]: unrecognized selector sent to instance
> 0x3662c0

> so I guess the wxNSView object that represents a panel can't currently
> have video subviews associated with it. Is there any way around
> this ?

Well, this is quite a pickle. :( You *might* be able to do some really black magic using PyObjC to solve this issue by dynamically adding those methods to your wxPanel's underlying NSView. It would go something like this:

import objc
from AppKit import *

def addVoutSubview_(self, subview):
        subview.setFrame_(self.bounds)
        self.addSubview_(subview)
        view.setAutoresizingMask_(NSViewHeightSizable | NSViewWidthSizable)

def removeVoutSubview_(self, subview):
        subview.removeFromSuperview()

objc.classAddMethods(NSView, addVoutSubview)
objc.classAddMethods(NSView, removeVoutSubview)

Note that this is all untested pseudocode, so no guarantees. If all goes well, then after this code is run, try the set_nsobject() function again and it should work. Hooray for Objective C having some of the dynamic dispatch of languages like Python. :)

In any case, I'd file a bug in the wx trac about not being able to create a wxWindow from a native handle cross-platform. It should definitely be possible, and it would make situations like this much easier. Then you could just create an NSView subclass in PyObjC, add those methods to it, and do wx.Window(myNSView) or some such to create the wx.Window. Resorting to black magic like this (which actually adds those methods to *all* NSViews) is, I think, far from ideal, and this would not have worked at all had we been dealing with C / C++.

Regards,

Kevin

> Andy

> --
> To unsubscribe, send email to wxpython-mac+unsubscribe@googlegroups.com
> or visit http://groups.google.com/group/wxpython-mac?hl=en


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.