Exemplo n.º 1
0
    def game(self):
        bg = pygame.image.load('Img/ss.jpg').convert()
        bg = pygame.transform.scale(bg, (BG_WIDTH, BG_HEIGHT))
        self.screen.blit(bg, (0, 0))
        self.start_ticks = pygame.time.get_ticks()

        self.render_multi_line(self.pytanie[0], 20, 20, 45)
        self.render_multi_line(self.odp[0], 50, 130, 30)
        self.render_multi_line(self.odp[1], 50, 200, 30)
        self.render_multi_line(self.odp[2], 50, 270, 30)
        self.render_multi_line(self.odp[3], 50, 340, 30)

        settings = {
            "command": self.print_on_enter,
            "inactive_on_enter": False,

        }
        self.entry1 = pygooey.TextBox(rect=(60, 450, 150, 30), **settings, id="1")
        self.entry2 = pygooey.TextBox(rect=(260, 450, 150, 30), **settings, id="2")
        self.entry3 = pygooey.TextBox(rect=(460, 450, 150, 30), **settings, id="3")
        self.entry4 = pygooey.TextBox(rect=(660, 450, 150, 30), **settings, id="4")

        self.zb = pygame.image.load('Img/buttonz.png')
        self.zb = pygame.transform.scale(self.zb, (BT_WIDTH-50, BT_HEIGHT-50))
        self.zbrect = pygame.Rect((10, 520), (BT_WIDTH-50, BT_HEIGHT-50))
        self.screen.blit(self.zb, (10, 520))
Exemplo n.º 2
0
#text box example use

import pygooey
import pygame as pg

pg.init()
screen = pg.display.set_mode((600, 400))
screen_rect = screen.get_rect()
done = False


def print_on_enter(id, final):
    print('enter pressed, textbox contains {}'.format(final))


#see all settings help(pygooey.TextBox.__init__)
settings = {
    "command": print_on_enter,
    "inactive_on_enter": False,
}
entry = pygooey.TextBox(rect=(70, 100, 150, 30), **settings)

while not done:
    for event in pg.event.get():
        if event.type == pg.QUIT:
            done = True
        entry.get_event(event)
    entry.update()
    entry.draw(screen)
    pg.display.update()
Exemplo n.º 3
0
    def addText(self, text="default"):
        self.screen.fill((white))
        self.screen.blit(self.font.render(text, True, (255, 0, 0)), (300, 100))
        pg.display.update()


pg.init()
screen = pg.display.set_mode((600, 400))
screen_rect = screen.get_rect()
done = False
widgets = []

#see all settings help(pygooey.TextBox.__init__)
entry_settings = {"inactive_on_enter": False, 'active': False}
entry = pygooey.TextBox(rect=(70, 100, 150, 30),
                        command=textbox_callback,
                        **entry_settings)
widgets.append(entry)

#see all settings help(pygooey.Button.__init__)
btn_settings = {
    "clicked_font_color": (0, 0, 0),
    "hover_font_color": (205, 195, 100),
    'font': pg.font.Font(None, 16),
    'font_color': (255, 255, 255),
    'border_color': (0, 0, 0),
}
btn = pygooey.Button(rect=(10, 10, 105, 25),
                     command=button_callback,
                     text='OK',
                     **btn_settings)
Exemplo n.º 4
0
    def mainLoop(self):
        pg.init()
        screen = pg.display.set_mode((600,400))
        screen_rect = screen.get_rect()
        done = False
        widgets = []

    
        #see all settings help(pygooey.TextBox.__init__)
        entry_settings = {
            "inactive_on_enter" : False,
            'active':False
        }

        #see all settings help(pygooey.Button.__init__)
        btn_settings = {
            "clicked_font_color" : (0,0,0),
            "hover_font_color"   : (205,195, 100),
            'font'               : pg.font.Font(None,16),
            'font_color'         : (255,255,255),
            'border_color'       : (0,0,0),
        }

        varDisplays = []
        valueDisplays = []
        yBias = 0
        for v in config.variable:
            entry = pygooey.TextBox(rect=(100,10+yBias,100,30), command=self.textbox_callback, **entry_settings)
            entry.id = v
            widgets.append(entry)
            btn = pygooey.Button(rect=(10,10+yBias,90,30), command=self.button_callback,returnObject=entry, text='Set value', **btn_settings)
            widgets.append(btn)
            
            display = pygooey.TextBox(rect=(210,10+yBias,130,30), command=self.textbox_callback, **entry_settings)
            display.disabled = True
            display.id = v
            display.color = pg.Color("gray")
            widgets.append(display)    
            varDisplays.append(display)

            display = pygooey.TextBox(rect=(345,10+yBias,100,30), command=self.textbox_callback, **entry_settings)
            display.disabled = True
            display.id = v
            display.color = pg.Color("gray")
            entry.display = display
            widgets.append(display)    
            valueDisplays.append(display)

            btn = pygooey.Button(rect=(450,10+yBias,20,15), command=self.button_callback_increment,returnObject=entry, text='+', **btn_settings)
            btn.id = display
            widgets.append(btn)
            btn = pygooey.Button(rect=(450,10+yBias+15,20,15), command=self.button_callback_decrement,returnObject=entry, text='-', **btn_settings)
            btn.id = display
            widgets.append(btn)

            yBias +=40
            
            
        dataload = mqttDatapump.MqttDatapump()
        dataload.startDatapump()

        # Send  GET_VARIABLE_VALUES
        self.createVariableSetterMessage("GET_VARIABLE_VALUES", 0)
        
        

        data = {}
        while not done:
            for event in pg.event.get():
                if event.type == pg.QUIT:
                    done = True
                for w in widgets:
                    w.get_event(event)
                    
            for disp in varDisplays:        
                disp.buffer = ("%s" % disp.id.name)
            
            while dataload.getDataLength() > 0:
                data = dataload.getData()
                for disp in valueDisplays:        
                    if disp.id.name in data.keys():
                        #disp.buffer =  disp.id.displayFormat
                        disp.buffer = (disp.id.displayFormat % data[disp.id.name])
            
            for w in widgets:
                w.update()
                w.draw(screen)
            pg.display.update()
Exemplo n.º 5
0
        pass


if __name__ == "__main__":
    white = [255, 255, 255]
    pg.init()
    flags = DOUBLEBUF
    screen = pg.display.set_mode([1400, 800], flags)

    widgets = []

    # Pygooey, create button and text fields within pygame framework
    entry_settings = {"inactive_on_enter": False, 'active': False}

    entry_0 = pygooey.TextBox(rect=(10, 700, 150, 30),
                              command=textbox_callback,
                              **entry_settings)
    widgets.append(entry_0)
    entry_1 = pygooey.TextBox(rect=(210, 700, 150, 30),
                              command=textbox_callback,
                              **entry_settings)
    widgets.append(entry_1)
    entry_2 = pygooey.TextBox(rect=(410, 700, 150, 30),
                              command=textbox_callback,
                              **entry_settings)
    widgets.append(entry_2)

    pg.font.init()
    entry_font = pg.font.Font(None, 25)
    kp_text = entry_font.render('kp:', False, white)
    ki_text = entry_font.render('ki:', False, white)