MCPcopy Index your code
hub / github.com/python/cpython / Listbox

Class Listbox

Lib/tkinter/__init__.py:3449–3559  ·  view source on GitHub ↗

Listbox widget which can display a list of strings.

Source from the content-addressed store, hash-verified

3447
3448
3449class Listbox(Widget, XView, YView):
3450 """Listbox widget which can display a list of strings."""
3451
3452 def __init__(self, master=None, cnf={}, **kw):
3453 """Construct a listbox widget with the parent MASTER.
3454
3455 Valid option names: background, bd, bg, borderwidth, cursor,
3456 exportselection, fg, font, foreground, height, highlightbackground,
3457 highlightcolor, highlightthickness, relief, selectbackground,
3458 selectborderwidth, selectforeground, selectmode, setgrid, takefocus,
3459 width, xscrollcommand, yscrollcommand, listvariable."""
3460 Widget.__init__(self, master, 'listbox', cnf, kw)
3461
3462 def activate(self, index):
3463 """Activate item identified by INDEX."""
3464 self.tk.call(self._w, 'activate', index)
3465
3466 def bbox(self, index):
3467 """Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle
3468 which encloses the item identified by the given index."""
3469 return self._getints(self.tk.call(self._w, 'bbox', index)) or None
3470
3471 def curselection(self):
3472 """Return the indices of currently selected item."""
3473 return self._getints(self.tk.call(self._w, 'curselection')) or ()
3474
3475 def delete(self, first, last=None):
3476 """Delete items from FIRST to LAST (included)."""
3477 self.tk.call(self._w, 'delete', first, last)
3478
3479 def get(self, first, last=None):
3480 """Get list of items from FIRST to LAST (included)."""
3481 if last is not None:
3482 return self.tk.splitlist(self.tk.call(
3483 self._w, 'get', first, last))
3484 else:
3485 return self.tk.call(self._w, 'get', first)
3486
3487 def index(self, index):
3488 """Return index of item identified with INDEX."""
3489 i = self.tk.call(self._w, 'index', index)
3490 if i == 'none': return None
3491 return self.tk.getint(i)
3492
3493 def insert(self, index, *elements):
3494 """Insert ELEMENTS at INDEX."""
3495 self.tk.call((self._w, 'insert', index) + elements)
3496
3497 def nearest(self, y):
3498 """Get index of item which is nearest to y coordinate Y."""
3499 return self.tk.getint(self.tk.call(
3500 self._w, 'nearest', y))
3501
3502 def scan_mark(self, x, y):
3503 """Remember the current X, Y coordinates."""
3504 self.tk.call(self._w, 'scan', 'mark', x, y)
3505
3506 def scan_dragto(self, x, y):

Callers 8

__init__Method · 0.90
create_page_fontMethod · 0.90
create_page_keysMethod · 0.90
create_frame_helpMethod · 0.90
create_widgetsMethod · 0.90
show_windowMethod · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…