Esempio n. 1
0
    def __init__(self, master=None, columns=(' ',), selectcmd=None,
                 command=None, expandcolumns=(), showroot=False,
                 selectforeground='white', selectbackground='#00008B', **kw):
        Treectrl.__init__(self, master, showroot=showroot, **kw)
        self._multilistbox_opts = {'selectcmd' : selectcmd,
                                   'command' : command,
                                   'expandcolumns' : expandcolumns,
                                   'columns' : columns,
                                   'selectforeground' : selectforeground,
                                   'selectbackground' : selectbackground}

        self._el_text = self.element_create(type='text',
                fill=(self._multilistbox_opts['selectforeground'],
                'selected'), lines=1)
        self._el_select = self.element_create(type='rect', showfocus=1,
                fill=(self._multilistbox_opts['selectbackground'], 'selected'))
        self._defaultstyle = self.style_create()
        self.style_elements(self._defaultstyle, self._el_select, self._el_text)
        self.style_layout(self._defaultstyle, self._el_text, padx=4,
                            iexpand='e', expand='ns')
        self.style_layout(self._defaultstyle, self._el_select,
                            union=(self._el_text,), ipady=1, iexpand='nsew')

        self._columns = []
        self._styles = []
        self.configure(columns=columns, expandcolumns=expandcolumns,
                       selectcmd=selectcmd, command=command)

        self.notify_bind('<Selection>', self._call_selectcmd)
        self.bind('<Double-Button-1>', self._call_command)
        self.bind('<Return>', self._call_command)
Esempio n. 2
0
 def configure(self, cnf=None, **kw):
     for opt in self._multilistbox_opts.keys():
         if not cnf is None and opt in cnf:
             self._configure_multilistbox(opt, cnf[opt])
             del cnf[opt]
         if opt in kw:
             self._configure_multilistbox(opt, kw[opt])
             del kw[opt]
     return Treectrl.configure(self, cnf, **kw)
Esempio n. 3
0
 def see(self, index, column=None, center=None):
     '''Like Tkinter.Listbox.see(). Note that this overrides the
     see() method inherited from Treectrl.'''
     item = self._index2item(index)
     if not item is None:
         Treectrl.see(self, item, column, center)
Esempio n. 4
0
 def activate(self, index):
     '''Like Tkinter.Listbox.activate(). Note that this overrides the
     activate() method inherited from Treectrl.'''
     item = self._index2item(index)
     if not item is None:
         Treectrl.activate(self, item)
Esempio n. 5
0
 def keys(self):
     keys = Treectrl.keys(self) + self._multilistbox_opts.keys()
     keys.sort()
     return keys
Esempio n. 6
0
 def cget(self, key):
     if key in self._multilistbox_opts.keys():
         return self._multilistbox_opts[key]
     return Treectrl.cget(self, key)
 def _setScrolledWidget(self):
     self.treectrl = Treectrl(self)
     return self.treectrl