'Automatically restore minimized tkinter window

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.



Solution 1:[1]

This can be done by invoking the following:

if data == "whatever":   
    window.state('zoomed')

Solution 2:[2]

On receipt of data call:

window.attributes('-zoomed', True)

Solution 3:[3]

If all you want to do is "un-minimize" the window, call deiconify, which will restore the window to the state it was in before it was minimized.

window.deiconify()

Solution 4:[4]

Just do window.attributes("-fullscreen", True)

Solution 5:[5]

well there is a very simple fix for the problem

if data == "data":
      window.wm_state('zoomed')

Solution 6:[6]

I think this is what you are looking for

import tkinter

yourwindow = tkinter.Tk()
yourwindow.state("zoomed")

yourwindow.mainloop()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 turnt
Solution 2 mhawke
Solution 3 Bryan Oakley
Solution 4 Phoenix Flight
Solution 5 Saksham
Solution 6 Naeem Ahmed