Hello,

 

You will find below a sample script explaining how to use Display3d
class with wxPython. Display3d class embeds a V3dViewer, V3dView,
WNT_Window and AISInteractiveContext.

 

Issue: the displayed shape resides on the bottom left corner. I don't
know why V3dView does not fit the wxPython frame. To be continued...

 

Thomas

 

#################

# test_Display3d.py #

#################

 

from OCC import *

import wx

 

class _3dPane(wx.Panel):

    def __init__(self, parent):

        wx.Panel.__init__(self, parent)

 

        wx.EVT_SIZE(self, self.OnSize)

        wx.EVT_IDLE(self, self.OnIdle)

        wx.EVT_MOVE(self, self.OnMove)

        wx.EVT_SET_FOCUS(self, self.OnFocus)

        wx.EVT_KILL_FOCUS(self, self.OnLostFocus)

 

        self.Display3d = Display3d()

        self.Display3d.Init(self.GetHandle())

       

 

    def OnSize(self, event):

        self.Display3d.Repaint()

 

       

    def OnMove(self, event):

        self.Display3d.Repaint()

 

    def OnIdle(self, event):

        self.Display3d.Repaint()

 

      

    def OnFocus(self, event):

        self.Display3d.Repaint()

        

    def OnLostFocus(self, event):

        self.Display3d.Repaint()

 

    def OnPaint(self, event):

        self.Display3d.Repaint()

 

 

class AppFrame(wx.Frame):

    def __init__(self, parent):

        wx.Frame.__init__(self, parent, -1, "pythonOCC 0.98 Display3d")

        graphic_panel = _3dPane(self)

        graphic_panel.Display3d.SetDisplayModeShaded()# or
SetDisplayModeWireFrame()

        # Make sphere

        S = BRepPrimAPI_MakeSphere(gp_Pnt(200.,300.,200.), 300.)

        shape = S.Shape()

        # Add sphere to context

        graphic_panel.Display3d.DisplayShape(S.Shape())

        

      

    

app = wx.PySimpleApp()

wx.InitAllImageHandlers()

frame = AppFrame(None)

frame.Show()

app.SetTopWindow(frame)

app.MainLoop()

_______________________________________________
Minerva-pythonocc mailing list
Minerva-pythonocc@gna.org
https://mail.gna.org/listinfo/minerva-pythonocc

Reply via email to