Thanks for the idea. It will make the code indeed odd. I was looking for a less intrusive method, something that I could easily replace the Frame() with ScrollFrame() in an existing application and everything should work.
My approach with binding on the toplevel works only if I have only one ScrollFrame, but if I have more in the application then it doesn't. What happens if I bind more than once a certain event? Does Tk calls in chain all handlers or only the last one? Vasilis ________________________________________ From: Tkinter-discuss [tkinter-discuss-bounces+vasilis.vlachoudis=cern...@python.org] on behalf of Michael Lange [klappn...@web.de] Sent: Wednesday, September 07, 2016 11:53 To: tkinter-discuss@python.org Subject: Re: [Tkinter-discuss] Frame button binding Hi, On Wed, 7 Sep 2016 06:31:06 +0000 Vasilis Vlachoudis <vasilis.vlachou...@cern.ch> wrote: > Hi Michael, > > the ScrollFrame is of generic use as a normal frame class. So I don't > know apriori how many children it will have. I could set the bind > recursively in all winfo_children() and sub-children etc. after the > frame is populated but I though it will be an overkill. > I see your point of course, especially since probably other events than <Button-2> should be handled, too. Not sure if there is an easy solution to this, though. One possibility that comes to mind is adding custom geometry methods to the ScrolledFrame class that handle the bindings, like: def pack_child(self, child, **kw): child.pack(**kw) child.bind("<Button-2>", self.dragStart) Then you could conveniently do something like b = Button(f, text="Button") f.pack_child(b, side='left') I haven't tried this, but I think it should work, however it might make the usage of the widget feel oddly unfamiliar. Otoh it should come in handy enough even for complex layouts with multiple layers of sub-frames (as long as these aren't ScrolledFrames themselves of course - definitely a flaw with this approach). Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Vulcans believe peace should not depend on force. -- Amanda, "Journey to Babel", stardate 3842.3 _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss