I'm trying to add in some pyHook in order to make it work in the background actually. This is as far as I've gotten. I believe I've messed up the def or the actual function but I'm just slamming my head against a wall at this point. Can only learn so much so fast. 5 bucks on it's a total mess and I should start over. LOL
Ideas? Error Message : Traceback (most recent call last): File "C:/Python27/Deathcounterv3", line 34, in <module> events = OnKeyboardEvent.event.get() AttributeError: 'function' object has no attribute 'event' Code : # Death Counter import sys import pygame from pygame.locals import * import pyHook #PyGame creates the window pygame.display.init() BLACK = (0,0,0) WIDTH = 320 HEIGHT = 260 windowSurface = pygame.display.set_mode((WIDTH, HEIGHT), 0, 32) windowSurface.fill(BLACK) # create a keyboard hook def OnKeyboardEvent(event): print 'MessageName:',event.MessageName print 'Message:',event.Message print 'Time:',event.Time print 'Window:',event.Window print 'WindowName:',event.WindowName print 'Ascii:', event.Ascii, chr(event.Ascii) print 'Key:', event.Key print 'KeyID:', event.KeyID print 'ScanCode:', event.ScanCode print 'Extended:', event.Extended print 'Injected:', event.Injected print 'Alt', event.Alt print 'Transition', event.Transition print '---' while True: events = OnKeyboardEvent.event.get() for event in events: if event.type==KEYDOWN: if event.key == K_1: with open("deathcounter.txt", "rt") as in_file: deathcount = int(in_file.read()) #store an integer deathcount = deathcount + 1 with open("deathcounter.txt", "wt") as out_file: out_file.write(str(deathcount)) if event.key == K_2: deathcount = 0 with open("deathcounter.txt", "wt") as out_file: out_file.write(str(deathcount)) print deathcount if event.type == QUIT: pygame.quit() sys.exit() # create a hook manager hm = pyHook.HookManager() # watch for all keyboard events hm.KeyDown = OnKeyboardEvent # set the hook hm.HookKeyboard() # initialize pygame and start the game loop pygame.init() while(1): pygame.event.pump() -- View this message in context: http://pygame-users.25799.x6.nabble.com/Requesting-a-hand-with-a-simple-Death-Counter-tp1481p1486.html Sent from the pygame-users mailing list archive at Nabble.com.