예제 #1
0
파일: main.py 프로젝트: codetricity/sgc
def main():

    btn.add(0)
    button2.add(1)
    combo_a.add(2)
    radio_box.add(3)
    switch.add(4)

    btn.level = 1
    level = btn.level
    btn.config_set = True

    screen_color = (50,50,50)

    while True:

        if android:
            if android.check_pause():
                android.wait_for_resume()

        time = clock.tick(30)

        for event in pygame.event.get():
            sgc.event(event)
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
            elif event.type == KEYDOWN and event.key == K_ESCAPE:
                pygame.quit()
                sys.exit()

        level = btn.level
        if level == 2:
            if btn.config_set == False:
                screen_color = BLUE
                btn.remove(fade=False)
                radio_box.remove(fade=False)
                combo_a.remove(fade = False)
                scale.remove(fade=False)
                switch.remove(fade=False)
                print("configured 2nd screen settings")
                label.add()
# input of text not working with android soft keyboard
#                inputbox.add()
#                input_ok.add()
                btn.config_set = True
        # if inputbox.has_focus():
        #     if android:
        #         android.show_keyboard()
        # else:
        #     if android:
        #         android.hide_keyboard()

        screen.fill(screen_color)
        sgc.update(time)
        pygame.display.flip()
예제 #2
0
	def internal_update(self):
		absroot.screen.screen.blit(absroot.gamedb(self.config.get("scn_image", "large_black_bg")), (0,0))
		absroot.screen.screen.blit(self.title_render, (0,0))
		# self.wait_button.render()
		# self.wait_button.tt_delay_update(self.wait_button.rect)
		sgc.update(absroot.clock.get_fps())

		for patron in self.people:
			patron.render()
			pygame.draw.rect(absroot.screen.screen, (255,0,0), patron.rect, 2)
			patron.tt_delay_update(patron.rect)
예제 #3
0
 def Run(self):
     pygame.mixer.music.play(-1)
     
     while self.Active:
         time = self.clock.tick(40)
         
         if self.shippos[0]+2>735:
             self.shippos = (-10, 400)
             self.helpidx += 1
             if self.helpidx==len(self.helpimgs): self.helpidx = 0
         self.shippos = (self.shippos[0]+2, self.shippos[1])
         
         #if random.randrange(0,15)>10:
         #    self.Explosions.append(Explosion( (random.randrange(0,639), random.randrange(0,450)), random.randrange(15,65)))
         #print len(self.Explosions)
         
         for event in pygame.event.get():
             sgc.event(event)
             if event.type == pygame.KEYDOWN:
                 keystate = pygame.key.get_pressed()
                 if keystate[K_j]==1:
                     self.startgame()
                 if keystate[K_q]==1:
                     self.exitgame()
                 elif keystate[K_F11]==1:
                     self.FullScreen = not self.FullScreen
                     if self.FullScreen:
                         window = pygame.display.set_mode(self.ScreenSize, FULLSCREEN)
                     else:
                         window = pygame.display.set_mode(self.ScreenSize)
             if event.type == GUI:
                 pass
             elif event.type == QUIT:
                 exit()
         
         #self.background = pygame.Surface(self.Screen.get_size())
         
         #self.background = self.background.convert()
         
         #for e in self.Explosions:
         #    e.Draw(self.background)
         
         #self.Screen.blit(self.background, (0,0))
         sgc.update(time)
         #for e in self.Explosions:
         #    e.Update()
         #self.Explosions = [e for e in self.Explosions if e.Alive]
         
         self.Screen.blit(self.shipimg, self.shippos)
         self.Screen.blit(self.helpimgs[self.helpidx], (self.shippos[0]-193, self.shippos[1]) )
         self.Screen.blit(self.grndimg, (0,448))
         
         pygame.display.flip()
     pygame.mixer.music.stop()
예제 #4
0
파일: menu.py 프로젝트: robberwick/Piradigm
 def run(self):
     logger.info("Initialising pygame")
     pygame.init()
     pygame.font.init()
     clock = pygame.time.Clock()
     logger.info("Hiding Cursor")
     pygame.mouse.set_visible(False)
     logger.info("Setting screen size to %s", SCREEN_SIZE)
     #pygame.display.init()
     self.screen = pygame.display.set_mode(SCREEN_SIZE)
     controls = sgc.surface.Screen(SCREEN_SIZE)
     self.buttons = self.setup_menu(self.screen)
     for btn in self.buttons:
        btn['btn'].add(btn['index'])
     running_challenge = None
     
     # While loop to manage touch screen inputs
     with ControllerResource() as self.joystick:
         while True:
             time = clock.tick(30)
             pygame.display.update()
             sgc.update(time)
             if self.joystick.connected:
                 self.joystick_handler(self.joystick.check_presses())
             for event in pygame.event.get():
                 sgc.event(event)
                 if event.type== GUI:
                     if event.widget_type is "Button":
                         requested_challenge = self.button_handler(event)
                         for btn in self.buttons:
                             btn['btn'].remove(btn['index'])
                         if requested_challenge:
                             logger.info("about to stop a thread if there's one running")
                             if running_challenge:
                                 logger.info("about to stop thread")
                                 self.stop_threads(running_challenge)
                         if requested_challenge is not None and requested_challenge is not "Exit" and requested_challenge is not "Other":
                             running_challenge = self.launch_challenge(requested_challenge)
                             logger.info("challenge %s launched", running_challenge.name)
                         elif requested_challenge == "Exit":
                             sys.exit()
                 # ensure there is always a safe way to end the program
                 # if the touch screen fails
                 elif event.type== KEYDOWN:
                     if event.key == K_ESCAPE:
                         sys.exit()
                 elif event.type == (USEREVENT+1):
                     print event.message
                     self.screen.fill(BLACK)
                     for btn in self.buttons:
                         btn['btn'].add(btn['index'])
예제 #5
0
def main():
    SURFSPOTS=("capitola", "pleasure_point", "the_hook")
    clock = pygame.time.Clock()
    SCREENSIZE = (800, 600)
    SCREEN = pygame.display.set_mode(SCREENSIZE)
    sgc.surface.Screen(SCREENSIZE) # needed for SGC GUI toolkit
    fonts = {"widget": "fnt/Ubuntu-M.ttf", "title": "fnt/Ubuntu-M.ttf",
             "mono": "fnt/Ubuntu-M.ttf"}
    sgc.Font.set_fonts(fonts)

    forecast = Forecast(SURFSPOTS)
    graph = Graph()

    for fcast in forecast.f_list:
        fcast.add()
    forecast.change_day_btn.add()
    forecast.reset_day_btn.add()
    tide_data = get_tide()
    graph.update(tide_data)

    # get weather from Open Weather Map
    weather = Weather()
    weather.forecast()
   # pprint.pprint(weather.weath_cast)
    pprint.pprint(weather.w_dict)

    while True:
        if android:
            if android.check_pause():
                android.wait_for_resume()
        time = clock.tick(30)

        for event in pygame.event.get():
            sgc.event(event)
            if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN 
                                             and event.key == pygame.K_ESCAPE):
                pygame.quit()
                sys.exit()

        if forecast.change_day_btn.clicked or forecast.reset_day_btn.clicked:
            forecast = update_days(forecast)
            tide_data = get_tide(forecast.days)
            graph.update(tide_data)

        graph_surface = draw_tide_graph(SCREENSIZE, graph)
        SCREEN.fill((0,0,0))
        SCREEN.blit(graph_surface, (0,0))
        sgc.update(time)
        pygame.display.update()
예제 #6
0
    def pygame_display_managing(self):
        time = self.clock.tick()
        self.screen.fill(self.bgColor)
        pxarray = pygame.PixelArray(self.screen.image)
        for el in self.env.agent_list:
            self.draw_point(el.position, pxarray, el.get_color())
        for el in self.env.object_list:
            self.draw_point(el.position, pxarray)
        del pxarray
        sgc.update(time)

        if (param.BORDER_MODE != param.BorderMode.NONE):
            pygame.draw.rect(
                self.screen.image, self.fgColor,
                (self.dw - param.BOX_SIZE / 2, self.dh - param.BOX_SIZE / 2,
                 param.BOX_SIZE, param.BOX_SIZE), 1)
        pygame.display.flip()
예제 #7
0
파일: android.py 프로젝트: codetricity/sgc
def main():
    while True:
        # A PGS4A program must include these two lines
        if android.check_pause():
            android.wait_for_resume()
        
        time = clock.tick(30)

        for event in pygame.event.get():
            sgc.event(event)
            if event.type == QUIT:
                sys.exit()
            elif event.type == KEYDOWN and event.key == K_ESCAPE:
                # Alternate way to exit the program in Android - back button
                sys.exit()
                
        screen.fill((0,0,0))
        sgc.update(time)
        pygame.display.flip()
예제 #8
0
파일: android.py 프로젝트: 602p/spacegame
def main():
    while True:
        # A PGS4A program must include these two lines
        if android.check_pause():
            android.wait_for_resume()

        time = clock.tick(30)

        for event in pygame.event.get():
            sgc.event(event)
            if event.type == QUIT:
                sys.exit()
            elif event.type == KEYDOWN and event.key == K_ESCAPE:
                # Alternate way to exit the program in Android - back button
                sys.exit()

        screen.fill((0, 0, 0))
        sgc.update(time)
        pygame.display.flip()
예제 #9
0
    def pygame_loop_cb(self):
        time = self.clock.tick(30)
        sgc.update(time)
        pygame.display.flip()

        for event in pygame.event.get():
            sgc.event(event)

            if event.type == pygame.QUIT:
                sys.exit()

            elif event.type == self.provider.PROVIDER_EVENT:
                if event.name == "photo":
                    self.show_image(event.image)
                    self.photo_object = event.photo_object
                    self.update_overlay()
                    logger.debug(self.photo_object)

                elif event.name == "error":
                    logger.error("Could not display photo: %s" % event.error)
                    if self.timer:
                        self.stop_slideshow()
                        self.start_slideshow()

            elif event.type == GUI:
                if event.widget == self.frame:
                    if self.overlay.active():
                        self.overlay.remove()
                        self.start_slideshow()
                    else:
                        self.stop_slideshow()
                        self.overlay.add()
                if event.widget == self.overlay.star_button:
                    self.toggle_star()
                if event.widget == self.overlay.remove_button:
                    self.toggle_remove()
                elif event.widget == self.overlay.back_button:
                    self.provider.next_photo(-1)
                elif event.widget == self.overlay.forward_button:
                    self.provider.next_photo(+1)

        return True
예제 #10
0
                evillaughSound.set_volume(0.2)
                soundPlay=evillaughSound.play()
                startflag = True
                oldTime = datetime.datetime.now()
        #测试坐标
        if event.type == MOUSEBUTTONDOWN:
            #坐标在“开始冒险”图像的范围内
            x, y = pygame.mouse.get_pos()
            #print(x,y)
    if startflag:
        newTime = datetime.datetime.now()
    if (newTime-oldTime).seconds >5:
        break
        
           
    sgc.update(timeClock)
    pygame.display.flip()
    pygame.display.update()

#移动画面显示环境和僵尸
x=0
isRightMove=False
isFirst = True
oldTime = None
zombieImg = pygame.image.load("images/Zombies/Zombie/stand.gif").convert()
#画面移动的速度 像素/秒
backendSpeed = 1
print timeClock
timePassSecond = timeClock/1000.0
distanceMoved = timePassSecond * backendSpeed
myMoved = distanceMoved
예제 #11
0
 def render_ui(self):
     if self.__dict__.get("ui_bg", False):
         self.root.screen.screen.blit(
             self.root.gamedb(self.__dict__["ui_bg"]), (0, 0))
     sgc.update(self.root.clock.get_fps())
     self.root.fps = 9999
예제 #12
0
 def internal_update(self):
     if "bg_image" in self.params.keys():
         self.root.screen.screen.blit(
             self.root.gamedb(self.params["bg_image"]), (0, 0))
     sgc.update(self.root.clock.get_fps())
     self.root.fps = 9999
예제 #13
0
파일: ui_states.py 프로젝트: 602p/spacegame
	def render_ui(self):
		if self.__dict__.get("ui_bg", False):
			self.root.screen.screen.blit(self.root.gamedb(self.__dict__["ui_bg"]), (0,0))
		sgc.update(self.root.clock.get_fps())
		self.root.fps=9999
예제 #14
0
파일: ui_states.py 프로젝트: 602p/spacegame
	def internal_update(self):		
		if "bg_image" in self.params.keys():
			self.root.screen.screen.blit(self.root.gamedb(self.params["bg_image"]), (0,0))
		sgc.update(self.root.clock.get_fps())
		self.root.fps=9999
예제 #15
0
파일: test.py 프로젝트: codetricity/sgc
    for event in pygame.event.get():
        # Send event to widgets
        sgc.event(event)
        if event.type == GUI:
            if event.widget_type is sgc.Button:
                print "Button event"
            if event.widget is button and event.gui_type == "click":
                button.config(col=[random.randrange(1,200) for x in range(3)])
            elif event.widget is input_box:
                clear()
        elif event.type == KEYDOWN:
            if event.key == K_f:
                fps.toggle()
        elif event.type == QUIT:
            exit()

    # Cleanup removed windows
    for widget in dialogs:
        if not widget.active():
            dialogs.remove(widget)

    if not screen._opengl:
        screen.fill(Color("blue"))
    else:
        glClearColor(0,0,1,1)
        glClear(GL_COLOR_BUFFER_BIT)
    # Update the widgets once for each frame
    sgc.update(time)

    pygame.display.flip()
예제 #16
0
 def update(self, delta):
     sgc.update(delta * 1000)
     self.lastScaleVal = self.sizeScale.value
예제 #17
0
                running = False

    current_time = pygame.time.get_ticks()

    if (end_slide <= current_time) and (current_image < len(images)):
        image = images[current_image]
        image_rect = image.get_rect()
        image_rect.center = display_rect.center

        end_slide = current_time + 2000  # 2000ms (2s)
        current_image += 1

        display_surface.fill(WHITE)
        display_surface.blit(image, image_rect)

    sgc.update(ticks)
    pygame.display.flip()

# ---

display_surface.fill(WHITE)

text = font.render('GeeksForGeeks', True, (0, 255, 0), (0, 0, 128))
text_rect = text.get_rect()
text_rect.center = display_rect.center
display_surface.blit(text, text_rect)

#pygame.display.update() # no need it
pygame.display.flip()

time.sleep(5)
예제 #18
0
def main():

    pg.init()
    done = False
    screen = pg.display.set_mode((SCREEN_LENGTH, SCREEN_WIDTH))
    screen_rect = screen.get_rect()
    pg.display.set_caption('Medieval RPG')
    clock = pg.time.Clock()
    playerSpeed = 4
    game_map = GameMap(screen, 'home.xlsx', 'art/characters.png',
                       'art/basictiles.png', 'art/things.png', 'art/dead.png')
    clock = pg.time.Clock()

    player = game_map.get_player_sprites()

    friend_sprites = game_map.get_friend_sprites()
    enemy_sprites = game_map.get_enemy_sprites()
    blocked_sprites = game_map.get_blocked_sprites()
    item_sprites = game_map.get_item_sprites()
    door_sprites = game_map.get_door_sprites()
    animated_sprites = game_map.get_animated_sprites()
    exit_sprites = game_map.get_exit_sprites()
    used_sprites = []
    used_sprites_locs = set()
    all_sprites_list = pg.sprite.Group()
    all_sprites_list.add(player)
    all_sprites_list.add(friend_sprites)
    all_sprites_list.add(blocked_sprites)
    all_sprites_list.add(item_sprites)
    all_sprites_list.add(door_sprites)
    all_sprites_list.add(animated_sprites)
    all_sprites_list.add(enemy_sprites)
    all_sprites_list.add(used_sprites)

    first_trader = friend_sprites[0]
    first_trader.trader_model.add_inventory(Jewel())
    first_trader.trader_model.add_inventory(Jewel())
    first_trader.trader_model.add_inventory(Armor())

    gui_screen = sgc.surface.Screen((SCREEN_LENGTH, SCREEN_WIDTH))
    my_font = pg.font.SysFont("Arial", 30)
    my_font_2 = pg.font.SysFont("Arial", 20)

    inventory_gui = InventoryGUI(gui_screen, my_font, player)

    trader_gui = TraderGUI(gui_screen, my_font_2, player, first_trader)

    trader_gui.update_trader_inventory_gui(first_trader.trader_model.inventory)

    player.player_model.add_inventory(Jewel())
    inventory_gui.update_inventory_gui(player.player_model.inventory)
    trader_gui.update_player_inventory_gui(player.player_model.inventory)

    stats_gui = StatsGUI(gui_screen, my_font, player)

    # Initialize all battle guis
    all_battle_guis = []
    for enemy in enemy_sprites:
        all_battle_guis.append(BattleGUI(gui_screen, my_font, player, enemy))
    battle_gui = all_battle_guis[0]

    # apply it to text on a label
    label = my_font.render("Python and Pygame are Fun!", 1,
                           pg.Color('#000000'))

    while not done:

        time = clock.tick(60)

        player.lastMove = -1

        for event in pg.event.get():
            sgc.event(event)
            if event.type == GUI:
                if event.gui_type == "click" and event.widget is trader_gui.sell_button:
                    trader_gui.execute_sell()
                if event.gui_type == "click" and event.widget is trader_gui.buy_button:
                    trader_gui.execute_buy()
                if event.gui_type == "click" and event.widget is battle_gui.attack_option:
                    battle_gui.execute_attack()
                if event.gui_type == "click" and event.widget is battle_gui.retreat_option:
                    battle_gui.execute_retreat()
                if event.gui_type == "click" and event.widget is inventory_gui.quit_button:
                    inventory_gui.active = False
                if event.gui_type == "click" and event.widget is inventory_gui.drop_button:
                    inventory_gui.execute_drop()
            elif event.type == pg.QUIT:
                done = True
            elif event.type == pg.KEYDOWN:
                if event.key == pg.K_q and inventory_gui.active:
                    inventory_gui.active = False
                    inventory_gui.hide()
                if event.key == pg.K_q and trader_gui.active:
                    trader_gui.active = False
                    trader_gui.hide()
                    player.rect.x = player.prev_x
                    player.rect.y = player.prev_y
                if event.key == pg.K_q and stats_gui.active:
                    stats_gui.active = False
                    stats_gui.hide()
                if event.key == pg.K_i and not inventory_gui.active:
                    inventory_gui.active = True
                    inventory_gui.update_inventory_gui(
                        player.player_model.inventory)
                    inventory_gui.show()
                    trader_gui.hide()
                    stats_gui.hide()
                    battle_gui.hide()

                if event.key == pg.K_t and not trader_gui.active:
                    trader_gui.active = True
                    trader_gui.update_player_inventory_gui(
                        player.player_model.inventory)
                    trader_gui.show()
                    inventory_gui.hide()
                    stats_gui.hide()
                    battle_gui.hide()

                if event.key == pg.K_p and not stats_gui.active:
                    stats_gui.active = True
                    stats_gui.update_stats()
                    stats_gui.show()
                    inventory_gui.hide()
                    trader_gui.hide()
                    battle_gui.hide()

        keys = pg.key.get_pressed()
        gui_on = stats_gui.active or inventory_gui.active or trader_gui.active or battle_gui.active
        if (keys[pg.K_LEFT] or keys[pg.K_a]) and not gui_on:
            player.move_left(playerSpeed)

        if (keys[pg.K_RIGHT] or keys[pg.K_d]) and not gui_on:
            player.move_right(playerSpeed)

        if (keys[pg.K_DOWN] or keys[pg.K_s]) and not gui_on:
            player.move_down(playerSpeed)

        if (keys[pg.K_UP] or keys[pg.K_w]) and not gui_on:
            player.move_up(playerSpeed)

        for sprite in blocked_sprites[:]:
            if player.rect.colliderect(sprite.rect):
                player.rect.x = player.prev_x
                player.rect.y = player.prev_y

        for idx, friend in enumerate(friend_sprites[:]):
            if player.rect.colliderect(friend.rect) and not trader_gui.active:
                trader_gui.active = True
                trader_gui.update_player_inventory_gui(
                    player.player_model.inventory)
                trader_gui.show()
                inventory_gui.hide()
                stats_gui.hide()
                battle_gui.hide()

                # Trader logic ---
                #player.rect.x = player.prev_x
                #player.rect.y = player.prev_y
                #sprite.display_label = True
                #sprite.start_display_time = datetime.now()

        for idx, enemy in enumerate(enemy_sprites[:]):
            if player.rect.colliderect(enemy.rect) and enemy.alive:
                player.rect.x = player.prev_x
                player.rect.y = player.prev_y
                battle_gui = all_battle_guis[idx]
                battle_gui.active = True
                inventory_gui.hide()
                trader_gui.hide()
                stats_gui.hide()
                battle_gui.show()
                enemy.pause_patrol = True

        for sprite in item_sprites[:]:
            if player.rect.colliderect(
                    sprite.rect) and sprite not in used_sprites:
                player.player_model.process_item(sprite.item_model)
                used_sprites.append(sprite)
                used_sprites_locs.add((sprite.rect.x, sprite.rect.y))
                sprite.kill()

        for sprite in door_sprites[:]:
            if player.rect.colliderect(sprite.rect):
                sprite.image = sprite.openImg.convert_alpha()
            else:
                sprite.image = sprite.closeImg.convert_alpha()

        for sprite in exit_sprites[:]:
            if player.rect.colliderect(sprite.rect):
                player.teleport(0, 0)
                game_map = GameMap(screen, 'cave.xlsx', 'art/characters.png',
                                   'art/basictiles.png', 'art/things.png',
                                   'art/dead.png')
                friend_sprites = game_map.get_friend_sprites()
                enemy_sprites = game_map.get_enemy_sprites()
                blocked_sprites = game_map.get_blocked_sprites()
                item_sprites = game_map.get_item_sprites()
                door_sprites = game_map.get_door_sprites()
                animated_sprites = game_map.get_animated_sprites()
                exit_sprites = game_map.get_exit_sprites()
                used_sprites = []
                used_sprites_locs = set()
                all_sprites_list = pg.sprite.Group()
                all_sprites_list.add(player)
                all_sprites_list.add(friend_sprites)
                all_sprites_list.add(blocked_sprites)
                all_sprites_list.add(item_sprites)
                all_sprites_list.add(door_sprites)
                all_sprites_list.add(animated_sprites)
                all_sprites_list.add(enemy_sprites)
                all_sprites_list.add(used_sprites)

        game_map.render_display(used_sprites_locs)
        all_sprites_list.update()
        all_sprites_list.draw(screen)
        player.rest()

        for sprite in friend_sprites[:]:
            if sprite.display_label:
                label = my_font.render(sprite.label, 1, pg.Color('#000000'))
                screen.blit(label, (150, 0))
                if (datetime.now() - sprite.start_display_time).seconds > 3:
                    sprite.display_label = False

        if inventory_gui.active or trader_gui.active or stats_gui.active or battle_gui.active:
            gui_screen.fill((0, 0, 0))
            sgc.update(time)

        pg.display.flip()
        clock.tick(30)
예제 #19
0
    pygame.display.init()
    pygame.font.init()

    screen = sgc.surface.Screen((640, 480))
    clock = pygame.time.Clock()

    # Basic widget, inherits behaviours from Simple
    widget = MyBasicWidget((200, 100),
                           pos=(10, 50),
                           label="Free label",
                           label_side="top")
    widget.add()

    other = MyWidget(pos=(200, 250), label="Custom")
    other.add(0)

    running = True
    while running:
        time = clock.tick(20)

        for event in pygame.event.get():
            if event.type == GUI:
                print("State: ", event.on)
            sgc.event(event)
            if event.type == QUIT:
                running = False

        screen.fill((0, 0, 100))
        sgc.update(time)
        pygame.display.flip()
예제 #20
0
def main():
    # Global variables & constants
    global ZMQ_TIMEOUT
    ZMQ_TIMEOUT = 2.4
    
    # Start information provider
    global pageInfo
    pageInfo = pageInfoProvider()
    pageInfo.daemon = True
    pageInfo.start()
    # Start MABx message receiver
#     mabxMsg = carserver.carInfo('MABx Messages', 1, 99999,['Code'],[''])
#     mabxMsg.daemon = True
#     mabxMsg.start()  

    # Pygame surfaces
    global screen
    screen = sgc.surface.Screen((LCDW, LCDH))
    clock = pygame.time.Clock()
    
    # Fill background
    global background
    background = pygame.Surface(screen.get_size())
    background = background.convert()
    background.fill((20, 25, 25))
    
    # Start threads that depend on Pygame
    # Homebrew notification manager
    global notify
    notify = notificationMgr()
    notify.daemon = True
    # Air conditioning manager
    global hvac
    hvac = carserver.hvacMgr('hvac', 5556)
    hvac.daemon = True
    hvac.start()
    
    # Text data is handled by the page thing
    infoFont = pygame.font.Font(os.path.join('res', 'Ticketing.otf'), 42)
    
    # Put on the button row
    btnFont = pygame.font.Font(os.path.join('res', 'OSP-DIN.ttf'), 28)
    acbtnFont = pygame.font.Font(os.path.join('res', 'OSP-DIN.ttf'), 22)
    btnLabel = ['ESS', 'HVAC', 'MABx', 'TM4', 'Top Bar test', 'Override Msg']
    btnPos = [25, LCDH - 80]
    
    # Painstakingly defining each button
    i = 0
    btn0 = sgc.Button(label=btnLabel[i], pos=(btnPos[0], btnPos[1]), col=(225, 128, 0), label_font=(btnFont))
    btn0.on_click = test_btn0
     
    i += 1
    btnPos[0] += 120
    btn1 = sgc.Button(label=btnLabel[i], pos=(btnPos[0], btnPos[1]), col=(107, 28, 214), label_font=(btnFont))
    btn1.on_click = test_btn1
     
    i += 1
    btnPos[0] += 120
    btn2 = sgc.Button(label=btnLabel[i], pos=(btnPos[0], btnPos[1]), col=(0, 180, 0), label_font=(btnFont))
    btn2.on_click = test_btn2
     
    i += 1
    btnPos[0] += 120
    btn3 = sgc.Button(label=btnLabel[i], pos=(btnPos[0], btnPos[1]), col=(0, 180, 0), label_font=(btnFont))
    btn3.on_click = test_btn3
 
    i += 1
    btnPos[0] += 120
    btn4 = sgc.Button(label=btnLabel[i], pos=(btnPos[0], btnPos[1]), col=(0, 180, 0), label_font=(btnFont))
    btn4.on_click = test_btn4
    
    i += 1
    btnPos[0] += 120
    btn5 = sgc.Button(label=btnLabel[i], pos=(btnPos[0], btnPos[1]), col=(0, 180, 0), label_font=(btnFont))
    btn5.on_click = test_btn5
    
    btnDismiss = sgc.Button(label="Dismiss", pos=(25, 405), col=(1, 1, 1), label_font=(btnFont))
    btnDismiss.on_click = dismiss_overlay
    
    acbtnPos = [25, 100]
    global acbtnOn
    acbtnOn = sgc.Switch(label="AC", pos=(acbtnPos[0], acbtnPos[1]), label_font=(acbtnFont), label_side="top")
    
    acbtnPos[0] += 140
    global acbtnTemp
    acbtnTemp = sgc.Scale(label="Temperature", pos=(acbtnPos[0], acbtnPos[1]), label_font=(acbtnFont), label_side="top", min=hvac.MIN_TEMP, max=hvac.MAX_TEMP)
    
    acbtnPos[0] += 260
    global acbtnFanSpd
    acbtnFanSpd = sgc.Scale(label="Fan Speed", pos=(acbtnPos[0], acbtnPos[1]), label_font=(acbtnFont), label_side="top")
    
    acbtnPos = [25, 180]
    global acbtnRecirc
    acbtnRecirc = sgc.Switch(label="Recirc", pos=(acbtnPos[0], acbtnPos[1]), label_font=(acbtnFont), label_side="top")
    
    notify.start()  # Display the welcome message and start notification mgr
    showMenuButton = True
    showACButton = False
    pageInfo.setPage(0)
    notify.send(-1, 'MalibuTake2 main Pygame loop started')
    
    while True:
        sgctime = clock.tick(30)
    
        for event in pygame.event.get():
            sgc.event(event)
            if event.type == GUI:
                print(event)
            if event.type == QUIT  or (event.type == KEYDOWN and event.key == K_ESCAPE):
                exit()
            if event.type == MOUSEBUTTONDOWN:
                if event.button == 1:
                    if event.pos[1] <= 60: # If click is in the top 60 pixels, go to message centre
                        pageInfo.setPage(9)

        # Button handlers
        if showMenuButton:
            btnDismiss.remove(1)
            btn0.add(0)
            btn1.add(0)
            btn2.add(0)
            btn3.add(0)
            btn4.add(0)
            btn5.add(0)
        elif not showMenuButton:
            btn0.remove(0)
            btn1.remove(0)
            btn2.remove(0)
            btn3.remove(0)
            btn4.remove(0)
            btn5.remove(0)
            
        if showACButton:
            hvac.pauseThread = False
            acbtnOn.add(0)
            acbtnTemp.add(0)
            acbtnFanSpd.add(0)
            acbtnRecirc.add(0)
        else:
            hvac.pauseThread = True
            acbtnOn.remove(0)
            acbtnTemp.remove(0)
            acbtnFanSpd.remove(0)
            acbtnRecirc.remove(0)
        
#         if pageInfo.activePage == 1:
#             afsd.add(0)
#         else:
#             asdf.remove(0)

        # Notifications are ran independently. Let's check on them:
        if notify.overlayActive:  # Overlay notification page
            showACButton = False
            showMenuButton = False     
            btn0.remove       
            dispScreen = pygame.display.set_mode([LCDW, LCDH])
            
            pygame.draw.rect(dispScreen, (200, 200, 200), (0, 0, LCDW, LCDH), 0)
            pygame.draw.rect(dispScreen, (200, 10, 10), (0, 0, LCDW, LCDH), 24)
            
            warnFont = pygame.font.Font(os.path.join('res', 'OSP-DIN.ttf'), 56)
            warnTxtPos = background.get_rect()
            warnTxtPos.left = 50
            warnTxtPos.centery = 320

            dispScreen.blit(warnFont.render(notify.OverlayText, 1, (180, 0, 0)), warnTxtPos)
            btnDismiss.add(0)
            
        elif pageInfo.activePage == 1:  # HVAC Page
            showACButton = True
            showMenuButton = True
            screen.blit(background, (0, 60))  # redraws background to cover everything up. 60 pixels top bar. 
            
            hvac.update([acbtnOn.state, acbtnTemp.value, acbtnFanSpd.value, acbtnRecirc.state])
         #   dispScreen = pygame.display.set_mode([LCDW,LCDH])
         
        elif pageInfo.activePage == 9:  # Message Centre
            showACButton = False
            showMenuButton = True
            
            screen.blit(background, (0, 60))  # redraws background to cover everything up. 60 pixels top bar. 
            thisLinePos = screen.get_rect()
            thisLinePos.top = 80
            thisLineColour = (190, 190, 190)
            thisLineKind = '?'
            
            msgListFont = pygame.font.Font(os.path.join('res', 'SourceSansPro-Regular.otf'), 24)
            
            listStart = len(notify.msgQueue) - 30
            if(listStart < 1): listStart = 1  # Anything above 0, because that's the logo 
            
            for i in xrange(listStart, len(notify.msgQueue)):
                
                kind = notify.msgQueue[i][1]
        
                if kind == -1:
                    thisLineColour = (190, 190, 190)
                    thisLineKind = 'LOG'
                elif kind == 1:
                    thisLineColour = (90, 90, 190)
                    thisLineKind = 'INFO'
                elif kind == 2:
                    thisLineColour = (255, 230, 82)
                    thisLineKind = 'CAUT'
                elif kind == 3:
                    thisLineColour = (200, 0, 0)
                    thisLineKind = 'WARN'
                
                thisLinePos.left = 25
                screen.blit(msgListFont.render(str(i), 1, thisLineColour), thisLinePos)
                thisLinePos.left += 30
                screen.blit(msgListFont.render(datetime.datetime.fromtimestamp(notify.msgQueue[i][0]).strftime('%H:%M:%S'), 1, thisLineColour), thisLinePos)
                thisLinePos.left += 90
                screen.blit(msgListFont.render(thisLineKind, 1, thisLineColour), thisLinePos)
                thisLinePos.left += 70
                screen.blit(msgListFont.render(notify.msgQueue[i][2], 1, thisLineColour), thisLinePos)
                thisLinePos.centery += 25
            
        else:  # Normal information page
            showACButton = False
            showMenuButton = True
            
            screen.blit(background, (0, 60))  # redraws background to cover everything up. 60 pixels top bar. 
            thisLinePos = screen.get_rect()
            thisLinePos.top = 80
            
#             print mabxMsg.data
#             print pageInfo.zmq_receiver.data
            
            for i in xrange(0, pageInfo.getDataLen()):
                thisLinePos.left = 25
                screen.blit(infoFont.render(str(pageInfo.zmq_receiver.data[0][i]), 1, (0, 144, 0)), thisLinePos)
                thisLinePos.left += LCDW * 0.3
                screen.blit(infoFont.render(str(pageInfo.zmq_receiver.data[1][i]), 1, (0, 222, 0)), thisLinePos)
                thisLinePos.left += LCDW * 0.4
                screen.blit(infoFont.render(str(pageInfo.zmq_receiver.data[2][i]), 1, (155, 155, 155)), thisLinePos)
                thisLinePos.centery += 50
            
        
        sgc.update(sgctime)
        pygame.display.flip()