Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'd like to have a Frame, where the user could add as many textfields as needed by the application.

The application starts with a textfield, and a button below that textfield. When the user presses the button, a new text entry will be added below the first one ( this may be repeated countless times ). In the middle of the window, there will be a Text widget, used to display text :)

However, I noticed this in the documentation:

This widget is used to implement scrolled listboxes, canvases, and text fields.

Is there a way to use the Scrollbar with a Frame?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
547 views
Welcome To Ask or Share your Answers For Others

1 Answer

If you can use Tix, there is the ScrolledWindow widget which has a window Frame and one or two Scrollbar widgets:

import Tix as tk

r= tk.Tk()
r.title("test scrolled window")
sw= tk.ScrolledWindow(r, scrollbar=tk.Y) # just the vertical scrollbar
sw.pack(fill=tk.BOTH, expand=1)
for i in xrange(10):
    e= tk.Entry(sw.window)
    e.pack()
r.mainloop()

Change the size of the root window. You will want to add code to the focus_get event of the Entry widgets to scroll the ScrolledWindow when tabbing through the keyboard.

Otherwise, you will have to use a Canvas widget (you can add Label, Entry and Text subwidgets) and write a lot more code yourself to implement your required functionality.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...