Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 class random var write to array
#6
(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! Heart
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()
Quote

Top Page

Messages In This Thread
class random var write to array - by storzo - Aug-02-2019, 11:05 AM
RE: class random var write to array - by fishhook - Aug-02-2019, 11:20 AM
RE: class random var write to array - by ThomasL - Aug-02-2019, 11:58 AM
RE: class random var write to array - by storzo - Aug-02-2019, 12:22 PM
RE: class random var write to array - by ThomasL - Aug-02-2019, 02:21 PM
RE: class random var write to array - by storzo - Aug-02-2019, 03:26 PM

Possibly Related Threads...
Thread Author Replies Views Last Post
  How do I write class objects to a file in binary mode? Exsul1 7 699 Sep-14-2019, 09:33 PM
Last Post: snippsat
  Multi-Dimm Array or Class? PappaBear 2 361 May-02-2019, 07:04 PM
Last Post: PappaBear
  20 x 20 Integer array with random numbers harryk 3 695 Jul-28-2018, 03:38 PM
Last Post: harryk
  Write selected (random) columns to output-file anjohepa 0 698 Feb-27-2018, 02:19 PM
Last Post: anjohepa
  Best construct? Array, class, other? PappaBear 1 1,482 May-10-2017, 06:02 PM
Last Post: nilamo
  What work faster and take less memory array or class? Kamilbek 1 1,293 Apr-20-2017, 05:32 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)