Reputation: 31
I'm looking for a way to add a python GUI, but an interface with inputs and then give me a comparison result afterwards.
So I would like to know how I could do to get what I want. My part of the program works, (thanks to your help by the way :) but I would like to go even further in this project but being a beginner in this field and especially in python language it's very complicated for me and explanations on the internet are a bit complicated for me so I call on you as a last resort!
You'll find my program below and a visual representation of what I would like to achieve in the end attached.
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",4,3,2,3)
Marin=Candidat("homme",5,2,4,3)
Alcaraz=Candidat("homme",4,3,2,1)
Allan=Candidat("homme",4,3,2,1)
Seby =Candidat("homme",4,3,2,1)
hommes['Bryan'] = Bryan
hommes['Adrien'] = Adrien
hommes['Marin'] = Marin
hommes['Alcaraz'] = Alcaraz
hommes['Allan'] = Allan
hommes['Seby'] = Seby
#--------------------------------#
Anissa=Candidat("femme",0,5,2,0)
Melanie=Candidat("femme",5,3,4,3)
Dita =Candidat("femme",4,4,3,2)
LeaMary=Candidat("femme",4,3,2,1)
Maisanne=Candidat("femme",4,3,2,1)
Kellyn=Candidat("femme",4,3,2,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])
Desired example:
Upvotes: 1
Views: 245
Reputation: 143
heres a simple demonstration.
from tkinter import *
root = Tk()
root.geometry('250x100')
Label(root,text='Male').grid(row=0,column=0)
Label(root,text='Female').grid(row=0,column=2)
Male = Entry(root)
Male.grid(row=1,column=0)
Label(root,text='&').grid(row=1,column=1)
Female = Entry(root)
Female.grid(row=1,column=2)
def test():
MaleEntry = Male.get()
FemaleEntry = Female.get()
#you can change the the conditions
if MaleEntry == FemaleEntry:
Label(root,text='0% compatibility').grid(row=2,column=0)
else:
Label(root,text='100% compatibility').grid(row=2,column=0)
Button(root,text='Test Compatibility',command=test).grid(row=2,column=2)
root.mainloop()
Upvotes: 1
Reputation: 143
if your looking for a basic GUI module in python that can achieve what you want you would be looking at learning Tkinter python check the following link for the entry widget: https://www.geeksforgeeks.org/python-tkinter-entry-widget/ and for the labels the following link: https://www.geeksforgeeks.org/python-tkinter-label/
Helpful videos: https://www.youtube.com/watch?v=ITaDE9LLEDY&ab_channel=EssentialEngineering https://www.youtube.com/watch?v=pD6a9MoQCVc&ab_channel=JohnPhilipJones
Tkinter tutorials: https://www.youtube.com/watch?v=yQSEXcf6s2I&list=PLCC34OHNcOtoC6GglhF3ncJ5rLwQrLGnV&ab_channel=Codemy.com
Upvotes: 0