将我的python代码集成到Tkinter

时间:2016-11-12 00:44:28

标签: python tkinter

我正在学习python(初学者),我想整合一个编写的代码Tkinter。 该程序通过输入'接收动词。并将其发送给检查动词状态的函数并显示其结合。

我想做的是:

  • 一个'条目'接受动词
  • A' Frame'包含结合的结果

我只知道Tkinter的基本功能,我认为你可以帮助我理解它们。

(谷歌翻译的一些文字,我是讲法语的人)先谢谢你了!

一个例子

def verification(verb):
    radical=verb[0:-2]
    subjects=["je","tu","il","nous","vous","ils"]
    termination=["e","es","e","ons","ez","ent"]
    for i in range(0,6):
        print(subjects[i],radical+termination[i])

verb = input("give a verb : ")
verification(verb)

1 个答案:

答案 0 :(得分:0)

不考虑样式/布局,可以这样做:

from tkinter import *

window = Tk()                     
window.title("")

def verification():                 
    verb = verb_entry.get()
    radical=verb[0:-2]
    subjects=["je","tu","il","nous","vous","ils"]
    termination=["e","es","e","ons","ez","ent"]
    for i in range(len(conjugated_verbs)):
        conjugated_verbs[i].configure(text=subjects[i]+" "+radical+termination[i])
        conjugated_verbs[i].pack()

verb_entry = Entry(window)
verb_entry.pack()

button = Button(window,text="Conjugate",command=verification)
button.pack()

conjugated_verbs = []
for x in range(6):
    conjugated_verbs.append(Label(window))

window.mainloop()