~ubuntu-branches/ubuntu/karmic/python3.0/karmic

« back to all changes in this revision

Viewing changes to Lib/tkinter/colorchooser.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-02-16 17:18:23 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090216171823-1d5cm5qnnjvmnzzm
Tags: 3.0.1-0ubuntu1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
        try:
35
35
            # make sure initialcolor is a tk color string
36
36
            color = self.options["initialcolor"]
37
 
            if type(color) == type(()):
 
37
            if isinstance(color, tuple):
38
38
                # assume an RGB triplet
39
39
                self.options["initialcolor"] = "#%02x%02x%02x" % color
40
40
        except KeyError:
41
41
            pass
42
42
 
43
43
    def _fixresult(self, widget, result):
 
44
        # result can be somethings: an empty tuple, an empty string or
 
45
        # a Tcl_Obj, so this somewhat weird check handles that
 
46
        if not result or not str(result):
 
47
            return None, None # canceled
 
48
 
44
49
        # to simplify application code, the color chooser returns
45
50
        # an RGB tuple together with the Tk color string
46
 
        if not result:
47
 
            return None, None # canceled
48
51
        r, g, b = widget.winfo_rgb(result)
49
 
        return (r/256, g/256, b/256), result
 
52
        return (r/256, g/256, b/256), str(result)
50
53
 
51
54
 
52
55
#
66
69
# test stuff
67
70
 
68
71
if __name__ == "__main__":
69
 
 
70
72
    print("color", askcolor())