wxpython 颜色对话框 ColourDialog

时间:2021-02-20 07:10:50
#!/usr/bin/env python
#coding:utf-8
"""
Author: u"王浩" --<823921498@qq.com>
Purpose: u"颜色选择框实例"
Created: 2014/8/26
"""

import wx


###############################################################################
class ColourDialog(wx.Frame):
""""""

#----------------------------------------------------------------------
def __init__(self):
"""Constructor"""
wx.Frame.__init__(self,None,-1,u"颜色选择")
panel = wx.Panel(self)
b = wx.Button(panel, -1, u"颜色选择")
self.Bind(wx.EVT_BUTTON, self.OnButton, b)

def OnButton(self, event):
dlg = wx.ColourDialog(self)
dlg.GetColourData().SetChooseFull(True)
if dlg.ShowModal() == wx.ID_OK:
data = dlg.GetColourData()
colour = data.GetColour().Get()
print colour
dlg.Destroy()

###############################################################################
if __name__ == '__main__':
frame = wx.PySimpleApp()
app = ColourDialog()
app.Show()
frame.MainLoop()