-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathleaderboard.py
30 lines (27 loc) · 1.09 KB
/
leaderboard.py
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
28
29
30
from tkinter import *
def draw_leaderboard(c, p, id):
if len(p) == 0:
return c
mx = c.winfo_reqwidth()
szx = 140
szy = 30 * len(p)
if len(p) > 0:
step = szy / len(p)
else:
step = 10
c.create_rectangle(mx - szx, 0, mx + 2, szy + 30, outline = 'red', dash=(3,5))
h = 10
c.create_text(5 + mx - szx / 2, h, text='Leaderboard', font=('Comic Sans MS', 15))
for i in range(len(p)):
s = str(i + 1) + '.'
s += ' ' + p[i]['name']
if p[i]['id'] == id:
c.create_text(mx - szx / 2, h + 20 + i*step + 10, fill='red', text=s, font=('Times New Roman', 12), activefill='blue')
else:
c.create_text(mx - szx / 2, h + 20 + i*step + 10, fill='black', text=s, font=('Times New Roman', 12), activefill='blue')
#c.create_text(mx-szx + 10, h + 20 + i*(szy - h - 20)/10 + 10, fill='red', text=s, anchor='w', font=('Times New Roman', 12))
return c
def draw_mass(c, a):
my = c.winfo_reqheight()
c.create_text(5, my-15, anchor='w', font=('Comin Sans MS', 12), text=str(a), fill='grey')
return c