你好,
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_()