Skip to content

Commit

Permalink
Fix playercard issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Hunter committed Sep 30, 2016
1 parent b50a57d commit 8e3824f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion application.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, master):
# will be the one that is visible.
frame.grid(column=0, row=1, sticky='news')

self.show_frame(Login)
self.show_frame(PlayerSearch)

def show_frame(self, c, **kwargs):
'''Show a frame for the given class'''
Expand Down
17 changes: 9 additions & 8 deletions core/playercard.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def create(player, cards=None, cardinfo=None):
cardinfo[player['color']]['width'],
cardinfo[player['color']]['position'] + cardinfo[player['color']]['height']
))

card = Image.new("RGB", cardbg.size, (29, 147, 171))
card.paste(cardbg, cardbg)

Expand All @@ -39,32 +40,32 @@ def create(player, cards=None, cardinfo=None):
r = requests.get(player['specialImages']['largeTOTWImgUrl'])
else:
r = requests.get(player['headshot']['largeImgUrl'])
headshot = Image.open(BytesIO(r.content))
card.paste(headshot, (cardinfo[player['color']]['width']-headshot.size[1]-3, 40), headshot)
headshot = Image.open(BytesIO(r.content)).convert('RGBA')
card.paste(headshot, (cardinfo[player['color']]['width']-headshot.size[1]-7, 40), headshot)

# Rating
renderedSize = _font25.getsize(str(player['rating']))
rating = Image.new('RGBA', renderedSize, (255, 255, 255, 0))
d = ImageDraw.Draw(rating)
d.text((0, 0), str(player['rating']), font=_font25, fill=(54, 33, 27, 255))
card.paste(rating, (45, 20), rating)
card.paste(rating, (42, 30), rating)

# Position
renderedSize = _font25.getsize(str(player['position']))
position = Image.new('RGBA', renderedSize, (255, 255, 255, 0))
d = ImageDraw.Draw(position)
d.text((0, 0), str(player['position']), font=_font16, fill=(54, 33, 27, 255))
card.paste(position, (45, 50), position)
card.paste(position, (42, 60), position)

# club image
r = requests.get(player['club']['imageUrls']['normal']['large'])
club = Image.open(BytesIO(r.content))
card.paste(club, (38, 76), club)
club = Image.open(BytesIO(r.content)).convert('RGBA')
card.paste(club, (35, 85), club)

# nation image
r = requests.get(player['nation']['imageUrls']['large'])
nation = Image.open(BytesIO(r.content))
card.paste(nation, (38, 123), nation)
nation = Image.open(BytesIO(r.content)).convert('RGBA')
card.paste(nation, (35, 130), nation)

if player['color'][0:3] == 'tot':
fillColor = (255, 234, 128, 255)
Expand Down
4 changes: 2 additions & 2 deletions frames/playersearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ def kill_job(self):

def active(self):
Base.active(self)
if self.controller.api is None:
self.controller.show_frame(Login)
# if self.controller.api is None:
# self.controller.show_frame(Login)

# Backwards compatability
if isinstance(self._playerFile, list):
Expand Down

0 comments on commit 8e3824f

Please sign in to comment.