[英]Pyglet running multiple windows
I have problem when running some test code. 运行一些测试代码时出现问题。 There is a lot of code so I will paste only summary of a problem:
有很多代码,所以我只粘贴问题摘要:
import pyglet
class Test(object):
def setUp(self):
self.window = pyglet.window.Window()
def tearDown(self):
del self.window
def wtf(self):
self.setUp()
self.tearDown()
self.setUp()
pyglet.app.run()
test = Test()
test.wtf()
I would expect upper code to open 1 window, however it opens 2. 我希望上面的代码打开1个窗口,但是打开2个。
How can I fix this problem? 我该如何解决这个问题?
import pyglet
class Test(object):
def setUp(self):
self.window = pyglet.window.Window()
def tearDown(self):
self.window.close()
del self.window
def wtf(self):
self.setUp()
self.tearDown()
self.setUp()
pyglet.app.run()
test = Test()
test.wtf()
You can also use set_visible in order to hide it as a temporary thing if you want to show it later. 如果要稍后显示它,也可以使用set_visible来将其隐藏为临时对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.