Python3 Tkinter...icon. What gives!?
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 3 of 3
  1. #1
    WnO3M Guest

    Python3 Tkinter...icon. What gives!?

    Hi,

    I'm using Python3, Tkinter.. from the repository (as of today since it didn't come preinstalled) and I immediately headed off for a tutorial. Here's the program.

    Code:
    import tkinter
    window = tkinter.Tk()
    window.title("Gaia")
    window.geometry("600x480")
    window.wm_iconbitmap('Orb.xbm')
    
    
    window.mainloop()
    Bearing in mind that the icon is in the same folder as the script...

    Code:
    Traceback (most recent call last):
      File "Gaia/init.py", line 16, in <module>
        window.wm_iconbitmap('Orb.xbm')
      File "/usr/lib/python3.3/tkinter/__init__.py", line 1637, in wm_iconbitmap
        return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
    _tkinter.TclError: bitmap "Orb.xbm" not defined
    Now if I put an "@" in front of the file name I get...

    Code:
    Traceback (most recent call last):
      File "Gaia/init.py", line 16, in <module>
        window.wm_iconbitmap('@Orb.xbm')
      File "/usr/lib/python3.3/tkinter/__init__.py", line 1637, in wm_iconbitmap
        return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
    _tkinter.TclError: error reading bitmap file "Orb.xbm"
    However the file opens up just fine with Gimp and I would really like a colour version.

    I also get the same problem with the Orb.xmp, Orb.ico Orb.gif Orb.png

    Any suggestions would be greatly appreciated.

  2. #2
    Join Date
    Nov 2006
    Location
    Detroit
    Posts
    7,084
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Python3 Tkinter...icon. What gives!?

    For .xbm files I believe you have to use this:
    Code:
    window.wm_iconbitmap(bitmap = "@Orb.xbm")
    If you want to use color icons in Tkinter, you have to use gif or ppm files, not png:
    Code:
    #!/usr/bin/python3
    import tkinter
    window = tkinter.Tk()
    window.title("Gaia")
    window.geometry("600x480")
    img = tkinter.PhotoImage(file='icon.gif')
    window.tk.call('wm', 'iconphoto', window._w, img)
    window.mainloop()
    OS: Fedora 32 x86_64 | Machine: Lenovo ThinkCentre M91P | CPU: Intel Core i5-2500 3.30GHz | RAM: 16GB PC3-12800 DDR3 | Disk: 500GB SATA | Video: Intel HD Graphics 2000 128MB | Sound: Turtle Beach Santa Cruz CS4630 | Ethernet: Intel 82579LM

  3. #3
    WnO3M Guest

    Re: Python3 Tkinter...icon. What gives!?

    Works brilliantly! Thank you

Similar Threads

  1. tkinter in python3 missing
    By asdf1234asdf in forum Using Fedora
    Replies: 4
    Last Post: 2nd December 2013, 12:16 AM
  2. Pygame for Python3
    By Mepoe in forum Programming & Packaging
    Replies: 4
    Last Post: 28th February 2013, 11:44 PM
  3. [SOLVED]
    Python3 Can't find tkinter...still
    By Mepoe in forum Using Fedora
    Replies: 15
    Last Post: 24th February 2013, 12:00 PM
  4. python3 idle
    By Aisthesis in forum Using Fedora
    Replies: 5
    Last Post: 30th May 2010, 01:36 AM
  5. PyQt4 for Python3.1?
    By nimrodel in forum Installation, Upgrades and Live Media
    Replies: 0
    Last Post: 24th May 2010, 03:08 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •