Scrolling an Entry widget on python

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lome1404
    New Member
    • Dec 2012
    • 1

    Scrolling an Entry widget on python

    I try to make scrolling on an Entry in python.
    when I run program nothing happen.
    Please any one help me??

    this is my code:

    Code:
    self.scrollbar = tk.Scrollbar(self,orient="horizontal")
            self.e3 =tk.Entry(self,xscrollcommand=self.scrollbar.set)
            self.e3.focus()
            self.e3.pack(side="bottom",fill="x")
            #self.e3.grid(row=10, column=7)
            self.scrollbar.pack(fill="x")
            self.scrollbar.config(command=self.e3.xview)
            self.e3.config()
    Last edited by Rabbit; Dec 24 '12, 04:16 PM. Reason: Please use code tags when posting code.
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    It works fine for me on Slackware Linux. Note that to scroll you have to have an entry that is wider than the box.
    Code:
    class TestEntry():
        def __init__(self):
                root = tk.Tk()
                self.scrollbar = tk.Scrollbar(root,orient="horizontal")
                txt = tk.StringVar()
                self.e3 =tk.Entry(root,
                         xscrollcommand=self.scrollbar.set,
                         textvariable=txt)
                txt.set("ABC"*10)  ## add some text to scroll
                self.e3.focus()
                self.e3.pack(side="bottom",fill="x")
                self.scrollbar.pack(fill="x")
                self.scrollbar.config(command=self.e3.xview)
                self.e3.config()
    
                root.mainloop()
    
    TestEntry()

    Comment

    Working...