Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
55f1b5a8
Commit
55f1b5a8
authored
Sep 28, 1998
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated to new post-PMW framework. Moved generators to here and added
the StripViewer class.
parent
e7ecafc4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
36 deletions
+74
-36
Tools/pynche/StripViewer.py
Tools/pynche/StripViewer.py
+74
-36
No files found.
Tools/pynche/StripViewer.py
View file @
55f1b5a8
...
@@ -21,6 +21,33 @@ BTNUP = 5
...
@@ -21,6 +21,33 @@ BTNUP = 5
BTNDRAG
=
6
BTNDRAG
=
6
def
constant
(
numchips
):
step
=
255.0
/
(
numchips
-
1
)
start
=
0.0
seq
=
[]
while
numchips
>
0
:
seq
.
append
(
int
(
start
))
start
=
start
+
step
numchips
=
numchips
-
1
return
seq
# red variations, green+blue = cyan constant
def
constant_cyan_generator
(
numchips
,
red
,
green
,
blue
):
seq
=
constant
(
numchips
)
return
map
(
None
,
seq
,
[
green
]
*
numchips
,
[
blue
]
*
numchips
)
# green variations, red+blue = magenta constant
def
constant_magenta_generator
(
numchips
,
red
,
green
,
blue
):
seq
=
constant
(
numchips
)
return
map
(
None
,
[
red
]
*
numchips
,
seq
,
[
blue
]
*
numchips
)
# blue variations, red+green = yellow constant
def
constant_yellow_generator
(
numchips
,
red
,
green
,
blue
):
seq
=
constant
(
numchips
)
return
map
(
None
,
[
red
]
*
numchips
,
[
green
]
*
numchips
,
seq
)
class
LeftArrow
:
class
LeftArrow
:
_ARROWWIDTH
=
30
_ARROWWIDTH
=
30
...
@@ -94,16 +121,16 @@ class StripWidget:
...
@@ -94,16 +121,16 @@ class StripWidget:
def
__init__
(
self
,
switchboard
,
def
__init__
(
self
,
switchboard
,
parent
=
None
,
parent
=
None
,
color
=
(
128
,
128
,
128
),
chipwidth
=
_CHIPWIDTH
,
chipwidth
=
self
.
_CHIPWIDTH
,
chipheight
=
_CHIPHEIGHT
,
chipheight
=
self
.
_CHIPHEIGHT
,
numchips
=
_NUMCHIPS
,
numchips
=
self
.
_NUMCHIPS
,
generator
=
None
,
generator
=
None
,
axis
=
None
,
axis
=
None
,
label
=
''
):
label
=
''
):
# instance variables
# instance variables
self
.
__generator
=
generator
self
.
__generator
=
generator
self
.
__axis
=
axis
self
.
__axis
=
axis
self
.
__numchips
=
numchips
assert
self
.
__axis
in
(
0
,
1
,
2
)
assert
self
.
__axis
in
(
0
,
1
,
2
)
self
.
__update_while_dragging
=
0
self
.
__update_while_dragging
=
0
# the last chip selected
# the last chip selected
...
@@ -148,7 +175,7 @@ class StripWidget:
...
@@ -148,7 +175,7 @@ class StripWidget:
# create the strip label
# create the strip label
self
.
__label
=
canvas
.
create_text
(
self
.
__label
=
canvas
.
create_text
(
3
,
y
+
chipheight
+
8
,
3
,
y
+
chipheight
+
8
,
text
=
self
[
'label'
]
,
text
=
label
,
anchor
=
W
)
anchor
=
W
)
# create the arrow and text item
# create the arrow and text item
...
@@ -158,39 +185,29 @@ class StripWidget:
...
@@ -158,39 +185,29 @@ class StripWidget:
chipx
=
self
.
__arrow_x
(
len
(
chips
)
-
1
)
chipx
=
self
.
__arrow_x
(
len
(
chips
)
-
1
)
self
.
__rightarrow
=
RightArrow
(
canvas
,
chipx
)
self
.
__rightarrow
=
RightArrow
(
canvas
,
chipx
)
# Invoked when one of the chips is clicked. This should just tell the
# switchboard to set the color on all the output components
def
__set_color
(
self
):
rgbtuple
=
self
[
'color'
]
self
.
set_color
(
self
,
rgbtuple
)
def
__arrow_x
(
self
,
chipnum
):
def
__arrow_x
(
self
,
chipnum
):
coords
=
self
.
__canvas
.
coords
(
chipnum
+
1
)
coords
=
self
.
__canvas
.
coords
(
chipnum
+
1
)
assert
coords
assert
coords
x0
,
y0
,
x1
,
y1
=
coords
x0
,
y0
,
x1
,
y1
=
coords
return
(
x1
+
x0
)
/
2.0
return
(
x1
+
x0
)
/
2.0
# Invoked when one of the chips is clicked. This should just tell the
# switchboard to set the color on all the output components
def
__select_chip
(
self
,
event
=
None
):
def
__select_chip
(
self
,
event
=
None
):
if
self
.
__delegate
:
x
=
event
.
x
x
=
event
.
x
y
=
event
.
y
y
=
event
.
y
canvas
=
self
.
__canvas
canvas
=
self
.
__canvas
chip
=
canvas
.
find_overlapping
(
x
,
y
,
x
,
y
)
chip
=
canvas
.
find_overlapping
(
x
,
y
,
x
,
y
)
if
chip
and
(
1
<=
chip
[
0
]
<=
self
.
__numchips
):
if
chip
and
(
1
<=
chip
[
0
]
<=
self
.
__numchips
):
color
=
self
.
__chips
[
chip
[
0
]
-
1
]
color
=
self
.
__chips
[
chip
[
0
]
-
1
]
rgbtupl
e
=
ColorDB
.
rrggbb_to_triplet
(
color
)
red
,
green
,
blu
e
=
ColorDB
.
rrggbb_to_triplet
(
color
)
etype
=
int
(
event
.
type
)
etype
=
int
(
event
.
type
)
if
(
etype
==
BTNUP
or
self
.
__update_while_dragging
):
if
(
etype
==
BTNUP
or
self
.
__update_while_dragging
):
# update everyone
# update everyone
self
.
__delegate
.
set_color
(
self
,
rgbtupl
e
)
self
.
__sb
.
update_views
(
red
,
green
,
blu
e
)
else
:
else
:
# just track the arrows
# just track the arrows
self
.
__trackarrow
(
chip
[
0
],
rgbtuple
)
self
.
__trackarrow
(
chip
[
0
],
(
red
,
green
,
blue
))
def
__set_delegate
(
self
):
self
.
__delegate
=
self
[
'delegate'
]
def
__trackarrow
(
self
,
chip
,
rgbtuple
):
def
__trackarrow
(
self
,
chip
,
rgbtuple
):
# invert the last chip
# invert the last chip
...
@@ -221,10 +238,6 @@ class StripWidget:
...
@@ -221,10 +238,6 @@ class StripWidget:
self
.
__canvas
.
itemconfigure
(
chip
,
outline
=
outline
)
self
.
__canvas
.
itemconfigure
(
chip
,
outline
=
outline
)
#
# public interface
#
def
update_yourself
(
self
,
red
,
green
,
blue
):
def
update_yourself
(
self
,
red
,
green
,
blue
):
assert
self
.
__generator
assert
self
.
__generator
i
=
1
i
=
1
...
@@ -233,7 +246,7 @@ class StripWidget:
...
@@ -233,7 +246,7 @@ class StripWidget:
tclcmd
=
[]
tclcmd
=
[]
tk
=
self
.
__canvas
.
tk
tk
=
self
.
__canvas
.
tk
# get the red, green, and blue components for all chips
# get the red, green, and blue components for all chips
for
t
in
self
.
__generator
(
self
.
__numchips
,
r
gbtupl
e
):
for
t
in
self
.
__generator
(
self
.
__numchips
,
r
ed
,
green
,
blu
e
):
rrggbb
=
ColorDB
.
triplet_to_rrggbb
(
t
)
rrggbb
=
ColorDB
.
triplet_to_rrggbb
(
t
)
chips
.
append
(
rrggbb
)
chips
.
append
(
rrggbb
)
tred
,
tgreen
,
tblue
=
t
tred
,
tgreen
,
tblue
=
t
...
@@ -248,3 +261,28 @@ class StripWidget:
...
@@ -248,3 +261,28 @@ class StripWidget:
def
set_update_while_dragging
(
self
,
flag
):
def
set_update_while_dragging
(
self
,
flag
):
self
.
__update_while_dragging
=
flag
self
.
__update_while_dragging
=
flag
class
StripViewer
:
def
__init__
(
self
,
switchboard
,
parent
=
None
):
self
.
__sb
=
switchboard
self
.
__reds
=
StripWidget
(
switchboard
,
parent
,
generator
=
constant_cyan_generator
,
axis
=
0
,
label
=
'Red Variations'
)
self
.
__greens
=
StripWidget
(
switchboard
,
parent
,
generator
=
constant_magenta_generator
,
axis
=
1
,
label
=
'Green Variations'
)
self
.
__blues
=
StripWidget
(
switchboard
,
parent
,
generator
=
constant_yellow_generator
,
axis
=
2
,
label
=
'Blue Variations'
)
def
update_yourself
(
self
,
red
,
green
,
blue
):
self
.
__reds
.
update_yourself
(
red
,
green
,
blue
)
self
.
__greens
.
update_yourself
(
red
,
green
,
blue
)
self
.
__blues
.
update_yourself
(
red
,
green
,
blue
)
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