嗨,
这里有PySide / PyQt4新手。 我们正在将OpenCasCade查看器后端从X11移植到Cocoa。 我无法理解为什么我的小部件不包含在QtGui.QMainWindow中...... 非常感谢任何指向我应该关注的内容......作为PySide的新手,API的范围可能有点压倒性;)
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_()