how to set button background with window background - Raspberry Pi Forums


hello freinds
have put image (self.image) on window background
now,
need put image(mi_but1) on window..
my problem:
image mi_but1 put on window gray square behind it(a gray square between image mi_but1 , window's background)
final gui doesnt nice
don't want gray background...
should do? how can remove gray square behind button(button background)? or how can put image of window background(self.image) in behind of button (button background)
my code:

code: select all

from tkinter import * pil import image, imagetk  root = tk() root.title("title") root.geometry("600x600") root.configure(background="black")  class example(frame):     def __init__(self, master, *pargs):         frame.__init__(self, master, *pargs)          self.image = image.open("/home/pi/desktop/images/background/image.png")         self.img_copy= self.image.copy()           self.background_image = imagetk.photoimage(self.image)          self.background = label(self, image=self.background_image)         self.background.pack(fill=both, expand=yes)         self.background.bind('<configure>', self._resize_image)          mi_but1=photoimage(file="/home/pi/downloads/images/buttons/starlarg.png")         button2 = button(self.background, text='button2',image=mi_but1)         button2.image=mi_but1         button2.pack(side='top')      def _resize_image(self,event):          new_width = event.width         new_height = event.height          self.image = self.img_copy.resize((new_width, new_height))          self.background_image = imagetk.photoimage(self.image)         self.background.configure(image =  self.background_image)  e = example(root) e.pack(fill=both, expand=yes) root.mainloop() 

two things try

set button's border width 0

code: select all

button2 = button(..., borderwidth=0) 
or use gif image transparency
https://stackoverflow.com/questions/443 ... background


raspberrypi



Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'