Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
04c78867
Kaydet (Commit)
04c78867
authored
Eyl 28, 1998
tarafından
Barry Warsaw
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Un PMW-ified
üst
987fb922
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
27 deletions
+41
-27
Main.py
Tools/pynche/Main.py
+41
-27
No files found.
Tools/pynche/Main.py
Dosyayı görüntüle @
04c78867
...
@@ -6,35 +6,38 @@ Pynche is based largely on a similar color editor I wrote years ago for the
...
@@ -6,35 +6,38 @@ 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
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 +
hacking X and C code to do it. Fast forward many years, to where Python +
Tkinter
+ Pmw provides such a nice programming environment, with enough
Tkinter
provides such a nice programming environment, with enough power, that
power, that I finally buckled down and implemented it. I changed the nam
e
I finally buckled down and implemented it. I changed the name because thes
e
because these
days, too many other systems have the acronym `ICE'.
days, too many other systems have the acronym `ICE'.
This program currently requires Python 1.5 with Tkinter. It
also requires at
This program currently requires Python 1.5 with Tkinter. It
has only been
least Pmw 0.6.1. It has only been tested on Solaris 2.6. Feedback is greatly
tested on Solaris 2.6. Feedback is greatly appreciated. Send email to
appreciated. Send email to
bwarsaw@python.org
bwarsaw@python.org
Usage:
%(PROGRAM)
s [-
c color] [-h
]
Usage:
%(PROGRAM)
s [-
d file] [-h] [initialcolor
]
Where:
Where:
--
color color
--
database file
-
c color
-
d file
initial color, as an X color name or #RRGGBB format
Alternate location of a color database file
--help
--help
-h
-h
print this message
print this message
initialcolor
initial color, as a color name or #RRGGBB format
"""
"""
__version__
=
'1.0'
__version__
=
'1.0'
import
sys
import
sys
import
getopt
import
getopt
import
Pmw
import
ColorDB
import
ColorDB
from
Tkinter
import
*
from
Tkinter
import
*
from
PyncheWidget
import
PyncheWidget
from
PyncheWidget
import
PyncheWidget
from
Switchboard
import
Switchboard
...
@@ -43,10 +46,6 @@ PROGRAM = sys.argv[0]
...
@@ -43,10 +46,6 @@ PROGRAM = sys.argv[0]
# Milliseconds between interrupt checks
# Milliseconds between interrupt checks
KEEPALIVE_TIMER
=
500
KEEPALIVE_TIMER
=
500
RGBCOLOR
=
1
HSICOLOR
=
2
NAMEDCOLOR
=
3
# Default locations of rgb.txt or other textual color database
# Default locations of rgb.txt or other textual color database
RGB_TXT
=
[
RGB_TXT
=
[
# Solaris OpenWindows
# Solaris OpenWindows
...
@@ -67,30 +66,38 @@ def usage(status, msg=''):
...
@@ -67,30 +66,38 @@ def usage(status, msg=''):
app
=
None
app
=
None
def
keepalive
():
def
keepalive
():
# Exercise the Python interpreter regularly so keybard interrupts get
# Exercise the Python interpreter regularly so keyb
o
ard interrupts get
# through.
# through.
app
.
tk
.
createtimerhandler
(
KEEPALIVE_TIMER
,
keepalive
)
app
.
tk
.
createtimerhandler
(
KEEPALIVE_TIMER
,
keepalive
)
def
finished
(
event
=
None
):
sys
.
exit
(
0
)
def
main
():
def
main
():
global
app
global
app
initialcolor
=
'grey50'
try
:
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
opts
,
args
=
getopt
.
getopt
(
'hc:'
,
sys
.
argv
[
1
:],
[
'color='
,
'help'
])
'hd:'
,
[
'database='
,
'help'
])
except
getopt
.
error
,
msg
:
except
getopt
.
error
,
msg
:
usage
(
1
,
msg
)
usage
(
1
,
msg
)
if
args
:
if
len
(
args
)
==
0
:
initialcolor
=
'grey50'
elif
len
(
args
)
==
1
:
initialcolor
=
args
[
0
]
else
:
usage
(
1
)
usage
(
1
)
for
opt
,
arg
in
opts
:
for
opt
,
arg
in
opts
:
if
opt
in
(
'-h'
,
'--help'
):
if
opt
in
(
'-h'
,
'--help'
):
usage
(
0
)
usage
(
0
)
elif
opt
in
(
'-
c'
,
'--color
'
):
elif
opt
in
(
'-
d'
,
'--database
'
):
initialcolor
=
arg
RGB_TXT
.
insert
(
0
,
arg
)
# create the windows and go
# create the windows and go
for
f
in
RGB_TXT
:
for
f
in
RGB_TXT
:
...
@@ -102,8 +109,10 @@ def main():
...
@@ -102,8 +109,10 @@ def main():
else
:
else
:
raise
IOError
(
'No color database file found'
)
raise
IOError
(
'No color database file found'
)
app
=
Pmw
.
initialise
(
fontScheme
=
'pmw1'
)
app
=
Tk
(
className
=
'Pynche'
)
app
.
protocol
(
'WM_DELETE_WINDOW'
,
finished
)
app
.
title
(
'Pynche
%
s'
%
__version__
)
app
.
title
(
'Pynche
%
s'
%
__version__
)
app
.
iconname
(
'Pynche'
)
app
.
tk
.
createtimerhandler
(
KEEPALIVE_TIMER
,
keepalive
)
app
.
tk
.
createtimerhandler
(
KEEPALIVE_TIMER
,
keepalive
)
# get triplet for initial color
# get triplet for initial color
...
@@ -114,9 +123,14 @@ def main():
...
@@ -114,9 +123,14 @@ def main():
try
:
try
:
red
,
green
,
blue
=
ColorDB
.
rrggbb_to_triplet
(
initialcolor
)
red
,
green
,
blue
=
ColorDB
.
rrggbb_to_triplet
(
initialcolor
)
except
ColorDB
.
BadColor
:
except
ColorDB
.
BadColor
:
usage
(
1
,
'Bad initial color:
%
s'
%
initialcolor
)
print
'Bad initial color, using default:
%
s'
%
initialcolor
initialcolor
=
'grey50'
p
=
PyncheWidget
(
colordb
,
app
,
color
=
(
red
,
green
,
blue
))
try
:
red
,
green
,
blue
=
ColorDB
.
rrggbb_to_triplet
(
initialcolor
)
except
ColorDB
.
BadColor
:
usage
(
1
,
'Cannot find an initial color to use'
)
s
=
Switchboard
(
app
,
colordb
,
red
,
green
,
blue
)
try
:
try
:
keepalive
()
keepalive
()
app
.
mainloop
()
app
.
mainloop
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment