1

Eyery single tkinter import creates a tkinter window with a winged sign

on the top. Here's a screenshot:tkinter_screenshot

Any ideas how to remove it? Thanks in advance!

I need the answer for Windows, not for UNIX

Timmy
  • 125
  • 1
  • 11
  • It is a duplicate, right, but it only works on UNIX – Timmy Jul 09 '18 at 16:47
  • The first answer in the link gives windows and UNIX solutions. – tgikal Jul 09 '18 at 16:52
  • It may be but I tried all answers out. NO ONE worked :-0 – Timmy Jul 09 '18 at 16:54
  • Please add an example of what you have tried. – tgikal Jul 09 '18 at 16:54
  • Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> ============ RESTART: C:\Users\timur\Documents\Phyton\New_book.py ============ Traceback (most recent call last): File "C:\Users\timur\Documents\Phyton\New_book.py", line 1, in from PIL import ImageTk ModuleNotFoundError: No module named 'PIL' >>> – Timmy Jul 09 '18 at 16:55
  • Do you want to have more??? – Timmy Jul 09 '18 at 16:55
  • That appears to be an import error with the Pillow module, I'm not seeing the relation to Tkinter. – tgikal Jul 09 '18 at 16:56
  • Of course. You are right. Can you tell me sth. about this "Pillow module"? – Timmy Jul 09 '18 at 17:01
  • It is used for image processing, it appears to not be installed, opening command prompt and typing: py -m pip install Pillow , should install it, if you are planning on using the module. – tgikal Jul 09 '18 at 17:03
  • 5
    Fun fact: That's not a wing, it's a feather. That is because tkinter is based on a Tcl interpreter, and Tcl is pronounced "tickle". – Bryan Oakley Jul 09 '18 at 17:38

2 Answers2

2

As indicated in https://stackoverflow.com/a/18277350/4777984 this is probably the best solution.

import tkinter
import tempfile, base64, zlib

ICON = zlib.decompress(base64.b64decode('eJxjYGAEQgEBBiDJwZDBy'
    'sAgxsDAoAHEQCEGBQaIOAg4sDIgACMUj4JRMApGwQgF/ykEAFXxQRc='))

_, ICON_PATH = tempfile.mkstemp()
with open(ICON_PATH, 'wb') as icon_file:
    icon_file.write(ICON)

tk = tkinter.Tk()
tk.iconbitmap(default=ICON_PATH)
label = tkinter.Label(tk, text="Window with transparent icon.")
label.pack()

tk.mainloop()
tgikal
  • 1,667
  • 1
  • 13
  • 27
  • Ok, you are right. – Timmy Jul 09 '18 at 17:04
  • Thank you all for all the help! – Timmy Jul 09 '18 at 17:04
  • Acknowledging the answer is on the linked duplicate and then basically copy pasting the code is not how this should be handled. This question should be closed as a duplicate. – Mike - SMT Jul 09 '18 at 17:46
  • @Mike-SMT I agree and flagged it duplicate, but the OP was having difficulty finding a solution in the linked duplicate that would work, so I caved, and posted it, sorry for ruining everything. – tgikal Jul 09 '18 at 20:28
  • It is not ruining everything. However your post could use an explanation as to why this code works. Taking code from another post and not apply any context or reason is not a good practice. there are times where you may need to take an example from another post and modify it to fit the OPs needs but you should provide a link to that post and give credit where credit is due. As well as explain what it is the code is doing. – Mike - SMT Jul 09 '18 at 20:40
  • I do not know how to link to more than another question, is there a way to link to a specific answer, since the one I posted was not the accepted answer? I could probably cleanup my answer a bit, but I was honestly expecting this to be closed as a duplicate since it is and I had already flagged it, and figured I would help the guy out getting his feather gone, so didn't see much point in spending my entire lunch break developing a well critiqued answer to a duplicate question. – tgikal Jul 09 '18 at 20:46
  • 1
    You can click on the `Share` button and get a link directly to the answer itself. I understand just wanting to help I do that myself. I just try to make it a point to make sure my answer explains the reason for the code. Providing a decent answer helps more than just the OP when other stumble across the post. It is up to you how you wish to answer someone I am just giving you some pointers and if you wish to follow them then great if not then that is up to you as well. – Mike - SMT Jul 09 '18 at 21:14
  • 1
    There we go, I didn't see the "share" button before, learn something new every day. – tgikal Jul 09 '18 at 21:41
1

Take a look at this question Set window icon. Basically you call root.iconbitmap(path_to_your_icon).

Yngvar 92
  • 31
  • 1
  • 3
  • Thank you for your help, but that didn't worked. – Timmy Jul 09 '18 at 16:49
  • You will either need to include a blank icon and link to that icon, or embed a blank icon into the code, as indicated in the numerous answers given in the link above. – tgikal Jul 09 '18 at 16:51