| 9 | default = "(None)" |
| 10 | |
| 11 | def __init__(self, master, **options): |
| 12 | # Create top frame, with scrollbar and listbox |
| 13 | self.master = master |
| 14 | self.frame = frame = Frame(master) |
| 15 | self.frame.pack(fill="both", expand=1) |
| 16 | self.vbar = vbar = Scrollbar(frame, name="vbar") |
| 17 | self.vbar.pack(side="right", fill="y") |
| 18 | self.listbox = listbox = Listbox(frame, exportselection=0, |
| 19 | background="white") |
| 20 | if options: |
| 21 | listbox.configure(options) |
| 22 | listbox.pack(expand=1, fill="both") |
| 23 | # Tie listbox and scrollbar together |
| 24 | vbar["command"] = listbox.yview |
| 25 | listbox["yscrollcommand"] = vbar.set |
| 26 | # Bind events to the list box |
| 27 | listbox.bind("<ButtonRelease-1>", self.click_event) |
| 28 | listbox.bind("<Double-ButtonRelease-1>", self.double_click_event) |
| 29 | if macosx.isAquaTk(): |
| 30 | listbox.bind("<ButtonPress-2>", self.popup_event) |
| 31 | listbox.bind("<Control-Button-1>", self.popup_event) |
| 32 | else: |
| 33 | listbox.bind("<ButtonPress-3>", self.popup_event) |
| 34 | listbox.bind("<Key-Up>", self.up_event) |
| 35 | listbox.bind("<Key-Down>", self.down_event) |
| 36 | # Mark as empty |
| 37 | self.clear() |
| 38 | |
| 39 | def close(self): |
| 40 | self.frame.destroy() |