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
85e69650
Commit
85e69650
authored
Oct 01, 1998
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed toggle b/w hex and decimal
parent
d344165f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
Tools/pynche/TypeinViewer.py
Tools/pynche/TypeinViewer.py
+21
-4
No files found.
Tools/pynche/TypeinViewer.py
View file @
85e69650
...
...
@@ -39,9 +39,24 @@ class TypeinViewer:
# Hex/Dec
self
.
__hex
=
Checkbutton
(
self
.
__frame
,
text
=
'Hexadecimal'
,
variable
=
self
.
__hexp
)
variable
=
self
.
__hexp
,
command
=
self
.
__togglehex
)
self
.
__hex
.
grid
(
row
=
4
,
column
=
0
,
columnspan
=
2
,
sticky
=
W
)
def
__togglehex
(
self
,
event
=
None
):
rstr
=
self
.
__x
.
get
()
gstr
=
self
.
__y
.
get
()
bstr
=
self
.
__z
.
get
()
if
self
.
__hexp
.
get
():
# it was decimal and is now hex
apply
(
self
.
update_yourself
,
tuple
(
map
(
int
,
(
rstr
,
gstr
,
bstr
))))
else
:
# it was hex and is now decimal
red
=
string
.
atoi
(
rstr
,
16
)
green
=
string
.
atoi
(
gstr
,
16
)
blue
=
string
.
atoi
(
bstr
,
16
)
self
.
update_yourself
(
red
,
green
,
blue
)
def
__normalize
(
self
,
event
=
None
):
ew
=
event
.
widget
contents
=
ew
.
get
()
...
...
@@ -55,9 +70,11 @@ class TypeinViewer:
v
=
string
.
atoi
(
contents
)
except
ValueError
:
v
=
None
# if value is not legal, delete the last character and ring the bell
# if value is not legal, delete the last character inserted and ring
# the bell
if
v
is
None
or
v
<
0
or
v
>
255
:
contents
=
contents
[:
-
1
]
i
=
ew
.
index
(
INSERT
)
contents
=
contents
[:
i
-
1
]
+
contents
[
i
:]
ew
.
bell
()
elif
self
.
__hexp
.
get
():
contents
=
hex
(
v
)
...
...
@@ -86,7 +103,7 @@ class TypeinViewer:
if
self
.
__hexp
.
get
():
redstr
,
greenstr
,
bluestr
=
map
(
hex
,
(
red
,
green
,
blue
))
else
:
redstr
,
greenstr
,
bluestr
=
map
(
int
,
(
red
,
green
,
blue
))
redstr
,
greenstr
,
bluestr
=
red
,
green
,
blue
self
.
__x
.
delete
(
0
,
END
)
self
.
__y
.
delete
(
0
,
END
)
self
.
__z
.
delete
(
0
,
END
)
...
...
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