[Tkinter-discuss] Posible SPAM: Re: simple scrollbar... not so simple
Michael O'Donnell
michael.odonnell at uam.es
Thu Nov 25 09:14:53 CET 2010
Hi Sorin.
Full example with at least vertical scrolling
from Tkinter import *
class ScrolledText(Frame):
def __init__(self, master, **keywords):
# Set some defaults
if not keywords.has_key("width"): keywords["width"]=24
#if not keywords.has_key("height"): keywords["height"]=20
if not keywords.has_key("bg"): keywords["bg"]="white"
if not keywords.has_key("relief"): keywords["relief"]="sunken"
Frame.__init__(self, master)
self.config(bg=keywords["bg"])
# Scrollbars
scrollbar = Scrollbar(self, orient=VERTICAL)
# Create the Text wgt
self.text=Text(self, yscrollcommand=scrollbar.set, **keywords)
scrollbar.config(command=self.text.yview)
scrollbar.pack(side=RIGHT, fill=Y)
self.text.pack(side=LEFT, fill=BOTH, expand=True)
self.scroll=scrollbar
tk = Tk()
st=ScrolledText(tk)
st.pack(expand=True, fill=BOTH)
st.text.insert(END, "Buttons:\n")
b1=Button(st.text, text="Hello 1")
st.text.window_create(END, window=b1)
st.text.insert(END, "\n")
b2=Button(st.text, text="Hello 2")
st.text.window_create(END, window=b2)
tk.mainloop()
On Thu, Nov 25, 2010 at 12:30 AM, Sorin Schwimmer <sxn02 at yahoo.com> wrote:
> Mick, you're right, Tkinter frames are not scrollable. That's why I'm nesting my frame into a Text widget... and am not getting anywhere :-(
>
> SxN
>
>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>
More information about the Tkinter-discuss
mailing list