2015-11-27 84 views
-1

當我調用該方法set_length()我得到的錯誤:類型錯誤:無法通過類型的非INT乘序「IntVar」

TypeError: can't multiply sequence by non-int of type 'IntVar' 

我該如何解決這個問題,簡單地進行數學運算?

class Section: 

    def __init__(self, id, bpm, bars, reps, num_tracks): 
     self.id = id 
     self.bpm = IntVar() 
     self.bpm.set(bpm) 
     self.bars = IntVar() 
     self.bars.set(bars) 
     self.reps = IntVar() 
     self.reps.set(reps) 
     self.num_tracks = num_tracks 
     self.tracks = {} 
     self.length = IntVar() 
     self.length.set(bars * 4/bpm * 60) 

    def bpm_change(self, value): 
     self.bpm = value 
     print(str(self.bpm)) 
     self.set_length() 

    def bars_change(self, value): 
     self.bars = value 
     print(str(self.bars)) 
     self.set_length() 

    def set_length(self): 
     self.length = (self.bars * 4/self.bpm * 60) 
+0

使用'self.bpm.get()'和到位的自我'用'self.bpm.set(值)' .bpm = value' – furas

+0

您是否願意回顧我以前的問題? –

回答

0

使用self.bpm.get()self.bars.get()得到int值。

BTW:使用self.bpm.set(value)self.bars.set(value)self.length.set(value)代替self.bpm = valueself.bars = valueself.length = value

相關問題