问题描述
所以我要重做一个帖子,因为我无法解决此问题。我有该程序的2个部分,我想将它们结合起来。
我有一个Tkinter部件,我想连接到我的程序,但是我做不到,也许有错误或需要修改。我是python的新手,我并不总是了解所有内容。
Tkinter的一部分(该程序不是我制作的,我可能需要更改一些东西):
from tkinter import *
root = Tk()
root.geometry('372x362')
root.configure(bg="pink")
Label(root,text='Homme',bg="pink",fg="black").grid(row=0,column=1)
Label(root,text='Femme',column=3)
Male = Entry(root)
Male.grid(row=1,text='&',fg="black").grid(row=1,column=2)
Female = Entry(root)
Female.grid(row=1,column=3)
def compare():#comparison function
MaleEntry = Male.get()
FemaleEntry = Female.get()
if MaleEntry == FemaleEntry:
Label(root,text='Mauvais Match 0%',bg="red",fg="white").grid(row=4,column=2)
else:
Label(root,text='Match Parfait 100%',bg="green",column=2)
Button(root,text='Test de Compatibilité',command=compare,bg="purple",fg="white",bd=4).grid(row=2,column=2)
root.mainloop()
我的角色:
class Candidat: #Subject class (characteristics)
def __init__(self,genre,humour,physique,intelligence,projet):
self.genre=genre
self.humour=humour
self.physique=physique
self.intelligence=intelligence
self.projet=projet
def compare(Test1,Test2): #comparison fonction
#Match à 100% :
if Test1.humour==Test2.humour and Test1.physique==Test2.physique and Test1.intelligence==Test2.intelligence and Test1.projet==Test2.projet:
print("Match Parfait : 100%")
elif Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match")
#Match à 75% :
if Test1.humour!=Test2.humour and Test1.physique==Test2.physique and Test1.intelligence==Test2.intelligence and Test1.projet==Test2.projet:
print("Mauvais Match : 75%")
elif Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match1")
if Test1.humour==Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence==Test2.intelligence and Test1.projet==Test2.projet:
print("Mauvais Match : 75%")
elif Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match2")
if Test1.humour==Test2.humour and Test1.physique==Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet==Test2.projet:
print("Mauvais Match : 75%")
elif Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match3")
if Test1.humour==Test2.humour and Test1.physique==Test2.physique and Test1.intelligence==Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match : 75%")
elif Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match4")
#Match à 50% :
if Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence==Test2.intelligence and Test1.projet==Test2.projet:
print("Mauvais Match : 50%")
elif Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match01")
if Test1.humour!=Test2.humour and Test1.physique==Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet==Test2.projet:
print("Mauvais Match : 50%")
elif Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match02")
if Test1.humour!=Test2.humour and Test1.physique==Test2.physique and Test1.intelligence==Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match : 50%")
elif Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match03")
if Test1.humour==Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet==Test2.projet:
print("Mauvais Match : 50%")
elif Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match04")
if Test1.humour==Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence==Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match : 50%")
elif Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match602")
if Test1.humour==Test2.humour and Test1.physique==Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match : 50%")
elif Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match103")
#Match à 25% :
if Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet==Test2.projet:
print("Mauvais Match : 25%")
elif Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match001")
if Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence==Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match : 25%")
elif Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match002")
if Test1.humour==Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match : 25%")
elif Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match003")
if Test1.humour!=Test2.humour and Test1.physique==Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match : 25%")
elif Test1.humour!=Test2.humour and Test1.physique!=Test2.physique and Test1.intelligence!=Test2.intelligence and Test1.projet!=Test2.projet:
print("Mauvais Match004")
#characteristics
hommes = {}
femmes = {}
Bryan=Candidat("homme",4,5,3,2)
Adrien=Candidat("homme",2,3)
Marin=Candidat("homme",3)
Alcaraz=Candidat("homme",1)
Allan=Candidat("homme",1)
Seby =Candidat("homme",1)
hommes['Bryan'] = Bryan
hommes['Adrien'] = Adrien
hommes['Marin'] = Marin
hommes['Alcaraz'] = Alcaraz
hommes['Allan'] = Allan
hommes['Seby'] = Seby
#--------------------------------#
Anissa=Candidat("femme",0)
Melanie=Candidat("femme",3)
Dita =Candidat("femme",2)
LeaMary=Candidat("femme",1)
Maisanne=Candidat("femme",1)
Kellyn=Candidat("femme",1)
femmes['Anissa'] = Anissa
femmes['Melanie'] = Melanie
femmes['Dita'] = Dita
femmes['LeaMary'] = LeaMary
femmes['Maisanne'] = Maisanne
femmes['Kellyn'] = Kellyn
homme = input("Choisir le prénom d'un homme : ")#input Man
femme = input("Choisir le prénom d'une femme : ")#input Woman
compare(hommes[homme],femmes[femme])
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)