මචං මේකයි කතන්දරේ
Module දෙකක් තියෙනවා එකක GUI class 1 තියෙනවා
අනිත් module එකේ තියෙන variable එක update වුනොත් GUI ක්ලාස් එකෙ තියෙන list box එකට add වෙන්න ඕන
දන්න කෙනෙක් sup එකක් දෙන්න
GUI.py
updater.py
Module දෙකක් තියෙනවා එකක GUI class 1 තියෙනවා
අනිත් module එකේ තියෙන variable එක update වුනොත් GUI ක්ලාස් එකෙ තියෙන list box එකට add වෙන්න ඕන
දන්න කෙනෙක් sup එකක් දෙන්න
GUI.py
Python:
from tkinter import *
import time
# def main():
# root = Tk()
# window1 = Window(root)
# # window1.insLi('00')
class Window:
def __init__(self,root,li) -> None:
self.li = li
self.root = root
def main(self):
# Creating the root window
self.root.geometry("609x96+951+216")
self.root.minsize(120, 1)
self.root.maxsize(2052, 1133)
self.root.resizable(1, 1)
self.root.title("Signal")
self.root.configure(background="#d9d9d9")
self.root.configure(highlightbackground="#d9d9d9")
self.root.configure(highlightcolor="black")
# Creating a Listbox and
# attaching it to root window
listbox = Listbox(self.root)
self.lb = listbox
# Adding Listbox to the left
# side of root window
listbox.pack(side=LEFT, fill=BOTH)
# Creating a Scrollbar and
# attaching it to root window
scrollbar = Scrollbar(self.root)
# Adding Scrollbar to the right
# side of root window
scrollbar.pack(side=RIGHT, fill=BOTH)
# Insert elements into the listbox
# for values in range(100):
listbox.config(yscrollcommand=scrollbar.set)
listbox.place(relx=0.0, rely=0.0, relheight=1.0, relwidth=1.0)
listbox.configure(background="#000000")
listbox.configure(disabledforeground="#6d6d6d")
listbox.configure(font="-family {Segoe UI Semibold} -size 18 -weight bold")
listbox.configure(foreground="#04ff24")
listbox.configure(highlightbackground="#d9d9d9")
listbox.configure(highlightcolor="black")
listbox.configure(selectbackground="blue")
listbox.configure(selectforeground="white")
# listbox.selection_set(END)
# listbox.see(END)
scrollbar.config(command=listbox.yview)
# self.root.after(1000,insLi)
self.root.mainloop()
def insLi(self):
# while True:
if self.li != '':
self.lb.selection_clear(0,END)
self.lb.insert(END, self.li)
self.lb.selection_set(END)
self.lb.see(END)
time.sleep(1)
updater.py
Python:
from tkinter import *
import GUI as sf
def popupmsg():
root = Tk()
window1 = sf.Window(root,'')
t=th.Thread(target=window1.main)
t.start()
popupmsg()
sf.window1.li='update me'