wxpython 颜色对话框 ColourDialog

#!/usr/bin/env python
#coding:utf-8
"""
  Author:  u"王浩" --<[email protected]>
  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()
    

你可能感兴趣的:(wxpython,python)