Hi,
PySide / PyQt4 novice here. We're in the process of porting our OpenCasCade viewer backend from X11 to Cocoa. I'm failing to see why my widget is not contained within the QtGui.QMainWindow... Any pointers to what I should be looking into are much appreciated... as a novice to PySide, the extent of the API can be a little overwhelming ;)
from qtDisplay import qtViewer3d
class MainWindow(QtGui.QMainWindow):
def __init__(self, *args):
apply(QtGui.QMainWindow.__init__,(self,)+args)
self.canva = qtViewer3d(self) # QtGui.QWidget instance
self.setWindowTitle("pythonOCC-%s 3d viewer ('qt' backend)"%VERSION)
self.setCentralWidget(self.canva)
self.resize(1024,768)
self.menuBar = self.menuBar()
self._menus = {}
self._menu_methods = {}
def add_menu(self, menu_name):
_menu = self.menuBar.addMenu("&"+menu_name)
self._menus[menu_name]=_menu
def add_function_to_menu(self, menu_name, _callable):
assert callable(_callable), 'the function supplied is not callable'
try:
_action = QtGui.QAction(_callable.__name__.replace('_', ' ').lower(), self)
self.connect(_action, QtCore.SIGNAL("triggered()"), _callable)
self._menus[menu_name].addAction(_action)
except KeyError:
raise ValueError('the menu item %s does not exist' % (menu_name))
app = QtGui.QApplication(sys.argv)
win = MainWindow()
win.canva.InitDriver()
win.show()
display = win.canva._display
display.SetBackgroundImage(get_bg_abs_filename())
def add_menu(*args, **kwargs):
win.add_menu(*args, **kwargs)
def add_function_to_menu(*args, **kwargs):
win.add_function_to_menu(*args, **kwargs)
def start_display():
app.exec_()