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
46670a2d
Kaydet (Commit)
46670a2d
authored
Eki 01, 1998
tarafından
Barry Warsaw
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
*** empty log message ***
üst
6e5b301b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
0 deletions
+98
-0
ListViewer.py
Tools/pynche/ListViewer.py
+98
-0
No files found.
Tools/pynche/ListViewer.py
0 → 100644
Dosyayı görüntüle @
46670a2d
import
sys
from
Tkinter
import
*
from
pynche
import
__version__
import
ColorDB
class
ListViewer
:
def
__init__
(
self
,
switchboard
,
parent
=
None
):
self
.
__sb
=
switchboard
self
.
__lastbox
=
None
root
=
self
.
__root
=
Toplevel
(
parent
,
class_
=
'Pynche'
)
root
.
protocol
(
'WM_DELETE_WINDOW'
,
self
.
__withdraw
)
root
.
title
(
'Pynche
%
s'
%
__version__
)
root
.
iconname
(
'Pynche Color List'
)
root
.
bind
(
'<Alt-q>'
,
self
.
__quit
)
root
.
bind
(
'<Alt-Q>'
,
self
.
__quit
)
#
# create the canvas which holds everything, and its scrollbar
#
canvas
=
self
.
__canvas
=
Canvas
(
root
,
width
=
160
,
height
=
300
)
self
.
__scrollbar
=
Scrollbar
(
root
)
self
.
__scrollbar
.
pack
(
fill
=
Y
,
side
=
RIGHT
)
canvas
.
pack
(
fill
=
BOTH
,
expand
=
1
)
canvas
.
configure
(
yscrollcommand
=
(
self
.
__scrollbar
,
'set'
))
self
.
__scrollbar
.
configure
(
command
=
(
canvas
,
'yview'
))
#
# create all the buttons
colordb
=
switchboard
.
colordb
()
row
=
0
names
=
colordb
.
all_names
()
names
.
sort
()
widest
=
0
bboxes
=
self
.
__bboxes
=
[]
for
name
in
names
:
exactcolor
=
ColorDB
.
triplet_to_rrggbb
(
colordb
.
find_byname
(
name
))
canvas
.
create_rectangle
(
5
,
row
*
20
+
5
,
20
,
row
*
20
+
20
,
fill
=
exactcolor
)
textid
=
canvas
.
create_text
(
25
,
row
*
20
+
13
,
text
=
name
,
anchor
=
W
)
x1
,
y1
,
textend
,
y2
=
canvas
.
bbox
(
textid
)
boxid
=
canvas
.
create_rectangle
(
3
,
row
*
20
+
3
,
textend
+
3
,
row
*
20
+
23
,
outline
=
''
,
tags
=
(
exactcolor
,))
canvas
.
tag_bind
(
boxid
,
'<ButtonPress>'
,
self
.
__onselection
)
bboxes
.
append
(
boxid
)
if
textend
+
3
>
widest
:
widest
=
textend
+
3
row
=
row
+
1
canvheight
=
(
row
-
1
)
*
20
+
25
canvas
.
config
(
scrollregion
=
(
0
,
0
,
150
,
canvheight
))
for
box
in
bboxes
:
x1
,
y1
,
x2
,
y2
=
canvas
.
coords
(
box
)
canvas
.
coords
(
box
,
x1
,
y1
,
widest
,
y2
)
def
__onselection
(
self
,
event
=
None
):
canvas
=
self
.
__canvas
# find the current box
x
=
canvas
.
canvasx
(
event
.
x
)
y
=
canvas
.
canvasy
(
event
.
y
)
ids
=
canvas
.
find_overlapping
(
x
,
y
,
x
,
y
)
for
boxid
in
ids
:
if
boxid
in
self
.
__bboxes
:
break
else
:
print
'No box found!'
return
tags
=
canvas
.
gettags
(
boxid
)
for
t
in
tags
:
if
t
[
0
]
==
'#'
:
break
else
:
print
'No color tag found!'
return
red
,
green
,
blue
=
ColorDB
.
rrggbb_to_triplet
(
t
)
self
.
__sb
.
update_views
(
red
,
green
,
blue
)
def
__selectbox
(
self
,
boxid
):
canvas
=
self
.
__canvas
# turn off the last box
if
self
.
__lastbox
:
canvas
.
itemconfigure
(
self
.
__lastbox
,
outline
=
''
)
self
.
__lastbox
=
boxid
canvas
.
itemconfigure
(
boxid
,
outline
=
'black'
)
def
__quit
(
self
,
event
=
None
):
sys
.
exit
(
0
)
def
__withdraw
(
self
,
event
=
None
):
self
.
__root
.
withdraw
()
def
deiconify
(
self
,
event
=
None
):
self
.
__root
.
deiconify
()
def
update_yourself
(
self
,
red
,
green
,
blue
):
colorname
=
ColorDB
.
triplet_to_rrggbb
((
red
,
green
,
blue
))
self
.
__selectbox
(
colorname
)
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