Jump to content

[Python] Graphics Module aligning text


Noskiw

Recommended Posts

from graphics import *
win = GraphWin("Players",300,600)
def printPlayers(fileRead,Position):
   y = 20
   LineSplit = Read.split('\n')
   for x in range(len(LineSplit)-1):
    CellSplit = LineSplit[x].split(',')
    if CellSplit[1] == Position:
	    a = Text(Point(100,y),CellSplit[0])
	    a.draw(win)
	    y+=20
f = open("players.csv","r")
Read = f.read()
printPlayers(Read,"MF")
win.getMouse()
win.close()

 

What I'm trying to do is perfectly align the player's names to a certain point, and right now, they look like this.

 

problem.png

 

What I want to do is to align them so they start at the same pixel, so they are left aligned. I have attached the whole thing including the players database file in a RAR file so that you may use this and see how it works. Thanks. (This is just a test for the entire project, it is a Fantasy Football League for the Npower Championship)

 

PlayersDatabase.zip

Link to comment
https://forums.phpfreaks.com/topic/273191-python-graphics-module-aligning-text/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.