Gettin started with PyQt, wxPython and pythonOCC

In this sample, we will set up a simple application that:

  • create a menu and 2 menus items,
  • these 2 menu items create a box for the first one, and a cylinder for the second one,
  • for both wxPython and PyQt

We first call the SimpleGui module, that provides a simple interface to design GUI for both PyQt, wxPython and python-xlib:

from OCC.Display.SimpleGui import *

If you want to use wxPython, just set the backend as following:


If you want to use rather PyQt, just replace the previous line with


or, for python-xlib:


The next step is to init the display functions:

display, start_display, add_menu, add_function_to_menu = init_display()

Let’s now define the two functions that create and display a box and a cylinder:

def simple_test(event=None):
def simple_cylinder(event=None):
    from OCC.BRepPrimAPI import BRepPrimAPI_MakeCylinder
    s = BRepPrimAPI_MakeCylinder(60, 200)

Now we create a menu named ‘simple test’ and add the two functions into submenus:

add_menu('simple test')
add_function_to_menu('simple test',simple_test)
add_function_to_menu('simple test',simple_cylinder)

Finally, ask the display to be rendered:

# display loop