[wxPython] hard time figuring out what to do :P

Hi everyone,

I found a class overview of ogl (wxWindows, Object Graphics Library).
Still haven't found much else. (gentoo linux here, I wonder if they put
it somewhere else? )

I have the following code. I'm just toying around with it and don't
succeed to get anything shown mostly (if not completely) due to my not
understanding how to use ogl :expressionless:

A strange thing is that it crashes the minute I click on the
wxShapeCanvas 'window'

Can anybody give me a pointer as to what I'm doing wrong or should be
doing?

Thank you.

Harold

#! /usr/bin/python

from wxPython.wx import *
from wxPython.ogl import *
  
class drawdocument(wxShapeCanvas):

  def OnLeftClick(self,x,y,keys = 0):
    print "left click"

  def OnRightClick(self,x,y,keys = 0):
    print "right click"

  def __init__(self,parent,id,title,width,height):
    wxShapeCanvas.__init__(self,parent,id,pos=(0,150),size=(width,height),style=wxBORDER)
    
    EVT_RIGHT_UP(self, self.OnRightClick)
    EVT_LEFT_UP(self,self.OnLeftClick)
    myshape = wxDiagram()
    myshape.SetCanvas(self)
    
    cirkeltje = wxCircleShape(53.15)
    myshape.AddShape(cirkeltje)
    
    dc = wxClientDC(self)
    myshape.DrawOutline(dc,2.0,2.0,10.0,10.0)
    myshape.ShowAll(true)

class Gui(wxFrame):
  
  def __init__(self,parent,id,title,width,height):
    wxFrame.__init__(self,parent,id, title, size = (
width,height),
style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
    
    self.mypanel =
wxPanel(self,101,pos=(0,0),size=(640,150),style=wxTAB_TRAVERSAL)
    self.mycanvas = drawdocument(self,100,"canvas",500,400)
    self.mycanvas.SetBackgroundColour('white')
    self.Show()
    
app = wxPyApp()
frame = Gui(None,-1,"Fusebox framework generator",640,480)
app.MainLoop()

Hiroshimator writes:
> Hi everyone,
>
> I found a class overview of ogl (wxWindows, Object Graphics Library).
> Still haven't found much else. (gentoo linux here, I wonder if they put
> it somewhere else? )
>
> I have the following code. I'm just toying around with it and don't
> succeed to get anything shown mostly (if not completely) due to my not
> understanding how to use ogl :expressionless:
>
> A strange thing is that it crashes the minute I click on the
> wxShapeCanvas 'window'
>
> Can anybody give me a pointer as to what I'm doing wrong or should be
> doing?
>
Ah, yes, ogl.... poorly underdocumented...

Here is a version of your drawdocument class that works a bit better:

class drawdocument(wxShapeCanvas):

    # these only take an event argument
    def OnLeftClick(self,evt):
        print "left click"

    def OnRightClick(self,evt):
        print "right click"

    def __init__(self,parent,id,title,width,height):
        wxShapeCanvas.__init__(self,parent,id,pos=(0,150),size=(width,height),s\
tyle=wxBORDER)

        EVT_RIGHT_UP(self, self.OnRightClick)
        EVT_LEFT_UP(self,self.OnLeftClick)
        myshape = wxDiagram()

  # The canvas need to know what diagram it should ues
        self.SetDiagram(myshape)
        myshape.SetCanvas(self)

        cirkeltje = wxCircleShape(53.15)

  # the shape needs to know what canvas it should use
        cirkeltje.SetCanvas(self)
        myshape.AddShape(cirkeltje)

        dc = wxClientDC(self)
        myshape.DrawOutline(dc,2.0,2.0,10.0,10.0)
        myshape.ShowAll(true)

···

--
  Pierre Hjälm, Systems Administrator
  Department of Information Science, Uppsala University, Sweden
  email:pierre.hjalm@dis.uu.se phone:+46-(0)18-4711044 fax:+46-(0)18-554422