如何正确定位 OPTIONMENU?
我是菜鸟,请帮助我:(
我如何更改 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
# 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论