kvar 0 Newbie Poster

Hello, I'm a newbie in python.
I've written a code for websocket for server and client communication. here im getting some data from server ( "sprintf(buffer,<STX,250,350,254,%d,858,STX>, i) and im saving this to RPI which is my client. now i've to display these readings on a window using tkinter. i've created an image to displat these values but the problem is that im getting only the starting value of the sprintf and it's not getting update every second. i've used .after() and update() but no use to it. any help would be a great from your side. im uploading my code and thanks in advance


importing libraries

from Tkinter import *
import Tkinter as Tk
import Tkinter as tk
import websocket
import time

Tkinter window for image background

window = tk.Tk()

defining colors

colors = ["#FF0000","#008000","#0000FF","#FFFF00","#FF8000","#000000","#FFFFFF",

creating variables

width_value = window.winfo_screenwidth()
height_value = window.winfo_screenheight()
image_bg = colors[4]
tittle_fg = colors[8]
tittle_bg = colors[6]
tittle_font = ("Times Roman",65)
x_coords = 420
y_coords = 0
fixed_txt = "Target = "
txt_fg = colors[0]
txt_font = ("Helvetica",35)
txt_bg = colors[5]

server and client communication

ws = websocket.WebSocket()
while 1:
result = ws.recv()

creating image attributes and coordinates

window.config(highlightthickness = 0)

creating text, font, bg, fg, label, x and y coords

canvas = Canvas(window, width = width_value, height = height_value, bg = image_bg)
tittle = Label(window, text = tittle_txt, fg = tittle_fg, font = tittle_font, bg = tittle_bg).place(x = x_coords, y = y_coords)
label1 = Label(window, text = fixed_txt+str(result), fg = txt_fg, font = txt_font, bg = txt_bg).place(x = label1_x_coords, y = label1_y_coords)


Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.