School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,464 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,654 people online right now. Registration is fast and FREE... Join Now!




[python] How to get rid of these weird boxes when loading text from a

 

[python] How to get rid of these weird boxes when loading text from a

xZachtmx

17 Jun, 2009 - 05:18 PM
Post #1

New D.I.C Head
*

Joined: 14 Jun, 2009
Posts: 38



Thanked: 1 times
My Contributions
Ok im making an alarm clock widget with pygame to draw the text to the screen.
Here is the code:
CODE

import pygame
import time
import sys
from pygame.locals import*
from sys import exit
pygame.init()

windowSize = 600,300

frameRate = 1

#intializing the window
gameWindow = pygame.display.set_mode((windowSize))
pygame.display.set_caption('Zach\'s Alarm clock')
screen = pygame.display.get_surface()

#clocks
# cpu time

clock = time.time()

# counts out seconds
ticker = pygame.time.Clock()

timeFont = pygame.font.Font(None, 120)
dateFont = pygame.font.Font(None, 25)
while True:
    # Limit frame speed to 50 FPS
    #
     time_passed = ticker.tick(frameRate)
    
     #loading alarm time
     file = open("alarm.txt","r")
     alarmHour = file.readline()
     alarmMinute =file.readline()
     file.close()
    
     digiTime = time.strftime('%H:%M:%S')
    
     date = time.strftime("%Y-%m-%d")
    
     # Render the text
     timeText = timeFont.render(digiTime, True, (255, 0, 0), (0, 0, 0))
              
     dateText = dateFont.render(date, True, (0, 255, 0), (0, 0, 0))
     dateTextPosition = (15, 15)    
    
     alarmText = dateFont.render( "Alarm: " + alarmHour + ":" + alarmMinute, True, (0,0,255))  
     alarmTextPosition = (250, 15)      

     # Create a rectangle
     textRect = timeText.get_rect()

     # Center the rectangle
     textRect.centerx = screen.get_rect().centerx
     textRect.centery = screen.get_rect().centery

     # Blit the text
     screen.blit(timeText, textRect)
     screen.blit(dateText, dateTextPosition)
     screen.blit(alarmText, alarmTextPosition)
    
                                                          
     pygame.event.pump()

     keyBState = pygame.key.get_pressed()
    
     if keyBState[K_ESCAPE]:
        exit()
        
     pygame.display.flip()


and the only stuff in the text file are:
CODE

2
55

so its sucessfuly loading the numbers but at the end of both numbers are two rectangular boxes which arent in the text file when i look at it... but it apears to be there as you can see for youself:
Attached Image

Can somone PLEASE help me with this?


User is offlineProfile CardPM
+Quote Post


xZachtmx

RE: [python] How To Get Rid Of These Weird Boxes When Loading Text From A

18 Jun, 2009 - 08:16 AM
Post #2

New D.I.C Head
*

Joined: 14 Jun, 2009
Posts: 38



Thanked: 1 times
My Contributions
Nevermind. I fixxed it by trimming the boxes of the end.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 02:24AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month