示例#1
0
class WindowInput(WindowUser):

    def __init__(self, text=""):
        WindowUser.__init__(self, 440, 90)
        self.create_cadre_text(text)
        self.create_valid_cancel()
    
    def create_cadre_text(self, text):
        width, height = self.contents_size
        mt = self.offsettext
        self.widget = InputText(mt, 0, text, width=width-2*mt, parent = self)
        self.widget.active = True
        
        
    def update(self, event):
        result = WindowUser.update(self, event)
        if result != None:
            pygame.event.clear()
            if result:
                return self.widget.text
            else:
                return ""
        else:
            self.widget.update(event)
            return None
    
    def draw(self, surf):
        self.widget.draw(self.contents)
        WindowUser.draw(self, surf)
        
    def loop(self, screen):
        while True:
            self.draw(screen)
            pygame.display.flip()
            pygame.time.Clock().tick(30)
            for event in pygame.event.get():
                result = self.update(event)
                if result != None:
                    return result
示例#2
0
 def create_cadre_text(self, text):
     width, height = self.contents_size
     mt = self.offsettext
     self.widget = InputText(mt, 0, text, width=width-2*mt, parent = self)
     self.widget.active = True