I NEED HELP!!! I am trying to make a program somewhat like keynote or powerpoint in python, and I need to know how to make text evenly spread out from the center on the y-axis, I can do that on the x-axis.

If you dont get what I am saying here is an example:
Right now I can start in reverse order from the bottom or top

I want it to be even along the x axis too, but I can't think of a way to do that besides a lot of if statements
if numoflines == 1:
if numoflines == 2:

I can do that on the x-axis.
I want it to be even along the x axis too, but I can't think of a way to do that

Can you give more detail? Are you using a graphics toolkit? What type of interface are we talking here?

I am using pygame and IDLE. I can't think of any more info besides "I just need to be able to print multiple lines that are all equally spaced from the dead center of the screen"

Can you give us the basic framework of your program? You can cut out all the bindings and special functions, just demonstrate how you set up your 'GUI'.

Since I would probably leave something important out, here is all of the code.

PS. If you could help with why the background isn't working, that would be great.

import os, sys, pygame
textname = raw_input("Name of NPresent file (without extension): ")
if textname == "":
    print "You must enter the name of a NPresent file!"
textname += ".npresent"
if os.sys.platform == 'darwin':
    comppath = os.getcwd() + "/Projects/" + textname
if os.sys.platform == 'win32' or os.sys.platform == 'win64':
    comppath = os.getcwd() + "\\Projects\\" + textname
if not os.path.exists(comppath):
    print "No such file!"
file1 = open(comppath, "r")
contents = file1.readlines()
linenum = 0
for line in contents:
    linenum += 1
bkgcheck = contents[linenum - 2]
colcheck = contents[linenum - 1]
if  bkgcheck[0:10] == "backround:":
    bkg = bkgcheck[10:]
    print os.path.exists(bkg)
    if os.path.exists(bkg) == False:
        print "Invaild backround filepath"
        print "Defaulting to black..."
if colcheck[0:11] == "text color:":
    color = colcheck[11:]
    txtcolor = eval(color)
slide = 1
print "Use arrow keys to change slides"
print "Press any key to begin"
screen = pygame.display.set_mode((1024, 768), pygame.FULLSCREEN, 32)
font = pygame.font.get_default_font()
thefont = pygame.font.Font(font,48)
linenum = 0
for x in range(0,len(contents)):
    text = thefont.render(contents[len(contents)-(x+1)], True, txtcolor)
    textpos = text.get_rect(centerx=512, centery = y)
    screen.blit(text, textpos)
    y -= 55

while 1:
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
        if event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT:
            slide -= 1
        if event.type == pygame.KEYDOWN and event.key == pygame.K_RIGHT:
            slide += 1
        # if slide == 0 or slide == (is greater than the num in file):
        if slide == 0:

Also, there is a corresponding text file for it that contains all of the stuff to display. In essence, what the editor will spit out.

backround:(Path to any image pygame can handle)
text color:tuple((255,255,255,255))

one last thing, I know I have not implemented the feature to display the background yet, but as you may have seen, the program says the legitimate path doesn't exist.

And as a note, you can get rid of all the extra event.type == pygame.KEYDOWN by using that as one conditional and sticking everything else under it; something like this:

if event.type == pygame.KEYDOWN:
    if event.key == pygame.ESCAPE:
    if event.key == pygame.K_LEFT:
        slide -= 1
    # ETC
This article has been dead for over six months. Start a new discussion instead.