How do I set the width of an Tkinter Entry widget in pixels?

后端 未结 3 758
醉梦人生
醉梦人生 2021-01-12 04:51

I noticed that the width argument for the Tkinter entry widget is in characters, not pixels.

Is it possible to adjust the width in pixels?

相关标签:
3条回答
  • 2021-01-12 05:03

    You can use "ipadx" and "ipady" while packing the "Entry" widget.

    You can also use it with "grid".

    import tkinter as tk
    
    root = tk.Tk
    
    e = tk.Entry()
    e.pack(ipadx=100, ipady=15)
    
    tk.mainloop()
    
    
    0 讨论(0)
  • 2021-01-12 05:04

    You can also use the Place geometry manager:

    entry.place(x=10, y=10, width=100) #width in pixels
    
    0 讨论(0)
  • 2021-01-12 05:05

    You cannot specify the worth in pixels using the '-width' option, but there are ways to accomplish the same thing. For example, you could pack an entry in a frame that has mo border, turn off geometry propagation, then set the width of the frame in pixels.

    0 讨论(0)
提交回复
热议问题