0

I have a problem: I want to make a honeycomb shape in which every hexagon is a clickable button, but don't know how.

I tried to make it by Button() and window() from Tkinter, but its shape is rectangluar. I need its shape to be hexagonal.

EDIT: I added a picture, just want each of these hexagons to be separate clickable button. Is it doable?

I could add that I am learning programming on my own and I don't know much, but I searched a lot and one and only thing that I found was creating rectangular button. :/

Honeycomb pattern

  • Hi there, welcome to Stackoverflow! I recommend you take the [welcome tour](https://stackoverflow.com/tour) to know your way arround here (and earn your first badge also ;) ). Also to improve the chances of getting useful answers please check [how to ask](https://stackoverflow.com/help/asking) and also how to create [Complete, Minimal, and Verifiable examples](https://stackoverflow.com/help/mcve). – DarkCygnus Jul 24 '17 at 00:33

1 Answers1

0

Well ,there is no direct method in tkinter to create shaped buttons other than the usual rectangle one, but you can do it by playing with colors and images.

  • Crop an image in the shape and color, in which you wish your button to be.
  • Then use the Button widget, to create the button having that particular image

For example:

from tkinter import *
root = Tk()
image_button = PhotoImage(root, file="hexagonal_button.png")
button_hex = Button(root, bg='white',border='0', image=image_button)
button_hex.pack()
root.mainloop()
  • Or else, you may try other GUI toolkits such as:

  • wxPython

  • PyQt

  • Kivy and many more ...

TheSHETTY-Paradise
  • 1,024
  • 2
  • 9
  • 19