关于wxPython

img

img

img


我是在wxPython官网去看的,然后自己照着敲,敲下来就报错了,有没有会的呀,帮帮我

直接复制没有什么问题,你这边可以检查下自己wxpython的版本
下面贴上我直接复制的内容

import wx
import wx.lib.colourdb

class MyFrame(wx.Frame):
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, wx.ID_ANY, title, size=(400, 300))
        # show the selected colour in this panel
        self.panel = wx.Panel(self)

        wx.lib.colourdb.updateColourDB()
        # create a colour list from the colourdb database
        colour_list = wx.lib.colourdb.getColourList()

        # create a choice widget
        self.choice = wx.Choice(self.panel, -1, choices=colour_list)
        # select item 0 (first item) in choice list to show
        self.choice.SetSelection(0)
        # set the current frame colour to the choice
        self.SetBackgroundColour(self.choice.GetStringSelection())
        # bind the checkbox events to an action
        self.choice.Bind(wx.EVT_CHOICE, self.OnChoice)


    def OnChoice(self, event):
        bgcolour = self.choice.GetStringSelection()
        # change colour of the panel to the selected colour ...
        self.panel.SetBackgroundColour(bgcolour)
        self.panel.Refresh()
        # show the selected colour in the frame title
        self.SetTitle(bgcolour.lower())

app = wx.App()
frame = MyFrame(None, 'Green')
frame.Show()
app.MainLoop()

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^