Back to index

python3.2  3.2.2
Public Member Functions | Private Attributes
pynche.pyColorChooser.Chooser Class Reference

List of all members.

Public Member Functions

def __init__
def show
def save

Private Attributes

 __master
 __databasefile
 __initfile
 __ignore
 __pw
 __wantspec
 __sb

Detailed Description

Ask for a color

Definition at line 10 of file pyColorChooser.py.


Constructor & Destructor Documentation

def pynche.pyColorChooser.Chooser.__init__ (   self,
  master = None,
  databasefile = None,
  initfile = None,
  ignore = None,
  wantspec = None 
)

Definition at line 17 of file pyColorChooser.py.

00017 
00018                  wantspec = None):
00019         self.__master = master
00020         self.__databasefile = databasefile
00021         self.__initfile = initfile or os.path.expanduser('~/.pynche')
00022         self.__ignore = ignore
00023         self.__pw = None
00024         self.__wantspec = wantspec

Here is the caller graph for this function:


Member Function Documentation

Definition at line 72 of file pyColorChooser.py.

00072 
00073     def save(self):
00074         if self.__sb:
00075             self.__sb.save_views()
00076 
00077 
# convenience stuff
def pynche.pyColorChooser.Chooser.show (   self,
  color,
  options 
)

Definition at line 25 of file pyColorChooser.py.

00025 
00026     def show(self, color, options):
00027         # scan for options that can override the ctor options
00028         self.__wantspec = options.get('wantspec', self.__wantspec)
00029         dbfile = options.get('databasefile', self.__databasefile)
00030         # load the database file
00031         colordb = None
00032         if dbfile != self.__databasefile:
00033             colordb = ColorDB.get_colordb(dbfile)
00034         if not self.__master:
00035             from tkinter import Tk
00036             self.__master = Tk()
00037         if not self.__pw:
00038             self.__pw, self.__sb = \
00039                        Main.build(master = self.__master,
00040                                   initfile = self.__initfile,
00041                                   ignore = self.__ignore)
00042         else:
00043             self.__pw.deiconify()
00044         # convert color
00045         if colordb:
00046             self.__sb.set_colordb(colordb)
00047         else:
00048             colordb = self.__sb.colordb()
00049         if color:
00050             r, g, b = Main.initial_color(color, colordb)
00051             self.__sb.update_views(r, g, b)
00052         # reset the canceled flag and run it
00053         self.__sb.canceled(0)
00054         Main.run(self.__pw, self.__sb)
00055         rgbtuple = self.__sb.current_rgb()
00056         self.__pw.withdraw()
00057         # check to see if the cancel button was pushed
00058         if self.__sb.canceled_p():
00059             return None, None
00060         # Try to return the color name from the database if there is an exact
00061         # match, otherwise use the "#rrggbb" spec.  BAW: Forget about color
00062         # aliases for now, maybe later we should return these too.
00063         name = None
00064         if not self.__wantspec:
00065             try:
00066                 name = colordb.find_byrgb(rgbtuple)[0]
00067             except ColorDB.BadColor:
00068                 pass
00069         if name is None:
00070             name = ColorDB.triplet_to_rrggbb(rgbtuple)
00071         return rgbtuple, name


Member Data Documentation

Definition at line 19 of file pyColorChooser.py.

Definition at line 21 of file pyColorChooser.py.

Definition at line 20 of file pyColorChooser.py.

Definition at line 18 of file pyColorChooser.py.

Definition at line 22 of file pyColorChooser.py.

Definition at line 37 of file pyColorChooser.py.

Definition at line 23 of file pyColorChooser.py.


The documentation for this class was generated from the following file: