Jump to content

[Python] Graphics Module aligning text


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.