我得到了两个文本小部件的代码,用于我必须编写的程序。
player1_label = Label(window,text='Player 1:')
player1_label.grid(row=0,column=0,sticky='W')
player1_score = Label(window)
player1_score.grid(row=0,column=1,sticky='W')
player1_text = Text(window,width=30)
player1_text.grid(row=1,column=0,columnspan=3,padx=10,pady=10)
player2_label = Label(window,text='Player 2:')
player2_label.grid(row=0,column=3,sticky='W')
player2_score = Label(window)
player2.grid(row=0,column=4,sticky='W')
player2_text = Text(window,width=30)
player2_text.grid(row=1,column=3,columnspan=3)
action_button = Button(window,text='Play',command=play_action)
action_button.grid(row=2,column=0,columnspan=2)
action_button['state'] = NORMAL
我为do_action()
编写了一个函数,导致打印出来。当我点击动作按钮时,我正在打印的字符串最终出现在解释器而不是文本小部件中。如何指定哪些字符串进入哪个小部件以及小部件的哪个窗口?
答案 0 :(得分:1)