kivy

时间:2016-02-05 13:27:21

标签: python combinations kivy

我开发了一个脚本,显示给定单词的组合

main.py(没有我完成的所有导入)

class Combinations(Popup):
def present(self):
    import itertools
    import sys
    a=str(self.word.text)
    count=0
    if len(a)>=6:
        os.startfile("e:\\Python27\\My programs\\Novos\\beta\\combinations.py")
    else:
        for h in itertools.permutations(a):
            count=count+1
            x=count, ''.join(h)
            x=str(x)
            x="\n"+x
            self.sh.text+=(str(x))
    self.sh.text+=(str("\nThere are {0} combinations of {1}".format(count,a)))

和相应的.kv文件

<Combinations>:
size_hint: .5, .9
title:"Permutations and Combinations"
word:wo
sh:sh
BoxLayout:
    orientation:"vertical"
    TextInput:
        id:wo
        text:""
        font_name:"Roboto-Light.ttf"
        font_size:30
    Button:
        text:"Done"
        on_press:root.present()
    TextInput:
        id:sh
        text:""
        multiline:True
        readonly:True
    Button:
        text:"Close"
        on_press:root.dismiss()

只有当单词长度为5个字母时,一切正常,否则kivy界面会挂起,我必须强行关闭它。

有人可以回答吗?

0 个答案:

没有答案