Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_custom_button.py
- from tkinter import *
- canvas = Canvas(width=200, height= 200, borderwidth=3, relief="raised", highlightthickness=0)
- padding = 10
- width = 200
- height = 200
- c = canvas.create_oval((padding,padding,
- width-padding, height-padding), outline='lightblue', fill='orange', width=10, tags='btn')
- canvas.create_text((102,100), text='Click Me!', font=("Verdana", 25), fill='black', tags='btn')
- def _on_press(event):
- canvas.configure(relief="sunken")
- canvas.coords(c, [i+5 for i in canvas.coords(c)])
- def _on_release(event):
- canvas.configure(relief="raised")
- canvas.coords(c, [i-5 for i in canvas.coords(c)])
- print('hello')
- canvas.bind("<ButtonPress-1>", _on_press)
- canvas.bind("<ButtonRelease-1>", _on_release)
- canvas.pack()
- canvas.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement