summaryrefslogtreecommitdiffstats
path: root/Tools/pynche/Main.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1999-04-26 23:17:16 (GMT)
committerBarry Warsaw <barry@python.org>1999-04-26 23:17:16 (GMT)
commit0604d723183bee9ca18920708ec7fd44fbc4c63b (patch)
treefdffddafc755782e374fe2b7a2efb0ea6443547f /Tools/pynche/Main.py
parent0ec1493d0b0bdbef561c819c560a6703256c88a1 (diff)
downloadcpython-0604d723183bee9ca18920708ec7fd44fbc4c63b.zip
cpython-0604d723183bee9ca18920708ec7fd44fbc4c63b.tar.gz
cpython-0604d723183bee9ca18920708ec7fd44fbc4c63b.tar.bz2
Lots of changes to support loading alternative color name database.
You can switch database by just loading the new one; the list window and nearest colors adapt to the new database. Some reorganizing of code. Also, the name of the database file is stored in the ~/.pynche pickle. If it can't be loaded, fallbacks are used.
Diffstat (limited to 'Tools/pynche/Main.py')
-rw-r--r--Tools/pynche/Main.py34
1 files changed, 21 insertions, 13 deletions
diff --git a/Tools/pynche/Main.py b/Tools/pynche/Main.py
index 1ec738b..459aaa5 100644
--- a/Tools/pynche/Main.py
+++ b/Tools/pynche/Main.py
@@ -49,7 +49,7 @@ Where:
"""
-__version__ = '0.1'
+__version__ = '0.2'
import sys
import os
@@ -120,19 +120,27 @@ def initial_color(s, colordb):
def build(master=None, initialcolor=None, initfile=None, ignore=None):
- # create the windows and go
- for f in RGB_TXT:
- try:
- colordb = ColorDB.get_colordb(f)
- if colordb:
- break
- except IOError:
- pass
- else:
- usage(1, 'No color database file found, see the -d option.')
-
# create all output widgets
- s = Switchboard(colordb, not ignore and initfile)
+ s = Switchboard(not ignore and initfile)
+
+ # load the color database
+ colordb = None
+ try:
+ dbfile = s.optiondb()['DBFILE']
+ colordb = ColorDB.get_colordb(dbfile)
+ except (KeyError, IOError):
+ # scoot through the files listed above to try to find a usable color
+ # database file
+ for f in RGB_TXT:
+ try:
+ colordb = ColorDB.get_colordb(f)
+ if colordb:
+ break
+ except IOError:
+ pass
+ if not colordb:
+ usage(1, 'No color database file found, see the -d option.')
+ s.set_colordb(colordb)
# create the application window decorations
app = PyncheWidget(__version__, s, master=master)