使用wxPython时为什么会出现两个窗口?

时间:2018-05-01 18:37:36

标签: python wxpython

我写了一个hello world wxpython应用程序,但我注意到当我运行它时,我得到了两个窗口渲染。查看带有窗口和代码的屏幕截图。为什么会这样?

enter image description here

2 个答案:

答案 0 :(得分:1)

#A code to open three window
# Imports the wx package
import wx

# Creates an application object
app = wx.App()

# Creates a Frame
top = wx.Frame(None, title="Hello World", size=(300, 200))

# You can add this line if you want to add more controls to the frame

top1 = wx.Frame(None, title="Bonjour le monde", size=(300, 200))
top2 = wx.Frame(None, title ="Hallo Welt", size=(400, 200))
top.Show(True)
top1.Show(True)
top2.Show(True)
app.MainLoop()

答案 1 :(得分:0)

尝试以下代码段

#Imports the wx package
import wx 

#Creates an application object  
app = wx.App() 

#Creates a Frame
top = wx.Frame(None, title = "Hello World", size = (300,200)) 

#You can add this line if you want to add more controls to the frame
panel = wx.Panel(top)


top.Show(True) 
app.MainLoop()

我认为您看到的2个窗口是因为参数redirect=true

此处有详细解释:

https://www.tutorialspoint.com/wxpython/wxpython_hello_world.htm

https://docs.wxpython.org/