Back to index

python3.2  3.2.2
Public Member Functions | Private Member Functions | Private Attributes
pynche.TypeinViewer.TypeinViewer Class Reference

List of all members.

Public Member Functions

def __init__
def update_yourself
def hexp_var
def save_options

Private Member Functions

def __togglehex
def __normalize
def __maybeupdate
def __update

Private Attributes

 __sb
 __hexp
 __uwtyping
 __frame
 __xl
 __xox
 __x
 __yl
 __yox
 __y
 __zl
 __zox
 __z
 __uwt
 __hex

Detailed Description

Definition at line 19 of file TypeinViewer.py.


Constructor & Destructor Documentation

def pynche.TypeinViewer.TypeinViewer.__init__ (   self,
  switchboard,
  master = None 
)

Definition at line 20 of file TypeinViewer.py.

00020 
00021     def __init__(self, switchboard, master=None):
00022         # non-gui ivars
00023         self.__sb = switchboard
00024         optiondb = switchboard.optiondb()
00025         self.__hexp = BooleanVar()
00026         self.__hexp.set(optiondb.get('HEXTYPE', 0))
00027         self.__uwtyping = BooleanVar()
00028         self.__uwtyping.set(optiondb.get('UPWHILETYPE', 0))
00029         # create the gui
00030         self.__frame = Frame(master, relief=RAISED, borderwidth=1)
00031         self.__frame.grid(row=3, column=1, sticky='NSEW')
00032         # Red
00033         self.__xl = Label(self.__frame, text='Red:')
00034         self.__xl.grid(row=0, column=0, sticky=E)
00035         subframe = Frame(self.__frame)
00036         subframe.grid(row=0, column=1)
00037         self.__xox = Label(subframe, text='0x')
00038         self.__xox.grid(row=0, column=0, sticky=E)
00039         self.__xox['font'] = 'courier'
00040         self.__x = Entry(subframe, width=3)
00041         self.__x.grid(row=0, column=1)
00042         self.__x.bindtags(self.__x.bindtags() + ('Normalize', 'Update'))
00043         self.__x.bind_class('Normalize', '<Key>', self.__normalize)
00044         self.__x.bind_class('Update'   , '<Key>', self.__maybeupdate)
00045         # Green
00046         self.__yl = Label(self.__frame, text='Green:')
00047         self.__yl.grid(row=1, column=0, sticky=E)
00048         subframe = Frame(self.__frame)
00049         subframe.grid(row=1, column=1)
00050         self.__yox = Label(subframe, text='0x')
00051         self.__yox.grid(row=0, column=0, sticky=E)
00052         self.__yox['font'] = 'courier'
00053         self.__y = Entry(subframe, width=3)
00054         self.__y.grid(row=0, column=1)
00055         self.__y.bindtags(self.__y.bindtags() + ('Normalize', 'Update'))
00056         # Blue
00057         self.__zl = Label(self.__frame, text='Blue:')
00058         self.__zl.grid(row=2, column=0, sticky=E)
00059         subframe = Frame(self.__frame)
00060         subframe.grid(row=2, column=1)
00061         self.__zox = Label(subframe, text='0x')
00062         self.__zox.grid(row=0, column=0, sticky=E)
00063         self.__zox['font'] = 'courier'
00064         self.__z = Entry(subframe, width=3)
00065         self.__z.grid(row=0, column=1)
00066         self.__z.bindtags(self.__z.bindtags() + ('Normalize', 'Update'))
00067         # Update while typing?
00068         self.__uwt = Checkbutton(self.__frame,
00069                                  text='Update while typing',
00070                                  variable=self.__uwtyping)
00071         self.__uwt.grid(row=3, column=0, columnspan=2, sticky=W)
00072         # Hex/Dec
00073         self.__hex = Checkbutton(self.__frame,
00074                                  text='Hexadecimal',
00075                                  variable=self.__hexp,
00076                                  command=self.__togglehex)
00077         self.__hex.grid(row=4, column=0, columnspan=2, sticky=W)

Here is the caller graph for this function:


Member Function Documentation

def pynche.TypeinViewer.TypeinViewer.__maybeupdate (   self,
  event = None 
) [private]

Definition at line 122 of file TypeinViewer.py.

00122 
00123     def __maybeupdate(self, event=None):
00124         if self.__uwtyping.get() or event.keysym in ('Return', 'Tab'):
00125             self.__update(event)

Here is the call graph for this function:

def pynche.TypeinViewer.TypeinViewer.__normalize (   self,
  event = None 
) [private]

Definition at line 89 of file TypeinViewer.py.

00089 
00090     def __normalize(self, event=None):
00091         ew = event.widget
00092         contents = ew.get()
00093         icursor = ew.index(INSERT)
00094         if contents and contents[0] in 'xX' and self.__hexp.get():
00095             contents = '0' + contents
00096         # Figure out the contents in the current base.
00097         try:
00098             if self.__hexp.get():
00099                 v = int(contents, 16)
00100             else:
00101                 v = int(contents)
00102         except ValueError:
00103             v = None
00104         # If value is not legal, or empty, delete the last character inserted
00105         # and ring the bell.  Don't ring the bell if the field is empty (it'll
00106         # just equal zero.
00107         if v is None:
00108             pass
00109         elif v < 0 or v > 255:
00110             i = ew.index(INSERT)
00111             if event.char:
00112                 contents = contents[:i-1] + contents[i:]
00113                 icursor -= 1
00114             ew.bell()
00115         elif self.__hexp.get():
00116             contents = hex(v)[2:]
00117         else:
00118             contents = int(v)
00119         ew.delete(0, END)
00120         ew.insert(0, contents)
00121         ew.icursor(icursor)

def pynche.TypeinViewer.TypeinViewer.__togglehex (   self,
  event = None 
) [private]

Definition at line 78 of file TypeinViewer.py.

00078 
00079     def __togglehex(self, event=None):
00080         red, green, blue = self.__sb.current_rgb()
00081         if self.__hexp.get():
00082             label = '0x'
00083         else:
00084             label = '  '
00085         self.__xox['text'] = label
00086         self.__yox['text'] = label
00087         self.__zox['text'] = label
00088         self.update_yourself(red, green, blue)

Here is the call graph for this function:

def pynche.TypeinViewer.TypeinViewer.__update (   self,
  event = None 
) [private]

Definition at line 126 of file TypeinViewer.py.

00126 
00127     def __update(self, event=None):
00128         redstr = self.__x.get() or '0'
00129         greenstr = self.__y.get() or '0'
00130         bluestr = self.__z.get() or '0'
00131         if self.__hexp.get():
00132             base = 16
00133         else:
00134             base = 10
00135         red, green, blue = [int(x, base) for x in (redstr, greenstr, bluestr)]
00136         self.__sb.update_views(red, green, blue)

Here is the caller graph for this function:

Definition at line 156 of file TypeinViewer.py.

00156 
00157     def hexp_var(self):
00158         return self.__hexp

def pynche.TypeinViewer.TypeinViewer.save_options (   self,
  optiondb 
)

Definition at line 159 of file TypeinViewer.py.

00159 
00160     def save_options(self, optiondb):
00161         optiondb['HEXTYPE'] = self.__hexp.get()
00162         optiondb['UPWHILETYPE'] = self.__uwtyping.get()
def pynche.TypeinViewer.TypeinViewer.update_yourself (   self,
  red,
  green,
  blue 
)

Definition at line 137 of file TypeinViewer.py.

00137 
00138     def update_yourself(self, red, green, blue):
00139         if self.__hexp.get():
00140             sred, sgreen, sblue = [hex(x)[2:] for x in (red, green, blue)]
00141         else:
00142             sred, sgreen, sblue = red, green, blue
00143         x, y, z = self.__x, self.__y, self.__z
00144         xicursor = x.index(INSERT)
00145         yicursor = y.index(INSERT)
00146         zicursor = z.index(INSERT)
00147         x.delete(0, END)
00148         y.delete(0, END)
00149         z.delete(0, END)
00150         x.insert(0, sred)
00151         y.insert(0, sgreen)
00152         z.insert(0, sblue)
00153         x.icursor(xicursor)
00154         y.icursor(yicursor)
00155         z.icursor(zicursor)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 29 of file TypeinViewer.py.

Definition at line 72 of file TypeinViewer.py.

Definition at line 24 of file TypeinViewer.py.

Definition at line 22 of file TypeinViewer.py.

Definition at line 67 of file TypeinViewer.py.

Definition at line 26 of file TypeinViewer.py.

Definition at line 39 of file TypeinViewer.py.

Definition at line 32 of file TypeinViewer.py.

Definition at line 36 of file TypeinViewer.py.

Definition at line 52 of file TypeinViewer.py.

Definition at line 45 of file TypeinViewer.py.

Definition at line 49 of file TypeinViewer.py.

Definition at line 63 of file TypeinViewer.py.

Definition at line 56 of file TypeinViewer.py.

Definition at line 60 of file TypeinViewer.py.


The documentation for this class was generated from the following file: