I did quite a lot of research both within and outside of stackoverflow. Yes, there are similar topics. But I could not find the answer to my specific problem. Maybe because I can not see the bigger picture yet with my current understanding of Python.
In the last line I get the error "No value for argument 'self' in method call". How would I have to properly call the method here? Or is it not possible at all to call methods within the same class?
class Main:
metronomeState = True
currentMillis = 0
lastMillis = 0
intervalMillis = 0
bpm = 120
measureCount = 0
def bpmToMilliInterval(self):
self.bps = Main.bpm/60
return int((1/self.bps)*1000)
Main.intervalMillis = Main.bpmToMilliInterval()
It might seem that there would be no reason for this class because I do not need to instantiate it. But I want to use the code of Main() in another class Gui() which is responsible for all the GUI stuff. So the different classes are a way for me to organize the code. Good approach or not?
Thanks in advance for your help!
bps, and it's not established in__init__; all the other attributes are class attributes. Is it supposed to be possible to make instances ofMain? If not, this is a very weird class, but you'd probably want to just makebpmToMilliIntervalan@classmethod(assumingbpsneeds to be preserved beyond the call) and (solely for proper style) change all references toselftocls. That final line would have to be outside the class definition (I suspect it is in your real code, since it wouldn't be legal to have it inside the class either way).