Tkinter AttributeError: 'Class' object has no attribute 'dev' or Unsupported operand type(s) for *: 'NoneType' and 'NoneType' (Python)

Viewed 10

I would like to implement a progress bar that is dependent on parameters of a measurement method. For this I have a class Controller, which performs the measurement and a class View, in which the progressbar should be implemented. I tried two different ways and got the error with one of them : Unsupported operand type(s) for *: 'NoneType' and 'NoneType' (Python) or AttributeError: 'Class' object has no attribute 'dev'

Class Controller:
  def __init__(self):
  
  def start_test(self, port):
    self.thread = threading.Thread(target=self.measure_data, args=(port,))
    self.thread.start()

def measure_data(self, port):
    self.device = Device(port)
    self.device.run_test("test",                               
    filename=file.txt)
 
        self.dev.stop_test()
        self.dev.close()

def get_test_done_time_cyclic(self):
    if self.thread.is_alive():
        return self.device.get_test_time("test")

def sample_period_cyclic(self):
    if self.thread.is_alive():
        return self.device.get_sample_period()


Class View:
    def __init__(self, master)

    def progress(self):
        if self.controller.thread.is_alive():
            self.stepValue = self.controller.get_test_done_time_cyclic()/ self.controller.sample_period_cyclic()

    while self.pb["value"] < 100:
        self.pb['value'] += self.stepValue
        self.percentLabel['text'] = self.update_progress_label()
        time.sleep(1.2)
        self.update_idletasks()
    if self.pb["value"] == 100:
        self.pb["value"] = 0
        self.percentLabel['text'] = "Current Progress: 0.0%"
        self.pb.stop()
        self.update_idletasks()
0 Answers
Related