V
V
Vladimir2015-07-04 19:35:37
Python
Vladimir, 2015-07-04 19:35:37

Tkinter (wm_iconwindow) Need help understanding a function?

I still want to know how iconwindow works.
I read a bunch of descriptions, and I'm trying to follow these descriptions.
I attached a screenshot with descriptions ...
Here is the whole code:

# coding=utf-8
__author__ = ‘Paddy’
from Tkinter import *
import os.path
import random
from PIL import Image, ImageDraw
root = Tk()





img = PhotoImage(name='skype.ico')

L2F= LabelFrame(root,width=100,heigh=200,bg='yellow')
L2F.pack()

print (root.wm_iconwindow(pathName=L2F))

def btn(event):
l= root.wm_state('icon')

print TkVersion


button = Button(root,
image=img,
text=u“Skype”,
width=30,height = 30)

button.bind(“<Button>”,btn)
button.pack()
root.mainloop()

Here is the compiler error when running iconwindow
C:\Python27\python.exe “CUsers/Paddy/Desktop/CodeAcademy/My project/Fitness/FitOne.py”
Traceback (most recent call last):
File “CUsers/Paddy/ Desktop/CodeAcademy/My project/Fitness/FitOne.py”, line 18, in
print (root.wm_iconwindow(pathName=L2F))
File “C:\Python27\lib\lib-tk\Tkinter.py”, line 1714, in wm_iconwindow
return self.tk.call('wm', 'iconwindow', self._w, pathName)
_tkinter.TclError: can't use .38925128L as icon window: not at top level
Process finished with exit code 1
Hope this helps , thanks in advance
550370d1436020031

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MK, 2015-07-12
@Maxsior

It is necessary to pass a child window as a parameter.

from tkinter import *
root=Tk()
tl=Toplevel(root)
root.title("root")
tl.title("tl")
root.iconwindow(tl)
mainloop()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question