-1

** In need to read input data from Tkinter Lable and use that for further processing. But to simplify this question, I need to Enter a Ticker symbol into label and get that ticker using .get() method and use it into other Entry. Followed is the code.

from tkinter import * 


top = Tk()   
top.title("NASDAR Stock price range prediction system")
top.geometry("1350x750")  
    


#user input Are
user_name = Label(top, text = "Ticker").place(x = 30,y = 60)  
user_name_input_area = Entry(top, width = 20)
user_name_input_area.place(x = 125,y = 60)

you_entered = Label(top, text = "You entered").place(x = 30,y = 85)  
you_entered_input_area = Entry(top, width = 20).place(x = 125,y = 85)  




daily_analysis = Button(top,text = "Daily Analysis", command=insert_data1)

intraday_analysis = Button(top,text = "Intraday Analysis").place(x = 330,y = 670)


def insert_data1():
    print("You enterted followed symbol")
    symbol = str(user_name_input_area.get())
    print(symbol)
    you_entered.insert(0, symbol)

    
top.mainloop() 


** I would like to see the input of Label Ticker into Entry of 'You entered'

acw1668
  • 40,144
  • 5
  • 22
  • 34
Dharmesh
  • 43
  • 6
  • Should be `you_entered['text'] = symbol` instead of `you_entered.insert(0, symbol)` – Delrius Euphoria Jan 11 '22 at 19:28
  • TypeError Traceback (most recent call last) in 19 20 ---> 21 daily_analysis = Button(top,text = "Daily Analysis", command=(insert_data())).place(x = 30,y = 670) 22 23 intraday_analysis = Button(top,text = "Intraday Analysis").place(x = 330,y = 670) in insert_data() 28 symbol = str(user_name_input_area.get()) 29 print(symbol) ---> 30 you_entered['text'] = symbol TypeError: 'NoneType' object does not support item assignment – Dharmesh Jan 11 '22 at 20:54
  • Got the above error – Dharmesh Jan 11 '22 at 20:55
  • 1
    Does this answer your question? http://stackoverflow.com/q/1101750/7432 – Bryan Oakley Jan 11 '22 at 21:03
  • @BryanOakley Why did you remove the answer? It should fix the problem if you also assign the variable properly too – Delrius Euphoria Jan 11 '22 at 21:14
  • 1
    @CoolCloud: I removed my answer because I'm not sure I fully understood the question. Now it appears the real question is just a dupe of the "nonetype" error that we see at least weekly. – Bryan Oakley Jan 12 '22 at 01:58
  • @BryanOakley True, but also the problem is that OP is using `you_entered.insert(0, symbol)`, so it might be good to let them know about that too – Delrius Euphoria Jan 12 '22 at 10:30
  • Does this answer your question? [Tkinter: AttributeError: NoneType object has no attribute ](https://stackoverflow.com/questions/1101750/tkinter-attributeerror-nonetype-object-has-no-attribute-attribute-name) – Delrius Euphoria Jan 12 '22 at 10:30

1 Answers1

0

Finally I was able to achieve what I needed. I had to use StringVar().. folllowed is some line of codes which worked

#user input Are
ticker_text = StringVar()
ticker_name = Label(top, text = "Ticker").place(x = 30,y = 40)
ticker_name_entry = Entry(top, textvariable = ticker_text)
ticker_name_entry.place(x = 125,y = 40)

** in the function to update values... followed worked..

current_price_input_area.insert(END, price)
    values = predict_stock(symbol)
    #Returned values insert
    date_entry.insert(END, values[0])
    R3_input_area.insert(END, values[1])
    R2_input_area.insert(END, values[2])
    R1_input_area.insert(END, values[3])
    Pivot_input_area.insert(END, values[4])
    S1_input_area.insert(END, values[5])
    S2_input_area.insert(END, values[6])
Dharmesh
  • 43
  • 6