here's what I have in mind: I have data (numbers) in an OPC server, which I want to retrieve via a GUI. This data should be updated every 5 seconds and therefore also be displayed in the GUI. I had tried this via a while loop, which also works as print output, but then no window is displayed to me anymore.
Would there perhaps someone an idea how I can implement this?
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import Tkinter
from Tkinter import *
import sys
import os
import time
from opcua import Client
url = "opc.tcp://xxxxxxx"
client = Client(url)
client.connect()
#create main window
master = Tkinter.Tk()
print('test')
master.title("GUI Raspberry")
master.geometry("900x900")
label = Tkinter.Label(master, text='test')
label2 = Tkinter.Label(master, text='')
label.pack(padx = 5, pady = 10, side = LEFT)
while True:
Mean = client.get_node("ns=2;i=3")
MeanValue = Mean.get_value()
label2['text'] = MeanValue
label2.pack(padx = 5, pady = 20, side = LEFT)
print(MeanValue)
time.sleep(5)
master.update()
time.sleep(2)
master.mainloop()
master.destroy()