Issue
I have written a code to create a GUI with Tkinter. In this GUI i can open an image and run a code that gives me the mean RGB value of that image:
x = image[np.all(image != 0, axis=2)].mean(axis=0)
At this moment I can only print the value in the shell. The next step is that I want to print the 'R' the 'G' and the 'B' in a different textboxes. I know how to create a textbox, but I don't know how to print the different values in this textbox.
Thanks
Solution
If you just want to put the values in x
into three Entry
widgets, below is an example:
import tkinter as tk
import numpy as np
...
x = image[np.all(image != 0, axis=2)].mean(axis=0)
root = tk.Tk()
for color, value in zip("RGB", x):
tk.Label(root, text=color).pack(side="left")
e = tk.Entry(root, width=10)
e.pack(side="left")
e.insert("end", f"{value:.4f}")
root.mainloop()
And the sample output:
Answered By - acw1668
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.