In my project, I am receiving some data occasionally from the serial port and display some data on a Tkinter window depending on the received data. I want to minimize my Tkinter window and perform my normal action on the computer. When any data will be received, the tkinter window should be restored ('un-minimized') and show the result. How can I restore my minized window depending on the received data?
import socket, Tkinter
from Tkinter import *
window = Tk()
window.title("maximize window test")
w, h = window.winfo_screenwidth(),window.winfo_screenheight()
window.geometry("%dx%d+0+0" % (w, h))
window.configure(background="white")
i = servicependingid1 = 1, 0
def monitor():
s = socket.socket()
host = socket.gethostname()
port = 12345
s.bind((host, port))
s.listen(5)
while True:
global i, servicependingid1
i = 1
c, addr = s.accept()
data = c.recv(1024)
print data
if data == "Bid1":
window.state('zoomed')
positionr1b1 = Label(window,text="Data comming from 1 ",fg="red",bg="blue",font=("Helvetica", 45))
positionr1b1.grid(row=i,column=6,sticky=W)
window.update()
servicependingid1 = i
i = i + 1
c.send("received")
c.close()
window.after(10, monitor)
window.mainloop()
I want to restore my window from the minimized condition when data is received.
This can be done by invoking the following:
if data == "whatever":
window.state('zoomed')
On receipt of data call:
window.attributes('-zoomed', True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With