-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
27 lines (19 loc) · 748 Bytes
/
main.py
File metadata and controls
27 lines (19 loc) · 748 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import tkinter as tk
from tkinter import Entry, Button, IntVar, Label
root = tk.Tk()
root.config(bd=4)
pesel = IntVar()
def check_pesel():
e = E.get()
first_10 = 1*int(e[0])+3*int(e[1])+7*int(e[2])+9*int(e[3])+1*int(e[4])+3*int(e[5])+7*int(e[6])+9*int(e[7])+1*int(e[8])+3*int(e[9])
last = 10 - int(str(first_10)[-1])
if str(last)[-1] == str(e)[-1]:
B.config(text="PESEL jest prawidłowy", fg='green')
else:
B.config(text="Podano niewłaściwy PESEL", fg='red')
L = tk.Label(root, text='PESEL: ').grid(row=0, column=0, sticky='W')
E = tk.Entry(root, textvariable=pesel)
E.grid(row=0, column=1)
B = tk.Button(root, text='Sprawdz PESEL', command=check_pesel)
B.grid(row=1, columnspan=2)
root.mainloop()