(Aug-02-2019, 02:21 PM)ThomasL Wrote: I tried to refactor your code in a way it makes sense from what i assume to understand you want to do.
Look and learn.
...
def randomi():
return [np.random.randint(0, 100) for i in range(5)]
...
x, y, r, g, b = randomi()
...
for i, character in enumerate('xyRGB'):
arr[i] = p.data[character]
print(character, arr[i])
Ty is hard, for me translate my algorythm to code, so in fir i try in simply way thenafter that i try to cut and short code.
In randomi i dont know that we can give every var def randomi:D that is good ty for your help
in second "for i, character in enumerate('xyRGB')" now i understood my mistake abouth characters.
I am very grateful!
no i can transport all data from another program in def randomi and swap
here is code about that mouse position i use pyautogui. This code is not done is some errors with "self" i try make window where is button to start another window who follow mouse and give coords. That def is work perfect if we do stand alone from first window...
import tkinter as tk import pyautogui, time class MainWindow(tk.Frame): counter = 0 def __init__(self, *args, **kwargs): tk.Frame.__init__(self, *args, **kwargs) self.button = tk.Button(self, text="Create new window", command=self.create_window) self.button.pack(side="top") def create_window(self): self.counter += 1 t = tk.Toplevel(self) t.wm_title("Window #%s" % self.counter) x, y = pyautogui.position() pixelColor = pyautogui.screenshot().getpixel((x, y)) x = x + 2 y = y + 1 loc = "150x45+" + str(x) + "+" + str(y) root.geometry(loc) root.attributes("-topmost", True, "-toolwindow", True, "-alpha", 0.7) root.after(25, move) pole = Label(root, text="X:" + str(x) + " Y:" + str(y) + "\n R:" + str(pixelColor[0]).rjust(3) + " G:" + str( pixelColor[1]).rjust(3) + " B:" + str(pixelColor[2]).rjust(3)) pole.place(x=0, y=0) if __name__ == "__main__": root = tk.Tk() main = MainWindow(root) main.pack(side="top", fill="both", expand=True) root.mainloop()