コード例 #1
0
    
    import SPLogging
    SPLogging.set_level('debug')
    SPLogging.start()
    
    from SPWidgets import Init
    
    import pygame
    from pygame.constants import *
    pygame.init() 
    
    from SPSpriteUtils import SPInit
 
    scr = pygame.display.set_mode((800, 600))
    back = scr.convert()
    actives = SPInit(scr, back)
    
    Init('seniorplay')
    
    def observer(state):
        global runloop
        print "observer called with state", state
        if state == 'stop':
            runloop = 0
    
    ####### movieplayer stuff, the rest is crap to mimic a CP environment ##########
    mprect = pygame.Rect(0, 80, 800, 500)
    mppos = mprect.topleft
    hidebuttons = False
    mp = MoviePlayer('test1.mpg', actives, mprect, observer, hidebuttons)
    mp.start()
コード例 #2
0
class SPGreeter:
    """Starts a login screen, this will be a window, not fullscreen.
    """
    def __init__(self, cmd_options, theme='default', vtkb=None, fullscr=None):
        global ACTIVITYDATADIR
        self.logger = logging.getLogger("childsplay.SPgdm.SPGreeter")
        self.logger.debug("Starting")
        self.cmd_options = cmd_options
        self.__name = ''
        captxt = _("Childsplay_sp login")
        if self.cmd_options.theme != 'default':
            captxt = captxt.replace('Childsplay_sp', self.cmd_options.theme)
        ICONPATH = os.path.join(ACTIVITYDATADIR, 'SPData', 'themes',
                                self.cmd_options.theme)
        DEFAULTICONPATH = os.path.join(ACTIVITYDATADIR, 'SPData', 'themes',
                                       'default')
        self.vtkb = vtkb  # is used in the _run_loop
        # setup screen
        size = (800, 600)
        if fullscr:
            self.screen = pygame.display.set_mode(size, FULLSCREEN)
        else:
            self.screen = pygame.display.set_mode(size)
        p = os.path.join(ICONPATH, 'spgdm_back.png')
        if not os.path.exists(p):
            p = os.path.join(DEFAULTICONPATH, 'spgdm_back.png')
        back = load_image(p)
        self.screen.blit(back, (0, 0))
        # get the version image
        vs = "Childsplay_sp version: %s" % Version.version
        if self.cmd_options.theme != 'default':
            vs = vs.replace('Childsplay_sp', self.cmd_options.theme)
        if self.cmd_options.adminmode:
            vs = vs + " (Adminmode)"
        vsurf = char2surf(vs,
                          TTFSIZE - 4, (0, 0, 0),
                          ttf=TTF,
                          bold=True,
                          antialias=False)
        self.screen.blit(vsurf, (300, 0))

        self.actives = SPInit(self.screen, self.screen.convert())

        pygame.display.set_caption(captxt.encode('utf-8'))

        # setup our SP widgets
        label = SPLabel(_("Username:"******"Login")
        but.set_text(t)  # we set the fontsize below

        but.child.create_style()
        but.child.style["font"]["size"] = TTFSIZE
        but.child.style['bgcolor'][ocwc.STATE_NORMAL] = KOBALT_LIGHT_BLUE
        but.create_style()['bgcolor'][ocwc.STATE_NORMAL] = KOBALT_LIGHT_BLUE
        but.connect_signal(ocwc.SIG_CLICKED, self._login_button_callback,
                           self.entry)
        #but.opacity = 255
        but.topleft = (340, 320)
        # We clear the event queue as we sometimes get an crash with the message
        # error: Event queue full
        # Nothing to be found on Google so I've put a clear before the error
        # was generated.
        pygame.event.clear()
        self.renderer.add_widget(but)

        # logout button
        p = os.path.join(ICONPATH, 'spgdm_quit_button.png')
        if not os.path.exists(p):
            p = os.path.join(DEFAULTICONPATH, 'spgdm_quit_button.png')
        but = ocw.ImageButton(p)
        but.create_style()['bgcolor'][ocwc.STATE_NORMAL] = KOBALT_LIGHT_BLUE
        but.connect_signal(ocwc.SIG_CLICKED, self._quit_button_callback, but)
        #but.opacity = 180
        but.topleft = (720, 520)
        self.renderer.add_widget(but)

        # info button
        p = os.path.join(ICONPATH, 'spgdm_info_button.png')
        if not os.path.exists(p):
            p = os.path.join(DEFAULTICONPATH, 'spgdm_info_button.png')
        but = ocw.ImageButton(p)
        #but.set_text(_("Quit"))
        #but.child.create_style()["font"]["size"] = 36
        but.create_style()['bgcolor'][ocwc.STATE_NORMAL] = KOBALT_LIGHT_BLUE
        but.connect_signal(ocwc.SIG_CLICKED, self._info_button_callback, but)
        #but.opacity = 180
        but.topleft = (20, 520)
        self.renderer.add_widget(but)

        self.clock = pygame.time.Clock()
        self.runloop = True

        pygame.display.update()
        # run the virtual keyboard if we have one.
        if self.vtkb:
            self._run_vtkb_loop(self.renderer)
        else:
            # else we run a 'normal' loop.
            self._run_loop()

    def _run_loop(self):
        #self.runloop=0 # Used when profiling this module
        while self.runloop:
            self.clock.tick(30)
            pygame.event.pump()
            events = pygame.event.get()
            for event in events:
                if event.type is KEYDOWN and event.key is K_ESCAPE or event.type is QUIT:
                    self.run_event_loop = False
                    self._quit_button_callback(None)
                elif event.type is KEYDOWN:
                    if self.actives.refresh(event):
                        self._login_button_callback(self.entry)
            self.renderer.distribute_events(*events)

    def _run_vtkb_loop(self, parent_re=None):
        self.vtkb.show()
        kb = self.vtkb.echo_run(parent_re=[parent_re, self.renderer])
        word = []
        while self.runloop:
            try:
                k = kb.next()  # this will return a string or none
                if k and k not in (
                        'quit', 'enter'
                ):  # user hits anything but None, enter or escape
                    word.append(k)
                    self.entry.set_text(''.join(word))
                elif k == 'quit':  # user hits escape
                    self._quit_button_callback()
                    break
                elif k == 'enter':
                    break
            except (StopIteration, VTKEscapeKeyException):
                self._quit_button_callback()
                break

    def _login_button_callback(self, entry):
        self.logger.debug("_login_button_callback called with %s" % entry)
        self.__name = entry.text
        self.runloop = False

    def _quit_button_callback(self, *args):
        self.logger.debug("_quit_button_callback called")
        if not self.cmd_options.noexitquestion:
            dlg = ExitDialog(self.renderer)
            c = dlg.run()
        else:
            c = 0
        if c == 0:
            self.logger.info("User wants exit")
            raise GDMEscapeKeyException  # let schoolsplay.py decide what next

    def _info_button_callback(self, but):
        self.logger.debug("_info_button_callback called")
        d = InfoDialog(self.renderer, SPHelpText.SPgdm._info_button_callback)
        d.run()

    def get_loginname(self):
        return self.__name
コード例 #3
0
    def __init__(self, cmd_options, theme='default', vtkb=None, fullscr=None):
        global ACTIVITYDATADIR
        self.logger = logging.getLogger("childsplay.SPgdm.SPGreeter")
        self.logger.debug("Starting")
        self.cmd_options = cmd_options
        self.__name = ''
        captxt = _("Childsplay_sp login")
        if self.cmd_options.theme != 'default':
            captxt = captxt.replace('Childsplay_sp', self.cmd_options.theme)
        ICONPATH = os.path.join(ACTIVITYDATADIR, 'SPData', 'themes',
                                self.cmd_options.theme)
        DEFAULTICONPATH = os.path.join(ACTIVITYDATADIR, 'SPData', 'themes',
                                       'default')
        self.vtkb = vtkb  # is used in the _run_loop
        # setup screen
        size = (800, 600)
        if fullscr:
            self.screen = pygame.display.set_mode(size, FULLSCREEN)
        else:
            self.screen = pygame.display.set_mode(size)
        p = os.path.join(ICONPATH, 'spgdm_back.png')
        if not os.path.exists(p):
            p = os.path.join(DEFAULTICONPATH, 'spgdm_back.png')
        back = load_image(p)
        self.screen.blit(back, (0, 0))
        # get the version image
        vs = "Childsplay_sp version: %s" % Version.version
        if self.cmd_options.theme != 'default':
            vs = vs.replace('Childsplay_sp', self.cmd_options.theme)
        if self.cmd_options.adminmode:
            vs = vs + " (Adminmode)"
        vsurf = char2surf(vs,
                          TTFSIZE - 4, (0, 0, 0),
                          ttf=TTF,
                          bold=True,
                          antialias=False)
        self.screen.blit(vsurf, (300, 0))

        self.actives = SPInit(self.screen, self.screen.convert())

        pygame.display.set_caption(captxt.encode('utf-8'))

        # setup our SP widgets
        label = SPLabel(_("Username:"******"Login")
        but.set_text(t)  # we set the fontsize below

        but.child.create_style()
        but.child.style["font"]["size"] = TTFSIZE
        but.child.style['bgcolor'][ocwc.STATE_NORMAL] = KOBALT_LIGHT_BLUE
        but.create_style()['bgcolor'][ocwc.STATE_NORMAL] = KOBALT_LIGHT_BLUE
        but.connect_signal(ocwc.SIG_CLICKED, self._login_button_callback,
                           self.entry)
        #but.opacity = 255
        but.topleft = (340, 320)
        # We clear the event queue as we sometimes get an crash with the message
        # error: Event queue full
        # Nothing to be found on Google so I've put a clear before the error
        # was generated.
        pygame.event.clear()
        self.renderer.add_widget(but)

        # logout button
        p = os.path.join(ICONPATH, 'spgdm_quit_button.png')
        if not os.path.exists(p):
            p = os.path.join(DEFAULTICONPATH, 'spgdm_quit_button.png')
        but = ocw.ImageButton(p)
        but.create_style()['bgcolor'][ocwc.STATE_NORMAL] = KOBALT_LIGHT_BLUE
        but.connect_signal(ocwc.SIG_CLICKED, self._quit_button_callback, but)
        #but.opacity = 180
        but.topleft = (720, 520)
        self.renderer.add_widget(but)

        # info button
        p = os.path.join(ICONPATH, 'spgdm_info_button.png')
        if not os.path.exists(p):
            p = os.path.join(DEFAULTICONPATH, 'spgdm_info_button.png')
        but = ocw.ImageButton(p)
        #but.set_text(_("Quit"))
        #but.child.create_style()["font"]["size"] = 36
        but.create_style()['bgcolor'][ocwc.STATE_NORMAL] = KOBALT_LIGHT_BLUE
        but.connect_signal(ocwc.SIG_CLICKED, self._info_button_callback, but)
        #but.opacity = 180
        but.topleft = (20, 520)
        self.renderer.add_widget(but)

        self.clock = pygame.time.Clock()
        self.runloop = True

        pygame.display.update()
        # run the virtual keyboard if we have one.
        if self.vtkb:
            self._run_vtkb_loop(self.renderer)
        else:
            # else we run a 'normal' loop.
            self._run_loop()
コード例 #4
0
ファイル: SPgdm.py プロジェクト: childsplay-mobi/cp-pygame
class SPGreeter:
    """Starts a login screen, this will be a window, not fullscreen.
    """
    def __init__(self, cmd_options, theme='default', vtkb=None, fullscr=None):
        global ACTIVITYDATADIR
        self.logger = logging.getLogger("childsplay.SPgdm.SPGreeter")
        self.logger.debug("Starting")
        self.cmd_options = cmd_options
        self.__name = ''
        captxt = _("Childsplay_sp login")
        if self.cmd_options.theme != 'default':
            captxt = captxt.replace('Childsplay_sp', self.cmd_options.theme)
        ICONPATH = os.path.join(ACTIVITYDATADIR, 'SPData', 'themes', self.cmd_options.theme)
        DEFAULTICONPATH = os.path.join(ACTIVITYDATADIR, 'SPData', 'themes', 'default')
        self.vtkb = vtkb# is used in the _run_loop
        # setup screen
        size = (800, 600)
        if fullscr:
            self.screen = pygame.display.set_mode(size, FULLSCREEN)
        else:
            self.screen = pygame.display.set_mode(size)
        p = os.path.join(ICONPATH, 'spgdm_back.png')
        if not os.path.exists(p):
            p = os.path.join(DEFAULTICONPATH, 'spgdm_back.png')
        back = load_image(p)
        self.screen.blit(back, (0, 0))
        # get the version image
        vs = "Childsplay_sp version: %s" % Version.version
        if self.cmd_options.theme != 'default':
            vs = vs.replace('Childsplay_sp', self.cmd_options.theme)
        if self.cmd_options.adminmode:
            vs = vs + " (Adminmode)"
        vsurf = char2surf(vs, TTFSIZE-4, (0, 0, 0), ttf=TTF, bold=True, antialias=False)
        self.screen.blit(vsurf, (300, 0))
        
        self.actives = SPInit(self.screen, self.screen.convert())
        
        pygame.display.set_caption(captxt.encode('utf-8'))

        # setup our SP widgets
        label = SPLabel(_("Username:"******"Login")
        but.set_text(t)# we set the fontsize below
        
        but.child.create_style()
        but.child.style["font"]["size"] = TTFSIZE
        but.child.style['bgcolor'][ocwc.STATE_NORMAL] = KOBALT_LIGHT_BLUE
        but.create_style()['bgcolor'][ocwc.STATE_NORMAL] = KOBALT_LIGHT_BLUE
        but.connect_signal(ocwc.SIG_CLICKED, self._login_button_callback, self.entry)
        #but.opacity = 255
        but.topleft = (340, 320)
        # We clear the event queue as we sometimes get an crash with the message
        # error: Event queue full
        # Nothing to be found on Google so I've put a clear before the error
        # was generated.
        pygame.event.clear()
        self.renderer.add_widget(but)
        
        # logout button
        p = os.path.join(ICONPATH, 'spgdm_quit_button.png')
        if not os.path.exists(p):
            p = os.path.join(DEFAULTICONPATH, 'spgdm_quit_button.png')
        but = ocw.ImageButton(p)
        but.create_style()['bgcolor'][ocwc.STATE_NORMAL] = KOBALT_LIGHT_BLUE
        but.connect_signal(ocwc.SIG_CLICKED, self._quit_button_callback, but)
        #but.opacity = 180
        but.topleft = (720, 520)
        self.renderer.add_widget(but)
        
        # info button
        p = os.path.join(ICONPATH, 'spgdm_info_button.png')
        if not os.path.exists(p):
            p = os.path.join(DEFAULTICONPATH, 'spgdm_info_button.png')
        but = ocw.ImageButton(p)
        #but.set_text(_("Quit"))
        #but.child.create_style()["font"]["size"] = 36
        but.create_style()['bgcolor'][ocwc.STATE_NORMAL] = KOBALT_LIGHT_BLUE
        but.connect_signal(ocwc.SIG_CLICKED, self._info_button_callback, but)
        #but.opacity = 180
        but.topleft = (20, 520)
        self.renderer.add_widget(but)
        
        self.clock = pygame.time.Clock()
        self.runloop = True
        
        pygame.display.update()
        # run the virtual keyboard if we have one.
        if self.vtkb:
            self._run_vtkb_loop(self.renderer)
        else:
            # else we run a 'normal' loop.
            self._run_loop()
        
    def _run_loop(self):
        #self.runloop=0 # Used when profiling this module
        while self.runloop:
            self.clock.tick(30)
            pygame.event.pump()
            events = pygame.event.get()
            for event in events:
                if event.type is KEYDOWN and event.key is K_ESCAPE or event.type is QUIT:
                    self.run_event_loop = False
                    self._quit_button_callback(None)
                elif event.type is KEYDOWN:
                    if self.actives.refresh(event):
                        self._login_button_callback(self.entry)
            self.renderer.distribute_events( * events)
            
            
    def _run_vtkb_loop(self, parent_re=None):
        self.vtkb.show()
        kb = self.vtkb.echo_run(parent_re=[parent_re, self.renderer])
        word = []
        while self.runloop:
            try:
                k = kb.next()# this will return a string or none
                if k and k not in ('quit', 'enter'):# user hits anything but None, enter or escape
                    word.append(k)
                    self.entry.set_text(''.join(word))
                elif k == 'quit':# user hits escape
                    self._quit_button_callback()
                    break
                elif k == 'enter':
                    break
            except (StopIteration, VTKEscapeKeyException):
                self._quit_button_callback()
                break
                
    def _login_button_callback(self, entry):
        self.logger.debug("_login_button_callback called with %s" % entry)
        self.__name = entry.text
        self.runloop = False

    def _quit_button_callback(self,  * args):
        self.logger.debug("_quit_button_callback called")
        if not self.cmd_options.noexitquestion:
            dlg = ExitDialog(self.renderer)
            c = dlg.run()
        else:
            c = 0
        if c == 0:
            self.logger.info("User wants exit")
            raise GDMEscapeKeyException # let schoolsplay.py decide what next

    def _info_button_callback(self, but):
        self.logger.debug("_info_button_callback called")
        d = InfoDialog(self.renderer, SPHelpText.SPgdm._info_button_callback)
        d.run()

    def get_loginname(self):
        return self.__name
コード例 #5
0
ファイル: SPgdm.py プロジェクト: childsplay-mobi/cp-pygame
    def __init__(self, cmd_options, theme='default', vtkb=None, fullscr=None):
        global ACTIVITYDATADIR
        self.logger = logging.getLogger("childsplay.SPgdm.SPGreeter")
        self.logger.debug("Starting")
        self.cmd_options = cmd_options
        self.__name = ''
        captxt = _("Childsplay_sp login")
        if self.cmd_options.theme != 'default':
            captxt = captxt.replace('Childsplay_sp', self.cmd_options.theme)
        ICONPATH = os.path.join(ACTIVITYDATADIR, 'SPData', 'themes', self.cmd_options.theme)
        DEFAULTICONPATH = os.path.join(ACTIVITYDATADIR, 'SPData', 'themes', 'default')
        self.vtkb = vtkb# is used in the _run_loop
        # setup screen
        size = (800, 600)
        if fullscr:
            self.screen = pygame.display.set_mode(size, FULLSCREEN)
        else:
            self.screen = pygame.display.set_mode(size)
        p = os.path.join(ICONPATH, 'spgdm_back.png')
        if not os.path.exists(p):
            p = os.path.join(DEFAULTICONPATH, 'spgdm_back.png')
        back = load_image(p)
        self.screen.blit(back, (0, 0))
        # get the version image
        vs = "Childsplay_sp version: %s" % Version.version
        if self.cmd_options.theme != 'default':
            vs = vs.replace('Childsplay_sp', self.cmd_options.theme)
        if self.cmd_options.adminmode:
            vs = vs + " (Adminmode)"
        vsurf = char2surf(vs, TTFSIZE-4, (0, 0, 0), ttf=TTF, bold=True, antialias=False)
        self.screen.blit(vsurf, (300, 0))
        
        self.actives = SPInit(self.screen, self.screen.convert())
        
        pygame.display.set_caption(captxt.encode('utf-8'))

        # setup our SP widgets
        label = SPLabel(_("Username:"******"Login")
        but.set_text(t)# we set the fontsize below
        
        but.child.create_style()
        but.child.style["font"]["size"] = TTFSIZE
        but.child.style['bgcolor'][ocwc.STATE_NORMAL] = KOBALT_LIGHT_BLUE
        but.create_style()['bgcolor'][ocwc.STATE_NORMAL] = KOBALT_LIGHT_BLUE
        but.connect_signal(ocwc.SIG_CLICKED, self._login_button_callback, self.entry)
        #but.opacity = 255
        but.topleft = (340, 320)
        # We clear the event queue as we sometimes get an crash with the message
        # error: Event queue full
        # Nothing to be found on Google so I've put a clear before the error
        # was generated.
        pygame.event.clear()
        self.renderer.add_widget(but)
        
        # logout button
        p = os.path.join(ICONPATH, 'spgdm_quit_button.png')
        if not os.path.exists(p):
            p = os.path.join(DEFAULTICONPATH, 'spgdm_quit_button.png')
        but = ocw.ImageButton(p)
        but.create_style()['bgcolor'][ocwc.STATE_NORMAL] = KOBALT_LIGHT_BLUE
        but.connect_signal(ocwc.SIG_CLICKED, self._quit_button_callback, but)
        #but.opacity = 180
        but.topleft = (720, 520)
        self.renderer.add_widget(but)
        
        # info button
        p = os.path.join(ICONPATH, 'spgdm_info_button.png')
        if not os.path.exists(p):
            p = os.path.join(DEFAULTICONPATH, 'spgdm_info_button.png')
        but = ocw.ImageButton(p)
        #but.set_text(_("Quit"))
        #but.child.create_style()["font"]["size"] = 36
        but.create_style()['bgcolor'][ocwc.STATE_NORMAL] = KOBALT_LIGHT_BLUE
        but.connect_signal(ocwc.SIG_CLICKED, self._info_button_callback, but)
        #but.opacity = 180
        but.topleft = (20, 520)
        self.renderer.add_widget(but)
        
        self.clock = pygame.time.Clock()
        self.runloop = True
        
        pygame.display.update()
        # run the virtual keyboard if we have one.
        if self.vtkb:
            self._run_vtkb_loop(self.renderer)
        else:
            # else we run a 'normal' loop.
            self._run_loop()
コード例 #6
0
ファイル: SPDebugDialog.py プロジェクト: sergiomb2/childsplay
    pygame.init()

    from SPSpriteUtils import SPInit
    from SPWidgets import Init

    def cbf(sprite, event, data):
        print 'cb called with sprite %s, event %s and data %s' % (sprite,
                                                                  event, data)
        print 'sprite name: %s' % sprite.get_name()
        print 'data is %s' % data

    scr = pygame.display.set_mode((800, 600))
    scr.fill(LIGHTSKYBLUE1)
    pygame.display.flip()
    back = scr.convert()
    actives = SPInit(scr, back)

    Init('braintrainer')

    db = Debugscreen('none_act', 'BT2.1', scr)
    actives.add(db.get_actives())
    runloop = 1
    while runloop:
        pygame.time.wait(100)
        pygame.event.pump()
        events = pygame.event.get()
        for event in events:
            if event.type is KEYDOWN:
                if event.key == K_ESCAPE:
                    runloop = 0
                elif event.key == K_F1:
コード例 #7
0
    import pygame
    from pygame.constants import *
    pygame.init()
    
    from SPSpriteUtils import SPInit
    from SPWidgets import Init
    def cbf(sprite, event, data):
        print 'cb called with sprite %s, event %s and data %s' % (sprite, event, data)
        print 'sprite name: %s' % sprite.get_name()
        print 'data is %s' % data
    
    scr = pygame.display.set_mode((800, 600))
    scr.fill(LIGHTSKYBLUE1)
    pygame.display.flip()
    back = scr.convert()
    actives = SPInit(scr, back)
    
    Init('braintrainer')

    db = Debugscreen('none_act', 'BT2.1', scr)
    actives.add(db.get_actives())
    runloop = 1 
    while runloop:
        pygame.time.wait(100)
        pygame.event.pump()
        events = pygame.event.get()
        for event in events:
            if event.type is KEYDOWN:
                if event.key == K_ESCAPE:
                    runloop = 0
                elif event.key == K_F1:
コード例 #8
0
ファイル: test.py プロジェクト: childsplay-mobi/cp-pygame
    
    def cbf_but(sprite, event, data=''):
        back = pygame.Surface((300,300))
        back.fill(GREEN)
        but = Button('Dialog Button', (10, 10), padding=6)
        but.connect_callback(cbf, MOUSEBUTTONUP, 'Dialog Button')
        objects =[but]
        
        dlg = DialogWindow(back,objects)
        dlg.run()
    
    scr = pygame.display.set_mode((800, 600))
    scr.fill(GREY90)
    pygame.display.flip()
    back = scr.convert()
    actives = SPInit(scr, back)
    
    Init('braintrainer')
    
#    but = Button('Button', (10, 80), padding=6)
#    but.connect_callback(cbf_but, MOUSEBUTTONUP, 'Button')
#    actives.add(but)
#    lbl = Label('Hit escape key to continue', (10, 130))
#    r = pygame.Rect(0, 0, 500, 240)
#    txt = "This program is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation.  A copy of this license should be included in the file GPL-3."
#    
#    tv = TextView(txt, (290, 180), r, autofit=True, border=True)
#    tv.display_sprite()
#    
#    va = VolumeAdjust((200, 20))
#    va.display()
コード例 #9
0
if __name__ == '__main__':
    
    import __builtin__
    __builtin__.__dict__['_'] = lambda x:x
    
    import SPLogging
    SPLogging.set_level('debug')
    SPLogging.start()
    
    pygame.init()
    
    from SPSpriteUtils import SPInit
    
    def cbf(sprite, event, data=''):
        print 'cb called with sprite %s, event %s and data %s' % (sprite, event, data)
        print 'sprite name: %s' % sprite.get_name()
        print 'data is %s' % data
    
    scr = pygame.display.set_mode((800, 600))
    scr.fill(GREY90)
    pygame.display.flip()
    back = scr.convert()
    actives = SPInit(scr, back)
    
    SPWidgets.Init('braintrainer')
    
    b = birthday(scr, back)
    b.run()
    

コード例 #10
0
    def cbf_but(sprite, event, data=''):
        back = pygame.Surface((300, 300))
        back.fill(GREEN)
        but = Button('Dialog Button', (10, 10), padding=6)
        but.connect_callback(cbf, MOUSEBUTTONUP, 'Dialog Button')
        objects = [but]

        dlg = DialogWindow(back, objects)
        dlg.run()

    scr = pygame.display.set_mode((800, 600))
    scr.fill(GREY90)
    pygame.display.flip()
    back = scr.convert()
    actives = SPInit(scr, back)

    Init('braintrainer')

    #    but = Button('Button', (10, 80), padding=6)
    #    but.connect_callback(cbf_but, MOUSEBUTTONUP, 'Button')
    #    actives.add(but)
    #    lbl = Label('Hit escape key to continue', (10, 130))
    #    r = pygame.Rect(0, 0, 500, 240)
    #    txt = "This program is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation.  A copy of this license should be included in the file GPL-3."
    #
    #    tv = TextView(txt, (290, 180), r, autofit=True, border=True)
    #    tv.display_sprite()
    #
    #    va = VolumeAdjust((200, 20))
    #    va.display()