title: Tkinter - Button Image Transparent Background
body: <p>I have worked out how to have an image for a button, thats positioned on top of a label (<em>I think I maybe doing it the long-winded way because I can't install PIL on my Mac for some reason</em>). Anyhow, it works as it should to a certain degree - the problem I have is it's adding white space either side, and then the image itself is not displaying its transparent background.</p>
  
  <p><a href="https://i.stack.imgur.com/DoUBV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DoUBV.png" alt="enter image description here"></a></p>
  
  <p>The code I am using is as follows:</p>
  
  <pre><code>from tkinter import *
  #from PIL import Image
  
  root = Tk()
  
  
  #Removes the title bar and places over mac top bar
  root.tk.call("::tk::unsupported::MacWindowStyle", "style", root._w, "plain", "none")
  # Makes the app full screen
  #root.wm_attributes('-fullscreen', 1)
  
  root.geometry('{}x{}'.format(480, 320))
  #root.attributes('-topmost', True)
  
  def quitApp():
      # mlabel = Label (root, text = 'Close').pack()
      root.destroy()
  
  
  background_img = PhotoImage(file="images/bg.gif")
  scanBtn_img = PhotoImage(file="images/scanBtn.gif")
  
  background = Label(root,
                     compound = CENTER,
                     quitButton = Button(image=scanBtn_img, command = quitApp).pack(),
                     image = background_img).pack(side="right")
  
  background.image = background_img # keep a reference!
  
  
  root.mainloop()
  </code></pre>