[HLA] Using Python threads

Hi,
I’m trying to use the threading module in an HLA. I want to display a custom GUI using Tk in a separate thread, but the thread doesn’t start.

class Gui(threading.Thread):
    def __init__(self):
        super().__init__()
        self.root = Tk()
        self.frm = ttk.Frame(self.root, padding=10)
        self.frm.grid()
        ttk.Label(self.frm, text="Hello World!").grid(column=0, row=0)
        ttk.Button(self.frm, text="Quit", command=self.root.destroy).grid(column=1, row=0)

    def run(self):
        print("run thread")
        self.root.mainloop()

class Hla(HighLevelAnalyzer):
    def __init__(self):
        self.gui = Gui()
        self.gui.start()

        print("Hello world")

Calling self.gui.start() has no effect at all. Neither the GUI shows up nor “run thread” gets printed. Any advice?

Best regards

@gietljohannes Sorry for the late reply! Our offices were closed for the holidays by the time your message came in.

I’ll need the expertise of our software team for this one. Let me send this over to them and we’ll share our updates with you.

Sorry for the trouble with this! I’d like to test this on our end, but I’m not 100% sure how it would work, since we generally call into python and then return from python, at which point we’re no longer running python code. I’ll check with the developer who owns the HLA system once he’s back from vacation.

I’ve been thinking about trying to do the same thing - I would suggest two other approaches:

  1. Use IPC and another python process to run the GUI, and push events from the HLA to the other process for display.
  2. Use an HTML front-end, and a web socket to push events from the HLA into the HTML UI. You should be able to launch the browser window from the HLA source code. I’m not sure exactly how well running a web socket server in the LLA will work, but it might make for a pretty flexible solution.

I love the idea of running a live dashboard entirely within an HLA while running a live recording!

Hi Mark,

thanks for your reply! Yes, I’ve also been thinking about using one of your proposed solutions.
But it still would be nice to know why the original solution isn’t working.

Best regards