Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Python - Non capisco a cosa si riferisca l'errore
Forum - Python - Non capisco a cosa si riferisca l'errore

Avatar
lorenzoscarrone (Normal User)
Pro


Messaggi: 92
Iscritto: 16/11/2011

Segnala al moderatore
Postato alle 19:07
Giovedė, 11/06/2015
Questo č l'errore:
Codice sorgente - presumibilmente Python

  1. Traceback (most recent call last):
  2.   File "tkprova.py", line 40, in <module>
  3.     s = Slider()
  4.   File "tkprova.py", line 34, in __init__
  5.     self.C = RGB_color()



Questo č il codice

Codice sorgente - presumibilmente Python

  1. class RGB_color():
  2.         RED = 0
  3.         GREEN = 0
  4.         BLUE = 0
  5.  
  6.         def __init__(self):
  7.                 print "RGB Setting"
  8.  
  9.         def StoreRGB(self, file_n, r,g,b):
  10.                 colors = [r,g,b]
  11.                 filem = open(file_n, 'w+')
  12.                 filem.writelines(colors)
  13.                 filem.close()
  14.  
  15.  
  16.         def GetRGB(self, file_n):
  17.                 global RED, GREEN, BLUE
  18.                 filem = open(file_n , 'r')
  19.                 colors = []
  20.                 colors = filem.readlines()
  21.                 RED = int(colors[0])
  22.                 GREEN = int(colors[1])
  23.                 BLUE = int(colors[2])
  24.                 filem.close()



Codice sorgente - presumibilmente Python

  1. import Tkinter
  2. from rgb_color import RGB_color
  3.  
  4. class Slider ():
  5.         r=0
  6.         g=0
  7.         b=0
  8.  
  9.         def CheckColorRed(self,val):
  10.                 global r,g,b
  11.                 r = val
  12.                 self.C.StoreRGB('rgb.txt',r,g,b)
  13.                 print "Color(",r,",",g,",",b,")\n"
  14.  
  15.         def CheckColorGreen(self,val):
  16.                 global r,g,b
  17.                 g = val
  18.                 self.C.StoreRGB('rgb.txt',r,g,b)
  19.                 print "Color(",r,",",g,",",b,")\n"
  20.  
  21.         def CheckColorBlue(self,val):
  22.                 global r,g,b
  23.                 b = val
  24.                 self.C.StoreRGB('rgb.txt',r,g,b)
  25.                 print "Color(",r,",",g,",",b,")\n"
  26.        
  27.         def __init__(self):
  28.                 global r,g,b
  29.                 self.W = Tkinter.Tk()
  30.                 self.W.title("Color Selector")
  31.                 self.Red = Tkinter.Scale(self.W, orient= Tkinter.HORIZONTAL, from_=0, to=255, tickinterval=30, length=300, command=self.CheckColorRed).pack()
  32.                 self.Green = Tkinter.Scale(self.W, orient= Tkinter.HORIZONTAL, from_=0, to=255, tickinterval=30, length=300, command=self.CheckColorGreen).pack()
  33.                 self.Blue = Tkinter.Scale(self.W, orient= Tkinter.HORIZONTAL, from_=0, to=255, tickinterval=30, length=300, command=self.CheckColorBlue).pack()
  34.                 self.C = RGB_color()
  35.                 self.W.update()
  36.  
  37.         def Update(self):
  38.                 self.W.mainloop()
  39.  
  40. s = Slider()
  41. s.Update()


PM Quote