MCPcopy Create free account
hub / github.com/ActiveState/code / Metro_Button

Class Metro_Button

recipes/Python/580729_Metro_UI_Tkinter/recipe-580729.py:238–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236 self._command()
237
238class Metro_Button(Button):
239 def __init__(self, master, text, background, ID=None, foreground="white", opacity=0.8, font=None, command=None, padx=7, pady=7):
240 opacity = float(opacity)
241
242 if background.startswith("#"):
243 r,g,b = hex2rgb(background)
244 else:
245 # Color name
246 r,g,b = master.winfo_rgb(background)
247
248 r = int(opacity*r)
249 g = int(opacity*g)
250 b = int(opacity*b)
251
252 if r <= 255 and g <= 255 and b <=255:
253 activebackground = '#%02x%02x%02x' % (r,g,b)
254 else:
255 activebackground = '#%04x%04x%04x' % (r,g,b)
256
257
258 Button.__init__(self, master, ID=ID, text=text, activebackground=activebackground, background=background, activeforeground=foreground, foreground=foreground, relief=FLAT, padx=padx, pady=pady, borderwidth=0, highlightthickness=0)
259 if font:
260 self.configure(font=font)
261
262 if command:
263 self.configure(command=command)
264
265class Metro_Entry(Frame):
266 BORDER_COLOR = "#999999"

Callers 2

__init__Method · 0.85
recipe-580729.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected