首页 > 试题广场 >

1[问答] 设计一个窗体,并放置一个按钮,单击按钮后弹出颜色

[问答题]
设计一个窗体,并放置一个按钮,单击按钮后弹出颜色对话框,关闭颜色对话框后提示选中的颜色。

import wx

class wxGUI(wx.App):

def OnInit(self):

frame = wx.Frame(parent=None, title='wxGUI', size=(160,140))

panel = wx.Panel(frame, -1)

buttonOK = wx.Button(panel, -1, 'OK', pos=(0,0))

self.Bind(wx.EVT_BUTTON, self.OnButtonOK, buttonOK)

frame.Show()

return True

def OnButtonOK(self, event):

colorDlg = wx.ColourDialog(None)

colorDlg.ShowModal()

color = colorDlg.GetColourData().Colour

wx.MessageBox(str(color))

app = wxGUI()

app.MainLoop()

发表于 2019-06-26 10:11:52 回复(0)

不会


发表于 2019-04-20 08:14:47 回复(1)