-1
因此,窗口小部件已創建,但文本框未填充來自組合框的選擇。如果有人能指出我的方向正確,我會很感激無法使文本框在文本框中填充組合框選擇。沒有錯誤返回
import tkinter as tk
from tkinter import ttk
from tkinter import scrolledtext
#from courses import NationalHunt
win = tk.Tk()
win.resizable(130,130)
win.title("RaceCourse GUI")
# create combobox
course = tk.StringVar()
courseChosen = ttk.Combobox(win, width=60,textvariable=course,state='readonly')
courseChosen['values'] = ("Choose a course","Aintree","Ascot","Ayr", "Bangor",
"Carlisle","Cartmel","Catterick","Cheltenham","Chepstow","Doncaster",
"Exeter","Fakenham","Fontwell","Haydock","Hereford","Hexham","Huntingdon",
"Kelso","Kempton","Leicester","Ludlow","Market Rasen","Musselburgh",
"Newbury","Newcastle","Newton Abbot","Perth","Plumpton","Sandown",
"Sedgefield","Southwell","Stratford","Taunton","Towcester","Uttoxeter",
"Warwick","Wetherby","Wincanton","Windsor","Worcester")
courseChosen.grid(column=5, row=1,rowspan = 3, columnspan = 3,padx = 300, pady = 40)
courseChosen.current(0)
courseChosen.bind("<<ComboboxSelected>>",course.get())
scrolW = 46
scrolH = 10
box = scrolledtext.ScrolledText(win, width=scrolW, height=scrolH,bd=5,wrap=tk.WORD)
box.grid(column=5, row=8, columnspan=3,padx = 300,pady = 10)
box.delete("1.0","5.20")
box.insert(tk.INSERT,course.get())
# Start GUI
win.mainloop()