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
aafae34f
Commit
aafae34f
authored
Feb 11, 1998
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Interface changes, delegate chaining, type in widget addition
parent
096c1a0f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
13 deletions
+37
-13
Tools/pynche/PyncheWidget.py
Tools/pynche/PyncheWidget.py
+37
-13
No files found.
Tools/pynche/PyncheWidget.py
View file @
aafae34f
...
...
@@ -5,13 +5,16 @@ from Tkinter import *
import
Pmw
import
ColorDB
from
ChipWidget
import
ChipWidget
from
TypeinWidget
import
TypeinWidget
class
PyncheWidget
(
Pmw
.
MegaWidget
):
def
__init__
(
self
,
colordb
,
parent
=
None
,
**
kw
):
self
.
__colordb
=
colordb
optionsdefs
=
((
'color'
,
'grey50'
,
self
.
__set_color
),)
self
.
defineoptions
(
kw
,
optionsdefs
)
options
=
((
'color'
,
(
128
,
128
,
128
),
self
.
__set_color
),
(
'delegate'
,
None
,
None
),
)
self
.
defineoptions
(
kw
,
options
)
# initialize base class -- after defining options
Pmw
.
MegaWidget
.
__init__
(
self
,
parent
)
...
...
@@ -32,20 +35,41 @@ class PyncheWidget(Pmw.MegaWidget):
self
.
__nearest
.
grid
(
row
=
0
,
column
=
1
)
# create the options window
options
=
Pmw
.
Group
(
parent
,
tag_text
=
'Options'
)
options
.
pack
(
expand
=
YES
,
fill
=
BOTH
)
group
=
Pmw
.
Group
(
parent
,
tag_text
=
'Options'
)
group
.
pack
(
expand
=
YES
,
fill
=
BOTH
)
self
.
__typein
=
TypeinWidget
(
group
.
interior
())
self
.
__typein
.
grid
()
# Check keywords and initialize options
self
.
initialiseoptions
(
PyncheWidget
)
self
.
__typein
.
configure
(
delegate
=
self
)
def
__set_color
(
self
):
color
=
self
[
'color'
]
try
:
red
,
green
,
blue
,
rrggbb
=
self
.
__colordb
.
find_byname
(
color
)
except
ColorDB
.
BadColor
:
red
,
green
,
blue
=
ColorDB
.
rrggbb_to_triplet
(
color
)
nearest
=
self
.
__colordb
.
nearest
(
red
,
green
,
blue
)
self
.
__selected
.
configure
(
color
=
color
)
#
# PUBLIC INTERFACE
#
def
set_color
(
self
,
obj
,
rgbtuple
):
print
'setting color to:'
,
rgbtuple
nearest
=
self
.
__colordb
.
nearest
(
rgbtuple
)
red
,
green
,
blue
,
rrggbb
=
self
.
__colordb
.
find_byname
(
nearest
)
# for an exact match, use the color name
if
(
red
,
green
,
blue
)
==
rgbtuple
:
self
.
__selected
.
configure
(
color
=
nearest
)
# otherwise, use the #rrggbb name
else
:
rrggbb
=
ColorDB
.
triplet_to_rrggbb
(
rgbtuple
)
self
.
__selected
.
configure
(
color
=
rrggbb
)
self
.
__nearest
.
configure
(
color
=
nearest
)
self
.
__typein
.
configure
(
color
=
rgbtuple
)
delegate
=
self
[
'delegate'
]
if
delegate
:
delegate
.
set_color
(
self
,
rgbtuple
)
#
# PRIVATE INTERFACE
#
def
__set_color
(
self
):
self
.
set_color
(
self
,
self
[
'color'
])
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