我正嘗試在使用GLUT的Python(v2.7)程序中創建一個右鍵單擊彈出式菜單。我還沒有找到Python特定的文檔來做這件事,所以我使用了C++文檔,這通常幾乎相似。在Python-OpenGL中創建GLUT彈出式菜單
這是我有:
if __name__=="__main__":
glutInit(sys.argv)
#...more initialization code...
createMenu()
init()
glutMainLoop()
這裏是創建菜單的功能:
def createMenu():
menu = glutCreateMenu(processMenuEvents)
glutAddMenuEntry("One", 1)
glutAddMenuEntry("Two", 2)
glutAttachMenu(GLUT_RIGHT_BUTTON)
def processMenuEvents(option):
logging.debug("Menu pressed")
# not using 'option' right now
菜單被正常顯示,但是當我點擊一個項目,我得到這個錯誤:
DEBUG:root:Menu pressed:
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 338, in 'converting callback result'
TypeError: an integer is required
Exception in <function processMenuEvents at 0x1760b90> ignored
python-opengl是否有不同的方式做到這一點?我在這裏做錯了什麼?
謝謝。