Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python中,如何获得所需大小的按钮?_Python_Button_Fonts - Fatal编程技术网

在Python中,如何获得所需大小的按钮?

在Python中,如何获得所需大小的按钮?,python,button,fonts,Python,Button,Fonts,如何使按钮达到所需的大小 增加字体大小不起作用 bou1_1 = Button(fen,text="\u2656",font=("Arial",24), width =9, height =4) bou1_1.grid(row =1, column =1) 以下是我得到的图像: 谢谢您想更改宽度和高度参数: bou1_1 = Button(fen,text="\u2656",font=("Arial",24), width = 18, height = 8) # 18 and 8 are

如何使按钮达到所需的大小

增加字体大小不起作用

bou1_1 = Button(fen,text="\u2656",font=("Arial",24), width =9, height =4)  
bou1_1.grid(row =1, column =1)
以下是我得到的图像:


谢谢

您想更改
宽度
高度
参数:

bou1_1 = Button(fen,text="\u2656",font=("Arial",24), width = 18, height = 8)
# 18 and 8 are just examples, set them to whatever you want
bou1_1.grid(row =1, column =1)

这将使整个按钮变大,而不包括文本本身。如果您只想增加文本大小,请增加字体大小。

对不起,我已经尝试过了,但没有效果。另外,行和列似乎也会影响大小。@user2984887我不确定你说的“不工作”是什么意思。更改宽度和高度会更改按钮的大小,这似乎是您想要的。宽度有效,但高度无效。按钮似乎需要一些文本而不是符号。要将按钮实际显示为符号,您需要使用
text=u'\u2656'
——这将字符串解释为Unicode字符串,并显示相应的字符。谢谢,它可以工作,但我仍然无法按我想要的方式调整按钮的大小。也许我应该用一个框架,上面有鼠标或者类似的东西。我想在这个象棋符号周围有一个正方形的按钮。