Login Generator with MVC -> finish

This commit is contained in:
Yousri 2022-04-25 11:56:16 +02:00
parent 021a26838c
commit 6d238e1571
1 changed files with 22 additions and 16 deletions

View File

@ -2676,7 +2676,7 @@ for question in data["results"]:
choices.append(question["correct_answer"])
choices.extend(question["incorrect_answers"])
for choice in enumerate(choices):
print(html.unescape("\t {} {}".format(*choice)))```
print(html.unescape("\t {} {}".format(*choice)))
```
You can get some *inspiration* from a small project I did for an other course.
@ -2917,7 +2917,7 @@ if __name__ == "__main__":
## Tkinter guess the number
```python
import time
from tkinter import *
import random
@ -2929,30 +2929,36 @@ class MainWindow(Frame):
MyNumber = random.randint(0, 100)
#Label
MyLabel = Label(MyPanel, text="I have a number in mind...", bg= "blue")
MyLabel.pack(fill="x", ipadx=25, ipady=20)
self.MyLabel = Label(MyPanel, text="I have a number in mind...", bg= "blue")
self.MyLabel.pack(fill="x", ipadx=25, ipady=20)
#TextBox
MyEntry = Entry(MyPanel)
MyEntry.place(x=200,y=90)
#Bouton
MyButton = Button(MyPanel, text="I'm clickable!", command=lambda : self.ButtonEnable(MyLabel,MyEntry, MyNumber))
MyButton = Button(MyPanel, text="I'm clickable!", command=lambda : self.ButtonEnable(MyEntry, MyNumber))
MyButton.place(x=10, y=90)
self.pack(fill=BOTH,expand=True)
def ButtonEnable(self, MyLabel, MyEntry, MyNumber):
def ButtonEnable(self, MyEntry, MyNumber):
if self.IsCorrect(MyEntry.get()):
number = int(MyEntry.get())
if number > MyNumber:
MyLabel.config(text="My number is smaller")
elif number < MyNumber:
MyLabel.config(text="My number is bigger")
if number != MyNumber:
self.GameOver(number, MyNumber)
else:
MyLabel.config(text="You WIN!")
self.Win()
else:
MyLabel.config(text="I need numbers!")
self.MyLabel.config(text="I need numbers!")
def GameOver(self, number, MyNumber):
if number > MyNumber:
self.MyLabel.config(text="My number is smaller")
else:
self.MyLabel.config(text="My number is bigger")
def Win(self):
self.MyLabel.config(text="You WIN!")
def IsCorrect(self, MyEntry):
x = str(MyEntry)