如何正确定位 OPTIONMENU?

发布于 2025-01-13 13:04:31 字数 2601 浏览 7 评论 0原文

我是菜鸟,请帮助我:(

我如何更改 TTK 选项菜单小部件的字体大小,以及如何将其放置在水箱编号输入框的旁边,使其看起来不错,

这就是它目前的样子

输入图像描述这里这是我的代码

# Creating Frame to Put widgets
frame = tk.Frame(main_window)

# Heading of the Window
ttk.Label(main_window, text="INVOICE GENERATOR", font=("Roboto", 30)).pack(ipady=20)

# Invoice No Label And Invoice No Entry
ttk.Label(frame, text='Invoice Number', font=("Roboto", 19)).grid(row=0, column=0, pady=7, 
sticky=tk.W)
ttk.Entry(frame, textvariable=invoice_no, width=40, font=("Roboto", 19)).grid(row=0, column=1, 
pady=7)

# Name Label And Name Entry 
ttk.Label(frame, text='Name', font=("Roboto", 19)).grid(row=1, column=0, pady=7, sticky=tk.W)
ttk.Entry(frame, textvariable=name, width=40, font=("Roboto", 19)).grid(row=1, column=1, 
pady=7)

# Date Label And Date Entry
ttk.Label(frame, text='Date', font=("Roboto", 19)).grid(row=2, column=0, pady=7, sticky=tk.W)
ttk.Entry(frame, textvariable=date, width=40, font=("Roboto", 19)).grid(row=2, column=1, 
pady=7)

# Vehicle No Label And Vehicle No Entry
ttk.Label(frame, text='Vehicle Number', font=("Roboto", 19)).grid(row=3, column=0, pady=7, 
sticky=tk.W)
ttk.Entry(frame, textvariable=vehicle_no, width=40, font=("Roboto", 19)).grid(row=3, column=1, 
pady=7)
# Price Label And Price Entry
ttk.Label(frame, text='Price', font=("Roboto", 19)).grid(row=4, column=0, pady=7, sticky=tk.W)
ttk.Entry(frame, textvariable=price, width=40, font=("Roboto", 19)).grid(row=4, column=1, 
pady=7)
# Tank Number Label And Tank Number Entry
ttk.Label(frame, text='Tank Number', font=("Roboto", 19)).grid(row=5, column=0, pady=7, 
sticky=tk.W, columnspan=5)
ttk.Entry(frame, textvariable=tank_no, width=30, font=("Roboto", 19)).grid(row=5, column=1, 
pady=7, sticky=tk.W)
tank_capacity_dropdown = ttk.OptionMenu(frame, tank_capacity, *options)
tank_capacity_dropdown['menu'].configure(font=('Roboto', 18))
tank_capacity_dropdown.grid(row=5, column=2, sticky=tk.W, ipadx= 10, ipady=9)
# Reducer Number Label And Reducer Number Entry
ttk.Label(frame, text='Reducer Number', font=("Roboto", 19)).grid(row=6, column=0, pady=7, 
padx=7, sticky=tk.W)
ttk.Entry(frame, textvariable=reducer_no, width=40, font=("Roboto", 19)).grid(row=6, column=1, 
pady=7)
# Button used to update and export the INVOICE.xlsx file
ttk.Button(frame, text="Export Invoice", command=gnrt_file, style="Accentbutton").grid(row=7, 
column=0, columnspan=3,
pady=7)
frame.place(anchor="c", relx=.5, rely=.5)
main_window.mainloop()

i am a noob, please help me :(

how can i change font size of the TTK optionmenu widget and also how can i place it right beside the entry box of the tank number to make it look good

this is how it is currently

enter image description here
this is my code

# Creating Frame to Put widgets
frame = tk.Frame(main_window)

# Heading of the Window
ttk.Label(main_window, text="INVOICE GENERATOR", font=("Roboto", 30)).pack(ipady=20)

# Invoice No Label And Invoice No Entry
ttk.Label(frame, text='Invoice Number', font=("Roboto", 19)).grid(row=0, column=0, pady=7, 
sticky=tk.W)
ttk.Entry(frame, textvariable=invoice_no, width=40, font=("Roboto", 19)).grid(row=0, column=1, 
pady=7)

# Name Label And Name Entry 
ttk.Label(frame, text='Name', font=("Roboto", 19)).grid(row=1, column=0, pady=7, sticky=tk.W)
ttk.Entry(frame, textvariable=name, width=40, font=("Roboto", 19)).grid(row=1, column=1, 
pady=7)

# Date Label And Date Entry
ttk.Label(frame, text='Date', font=("Roboto", 19)).grid(row=2, column=0, pady=7, sticky=tk.W)
ttk.Entry(frame, textvariable=date, width=40, font=("Roboto", 19)).grid(row=2, column=1, 
pady=7)

# Vehicle No Label And Vehicle No Entry
ttk.Label(frame, text='Vehicle Number', font=("Roboto", 19)).grid(row=3, column=0, pady=7, 
sticky=tk.W)
ttk.Entry(frame, textvariable=vehicle_no, width=40, font=("Roboto", 19)).grid(row=3, column=1, 
pady=7)
# Price Label And Price Entry
ttk.Label(frame, text='Price', font=("Roboto", 19)).grid(row=4, column=0, pady=7, sticky=tk.W)
ttk.Entry(frame, textvariable=price, width=40, font=("Roboto", 19)).grid(row=4, column=1, 
pady=7)
# Tank Number Label And Tank Number Entry
ttk.Label(frame, text='Tank Number', font=("Roboto", 19)).grid(row=5, column=0, pady=7, 
sticky=tk.W, columnspan=5)
ttk.Entry(frame, textvariable=tank_no, width=30, font=("Roboto", 19)).grid(row=5, column=1, 
pady=7, sticky=tk.W)
tank_capacity_dropdown = ttk.OptionMenu(frame, tank_capacity, *options)
tank_capacity_dropdown['menu'].configure(font=('Roboto', 18))
tank_capacity_dropdown.grid(row=5, column=2, sticky=tk.W, ipadx= 10, ipady=9)
# Reducer Number Label And Reducer Number Entry
ttk.Label(frame, text='Reducer Number', font=("Roboto", 19)).grid(row=6, column=0, pady=7, 
padx=7, sticky=tk.W)
ttk.Entry(frame, textvariable=reducer_no, width=40, font=("Roboto", 19)).grid(row=6, column=1, 
pady=7)
# Button used to update and export the INVOICE.xlsx file
ttk.Button(frame, text="Export Invoice", command=gnrt_file, style="Accentbutton").grid(row=7, 
column=0, columnspan=3,
pady=7)
frame.place(anchor="c", relx=.5, rely=.5)
main_window.mainloop()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文