-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfindPlayer.py
More file actions
74 lines (55 loc) · 2.22 KB
/
findPlayer.py
File metadata and controls
74 lines (55 loc) · 2.22 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import urllib
import json
from bs4 import BeautifulSoup
from bs4 import element
import xml.etree.ElementTree as ET
from pymongo import MongoClient
from Tkinter import *
import ttk
client = MongoClient()
db = client.cricket
collection = db.statistics
Pname = "MS Dhoni"
def getPlayerInfo():
result = collection.find_one({"player.fullName" : { '$regex': '.*'+playerName.get()+'.*', '$options': 'i' }})
if result == None:
resultName.set("Not found")
resultNationality.set("Not Found")
else:
resultName.set(result['player']['fullName'])
resultNationality.set(result['player']['nationality'])
print(result['player']['fullName'])
for matchType in result['stats']:
if matchType['matchType'] == "IPLT20":
for a,b in matchType['battingStats'].items():
formattedResult = str(a) + ": " + str(b)
print formattedResult
print ("====================================")
#stats = (result['stats']['nationality'])
def calculate(*args):
try:
value = float(playerName.get())
resultName.set((0.3048 * value * 10000.0 + 0.5)/10000.0)
except ValueError:
pass
root = Tk()
root.title("Player Search")
mainframe = ttk.Frame(root,padding="3 3 12 12")
mainframe.grid(column=0,row=0,sticky=(N,W,E,S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0,weight =1)
playerName = StringVar()
resultName = StringVar()
resultNationality = StringVar()
playerName_entry = ttk.Entry(mainframe, width=50, textvariable=playerName)
playerName_entry.grid(column=2, row=1, sticky=(W, E))
ttk.Label(mainframe, textvariable=resultName).grid(column=2, row=2, sticky=(W, E))
ttk.Button(mainframe, text="Calculate", command=getPlayerInfo).grid(column=3, row=3, sticky=W)
ttk.Label(mainframe, text="Name").grid(column=1, row=1, sticky=W)
ttk.Label(mainframe, text="Player: ").grid(column=1, row=2, sticky=E)
ttk.Label(mainframe, text="Nationality: ").grid(column=3, row=2, sticky=W)
ttk.Label(mainframe, textvariable=resultNationality).grid(column=4, row=2, sticky=W)
for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5)
playerName_entry.focus()
root.bind('<Return>', calculate)
root.mainloop()