I'm basically writing a module for a basic pygame drawing app. im using a Tk window to get the three color values for a custom color. i have a file that opens a Tk window and askes for 3 color values made but i cant figure how to get it all to work well and im starting to get confused
Here is my code for the Tk window:
from Tkinter import *
class Custom():
def get_color(self):
root = Tk()
root.configure(background='black')
root.wm_title("Custom")
label1 = Label(root, text='Red Value:',bg="black", fg="white")
label1.grid(row=2, column=0,columnspan=2)
enter1 = Entry(root, bg='white')
enter1.grid(row=3, column=0,columnspan=2)
label2 = Label(root, text='Green Value:',bg="black", fg="white")
label2.grid(row=4, column=0,columnspan=2)
enter2 = Entry(root, bg='white')
enter2.grid(row=5, column=0, columnspan=2)
label3 = Label(root, text='Blue Value:',bg="black", fg="white")
label3.grid(row=6, column=0,columnspan=2)
enter3 = Entry(root, bg='white')
enter3.grid(row=7, column=0, columnspan=2)
btn1 = Button(root, text='OK', command= self.return_color, bg="black",activebackground="green", fg="white")
btn1.grid(row=14, column=0, columnspan=2)
label7 = Label(root, bg="black", fg = "white")
label7.grid(row=15, column=0, columnspan=2)
enter1.focus()
root.mainloop()
def return_color(self):
try:
r = str(self.enter1.get())
g = str(self.enter2.get())
b = str(self.enter3.get())
except ValueError:
window.label7.config(text='Enter Numbers!', fg = "red")
root.destroy()
return (r,g,b)
c = Custom()
c.get_color()
it works but im trying to be able to import it so i made two functions and put them in a class but now im getting confused i need to run get_color
then when i click the OK button i need to run return_color
i dont know if this is the way to do it ive just been trying all kinds of differnt things its saying that return_color
cant get the self.enter1.get()
same with enter2 and 3
here is where im giving to my draw pad program:
if key[pygame.K_c]:
import CustomColor
c = CustomColor.Custom()
c.get_color()
self.color = c.return_color()
im starting to get really confused if someone could clear this all up i would be so thank ful!!