简体   繁体   English

如何减小 tkinter python 中条目的大小

[英]How to decrease the size of an entry in tkinter python

I want to decrease the size of an entry in tkinter python.我想减小 tkinter python 中条目的大小。 ive already asked about label but i havent used fyi我已经询问过 label 但我没有使用过 fyi

the code:编码:

from tkinter import *
from tkinter import messagebox

top = Tk()
top.title("Hello wold")
top.geometry("300x300")

ei = StringVar()
ei1 = StringVar()

def karma():
    try:
        ee = ei.get()
        ee1 = ei1.get()
        ez = int(ee) + int(ee1)
        return messagebox.showinfo('message', f'{ee} + {ee1} = {ez}')
    except ValueError:
        return messagebox.showinfo('message', f'ERROR')

name = Label(top,text="1st no. : ").place(x = 20,y = 50)
e = Entry(top,textvariable=ei).place(x = 100, y = 50)
name1 = Label(top,text="2nd no. : ").place(x = 20,y = 100)
e1 = Entry(top,textvariable=ei1).place(x = 100, y = 100)
b = Button(top, text="Click here", command=karma).place(x = 20,y = 150)

top.mainloop()

you may use the font option in Entry to adjust the size.您可以使用Entry中的font选项来调整大小。

Here is an example (to change it to 8pts)这是一个示例(将其更改为 8pts)

import tkFont

helv8 = tkFont.Font(family='Helvetica', size=8)

e = Entry(top, font = helv8, textvariable=ei).place(x = 100, y = 50)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM