-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecipe_52266.py.diff
72 lines (63 loc) · 3.18 KB
/
recipe_52266.py.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
For reference: our customizations to this code snippet found on the internet,
not including changes in amount of whitespace only (diff -w option)
i.e. our work on this code
- is original version
+ is our version
how to reproduce this diff? -- install git, then, in a bash shell, do the following:
$ git clone git://github.com/P2000/penview.git
$ cd penview
$ set -- $(git log --grep="oOriginal version from http://code.activestate.com/recipes/52266/" --oneline)
$ set -- $(git ls-tree $1 -- lib/recipe_52266.py)
$ git diff -w $3 recipe_52266.py
sidenote 0: lib/recipe_52266.py was moved to recipe_52266.py in commit 6c579f04
sidenote 1: The original file version exists in commit 374d09dc, with the following message:
"This is the oOriginal version from http://code.activestate.com/recipes/52266/ [on 21. Dec 2010] --- just as a reference"
Line 3 finds this commit, line 4 finds lib/recipe_52266.py in it, and in line 5 $3 should be
"3f8cf1040e35e85b485c3880dec4027fada9fa9c", the sha1-sum of the git object holding the original content of lib/recipe_52266.py
sidenote 2: "oOriginal" is a typo. It will last for all times, since you can't ("legally")
change commit message in git: http://www.gelato.unsw.edu.au/archives/git/0702/38650.html
diff --git a/recipe_52266.py b/recipe_52266.py
index 3f8cf10..c070470 100644
--- a/recipe_52266.py
+++ b/recipe_52266.py
@@ -1,14 +1,16 @@
+# from http://code.activestate.com/recipes/52266/
+
from Tkinter import *
class MultiListbox(Frame):
def __init__(self, master, lists):
Frame.__init__(self, master)
self.lists = []
- for l,w in lists:
+ for l in lists:
frame = Frame(self); frame.pack(side=LEFT, expand=YES, fill=BOTH)
Label(frame, text=l, borderwidth=1, relief=RAISED).pack(fill=X)
- lb = Listbox(frame, width=w, borderwidth=0, selectborderwidth=0,
- relief=FLAT, exportselection=FALSE)
+ lb = Listbox(frame, borderwidth=0, selectborderwidth=0,
+ relief=FLAT, exportselection=FALSE, width=0)
lb.pack(expand=YES, fill=BOTH)
self.lists.append(lb)
lb.bind('<B1-Motion>', lambda e, s=self: s._select(e.y))
@@ -17,10 +19,10 @@ class MultiListbox(Frame):
lb.bind('<B2-Motion>', lambda e, s=self: s._b2motion(e.x, e.y))
lb.bind('<Button-2>', lambda e, s=self: s._button2(e.x, e.y))
frame = Frame(self); frame.pack(side=LEFT, fill=Y)
- Label(frame, borderwidth=1, relief=RAISED).pack(fill=X)
+ Label(frame, text="\n", borderwidth=1, relief=RAISED).pack(fill=X)
sb = Scrollbar(frame, orient=VERTICAL, command=self._scroll)
sb.pack(expand=YES, fill=Y)
- self.lists[0]['yscrollcommand']=sb.set
+ for l in self.lists: l['yscrollcommand']=lambda *args: self._yscroll(sb, *args)
def _select(self, y):
row = self.lists[0].nearest(y)
@@ -40,6 +42,11 @@ class MultiListbox(Frame):
for l in self.lists:
apply(l.yview, args)
+ def _yscroll(self, sb, top, bottom):
+ for l in self.lists: # FIXME: the event generating listbox is also scrolled again.... seems to work so far though
+ l.yview('moveto', top)
+ sb.set(top, bottom)
+
def curselection(self):
return self.lists[0].curselection()