python - Create a tkinter image button without a border -


i have seen posts on topic , have tried suggestions without success. want create tkinter button using image. code below creates button fine, draws thin border beyond image looks ugly. how can rid of button border? using python 3.5 on mac os x 10.12.3.

here's code:

from tkinter import * tkinter import ttk  sdefaultimage = none  def sstockpileobserver():     print("button clicked")  def main():     global sdefaultimage     sroot = tk()     smainframe = ttk.frame(sroot, padding="3 3 12 12")     smainframe.grid(column=0, row=0, sticky=(n, w, e, s))     smainframe.columnconfigure(0, weight=1)     smainframe.rowconfigure(0, weight=1)     smainframe.rowconfigure(2, minsize=85)     sdefaultimage = photoimage(file='backdimmed.gif')      s = ttk.style()     bg = s.lookup('tframe', 'background')     s.configure("solitairecard.tbutton", borderwidth=0, background=bg, highlightbackground=bg, \                           highlightthickness=0, activebackground=bg, activeforeground=bg, padx=0)     sstockpilebutton = ttk.button(smainframe, image=sdefaultimage, style="solitairecard.tbutton", width=0, command=lambda: sstockpileobserver())     sstockpilebutton.grid(column=1, row=1, sticky=(w, e), padx=0)     return sroot  sroot = main() sroot.mainloop() 

here produces:

button shown thin border

on osx , windows don't have control on appearance of buttons.

one solution create button label or canvas. have add own bindings handle clicks, that's pretty simple do. part, bindings change border raised lowered, , call function when finish click.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -