CubeColourDialog.py :  » GUI » wxPython » wxPython-src-2.8.11.0 » wxPython » demo » agw » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » GUI » wxPython 
wxPython » wxPython src 2.8.11.0 » wxPython » demo » agw » CubeColourDialog.py
import wx

import os
import sys

try:
    dirName = os.path.dirname(os.path.abspath(__file__))
except:
    dirName = os.path.dirname(os.path.abspath(sys.argv[0]))

sys.path.append(os.path.split(dirName)[0])

try:
    from agw import cubecolourdialog
except ImportError: # if it's not there locally, try the wxPython lib.
    import wx.lib.agw.cubecolourdialog as CCD


class CubeColourDialogDemo(wx.Panel):

    def __init__(self, parent, log):

        wx.Panel.__init__(self, parent, -1)

        static = wx.StaticText(self, -1, "Notice the panel background colour!", (50, 50))
        b = wx.Button(self, -1, "Create and Show a CubeColourDialog", (50, 70))
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)

        self.log = log        


    def OnButton(self, evt):

        if not hasattr(self, "colourData"):
            self.colourData = wx.ColourData()
            
        self.colourData.SetColour(self.GetBackgroundColour())
        
        dlg = CCD.CubeColourDialog(self, self.colourData)

        if dlg.ShowModal() == wx.ID_OK:

            # If the user selected OK, then the dialog's wx.ColourData will
            # contain valid information. Fetch the data ...
            self.colourData = dlg.GetColourData()
            h, s, v, a = dlg.GetHSVAColour()

            # ... then do something with it. The actual colour data will be
            # returned as a three-tuple (r, g, b) in this particular case.
            colour = self.colourData.GetColour()
            self.log.WriteText('You selected: %s: %d, %s: %d, %s: %d, %s: %d\n' % ("Red", colour.Red(),
                                                                                   "Green", colour.Green(),
                                                                                   "Blue", colour.Blue(),
                                                                                   "Alpha", colour.Alpha()))
            self.log.WriteText('HSVA Components: %s: %d, %s: %d, %s: %d, %s: %d\n\n' % ("Hue", h,
                                                                                        "Saturation", s,
                                                                                        "Brightness", v,
                                                                                        "Alpha", a))
            self.SetBackgroundColour(self.colourData.GetColour())
            self.Refresh()

        # Once the dialog is destroyed, Mr. wx.ColourData is no longer your
        # friend. Don't use it again!
        dlg.Destroy()


#----------------------------------------------------------------------

def runTest(frame, nb, log):
    win = CubeColourDialogDemo(nb, log)
    return win

#----------------------------------------------------------------------

overview = CCD.__doc__

if __name__ == '__main__':
    import sys,os
    import run
    run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.