Welcome, guest | Sign In | My Account | Store | Cart
from Tkinter import *

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)


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()

Diff to Previous Revision

--- revision 3 2014-06-04 00:50:29
+++ revision 4 2014-06-04 00:51:00
@@ -1,3 +1,5 @@
+from Tkinter import *
+
 class SimultaneousPanels(PanedWindow):
 
  	def __init__(self):
@@ -44,3 +46,26 @@
 		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()

History