class SimultaneousPanels(PanedWindow):
def __init__(self):
self.collectionOfPanedsWindows = {}
def create_widget(self,master, tag= '_default', **kargs):
widget = PanedWindow(master, **kargs)
self.add_conexion(widget,tag)
return widget
def add_conexion(self, widget, tag):
widget.other_paneds_windows = []
if tag in self.collectionOfPanedsWindows:
for pwindow in self.collectionOfPanedsWindows[tag]:
widget.other_paneds_windows.append(pwindow)
pwindow.other_paneds_windows.append(widget)
self.collectionOfPanedsWindows[tag].append(widget)
else:
self.collectionOfPanedsWindows[tag] = [widget]
widget.bind('<Button-1>', self.sash_mark)
widget.bind('<B1-Motion>', self.sash_dragto)
def sash_mark(self,event):
this_widget = event.widget
identity = this_widget.identify(event.x, event.y)
if len(identity) ==2:
index = identity[0]
this_widget.activedSash=index
else:
this_widget.activedSash = None
def sash_dragto(self,event):
this_widget = event.widget
activedSash = this_widget.activedSash
if activedSash != None:
for pwindow in this_widget.other_paneds_windows:
pwindow.sash_place(activedSash, event.x, event.y)
Diff to Previous Revision
--- revision 2 2014-06-03 20:31:40
+++ revision 3 2014-06-04 00:50:29
@@ -1,5 +1,3 @@
-from Tkinter import *
-
class SimultaneousPanels(PanedWindow):
def __init__(self):
@@ -7,6 +5,11 @@
def create_widget(self,master, tag= '_default', **kargs):
widget = PanedWindow(master, **kargs)
+ self.add_conexion(widget,tag)
+
+ return widget
+
+ def add_conexion(self, widget, tag):
widget.other_paneds_windows = []
if tag in self.collectionOfPanedsWindows:
@@ -22,7 +25,6 @@
widget.bind('<Button-1>', self.sash_mark)
widget.bind('<B1-Motion>', self.sash_dragto)
- return widget
def sash_mark(self,event):
this_widget = event.widget
@@ -42,25 +44,3 @@
if activedSash != None:
for pwindow in this_widget.other_paneds_windows:
pwindow.sash_place(activedSash, event.x, event.y)
-
-def test():
-
- def _print(x,y):
- print "Window: %s; Pane: %s" %(x,y)
- root = Tk()
- root.geometry("190x350")
-
- connectedPanels = SimultaneousPanels()
-
- for i in range(3):
- m = connectedPanels.create_widget(root, bd=1, orient=VERTICAL,sashwidth=2,sashrelief=RIDGE)
- m.place(x=30,y=30+100*i)
-
- for j in range(3):
- panel= Label(m, text="panel number %s" %j)
- m.add(panel)
-
- root.mainloop()
-
-if __name__ == '__main__':
- test()