import tkinter as tk
from tkinter import ttk
##### create the root window
root = tk.Tk()
root.title('示范')
root.resizable(False, False)
root.geometry('500x390+630+420')# (宽度x高度)+(x轴+y轴)
宽度=14
高度=25
左右內距=8
上下內距=5
左右间距=5
上下间距=5
#####combobox
lb_人员选择 = tk.Label(root,width =宽度,padx=左右间距,pady=上下间距,text="人员选择")
## Combobox(人员) creation
人员选择text = tk.StringVar()
人员选择 = ttk.Combobox(root,width = 宽度+2,height=高度, textvariable=人员选择text)
人员选择['values'] = ['小余','小华','小泽','小文']
##### entry
## entry label creation
lb_人员 = tk.Label(root,width =宽度,padx=左右间距,pady=上下间距,text="人 员")
人员text = tk.StringVar()
人员=ttk.Entry(root,width = 宽度+4)
####控件显示
lb_人员选择.grid(column=0,row=0, sticky="e")
人员选择.grid(column=1,row=0,padx=左右间距, sticky="w")
lb_人员.grid(column=0,row=1, sticky="e")
人员.grid(column=1,row=1,padx=左右间距, sticky="w")
def ajouter():
人员.insert(tk.END, 人员选择.get()+"、")
#buton
buton=tk.Button(root,text='人员添加',fg='black',command=ajouter)
buton.place(x=256,y=35,height=22)
##### run the application
root.mainloop()
启发来源:https://stackoverflow.com/questions/69508584/how-get-values-from-combobox-to-write-into-textbox