Reputation: 862
I wanted to know how to display the integer and double values in the text box. As I have to calculate mean values of an image, and I want those values to be displayed in the text box in the GUI.
When I tried with my code I got an error:
AttributeError: numpy.ndarray object has no attribute set
This is because I'm using .set()
for ndarray. But without .set()
how to send the values to the textbox?
Here's my code snippet:
def open():
path=tkFileDialog.askopenfilename(filetypes=[("Image File",'.jpg')])
blue, green, red = cv2.split(re_img)
total = re_img.size
B = sum(blue) / total
G = sum(green) / total
R = sum(red) / total
B_mean1.append(B)
G_mean1.append(G)
R_mean1.append(R)
blue.set(B_mean)
root = Tk()
blue_label = Label(app,text = 'Blue Mean')
blue_label.place(x = 850,y = 140)
blue = IntVar(None)
blue_text = Entry(app,textvariable = blue)
blue_text.place(x = 1000,y = 140)
button = Button(app, text='Select an Image',command = open)
button.pack(padx = 1, pady = 1,anchor='ne')
button.place( x = 650, y = 60)
root.mainloop()
I have no idea whether my coding is wrong or not. And these mean values are being stored in list. Any suggestions for this problem?
Thanks for your support!
Upvotes: 0
Views: 842
Reputation: 7845
There's nothing on numpy.ndarray called "set":
http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html
Take a good look at this reference and figure out how to apply B_mean to blue.
Upvotes: 0
Reputation: 1121972
blue
is a local name in your function, shadowing your global IntVar
reference blue
.
Rename one or the other.
Upvotes: 1