[Python-checkins] CVS: python/dist/src/Tools/pynche TypeinViewer.py,2.13,2.14

Barry Warsaw bwarsaw@users.sourceforge.net
Thu, 01 Feb 2001 13:32:00 -0800


Update of /cvsroot/python/python/dist/src/Tools/pynche
In directory usw-pr-cvs1:/tmp/cvs-serv15869

Modified Files:
	TypeinViewer.py 
Log Message:
Special case around some of the nastier annoyances with the type-in
fields.  You can now backspace out the 0 in 0x0, and you can clear the
field when in decimal mode.  There are still some oddities about
typing into these fields, but it should be much less annoying.  The
real solution is to ditch the update-while-typing "feature".


Index: TypeinViewer.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/pynche/TypeinViewer.py,v
retrieving revision 2.13
retrieving revision 2.14
diff -C2 -r2.13 -r2.14
*** TypeinViewer.py	1998/10/22 18:48:45	2.13
--- TypeinViewer.py	2001/02/01 21:31:58	2.14
***************
*** 69,75 ****
          contents = ew.get()
          icursor = ew.index(INSERT)
!         if contents == '':
!             contents = '0'
!         if contents[0] in 'xX' and self.__hexp.get():
              contents = '0' + contents
          # figure out what the contents value is in the current base
--- 69,73 ----
          contents = ew.get()
          icursor = ew.index(INSERT)
!         if contents and contents[0] in 'xX' and self.__hexp.get():
              contents = '0' + contents
          # figure out what the contents value is in the current base
***************
*** 90,94 ****
              ew.bell()
          elif self.__hexp.get():
!             contents = hex(v)
          else:
              contents = int(v)
--- 88,99 ----
              ew.bell()
          elif self.__hexp.get():
!             # Special case: our contents were 0x0 and we just deleted the
!             # trailing 0.  We want our contents to now be 0x and not 0x0.
!             if v == 0 and contents == '0':
!                 contents = '0x'
!                 icursor = END
!                 ew.bell()
!             elif not (v == 0 and contents == '0x'):
!                 contents = hex(v)
          else:
              contents = int(v)
***************
*** 110,119 ****
              blue = string.atoi(bluestr, 16)
          else:
!             red, green, blue = map(string.atoi, (redstr, greenstr, bluestr))
          self.__sb.update_views(red, green, blue)
  
      def update_yourself(self, red, green, blue):
          if self.__hexp.get():
!             redstr, greenstr, bluestr = map(hex, (red, green, blue))
          else:
              redstr, greenstr, bluestr = red, green, blue
--- 115,138 ----
              blue = string.atoi(bluestr, 16)
          else:
!             def intify(colorstr):
!                 if colorstr == '':
!                     return 0
!                 else:
!                     return string.atoi(colorstr)
!             red, green, blue = map(intify, (redstr, greenstr, bluestr))
          self.__sb.update_views(red, green, blue)
  
      def update_yourself(self, red, green, blue):
          if self.__hexp.get():
!             # Special case: our contents were 0x0 and we just deleted the
!             # trailing 0.  We want our contents to now be 0x and not 0x0.
!             def hexify((color, widget)):
!                 contents = widget.get()
!                 if not (color == 0 and contents == '0x'):
!                     return hex(color)
!                 return contents
!             redstr, greenstr, bluestr = map(hexify, ((red, self.__x),
!                                                      (green, self.__y),
!                                                      (blue, self.__z)))
          else:
              redstr, greenstr, bluestr = red, green, blue