#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    8
    Rep Power
    0

    Arrow Saving content of entry through save option in menu


    Hi Friends,

    Hi Friends,

    Actually I want to save the content of entry using Save Option in menu.
    I can directly use the e.get() but problem is I am creating entry and label depending upon total count in a file(list.txt).
    And that is created easily but what I need is to save the content of each entry box through menubar. I dont know how exactly that could be done.Here is my piece of code. PLease let me know what should I add in it.
    Code:
    count=0
    for line in fileinput.input(['list.txt']): 			   label=Label(frame,text=line) 			
    entry=Entry(frame,width=10) 			label.grid(row=count,sticky=W+E+N+S) 			entry.grid(row=count,column=1,sticky=W+E+N+S ) 			count=count+1
    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2009
    Posts
    503
    Rep Power
    33
    You have to save the Entry boxes id's so you know which widget you want to get from. So append each one to a list.
    Code:
    try:
        import Tkinter as tk     ## Python 2.x
    except ImportError:
        import tkinter as tk     ## Python 3.x
    
    top_frame = tk.Tk()
    
    def button_pressed():
        for entry in list_of_boxes:
            print entry.get()
    
    list_of_boxes = []
    for count in range(5):
        label=tk.Label(top_frame, text=str(count), width=10) 			
        entry=tk.Entry(top_frame, width=10)
        label.grid(row=count)
        entry.grid(row=count, column=1)
        list_of_boxes.append(entry)
    
    but=tk.Button(top_frame, text="Get Contents", command=button_pressed)
    but.grid(row=20)
    
    top_frame.mainloop()
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    8
    Rep Power
    0
    Thanks man.....This will help me

IMN logo majestic logo threadwatch logo seochat tools logo