Commit 680ca08c authored by Barry Warsaw's avatar Barry Warsaw

Some fixes based on feedback from Hans Petter Langtangen.

build(): Fix the logic here for calculating fallbacks if the dbfile
isn't parseable.

main(): Fix the semantics for -d/--database; this should override any
database value found in the .pynche file.

Update some comments, and author contact info.

Bump to v1.4

Whitespace normalization.
parent 83dc2327
"""Pynche -- The PYthon Natural Color and Hue Editor.
Contact: Barry Warsaw
Email: bwarsaw@python.org
Contact: %(AUTHNAME)s
Email: %(AUTHEMAIL)s
Version: %(__version__)s
Pynche is based largely on a similar color editor I wrote years ago for the
Sunview window system. That editor was called ICE: the Interactive Color
SunView window system. That editor was called ICE: the Interactive Color
Editor. I'd always wanted to port the editor to X but didn't feel like
hacking X and C code to do it. Fast forward many years, to where Python +
Tkinter provides such a nice programming environment, with enough power, that
I finally buckled down and implemented it. I changed the name because these
days, too many other systems have the acronym `ICE'.
This program currently requires Python 1.5 with Tkinter. It has only been
tested on Solaris 2.6. Feedback is greatly appreciated. Send email to
bwarsaw@python.org
This program currently requires Python 2.2 with Tkinter.
Usage: %(PROGRAM)s [-d file] [-i file] [-X] [-v] [-h] [initialcolor]
......@@ -38,7 +36,7 @@ Where:
--version
-v
print the version number
print the version number and exit
--help
-h
......@@ -48,7 +46,7 @@ Where:
initial color, as a color name or #RRGGBB format
"""
__version__ = '1.3'
__version__ = '1.4'
import sys
import os
......@@ -64,6 +62,8 @@ from TypeinViewer import TypeinViewer
PROGRAM = sys.argv[0]
AUTHNAME = 'Barry Warsaw'
AUTHEMAIL = 'barry@python.org'
# Default locations of rgb.txt or other textual color database
RGB_TXT = [
......@@ -120,25 +120,26 @@ def initial_color(s, colordb):
def build(master=None, initialcolor=None, initfile=None, ignore=None):
def build(master=None, initialcolor=None, initfile=None, ignore=None,
dbfile=None):
# create all output widgets
s = Switchboard(not ignore and initfile)
# load the color database
# defer to the command line chosen color database, falling back to the one
# in the .pynche file.
if dbfile is None:
dbfile = s.optiondb()['DBFILE']
# find a parseable color database
colordb = None
files = RGB_TXT[:]
while colordb is 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 colordb is None:
if not files:
break
dbfile = files.pop(0)
if not colordb:
usage(1, 'No color database file found, see the -d option.')
s.set_colordb(colordb)
......@@ -193,28 +194,30 @@ def main():
else:
usage(1)
ignore = 0
ignore = False
dbfile = None
initfile = os.path.expanduser('~/.pynche')
for opt, arg in opts:
if opt in ('-h', '--help'):
usage(0)
elif opt in ('-v', '--version'):
print '''\
print """\
Pynche -- The PYthon Natural Color and Hue Editor.
Contact: Barry Warsaw
Email: bwarsaw@python.org
Version: %s''' % __version__
Contact: %(AUTHNAME)s
Email: %(AUTHEMAIL)s
Version: %(__version__)s""" % globals()
sys.exit(0)
elif opt in ('-d', '--database'):
RGB_TXT.insert(0, arg)
dbfile = arg
elif opt in ('-X', '--ignore'):
ignore = 1
ignore = True
elif opt in ('-i', '--initfile'):
initfile = arg
app, sb = build(initialcolor=initialcolor,
initfile=initfile,
ignore=ignore)
ignore=ignore,
dbfile=dbfile)
run(app, sb)
sb.save_views()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment