Back to index

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

List of all members.

Public Member Functions

def __init__

Private Member Functions

def __populate
def __onrelease

Private Attributes

 __sb
 __lastbox
 __dontcenter
 __root
 __frame
 __canvas
 __scrollbar
 __uoc
 __uocbtn
 __alabel
 __aliases
 __bboxes

Detailed Description

Definition at line 23 of file ListViewer.py.


Constructor & Destructor Documentation

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

Definition at line 24 of file ListViewer.py.

00024 
00025     def __init__(self, switchboard, master=None):
00026         self.__sb = switchboard
00027         optiondb = switchboard.optiondb()
00028         self.__lastbox = None
00029         self.__dontcenter = 0
00030         # GUI
00031         root = self.__root = Toplevel(master, class_='Pynche')
00032         root.protocol('WM_DELETE_WINDOW', self.withdraw)
00033         root.title('Pynche Color List')
00034         root.iconname('Pynche Color List')
00035         root.bind('<Alt-q>', self.__quit)
00036         root.bind('<Alt-Q>', self.__quit)
00037         root.bind('<Alt-w>', self.withdraw)
00038         root.bind('<Alt-W>', self.withdraw)
00039         #
00040         # create the canvas which holds everything, and its scrollbar
00041         #
00042         frame = self.__frame = Frame(root)
00043         frame.pack()
00044         canvas = self.__canvas = Canvas(frame, width=160, height=300,
00045                                         borderwidth=2, relief=SUNKEN)
00046         self.__scrollbar = Scrollbar(frame)
00047         self.__scrollbar.pack(fill=Y, side=RIGHT)
00048         canvas.pack(fill=BOTH, expand=1)
00049         canvas.configure(yscrollcommand=(self.__scrollbar, 'set'))
00050         self.__scrollbar.configure(command=(canvas, 'yview'))
00051         self.__populate()
00052         #
00053         # Update on click
00054         self.__uoc = BooleanVar()
00055         self.__uoc.set(optiondb.get('UPONCLICK', 1))
00056         self.__uocbtn = Checkbutton(root,
00057                                     text='Update on Click',
00058                                     variable=self.__uoc,
00059                                     command=self.__toggleupdate)
00060         self.__uocbtn.pack(expand=1, fill=BOTH)
00061         #
00062         # alias list
00063         self.__alabel = Label(root, text='Aliases:')
00064         self.__alabel.pack()
00065         self.__aliases = Listbox(root, height=5,
00066                                  selectmode=BROWSE)
00067         self.__aliases.pack(expand=1, fill=BOTH)

Here is the caller graph for this function:


Member Function Documentation

def pynche.ListViewer.ListViewer.__onrelease (   self,
  event = None 
) [private]

Definition at line 100 of file ListViewer.py.

00100 
00101     def __onrelease(self, event=None):
00102         canvas = self.__canvas
00103         # find the current box
00104         x = canvas.canvasx(event.x)
00105         y = canvas.canvasy(event.y)
00106         ids = canvas.find_overlapping(x, y, x, y)
00107         for boxid in ids:
00108             if boxid in self.__bboxes:
00109                 break
        else:
def pynche.ListViewer.ListViewer.__populate (   self) [private]

Definition at line 68 of file ListViewer.py.

00068 
00069     def __populate(self):
00070         #
00071         # create all the buttons
00072         colordb = self.__sb.colordb()
00073         canvas = self.__canvas
00074         row = 0
00075         widest = 0
00076         bboxes = self.__bboxes = []
00077         for name in colordb.unique_names():
00078             exactcolor = ColorDB.triplet_to_rrggbb(colordb.find_byname(name))
00079             canvas.create_rectangle(5, row*20 + 5,
00080                                     20, row*20 + 20,
00081                                     fill=exactcolor)
00082             textid = canvas.create_text(25, row*20 + 13,
00083                                         text=name,
00084                                         anchor=W)
00085             x1, y1, textend, y2 = canvas.bbox(textid)
00086             boxid = canvas.create_rectangle(3, row*20+3,
00087                                             textend+3, row*20 + 23,
00088                                             outline='',
00089                                             tags=(exactcolor, 'all'))
00090             canvas.bind('<ButtonRelease>', self.__onrelease)
00091             bboxes.append(boxid)
00092             if textend+3 > widest:
00093                 widest = textend+3
00094             row += 1
00095         canvheight = (row-1)*20 + 25
00096         canvas.config(scrollregion=(0, 0, 150, canvheight))
00097         for box in bboxes:
00098             x1, y1, x2, y2 = canvas.coords(box)
00099             canvas.coords(box, x1, y1, widest, y2)


Member Data Documentation

Definition at line 62 of file ListViewer.py.

Definition at line 64 of file ListViewer.py.

Definition at line 75 of file ListViewer.py.

Definition at line 43 of file ListViewer.py.

Definition at line 28 of file ListViewer.py.

Definition at line 41 of file ListViewer.py.

Definition at line 27 of file ListViewer.py.

Definition at line 30 of file ListViewer.py.

Definition at line 25 of file ListViewer.py.

Definition at line 45 of file ListViewer.py.

Definition at line 53 of file ListViewer.py.

Definition at line 55 of file ListViewer.py.


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