Feb-19-2020, 04:03 PM
You should split the GUI from code for calculation. Then you can test it better.
First comes the calculation:
Example:
Instead of using indicies, you could use for example the name: "Stuhl"
First comes the calculation:
Example:
class RoomSound: def __init__(self, length, width, height, area_window): self.length = length self.width = width self.height = height self.area_window = area_window @property def area(self): """ Area in m² """ return self.length * self.width @property def volume(self): """ Volume in m³ """ return self.length * self.width * self.height @property def area_volume_ratio(self): return self.area / self.volume @property def area_room(self): """ Area of room in m² """ return 2 * self.length * self.height + 2 * self.height * self.width - self.area_window @property def reverberation(self): """ Reverberation with sabine equation """ return 0.163 * self.area_volume_ratio if __name__ == "__main__": length = 9.92 # Länge width = 10.5 # Breite height = 2.34 # Höhe A_f = 30.45 # Fensterfläche room1 = RoomSound(length, width, height, A_f) print(room1.area, room1.volume, room1.reverberation)The parameters could expressed in dicts for example:
Instead of using indicies, you could use for example the name: "Stuhl"
objekte = { "Stuhl": 3.4533333333333336, "MP": 0.5916666666666667, "WP": 0.2833333333333334, } print(objekte["Stuhl"])Or with the different sounds:
sounds = { "Musik": {"factor": 0.45, "offset": 0.07}, "Sprache": {"factor": 0.37, "offset": -0.14}, "Vortrag": {"factor": 0.32, "offset": -0.17}, "Spr.+Vor.": {"factor": 0.26, "offset": -0.17}, "Sport": {"factor": 0.75, "offset": -1}, } def get_level(sound_type, V): sound = sounds[sound_type] return sound["factor"] * math.log10(V) + sound["offset"] print(get_level("Musik", 20))To get for example all type of sounds, use the keys:
print("Sounds:", list(sounds.keys()))This would make the creation of the Listbox more dynamic.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!