mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
improved button rendering with polygons instead of ovals and rects
This commit is contained in:
parent
eb849991b4
commit
ec2499cb2f
@ -76,15 +76,15 @@ class CTkButton(tkinter.Frame):
|
|||||||
self.image = image
|
self.image = image
|
||||||
self.compound = compound
|
self.compound = compound
|
||||||
|
|
||||||
self.configure(width=self.width+1, height=self.height+1)
|
self.configure(width=self.width, height=self.height)
|
||||||
|
|
||||||
if sys.platform == "darwin" and self.function is not None:
|
if sys.platform == "darwin" and self.function is not None:
|
||||||
self.configure(cursor="pointinghand") # other cursor when hovering over button with command
|
self.configure(cursor="pointinghand") # other cursor when hovering over button with command
|
||||||
|
|
||||||
self.canvas = tkinter.Canvas(master=self,
|
self.canvas = tkinter.Canvas(master=self,
|
||||||
highlightthicknes=0,
|
highlightthicknes=0,
|
||||||
width=self.width+1,
|
width=self.width,
|
||||||
height=self.height+1)
|
height=self.height)
|
||||||
self.canvas.grid(row=0, column=0, rowspan=2, columnspan=2)
|
self.canvas.grid(row=0, column=0, rowspan=2, columnspan=2)
|
||||||
|
|
||||||
if self.hover is True:
|
if self.hover is True:
|
||||||
@ -147,7 +147,7 @@ class CTkButton(tkinter.Frame):
|
|||||||
# create border button parts (only if border exists)
|
# create border button parts (only if border exists)
|
||||||
if self.border_width > 0:
|
if self.border_width > 0:
|
||||||
if not self.canvas.find_withtag("border_line"):
|
if not self.canvas.find_withtag("border_line"):
|
||||||
self.canvas.create_polygon((0, 0, 0, 0), tags=("border_line"))
|
self.canvas.create_polygon((0, 0, 0, 0), tags=("border_line",))
|
||||||
|
|
||||||
self.canvas.coords("border_line",
|
self.canvas.coords("border_line",
|
||||||
(self.corner_radius,
|
(self.corner_radius,
|
||||||
|
Loading…
Reference in New Issue
Block a user