1

我用 wxPython 和 VPython 编写程序,但我有一个大问题:模块 VPython 并不总是运行。如果我在解释器中运行程序,程序运行的频率要比编译后的频率高。代码从不返回任何错误。我在其他电脑上试了一下,程序是一样的。

Win7 Python 2.7.5 32 位 wxPython 2.9.4 VPython 6.0.5

import visual as v
import wx

class Maintest(v.window):
    def InitUI(self):
        fileMenu = wx.Menu()


        self.menubar.Append(fileMenu, '&Plik')
        self.menubar.Remove(0)

    def asd(self, scene):
        v.box()


def main():
    w = Maintest(menus=True, title="program", x=100, y=100, width=1024, height=600)
    w.InitUI()
    scene = v.display(window=w, x=0, y=0, width=600, height=600,  up=(0,0,1), background=(1,1,1), foreground = (0,1,0), forward=(-1,-1,-1))
    w.asd(scene)
    while True:
        v.rate(60)

if __name__ == '__main__':
    main()

一切正常:http: //imageshack.us/photo/my-images/199/tpp.png/ 不正常:http: //imageshack.us/photo/my-images/689/akun.png/

它只是主程序的一部分,但问题是一样的。怎么了?我应该怎么做?我将不胜感激。

4

3 回答 3

0

使用 Win7 Python 2.7.5 64bit wxPython 2.9.4 VPython 6.0.5 我无法让程序失败。该问题并非完全可重现(并且我完全无法重现)这一事实表明图形驱动程序需要更新的可能性。VPython 使用对驱动程序问题敏感的 OpenGL 3D 图形库。

于 2013-10-18T21:27:47.700 回答
0

只是猜测,但您可能已经泄露了一些信息:

import wx

app = wx.App(redirect=True)
top = wx.Frame(None, title="Hello World", size=(300,200))
top.Show() # you need this
app.MainLoop() # you need this
于 2013-09-10T12:54:58.537 回答
0

我遇到了类似的问题,或者至少有类似的症状,并且发现它取决于鼠标在启动时的位置(请参阅此处的完整描述)。

解决方法是在显示创建完成后,依次调用 Hide and Show。

需要对馈送到显示对象的面板进行这些调用。

win.panel.Hide() win.panel.Show()

于 2014-02-10T18:08:32.097 回答