2016-10-07 3 views
0

GUI에서 연속 값을 가져 오려고하는 저울이 있습니다. 아래는 제 코드입니다.파이썬 슬라이더 값

getVoltage() takes exactly 1 argument, two was given 

내가 할 노력하고있어 모든 슬라이더의 값을 얻을 수 있습니다 : 나는 위의 코드를 실행하고 내 슬라이더를 시작하면

from Tkinter import * 
class Application(Frame): 
    def getVoltage(self): 
     print self.voltage_scale.get() 
    def createWidgets(self): 
     self.voltage_scale = Scale(self) 
     self.voltage_scale["from_"] = 0 
     self.voltage_scale["to"] = 32 
     self.voltage_scale["orient"] = "horizontal" 
     self.voltage_scale["command"] = self.getVoltage 
     self.voltage_scale.grid(column=0,row=9) 
    def __init__(self,Master=None) 
     Frame.__init__(self,master) 
     self.createWidgets() 
     self.tn = None 
root = Tk() 
app = Application(master=root) 
app.mainloop() 
root.destroy() 

, 나는라는 오류가 발생합니다. 어떤 도움을 주시면 감사하겠습니다.

답변

2

def getVoltage(self, event_arg):이 수정됩니다. 일부 tk 컨트롤의 명령은 일부 이벤트 데이터를 추가 인수로 전달됩니다.

+0

뛰어난! 완벽하게 작동합니다! – DeeTee