maximize widgets AND win/mac difference

Again, in the attempt of porting code from windows to macOS I have
some trouble.
This time the task was to add to widgets the functionalaty of going
full screen (a splash screen) and, on closing, just going back in the
right position. I achieved that with child frame and reparenting.
However, whil on windows the code work fine, on mac: the widgets is
not displayed (although functionality is still there...try to click on
the screen...); on close the widget is not in the right position (but
if I move the frame the widget is placed correctly).
It seems to me that on mac the SendEventSize does not work properly.
Where I'm doing wrong?

Thanks

<code>

import wx
try:
    from wx import glcanvas
    haveGLCanvas = True
except ImportError:
    haveGLCanvas = False

try:
    from OpenGL.GL import *
    from OpenGL.GLUT import *
    from OpenGL.GLU import *

    haveOpenGL = True
except ImportError:
    haveOpenGL = False

import numpy as np

···

##---------------------------------------

class MySplash(wx.Frame):
    def __init__(self, element, parent, id = wx.ID_ANY, title =
wx.EmptyString):
        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition,
wx.DefaultSize)#, wx.CAPTION|wx.CLOSE_BOX|wx.SYSTEM_MENU|
wx.CLIP_CHILDREN)#|wx.MAXIMIZE)
        self.m_parentWindow = element.GetParent()
        self.m_parentFrame = parent
        self.m_oldPos = self.m_parentWindow.GetPosition()
        self.m_oldSize = self.m_parentWindow.GetClientSize()
        self.splashedelement = element
        self.outer_sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetBackgroundColour(wx.Colour( 0, 0, 0 ) )
        self.outer_sizer.Add(element, 1, wx.ALIGN_CENTER|wx.EXPAND|
wx.SHAPED, 5)
        self.SetSizer(self.outer_sizer)
        self.outer_sizer.Fit(self)
        self.Layout()
        self.Maximize()
        self.Show(False)
        self.Bind(wx.EVT_CLOSE, self.onClose)

    def setOldSize(self,size):
        self.m_oldSize = size

    def setOldPos(self,pos):
        #print "passed pos",pos
        self.m_oldPos = pos

    def getOldSize(self):
        return self.m_oldSize

    def getOldPos(self):
        return self.m_oldPos

    def onClose(self, event):
        self.splashedelement.Reparent(self.m_parentWindow)
        self.Show(False)
        self.splashedelement.SetClientSize(self.m_oldSize)
        self.splashedelement.SetPosition(self.m_oldPos)
        self.m_parentFrame.SendSizeEvent()

##---------------------------------------
class GLPanePixelSel(glcanvas.GLCanvas):
    def __init__(self, parent, ID = wx.ID_ANY, pos =
wx.DefaultPosition, size = wx.DefaultSize,
             style = 0, name = wx.EmptyString, gl_attr = None):
        glcanvas.GLCanvas.__init__(self, parent, ID, pos, size, style
= wx.FULL_REPAINT_ON_RESIZE, name = wx.EmptyString, attribList = None)
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.init_fl = False
        self.m_imgHight = size[1]
        self.m_imgWidth = size[0]
        self.m_panHight = 0
        self.m_panWidth = 0
        self.m_zoomH = 1
        self.m_zoomW = 1
        self.Bind(wx.EVT_LEFT_UP, self.OnLeftDown)
        self.zoomed=[]
        self.real=[]
        self.contDot=0
        self.radius = 10
        self.sinR=self.radius*np.sin(np.linspace(0,2*np.pi,20))
        self.cosR=self.radius*np.cos(np.linspace(0,2*np.pi,20))

        self.splashFrame = MySplash(self, wx.GetTopLevelParent(self))
        self.Bind(wx.EVT_RIGHT_DOWN, self.mouseRightClick)

    def mouseRightClick(self, event):
        self.splashFrame.setOldSize(self.GetClientSize())
        self.splashFrame.setOldPos(self.GetPosition())
        self.Reparent(self.splashFrame)
        self.splashFrame.Show(True)
        self.onDraw()

    def OnLeftDown(self, event):
        pt = event.GetPosition() # position tuple
        realpt = (round(pt[0]/self.m_zoomW),round(pt[1]/self.m_zoomH))
        self.real.append(realpt)
        print pt
        self.zoomed.append(pt)
        self.contDot+=1
        self.Refresh()

    def initGL(self):
        ##openGL required!!
        glClearColor(0, 0, 0, 0)
        glShadeModel(GL_FLAT)
        glPixelStorei(GL_UNPACK_ALIGNMENT,1)
        self.init_fl = True

    def onDraw(self):
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
        glPushMatrix()
        glPopMatrix()
        glPointSize(10.0)
#########CIRCLES
        glColor3f(0.5, 1.0, 0.5)
        glLineWidth(2.0)
        glEnable(GL_LINE_SMOOTH)
        for dot in self.zoomed:
            glBegin(GL_LINE_LOOP)
            for s,c in zip(self.sinR,self.cosR):
                glVertex2f( dot[0]+s, dot[1]+c)
            glEnd()
        glFlush()
        self.SwapBuffers()

    def OnPaint(self, event):
        dc = wx.PaintDC(self)
        if not self.GetContext():
            return
        if not self.init_fl:
             self.initGL()

        self.SetCurrent()
        self.onDraw()

    def OnSize(self, event):
        size = self.GetClientSize()
        self.m_panWidth,self.m_panHight = size.width, size.height
        self.m_zoomH = (1.0*self.m_panHight)/self.m_imgHight
        self.m_zoomW = (1.0*self.m_panWidth)/self.m_imgWidth
        cont = 0
        while cont<self.contDot:
            self.zoomed[cont]=(self.real[cont]
[0]*self.m_zoomW,self.real[cont][1]*self.m_zoomH)
            cont+=1
        if self.GetContext():
            self.SetCurrent()
            glViewport(0, 0, self.m_panWidth,self.m_panHight)
            glMatrixMode (GL_PROJECTION)
            glLoadIdentity ()
            gluOrtho2D (0.0, self.m_panWidth, self.m_panHight, 0.0)

    def OnEraseBackground(self, event):
        pass
##--------------------------------
class MyFrame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1, "Click for mouseposition",
size=(400,300),
                      style=wx.DEFAULT_FRAME_STYLE |
wx.NO_FULL_REPAINT_ON_RESIZE)
        self.panel1=wx.Panel(self,-1)
        self.panel1.SetBackgroundColour('Goldenrod')
        self.bitmap1=GLPanePixelSel(self.panel1, size=(200,100))
        self.bitmap2=GLPanePixelSel(self.panel1, size=(200,100))
        sizer1=wx.BoxSizer(wx.HORIZONTAL)
        sizer2=wx.BoxSizer(wx.HORIZONTAL)
        sizer2.Add(self.bitmap1, 1, wx.ALL|wx.EXPAND|wx.SHAPED|
wx.ALIGN_CENTER, 5)
        sizer2.Add(self.bitmap2, 1, wx.ALL|wx.EXPAND|wx.SHAPED|
wx.ALIGN_CENTER, 5)
        self.panel1.SetSizer(sizer2)

        sizer1.Add(self.panel1,1,wx.EXPAND, 0)
        self.SetSizer(sizer1)
        sizer1.Fit(self)
        self.Layout()
        self.Maximize(False)
##--------------------------------
app = wx.PySimpleApp()
frame = MyFrame(None)
frame.Show(True)
app.MainLoop()

</code>

Send an email and attach the code and I'll try it out.

Mark

···

On Aug 12, 5:45 pm, tinauser <tinau...@libero.it> wrote:

Again, in the attempt of porting code from windows to macOS I have
some trouble.
This time the task was to add to widgets the functionalaty of going
full screen (a splash screen) and, on closing, just going back in the
right position. I achieved that with child frame and reparenting.
However, whil on windows the code work fine, on mac: the widgets is
not displayed (although functionality is still there...try to click on
the screen...); on close the widget is not in the right position (but
if I move the frame the widget is placed correctly).
It seems to me that on mac the SendEventSize does not work properly.
Where I'm doing wrong?

Thanks

<code>

import wx
try:
from wx import glcanvas
haveGLCanvas = True
except ImportError:
haveGLCanvas = False

try:
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *

haveOpenGL = True

except ImportError:
haveOpenGL = False

import numpy as np
##---------------------------------------

class MySplash(wx.Frame):
def __init__(self, element, parent, id = wx.ID_ANY, title =
wx.EmptyString):
wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition,
wx.DefaultSize)#, wx.CAPTION|wx.CLOSE_BOX|wx.SYSTEM_MENU|
wx.CLIP_CHILDREN)#|wx.MAXIMIZE)
self.m_parentWindow = element.GetParent()
self.m_parentFrame = parent
self.m_oldPos = self.m_parentWindow.GetPosition()
self.m_oldSize = self.m_parentWindow.GetClientSize()
self.splashedelement = element
self.outer_sizer = wx.BoxSizer(wx.VERTICAL)
self.SetBackgroundColour(wx.Colour( 0, 0, 0 ) )
self.outer_sizer.Add(element, 1, wx.ALIGN_CENTER|wx.EXPAND|
wx.SHAPED, 5)
self.SetSizer(self.outer_sizer)
self.outer_sizer.Fit(self)
self.Layout()
self.Maximize()
self.Show(False)
self.Bind(wx.EVT_CLOSE, self.onClose)

def setOldSize\(self,size\):
    self\.m\_oldSize = size

def setOldPos\(self,pos\):
    \#print &quot;passed pos&quot;,pos
    self\.m\_oldPos = pos

def getOldSize\(self\):
    return self\.m\_oldSize

def getOldPos\(self\):
    return self\.m\_oldPos

def onClose\(self, event\):
    self\.splashedelement\.Reparent\(self\.m\_parentWindow\)
    self\.Show\(False\)
    self\.splashedelement\.SetClientSize\(self\.m\_oldSize\)
    self\.splashedelement\.SetPosition\(self\.m\_oldPos\)
    self\.m\_parentFrame\.SendSizeEvent\(\)

##---------------------------------------
class GLPanePixelSel(glcanvas.GLCanvas):
def __init__(self, parent, ID = wx.ID_ANY, pos =
wx.DefaultPosition, size = wx.DefaultSize,
style = 0, name = wx.EmptyString, gl_attr = None):
glcanvas.GLCanvas.__init__(self, parent, ID, pos, size, style
= wx.FULL_REPAINT_ON_RESIZE, name = wx.EmptyString, attribList = None)
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.init_fl = False
self.m_imgHight = size[1]
self.m_imgWidth = size[0]
self.m_panHight = 0
self.m_panWidth = 0
self.m_zoomH = 1
self.m_zoomW = 1
self.Bind(wx.EVT_LEFT_UP, self.OnLeftDown)
self.zoomed=
self.real=
self.contDot=0
self.radius = 10
self.sinR=self.radius*np.sin(np.linspace(0,2*np.pi,20))
self.cosR=self.radius*np.cos(np.linspace(0,2*np.pi,20))

    self\.splashFrame = MySplash\(self, wx\.GetTopLevelParent\(self\)\)
    self\.Bind\(wx\.EVT\_RIGHT\_DOWN, self\.mouseRightClick\)

def mouseRightClick\(self, event\):
    self\.splashFrame\.setOldSize\(self\.GetClientSize\(\)\)
    self\.splashFrame\.setOldPos\(self\.GetPosition\(\)\)
    self\.Reparent\(self\.splashFrame\)
    self\.splashFrame\.Show\(True\)
    self\.onDraw\(\)

def OnLeftDown\(self, event\):
    pt = event\.GetPosition\(\)  \# position tuple
    realpt = \(round\(pt\[0\]/self\.m\_zoomW\),round\(pt\[1\]/self\.m\_zoomH\)\)
    self\.real\.append\(realpt\)
    print pt
    self\.zoomed\.append\(pt\)
    self\.contDot\+=1
    self\.Refresh\(\)

def initGL\(self\):
    \#\#openGL required\!\!
    glClearColor\(0, 0, 0, 0\)
    glShadeModel\(GL\_FLAT\)
    glPixelStorei\(GL\_UNPACK\_ALIGNMENT,1\)
    self\.init\_fl = True

def onDraw\(self\):
    glClear\( GL\_COLOR\_BUFFER\_BIT | GL\_DEPTH\_BUFFER\_BIT \)
    glPushMatrix\(\)
    glPopMatrix\(\)
    glPointSize\(10\.0\)

#########CIRCLES
glColor3f(0.5, 1.0, 0.5)
glLineWidth(2.0)
glEnable(GL_LINE_SMOOTH)
for dot in self.zoomed:
glBegin(GL_LINE_LOOP)
for s,c in zip(self.sinR,self.cosR):
glVertex2f( dot[0]+s, dot[1]+c)
glEnd()
glFlush()
self.SwapBuffers()

def OnPaint\(self, event\):
    dc = wx\.PaintDC\(self\)
    if not self\.GetContext\(\):
        return
    if not self\.init\_fl:
         self\.initGL\(\)

    self\.SetCurrent\(\)
    self\.onDraw\(\)

def OnSize\(self, event\):
    size = self\.GetClientSize\(\)
    self\.m\_panWidth,self\.m\_panHight = size\.width, size\.height
    self\.m\_zoomH = \(1\.0\*self\.m\_panHight\)/self\.m\_imgHight
    self\.m\_zoomW = \(1\.0\*self\.m\_panWidth\)/self\.m\_imgWidth
    cont = 0
    while cont&lt;self\.contDot:
        self\.zoomed\[cont\]=\(self\.real\[cont\]

[0]*self.m_zoomW,self.real[cont][1]*self.m_zoomH)
cont+=1
if self.GetContext():
self.SetCurrent()
glViewport(0, 0, self.m_panWidth,self.m_panHight)
glMatrixMode (GL_PROJECTION)
glLoadIdentity ()
gluOrtho2D (0.0, self.m_panWidth, self.m_panHight, 0.0)

def OnEraseBackground\(self, event\):
    pass

##--------------------------------
class MyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "Click for mouseposition",
size=(400,300),
style=wx.DEFAULT_FRAME_STYLE |
wx.NO_FULL_REPAINT_ON_RESIZE)
self.panel1=wx.Panel(self,-1)
self.panel1.SetBackgroundColour('Goldenrod')
self.bitmap1=GLPanePixelSel(self.panel1, size=(200,100))
self.bitmap2=GLPanePixelSel(self.panel1, size=(200,100))
sizer1=wx.BoxSizer(wx.HORIZONTAL)
sizer2=wx.BoxSizer(wx.HORIZONTAL)
sizer2.Add(self.bitmap1, 1, wx.ALL|wx.EXPAND|wx.SHAPED|
wx.ALIGN_CENTER, 5)
sizer2.Add(self.bitmap2, 1, wx.ALL|wx.EXPAND|wx.SHAPED|
wx.ALIGN_CENTER, 5)
self.panel1.SetSizer(sizer2)

    sizer1\.Add\(self\.panel1,1,wx\.EXPAND, 0\)
    self\.SetSizer\(sizer1\)
    sizer1\.Fit\(self\)
    self\.Layout\(\)
    self\.Maximize\(False\)

##--------------------------------
app = wx.PySimpleApp()
frame = MyFrame(None)
frame.Show(True)
app.MainLoop()

</code>

The problem isn't with the size event or layout, but rather it seems that the system OpenGL drawing layer is not moving to the new window and back along with the GLCanvas window. You can probably confirm this by using a wx.Panel instead of the GLCanvas in your test app and watch how it behaves[1]. I know very little about OpenGL and especially not about its implementation on Mac (except for some very high level stuff) so I'm not sure what it would take to make this work.

Instead of reparenting the existing GLCanvas you could create a new one and simply give it the same content to display as the original one. Or perhaps using two GLCanvas windows that share the same GLContext object will work. You can do that by creating the 2nd canvas something like this:

     canvas2 = GLCanvasWithContext(parent, canvas1.GetContext())

[1] Using the WIT will also help. http://wiki.wxpython.org/Widget_Inspection_Tool

···

On 8/12/10 2:45 AM, tinauser wrote:

Again, in the attempt of porting code from windows to macOS I have
some trouble.
This time the task was to add to widgets the functionalaty of going
full screen (a splash screen) and, on closing, just going back in the
right position. I achieved that with child frame and reparenting.
However, whil on windows the code work fine, on mac: the widgets is
not displayed (although functionality is still there...try to click on
the screen...); on close the widget is not in the right position (but
if I move the frame the widget is placed correctly).
It seems to me that on mac the SendEventSize does not work properly.
Where I'm doing wrong?

--
Robin Dunn
Software Craftsman

As Robin says, the problem seems to be with openGL, and using a panel
instead of canvas does not rise problem;
running the script on win and mac and using WIT give just the results
on WIT (so apparently the openGL canvas is correctly reparented), but
the openGL does not draw on the frame. What I noticed is that if I
minimize the child frame (mysplash) the canvas is kind of floating on
the old frame...
I'm trying to get help from the pyopengl and from the macpython
groups, but there is less participation there...Here it would be
enough if anyone could tell me if running the script on a mac lead to
the same problem I observed.
Regarding your suggestion of creating a new canvas with the same
content, I'll try (actually, I already tried with no success, but I
shall try more), but eventually this would not help in the case the
canvas as to be rasterized on a timer event (unless at any time event
I refresh both canvas, that is time consuming)...Am I right supposing
that?

···

On Aug 13, 10:11 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 8/12/10 2:45 AM, tinauser wrote:

> Again, in the attempt of porting code from windows to macOS I have
> some trouble.
> This time the task was to add to widgets the functionalaty of going
> full screen (a splash screen) and, on closing, just going back in the
> right position. I achieved that with child frame and reparenting.
> However, whil on windows the code work fine, on mac: the widgets is
> not displayed (although functionality is still there...try to click on
> the screen...); on close the widget is not in the right position (but
> if I move the frame the widget is placed correctly).
> It seems to me that on mac the SendEventSize does not work properly.
> Where I'm doing wrong?

The problem isn't with the size event or layout, but rather it seems
that the system OpenGL drawing layer is not moving to the new window and
back along with the GLCanvas window. You can probably confirm this by
using a wx.Panel instead of the GLCanvas in your test app and watch how
it behaves[1]. I know very little about OpenGL and especially not about
its implementation on Mac (except for some very high level stuff) so I'm
not sure what it would take to make this work.

Instead of reparenting the existing GLCanvas you could create a new one
and simply give it the same content to display as the original one. Or
perhaps using two GLCanvas windows that share the same GLContext object
will work. You can do that by creating the 2nd canvas something like this:

 canvas2 = GLCanvasWithContext\(parent, canvas1\.GetContext\(\)\)

[1] Using the WIT will also help.http://wiki.wxpython.org/Widget_Inspection_Tool

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

I haven't looked through your code closely, but I use
wx.Frame.ShowFullScreen(self, True) to full screen my GLCanvas and I
haven't seen any problems on the Mac yet. I believe its the same thing
you are trying to do.

···

On Sep 3, 11:19 pm, tinauser <tinau...@libero.it> wrote:

As Robin says, the problem seems to be with openGL, and using a panel
instead of canvas does not rise problem;
running the script on win and mac and using WIT give just the results
on WIT (so apparently the openGL canvas is correctly reparented), but
the openGL does not draw on the frame. What I noticed is that if I
minimize the child frame (mysplash) the canvas is kind of floating on
the old frame...
I'm trying to get help from the pyopengl and from the macpython
groups, but there is less participation there...Here it would be
enough if anyone could tell me if running the script on a mac lead to
the same problem I observed.
Regarding your suggestion of creating a new canvas with the same
content, I'll try (actually, I already tried with no success, but I
shall try more), but eventually this would not help in the case the
canvas as to be rasterized on a timer event (unless at any time event
I refresh both canvas, that is time consuming)...Am I right supposing
that?

On Aug 13, 10:11 pm, Robin Dunn <ro...@alldunn.com> wrote:

> On 8/12/10 2:45 AM, tinauser wrote:

> > Again, in the attempt of porting code from windows to macOS I have
> > some trouble.
> > This time the task was to add to widgets the functionalaty of going
> > full screen (a splash screen) and, on closing, just going back in the
> > right position. I achieved that with child frame and reparenting.
> > However, whil on windows the code work fine, on mac: the widgets is
> > not displayed (although functionality is still there...try to click on
> > the screen...); on close the widget is not in the right position (but
> > if I move the frame the widget is placed correctly).
> > It seems to me that on mac the SendEventSize does not work properly.
> > Where I'm doing wrong?

> The problem isn't with the size event or layout, but rather it seems
> that the system OpenGL drawing layer is not moving to the new window and
> back along with the GLCanvas window. You can probably confirm this by
> using a wx.Panel instead of the GLCanvas in your test app and watch how
> it behaves[1]. I know very little about OpenGL and especially not about
> its implementation on Mac (except for some very high level stuff) so I'm
> not sure what it would take to make this work.

> Instead of reparenting the existing GLCanvas you could create a new one
> and simply give it the same content to display as the original one. Or
> perhaps using two GLCanvas windows that share the same GLContext object
> will work. You can do that by creating the 2nd canvas something like this:

> canvas2 = GLCanvasWithContext(parent, canvas1.GetContext())

> [1] Using the WIT will also help.http://wiki.wxpython.org/Widget_Inspection_Tool

> --
> Robin Dunn
> Software Craftsmanhttp://wxPython.org

Since you are wanting to simulate the effect of reparenting the window you could just Destroy() the old one after you've created the new canvas on the other parent. Then there would still be just the one canvas that needed updating.

···

On 9/3/10 8:19 AM, tinauser wrote:

As Robin says, the problem seems to be with openGL, and using a panel
instead of canvas does not rise problem;
running the script on win and mac and using WIT give just the results
on WIT (so apparently the openGL canvas is correctly reparented), but
the openGL does not draw on the frame. What I noticed is that if I
minimize the child frame (mysplash) the canvas is kind of floating on
the old frame...
I'm trying to get help from the pyopengl and from the macpython
groups, but there is less participation there...Here it would be
enough if anyone could tell me if running the script on a mac lead to
the same problem I observed.
Regarding your suggestion of creating a new canvas with the same
content, I'll try (actually, I already tried with no success, but I
shall try more), but eventually this would not help in the case the
canvas as to be rasterized on a timer event (unless at any time event
I refresh both canvas, that is time consuming)...Am I right supposing
that?

--
Robin Dunn
Software Craftsman

Dear Mark,

the problem is not with making the glcanvas full screen, rather to
reparent the glcanvas to a second frame.

AT ANY RATE, I found a work around; if you could have a look and tell
me what you think of it, it would be great.
In particular,I have still problemss with the update/refresh event in
macos: I have to call the maximize(True) and Maximize(False) to send a
repaint event to the glcanvas...

import wx

try:
    from wx import glcanvas
    haveGLCanvas = True
except ImportError:
    haveGLCanvas = False

try:
    from OpenGL.GL import *
    from OpenGL.GLUT import *
    from OpenGL.GLU import *

    haveOpenGL = True
except ImportError:
    haveOpenGL = False

import numpy as np

···

##---------------------------------------
##---------------------------------------
class GLPanePixelSel(glcanvas.GLCanvas):
    def __init__(self, parent, ID = wx.ID_ANY, pos =
wx.DefaultPosition, size = wx.DefaultSize,
             style = 0, name = wx.EmptyString, gl_attr = None):
        glcanvas.GLCanvas.__init__(self, parent, ID, pos, size, style
= wx.FULL_REPAINT_ON_RESIZE, name = wx.EmptyString, attribList = None)
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.init_fl = False
        self.m_imgHight = size[1]
        self.m_imgWidth = size[0]
        self.m_panHight = 0
        self.m_panWidth = 0
        self.m_zoomH = 1
        self.m_zoomW = 1
        self.Bind(wx.EVT_LEFT_UP, self.OnLeftDown)
        self.zoomed=
        self.real=
        self.contDot=0
        self.radius = 10
        self.sinR=self.radius*np.sin(np.linspace(0,2*np.pi,20))
        self.cosR=self.radius*np.cos(np.linspace(0,2*np.pi,20))

        self.Bind(wx.EVT_RIGHT_DOWN, self.mouseRightClick)
        self.memory = None
        self.fullscreen = False

    def mouseRightClick(self, event):
        if self.fullscreen:
            f = wx.GetTopLevelParent(self)
            s = f.GetSizer()
            s.Clear()
            s.Add(self.memory,1,wx.EXPAND, 0)
            f.Maximize(True)
            f.Maximize(False)
        else:
            f = wx.GetTopLevelParent(self)
            s = f.GetSizer()
            c = f.GetChildren()
            self.memory = c[0]
            self.Reparent(f)
            s.Clear()
            s.Add(self,1,wx.EXPAND, 0)
            f.Maximize(True)
            f.Maximize(False)
            self.fullscreen=True

    def OnLeftDown(self, event):
        pt = event.GetPosition() # position tuple
        realpt = (round(pt[0]/self.m_zoomW),round(pt[1]/self.m_zoomH))
        self.real.append(realpt)
        self.zoomed.append(pt)
        self.contDot+=1
        self.Refresh()

    def initGL(self):
        ##openGL required!!
        glClearColor(0, 0, 0, 0)
        glShadeModel(GL_FLAT)
        glPixelStorei(GL_UNPACK_ALIGNMENT,1)
        self.init_fl = True

    def onDraw(self):
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
        glPushMatrix()
        glPopMatrix()
        glPointSize(10.0)
#########CIRCLES
        glColor3f(0.5, 1.0, 0.5)
        glLineWidth(2.0)
        glEnable(GL_LINE_SMOOTH)
        for dot in self.zoomed:
            glBegin(GL_LINE_LOOP)
            for s,c in zip(self.sinR,self.cosR):
                glVertex2f( dot[0]+s, dot[1]+c)
            glEnd()
        glFlush()
        self.SwapBuffers()

    def OnPaint(self, event):
        #dc = wx.PaintDC(self)##required only on windows?http://
groups.google.com/group/wxpython-users/browse_thread/thread/
49c9e4b8f7db30c9/ebee891d7114b218?lnk=gst&q=opengl
+mac#ebee891d7114b218
        if not self.GetContext():
            print "No Context!!!"
            return
        if not self.init_fl:
             self.initGL()

        self.SetCurrent()
        self.onDraw()
        event.Skip()

    def OnSize(self, event):
        size = self.GetClientSize()
        self.m_panWidth,self.m_panHight = size.width, size.height
        self.m_zoomH = (1.0*self.m_panHight)/self.m_imgHight
        self.m_zoomW = (1.0*self.m_panWidth)/self.m_imgWidth
        cont = 0
        while cont<self.contDot:
            self.zoomed[cont]=(self.real[cont]
[0]*self.m_zoomW,self.real[cont][1]*self.m_zoomH)
            cont+=1
        if self.GetContext():
            self.SetCurrent()
            glViewport(0, 0, self.m_panWidth,self.m_panHight)
            glMatrixMode (GL_PROJECTION)
            glLoadIdentity ()
            gluOrtho2D (0.0, self.m_panWidth, self.m_panHight, 0.0)

    def OnEraseBackground(self, event):
        pass

##--------------------------------
class MyFrame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1, "Click for mouseposition",
size=(400,300),
                      style=wx.DEFAULT_FRAME_STYLE |
wx.NO_FULL_REPAINT_ON_RESIZE)
        self.panel1=wx.Panel(self,-1)
        self.panel1.SetBackgroundColour('Goldenrod')
        self.bitmap1=GLPanePixelSel(self.panel1, size=(200,100))
        self.bitmap2=GLPanePixelSel(self.panel1, size=(200,100))
        sizer1=wx.BoxSizer(wx.HORIZONTAL)
        sizer2=wx.BoxSizer(wx.HORIZONTAL)
        sizer2.Add(self.bitmap1, 1, wx.ALL|wx.EXPAND|wx.SHAPED|
wx.ALIGN_CENTER, 5)
        sizer2.Add(self.bitmap2, 1, wx.ALL|wx.EXPAND|wx.SHAPED|
wx.ALIGN_CENTER, 5)
        self.panel1.SetSizer(sizer2)

        sizer1.Add(self.panel1,1,wx.EXPAND, 0)
        self.SetSizer(sizer1)
        sizer1.Fit(self)
        self.Layout()
        self.Maximize(True)
        self.Maximize(False)
##--------------------------------
app = wx.PySimpleApp()
frame = MyFrame(None)
frame.Show(True)
app.MainLoop()

On Sep 3, 9:06 pm, Mark <markree...@gmail.com> wrote:

I haven't looked through your code closely, but I use
wx.Frame.ShowFullScreen(self, True) to full screen my GLCanvas and I
haven't seen any problems on the Mac yet. I believe its the same thing
you are trying to do.

On Sep 3, 11:19 pm, tinauser <tinau...@libero.it> wrote:

> As Robin says, the problem seems to be with openGL, and using a panel
> instead of canvas does not rise problem;
> running the script on win and mac and using WIT give just the results
> on WIT (so apparently the openGL canvas is correctly reparented), but
> the openGL does not draw on the frame. What I noticed is that if I
> minimize the child frame (mysplash) the canvas is kind of floating on
> the old frame...
> I'm trying to get help from the pyopengl and from the macpython
> groups, but there is less participation there...Here it would be
> enough if anyone could tell me if running the script on a mac lead to
> the same problem I observed.
> Regarding your suggestion of creating a new canvas with the same
> content, I'll try (actually, I already tried with no success, but I
> shall try more), but eventually this would not help in the case the
> canvas as to be rasterized on a timer event (unless at any time event
> I refresh both canvas, that is time consuming)...Am I right supposing
> that?

> On Aug 13, 10:11 pm, Robin Dunn <ro...@alldunn.com> wrote:

> > On 8/12/10 2:45 AM, tinauser wrote:

> > > Again, in the attempt of porting code from windows to macOS I have
> > > some trouble.
> > > This time the task was to add to widgets the functionalaty of going
> > > full screen (a splash screen) and, on closing, just going back in the
> > > right position. I achieved that with child frame and reparenting.
> > > However, whil on windows the code work fine, on mac: the widgets is
> > > not displayed (although functionality is still there...try to click on
> > > the screen...); on close the widget is not in the right position (but
> > > if I move the frame the widget is placed correctly).
> > > It seems to me that on mac the SendEventSize does not work properly.
> > > Where I'm doing wrong?

> > The problem isn't with the size event or layout, but rather it seems
> > that the system OpenGL drawing layer is not moving to the new window and
> > back along with the GLCanvas window. You can probably confirm this by
> > using a wx.Panel instead of the GLCanvas in your test app and watch how
> > it behaves[1]. I know very little about OpenGL and especially not about
> > its implementation on Mac (except for some very high level stuff) so I'm
> > not sure what it would take to make this work.

> > Instead of reparenting the existing GLCanvas you could create a new one
> > and simply give it the same content to display as the original one. Or
> > perhaps using two GLCanvas windows that share the same GLContext object
> > will work. You can do that by creating the 2nd canvas something like this:

> > canvas2 = GLCanvasWithContext(parent, canvas1.GetContext())

> > [1] Using the WIT will also help.http://wiki.wxpython.org/Widget_Inspection_Tool

> > --
> > Robin Dunn
> > Software Craftsmanhttp://wxPython.org