jorden435
jorden435

Reputation: 13

Button width and height not working in tkinter tkmacosx

when i use tkinter button i get the results i want though i'm using tkinter button from tkmacosx library as it supports background color. The problem is when i replace normal button with tkmacosx button they appear like dots.

import tkinter as tk
import tkmacosx as tkm
from tkinter.font import Font

root = tk.Tk()
color_list = ('#462066', '#FFB85F', '#FF7A5A', 
              '#00AAA0', '#8ED2C9', '#FCF4D9')

button_font = Font(family="Comic Sans MS", size='30')

for row, bg in enumerate(color_list):
    b1 = tkm.Button(
        root, text='%s'%row, bg=bg, borderless=1,
        width=5, height=3, font=button_font)
    b1.grid(row=row%2, column=row%3)
root.mainloop()

images:

tkmacosx buttons appear like this this but i want the button to sizes like this.

Thanks

Upvotes: 1

Views: 998

Answers (1)

Ramesh
Ramesh

Reputation: 554

you need to increase number of pixels width= 200, height = 100

import tkinter as tk
import tkmacosx as tkm
from tkinter.font import Font

root = tk.Tk()
color_list = ('#462066', '#FFB85F', '#FF7A5A',
              '#00AAA0', '#8ED2C9', '#FCF4D9')

button_font = Font(family="Comic Sans MS", size='30')

for row, bg in enumerate(color_list):
    b1 = tkm.Button(root, width=200,  height=100,  text='%s' % row, bg=bg, borderless=1,  font=button_font)
    b1.grid(row=row % 2, column=row % 3)
root.mainloop()

here is output output

Upvotes: 3

Related Questions