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
e7f4a47b
Kaydet (Commit)
e7f4a47b
authored
Eki 06, 1998
tarafından
Barry Warsaw
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Better initial color choosing
üst
45c8d342
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
17 deletions
+37
-17
Main.py
Tools/pynche/Main.py
+30
-13
PyncheWidget.py
Tools/pynche/PyncheWidget.py
+7
-4
No files found.
Tools/pynche/Main.py
Dosyayı görüntüle @
e7f4a47b
...
@@ -62,6 +62,34 @@ def usage(status, msg=''):
...
@@ -62,6 +62,34 @@ def usage(status, msg=''):
def
initial_color
(
s
,
colordb
):
# function called on every color
def
scan_color
(
s
,
colordb
=
colordb
):
try
:
r
,
g
,
b
=
colordb
.
find_byname
(
s
)
except
ColorDB
.
BadColor
:
try
:
r
,
g
,
b
=
ColorDB
.
rrggbb_to_triplet
(
s
)
except
ColorDB
.
BadColor
:
return
None
,
None
,
None
return
r
,
g
,
b
#
# First try the passed in color
r
,
g
,
b
=
scan_color
(
s
)
if
r
is
None
:
# try the same color with '#' prepended, since some shells require
# this to be escaped, which is a pain
r
,
g
,
b
=
scan_color
(
'#'
+
s
)
if
r
is
None
:
print
'Bad initial color, using gray50:'
,
s
r
,
g
,
b
=
scan_color
(
'gray50'
)
if
r
is
None
:
usage
(
1
,
'Cannot find an initial color to use'
)
# does not return
return
r
,
g
,
b
def
main
():
def
main
():
try
:
try
:
opts
,
args
=
getopt
.
getopt
(
opts
,
args
=
getopt
.
getopt
(
...
@@ -95,19 +123,8 @@ def main():
...
@@ -95,19 +123,8 @@ def main():
else
:
else
:
usage
(
1
,
'No color database file found, see the -d option.'
)
usage
(
1
,
'No color database file found, see the -d option.'
)
# get triplet for initial color
# get the initial color as components
try
:
red
,
green
,
blue
=
initial_color
(
initialcolor
,
colordb
)
red
,
green
,
blue
=
colordb
.
find_byname
(
initialcolor
)
except
ColorDB
.
BadColor
:
# must be a #rrggbb style color
try
:
red
,
green
,
blue
=
ColorDB
.
rrggbb_to_triplet
(
initialcolor
)
except
ColorDB
.
BadColor
:
try
:
red
,
green
,
blue
=
ColorDB
.
rrggbb_to_triplet
(
'#7f7f7f'
)
print
'Bad initial color, using gray50:'
,
initialcolor
except
ColorDB
.
BadColor
:
usage
(
1
,
'Cannot find an initial color to use'
)
# create all output widgets
# create all output widgets
s
=
Switchboard
(
colordb
)
s
=
Switchboard
(
colordb
)
...
...
Tools/pynche/PyncheWidget.py
Dosyayı görüntüle @
e7f4a47b
...
@@ -40,7 +40,7 @@ class PyncheWidget:
...
@@ -40,7 +40,7 @@ class PyncheWidget:
#
#
filemenu
=
self
.
__filemenu
=
Menu
(
menubar
,
tearoff
=
0
)
filemenu
=
self
.
__filemenu
=
Menu
(
menubar
,
tearoff
=
0
)
filemenu
.
add_command
(
label
=
'Quit'
,
filemenu
.
add_command
(
label
=
'Quit'
,
command
=
tkroot
.
quit
,
command
=
self
.
__
quit
,
accelerator
=
'Alt-Q'
,
accelerator
=
'Alt-Q'
,
underline
=
0
)
underline
=
0
)
#
#
...
@@ -78,12 +78,15 @@ class PyncheWidget:
...
@@ -78,12 +78,15 @@ class PyncheWidget:
# now create the top level window
# now create the top level window
root
=
self
.
__root
=
Toplevel
(
tkroot
,
class_
=
'Pynche'
,
menu
=
menubar
)
root
=
self
.
__root
=
Toplevel
(
tkroot
,
class_
=
'Pynche'
,
menu
=
menubar
)
root
.
protocol
(
'WM_DELETE_WINDOW'
,
tkroot
.
quit
)
root
.
protocol
(
'WM_DELETE_WINDOW'
,
self
.
__
quit
)
root
.
title
(
'Pynche
%
s'
%
version
)
root
.
title
(
'Pynche
%
s'
%
version
)
root
.
iconname
(
'Pynche'
)
root
.
iconname
(
'Pynche'
)
root
.
tk
.
createtimerhandler
(
KEEPALIVE_TIMER
,
self
.
__keepalive
)
root
.
tk
.
createtimerhandler
(
KEEPALIVE_TIMER
,
self
.
__keepalive
)
root
.
bind
(
'<Alt-q>'
,
tkroot
.
quit
)
root
.
bind
(
'<Alt-q>'
,
self
.
__quit
)
root
.
bind
(
'<Alt-Q>'
,
tkroot
.
quit
)
root
.
bind
(
'<Alt-Q>'
,
self
.
__quit
)
def
__quit
(
self
,
event
=
None
):
self
.
__root
.
quit
()
def
__keepalive
(
self
):
def
__keepalive
(
self
):
# Exercise the Python interpreter regularly so keyboard interrupts get
# Exercise the Python interpreter regularly so keyboard interrupts get
...
...
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