Login Generator with MVC -> finish
This commit is contained in:
parent
021a26838c
commit
6d238e1571
|
@ -2676,7 +2676,7 @@ for question in data["results"]:
|
||||||
choices.append(question["correct_answer"])
|
choices.append(question["correct_answer"])
|
||||||
choices.extend(question["incorrect_answers"])
|
choices.extend(question["incorrect_answers"])
|
||||||
for choice in enumerate(choices):
|
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.
|
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
|
## Tkinter guess the number
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
import time
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
@ -2929,30 +2929,36 @@ class MainWindow(Frame):
|
||||||
MyNumber = random.randint(0, 100)
|
MyNumber = random.randint(0, 100)
|
||||||
|
|
||||||
#Label
|
#Label
|
||||||
MyLabel = Label(MyPanel, text="I have a number in mind...", bg= "blue")
|
self.MyLabel = Label(MyPanel, text="I have a number in mind...", bg= "blue")
|
||||||
MyLabel.pack(fill="x", ipadx=25, ipady=20)
|
self.MyLabel.pack(fill="x", ipadx=25, ipady=20)
|
||||||
#TextBox
|
#TextBox
|
||||||
MyEntry = Entry(MyPanel)
|
MyEntry = Entry(MyPanel)
|
||||||
MyEntry.place(x=200,y=90)
|
MyEntry.place(x=200,y=90)
|
||||||
#Bouton
|
#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)
|
MyButton.place(x=10, y=90)
|
||||||
|
|
||||||
self.pack(fill=BOTH,expand=True)
|
self.pack(fill=BOTH,expand=True)
|
||||||
|
|
||||||
|
|
||||||
def ButtonEnable(self, MyLabel, MyEntry, MyNumber):
|
def ButtonEnable(self, MyEntry, MyNumber):
|
||||||
if self.IsCorrect(MyEntry.get()):
|
if self.IsCorrect(MyEntry.get()):
|
||||||
number = int(MyEntry.get())
|
number = int(MyEntry.get())
|
||||||
if number > MyNumber:
|
if number != MyNumber:
|
||||||
MyLabel.config(text="My number is smaller")
|
self.GameOver(number, MyNumber)
|
||||||
elif number < MyNumber:
|
|
||||||
MyLabel.config(text="My number is bigger")
|
|
||||||
else:
|
else:
|
||||||
MyLabel.config(text="You WIN!")
|
self.Win()
|
||||||
else:
|
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):
|
def IsCorrect(self, MyEntry):
|
||||||
x = str(MyEntry)
|
x = str(MyEntry)
|
||||||
|
|
Loading…
Reference in New Issue