def __init__(self, turn, **kwargs): super().__init__(resources.load_image('WindowBorder.png'), (70, 70), layout_height=gui.LayoutParams.FILL_PARENT, layout_width=270, layout_gravity=gui.Gravity.RIGHT, gravity=Gravity.TOPLEFT, padding=30, **kwargs) font = f.MEDIEVAL18 self.endturn_btn = gui.Button(_("End Turn"), font, layout_gravity=Gravity.BOTTOMRIGHT, callback=lambda *_: turn.end_turn()) self.turn_label = gui.Label(_("{team} turn"), font) self.terrain_label = gui.Label( f'Terrain: {{0}}\n{_("Def")}: {{1}}\n{_("Avoid")}: {{2}}\n{_("Allowed")}: {{3}}', font) self.unit_label = gui.Label( 'Unit: {0}\nHealth: {1}\nCan move on: {2}\nWeapon: {3}', font) self.coord_label = gui.Label('X: {0} Y: {1}', font, layout_gravity=Gravity.BOTTOM) self.clock = gui.Clock(font, layout_gravity=Gravity.BOTTOM) self.add_children(self.turn_label, self.terrain_label, self.unit_label, self.coord_label, self.clock) if isinstance(turn, game.PlayerTurn): self.add_child(self.endturn_btn)
def _create_pc_frame(self, n): frame = gui.Frame(parent=self.root_right, frame_color=(0.8, 0.8, 0.8, 0.5), frame_size=(-0.4, 0.4, -0.075, 0.075), pos=(-0.45 - 0.05 * n, 0, -0.55 - 0.175 * n)) frame.label = gui.Label(parent=frame, text='', text_scale=(0.04, 0.04), text_align=p3d.TextNode.ALeft, frame_color=(0, 0, 0, 0), pos=(-0.375, 0, 0.04)) frame.hpbar = gui.WaitBar( parent=frame, value=100, text='0/0', text_scale=(0.025, 0.025), text_pos=(0, -0.01), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 0.8), frame_color=(0, 0, 0, 1), frame_size=(-0.35, 0.35, -0.015, 0.015), ) frame.attacklabel = gui.Label( parent=frame, text='', text_scale=(0.03, 0.03), text_align=p3d.TextNode.ALeft, pos=(-0.375, 0, -0.05), ) return frame
def update_games_list_gui(self): self.gui_container.empty() y = 50 for ip, infos in self.games_list.items(): game_name_label = gui.Label( font=self.normal_font, text=infos['name'], on_click=self.on_server_click, data={'ip': ip, **infos} ) game_name_label.rect.left = 10 game_name_label.rect.top = y self.gui_container.add(game_name_label) game_ip_label = gui.Label( font=self.normal_font, text='{}{}'.format(ip, ' (' + infos['country'] + ')' if 'country' in infos and infos['country'] else ''), on_click=self.on_server_click, data={'ip': ip, **infos} ) game_ip_label.rect.right = settings.WINDOW_SIZE[0] - 10 game_ip_label.rect.top = y self.gui_container.add(game_ip_label) y += 50
def update(): """update with new text""" help_labels.empty() y = 100 help_labels.add(gui.Label(100, 10, parts[current_part][0], 30)) for t in parts[current_part][2:]: help_labels.add(gui.Label(10, y, t, 20)) y += 20
def __init__(self, unit: Unit, vector, on_animation_finished, **kwargs): super().__init__(padding=100, **kwargs) self.unit = unit self.animation = AttackAnimation( gui.Image(unit.image, die_when_done=False, bg_color=c.MENU_BG), vector, on_animation_finished) self.name = gui.Label(unit.name, f.MAIN, txt_color=unit.team.color) self.life = gui.LifeBar(points=unit.health_max, value=unit.health) self.stats = gui.Label(str(unit), f.SMALL) self.add_children(self.animation, self.name, self.life, self.stats)
def __init__(self): ''' Draws the Facilities panel ''' self.update_flag = True myfont1 = pygame.font.Font( "font.ttf", threades.resize_pt(20)) # For model.resources name and their value self.name_labels = [] self.labelstyle1 = gui.defaultLabelStyle.copy() self.labelstyle1['border-width'] = 0 self.labelstyle1['wordwrap'] = False self.labelstyle1['autosize'] = False self.labelstyle1['font'] = myfont1 self.labelstyle1['font-color'] = self.font_color #self.labelstyle1['bg-color'] = self.font_bg_color self.list_titles = model.text_file.facilities_list self.list_names = [model.text_file.num_text[0] + ': '] self.list_values1 = (model.House.get_number(), model.School.get_number(), model.Hospital.get_number(), model.Workshop.get_number(), model.Farm.get_number(), model.Fountain.get_number()) self.list_values2 = (model.House.get_level(), model.School.get_level(), model.Hospital.get_level(), model.Workshop.get_level(), model.Farm.get_level(), model.Fountain.get_level()) self.value_labels = [] for i in range(6): label = gui.Label(position=threades.resize_pos((950, 50 + 55 * i)), size=threades.resize_pos((300, 30)), parent=threades.desktop, text=self.list_titles[i], style=self.labelstyle1) self.name_labels.append(label) label = gui.Label(position=threades.resize_pos((950, 75 + 55 * i)), size=threades.resize_pos((300, 30)), parent=threades.desktop, text=self.list_names[0] + str(int(self.list_values1[i])) + model.text_file.level_text[0] + ':' + str(int(self.list_values2[i])), style=self.labelstyle1) self.name_labels.append(label) label.surf.set_alpha(200) self.value_labels.append(label)
def createSettingsSprites(self): label = gui.Label(self) label.set_fontSize(50) label.set_text("SETTINGS") label.set_size((200, 70)) label.set_center((400, 100)) label.set_backgroundImg(label.COLOR, (255, 255, 255)) label.set_aa(True) videoSet = gui.GoTo(self) videoSet.set_goto(self.VSETTINGS) videoSet.set_text("Video settings") videoSet.set_size((150, 40)) videoSet.set_center((160, 200)) videoSet.set_normBg(videoSet.IMAGE, "Graphics/Menu/button.png") videoSet.set_activeBg(videoSet.IMAGE, "Graphics/Menu/button_active.png") videoSet.set_clickedBg(videoSet.IMAGE, "Graphics/Menu/button_clicked.png") videoSet.set_aa(True) backButton = gui.GoTo(self) backButton.set_goto(self.MAINMENU) backButton.set_text("Back") backButton.set_center((400, 500)) backButton.set_normBg(backButton.IMAGE, "Graphics/Menu/button.png") backButton.set_activeBg(backButton.IMAGE, "Graphics/Menu/button_active.png") backButton.set_clickedBg(backButton.IMAGE, "Graphics/Menu/button_clicked.png") backButton.set_aa(True) self.settingsGroup = pygame.sprite.Group(label, videoSet, backButton)
def setup_selections(self, title, selections, select_cb): if self._selection_frame: self._selection_frame.destroy() self._selection_frame = None for i in self._selection_items: i.destroy() self._selection_items = [] num_items = len(selections) frame_size = num_items / 10.0 + 0.06 self._selection_frame = gui.Frame(parent=self.root, frame_color=(0.8, 0.8, 0.8, 0.5), frame_size=(-0.25, 0.25, 0.0, frame_size), pos=(0, 0, -1.0)) gui.Label(parent=self._selection_frame, text=title, text_scale=(0.05, 0.05), frame_color=(0, 0, 0, 0), pos=(0, 0, frame_size)) for idx, selection in enumerate(selections): btn = gui.Button(parent=self.root, style='button_combat', command=select_cb, extra_args=[idx], text=selection, frame_size=(-0.25, 0.25, -0.04, 0.04), pos=(0, 0, (0.1 * num_items - 1.02) - 0.1 * idx)) self._selection_items.append(btn)
def createResErrorSprites(self): errorLabel = gui.Label(self) errorLabel.set_size((300, 50)) errorLabel.set_center((400, 300)) errorLabel.set_text("This resolution is too big for your screen") self.resErrorGroup = pygame.sprite.Group(errorLabel)
def __init__(self): self.cells = [] # 220 squares to make up the visual board self.scoreLabel = score.scoreLabel self.yourFinalScore = gui.Label('Your Final Score Is') world.add(self.scoreLabel, config['worldSize'] - (config['worldMarginY'] * 4), (config['worldMarginY']))
def setup_gui(data): b = gui.Box(orientation=gui.Box.HORIZONTAL) b.background = gui.BoxTexture('gui.atlas:bar', [-1], [-1, 1]) b.padding = gui.Rect(6, 6, 6, 6) b.alignment.y = 1 b.fill.x = True b.homogeneous = False b.spacing = 6 play = gui.Button(icon='gui.atlas:play') b.add(play) step = gui.Button(icon='gui.atlas:step') b.add(step) la = gui.Widget(alignment=gui.Alignment(1, 0.5), fill=gui.Fill(True, True)) l = gui.Label(text='time: {:>6.3f}'.format(0)) l.color = gui.Color(1, 1, 1, 1) l.padding = gui.Rect.uniform(3) l.alignment = gui.Alignment(1, 0.5) la.add(l) b.add(la) data.gui.add(b) data.lbl_time = l
def __init__(self, image, vector, on_animation_finished): super().__init__(vector, 200, callback=on_animation_finished, die_when_done=False) self.text = gui.Label("", f.SMALL, visible=False) self.add_children(self.text, image)
def graphics(self): logo = pygame.image.load(os.path.join('data', 'logo.png')).convert() self.ff_logo = pygame.transform.scale(logo, threades.resize_pos((1111, 250))) threades.screen.fill((0, 0, 0)) threades.screen.blit(self.ff_logo, threades.resize_pos((40, 50))) # Font type myfont = pangofont.PangoFont(size=threades.resize_pt(17)) #creating new label showing loading of level labelStyleCopy = gui.defaultLabelStyle.copy() labelStyleCopy['border-width'] = 1 labelStyleCopy['wordwrap'] = True labelStyleCopy['autosize'] = False labelStyleCopy['font'] = myfont labelStyleCopy['font-color'] = (0, 200, 0) if self.level_no == -1: text1 = _('Loading New Level...') else: text1 = _('Loading Level No:') + str(self.level_no) #creating the label label = gui.Label(position=threades.resize_pos((500, 600)), size=threades.resize_pos((250, 50)), parent=desktop_level, style=labelStyleCopy, text=text1)
def searchRequest(message="What artist are you interested in?", arbitraryFunction=main): global requestWindow, artistField requestWindow = gui.Display("Choose Artist",300,100,(getScreenWidth()/2)-150, (getScreenHeight()/2)-100) requestWindow.add(gui.Label(message), 25, 15) artistField = gui.TextField("What Artist?", 8) requestWindow.add(artistField, 25, 40) okButton = gui.Button("OK", arbitraryFunction) requestWindow.add(okButton, 215, 60)
def __init__(self): ''' Draws the Facilities panel ''' self.update_flag = True myfont1 = pangofont.PangoFont(size=threades.resize_pt( 25)) # For model.resources name and their value self.labelstyle1 = gui.defaultLabelStyle.copy() self.labelstyle1['border-width'] = 0 self.labelstyle1['wordwrap'] = False self.labelstyle1['autosize'] = False self.labelstyle1['font'] = myfont1 self.labelstyle1['font-color'] = self.font_color #self.labelstyle1['bg-color'] = self.font_bg_color self.list_titles = (_('Houses '), _('Schools '), _('Hospitals '), _('Workshops '), _('Farms '), _('Wells ')) self.list_names = (_('Number: '), _('Number: '), _('Number: '), _('Number: '), _('Number: '), _('Number: ')) self.list_values1 = (model.House.get_number(), model.School.get_number(), model.Hospital.get_number(), model.Workshop.get_number(), model.Farm.get_number(), model.Fountain.get_number()) self.list_values2 = (model.House.get_level(), model.School.get_level(), model.Hospital.get_level(), model.Workshop.get_level(), model.Farm.get_level(), model.Fountain.get_level()) self.value_labels = [] for i in range(6): label = gui.Label(position=threades.resize_pos((950, 50 + 55 * i)), size=threades.resize_pos((300, 30)), parent=threades.desktop, text=self.list_titles[i], style=self.labelstyle1) label = gui.Label(position=threades.resize_pos((950, 75 + 55 * i)), size=threades.resize_pos((300, 30)), parent=threades.desktop, text=self.list_names[i] + str(int(self.list_values1[i])) + _(' Level: ') + str(int(self.list_values2[i])), style=self.labelstyle1) label.surf.set_alpha(200) self.value_labels.append(label)
def setup_status(self, mechs, back_cb=None, back_args=[]): for i in self._mech_frames: i.destroy() self._mech_frames = [] if self._back_btn: self._back_btn.destroy() for idx, mech in enumerate(mechs): frame = gui.Frame(parent=self.root, frame_color=(0.3, 0.3, 0.3, 0.5), frame_size=(-0.9, 0.9, -0.20, 0.20), pos=(0.0, 0.0, 0.70 - 0.50 * idx)) frame.label = gui.Label(parent=frame, style='text_base', text=mech.name, pos=(-0.85, 0, 0.15)) frame.hp = gui.Label(parent=frame, style='text_base', text="HP: {}".format(mech.health), pos=(-0.80, 0, 0.05)) frame.attack = gui.Label(parent=frame, style='text_base', text="ATK: {}".format(mech.health), pos=(-0.30, 0, 0.05)) frame.roles = gui.Label(parent=frame, style='text_base', text="Roles: {}".format(', '.join( mech.roles)), pos=(-0.80, 0, -0.05)) self._mech_frames.append(frame) if back_cb: self._back_btn = gui.Button(parent=self.root, style='button_general', command=back_cb, extra_args=back_args, text='Back', frame_size=(-0.25, 0.25, -0.04, 0.04), pos=(-0.2, 0, -0.9))
def __init__(self): super().__init__() self._selection_items = [] gui.Frame(parent=self.root_full, style='title_bg') gui.Label(parent=self.root, style='text_title', text='Prototype Hydrogen', pos=(0.0, 0.0, 0.8))
def __init__(self, settings, **params): # The framework GUI is just basically a HTML-like table # There are 2 columns right-aligned on the screen gui.Table.__init__(self, **params) self.form = gui.Form() fg = (255, 255, 255) # "Toggle menu" self.tr() self.td(gui.Label("F1: Toggle Menu", color=(255, 0, 0)), align=1, colspan=2) for slider in sliders: # "Slider title" self.tr() self.td(gui.Label(slider['text'], color=fg), align=1, colspan=2) # Create the slider self.tr() e = gui.HSlider(getattr(settings, slider['name']), slider['min'], slider['max'], size=20, width=100, height=16, name=slider['name']) self.td(e, colspan=2, align=1) # Add each of the checkboxes. for text, variable in checkboxes: self.tr() if variable == None: # Checkboxes that have no variable (i.e., None) are just labels. self.td(gui.Label(text, color=fg), align=1, colspan=2) else: # Add the label and then the switch/checkbox self.td(gui.Label(text, color=fg), align=1) self.td( gui.Switch(value=getattr(settings, variable), name=variable))
def __init__(self): super().__init__(allowed_events=[pl.MOUSEMOTION, pl.MOUSEBUTTONDOWN, pl.KEYDOWN], bg_color=c.BLACK, bg_image=resources.load_image('Ice Emblem.png'), layout_width=FILL, layout_height=FILL, spacing=50) self.click_to_start = gui.Label(_("Click to Start"), f.MAIN_MENU, padding=10, txt_color=c.ICE, layout_gravity=gui.Gravity.BOTTOM, die_when_done=False) self.hmenu = gui.HorizontalMenu([(_("License"), self.show_license), (_("Settings"), self.settings_menu)], f.SMALL, die_when_done=False, layout_gravity=gui.Gravity.BOTTOMRIGHT) self.add_children(self.click_to_start, self.hmenu) self.bind_keys((pl.K_RETURN, pl.K_SPACE), self.show_map_menu) self.bind_click((1,), self.show_map_menu, self.hmenu.rect, False)
def _create_ec_frame(self, n, empty=False): frame_per_column = 12 col = n // frame_per_column row = n % frame_per_column frame = gui.Frame(parent=self.root_left, frame_color=(0.8, 0.8, 0.8, 0.5), frame_size=(-0.2, 0.2, -0.08, 0.08), pos=(0.215 + 0.405 * col, 0, -1.075 + 0.167 * frame_per_column - 0.167 * row)) if not empty: frame.label = gui.Label(parent=frame, text='', text_scale=(0.035, 0.035), text_align=p3d.TextNode.ALeft, frame_color=(0, 0, 0, 0), pos=(-0.175, 0, 0.025)) frame.hpbar = gui.WaitBar( parent=frame, value=100, text='0/0', text_scale=(0.025, 0.025), text_pos=(0, -0.006), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 0.8), frame_color=(0, 0, 0, 1), frame_size=(-0.15, 0.15, -0.01, 0.01), ) frame.attacklabel = gui.Label( parent=frame, text='', text_scale=(0.025, 0.025), text_align=p3d.TextNode.ALeft, pos=(-0.175, 0, -0.05), ) return frame
def test(): import resources import room import fonts as f import logging logging.basicConfig(level=logging.DEBUG) nine = NinePatch(resources.load_image('WindowBorder.png'), (70, 70), wait=False, padding=100, layout_gravity=gui.Gravity.FILL) nine.add_child(gui.Label("test", f.MAIN)) nine.add_child(gui.Clock(f.MAIN)) room.run_room(nine)
def chatWindow(self, windowtext=None): ''' Opens a new chat window ''' global desktopChat global move_to_next_chatwin_flag move_to_next_chatwin_flag = False #so that the next window waits for the user to press enter # Disable other gui gui_buttons.gui_obj.disable_buttons() # Stopping the updation thread threades.pause_update_thread() # Custom Window Style win_style = gui.defaultWindowStyle.copy() win_style['bg-color'] = (0, 0, 0) # Calculating position and size of window from the size of the desktop position_win = threades.resize_pos((150.0, 50.0)) size_win = threades.resize_pos((900, 800)) #print 'size win is',size_win,'\n' # Creating window self.chatWin = gui.Window(position=position_win, size=size_win, parent=desktopChat, text='', style=win_style, closeable=False, shadeable=False, moveable=False) self.chatWin.surf.fill((0, 0, 0, 140)) self.chatWinFlag = True #NOTE: This part will be used once we know how to blit buttons on the chat window #self.button_skip = gui.Button(position = threades.resize_pos((500.0,10.0),(900.0,800.0),self.size_win), size = threades.resize_pos((80.0,30.0),(900.0,800.0),self.size_win), parent = self.chatWin, text = "Skip",style = self.button_style) #self.button_next = gui.Button(position = threades.resize_pos((200.0,10.0),(900.0,800.0),self.size_win), size = threades.resize_pos((80.0,30.0),(900.0,800.0),self.size_win), parent = self.chatWin, text = "Next >",style = self.button_style) #self.button_skip.onClick=self.closeChatWindow #self.button_skip.onMouseOver=self.closeChatWindow #print self.button_skip.enabled #creating label for writing the text self.label = gui.Label(position=threades.resize_pos( (100.0, 760.0), (900.0, 800.0), self.chatWin.size), size=threades.resize_pos((700.0, 30.0), (900.0, 800.0), self.chatWin.size), parent=self.chatWin, text=model.text_file.proceed_text[0], style=self.labelStyleCopy)
def __init__(self): gui.Window.__init__(self, title='Functions', size=(500, 300)) box = gui.Box(self, 'horizontal') # split = gui.Splitter(box, 'horizontal', stretch=1) # self.categories = gui.List(split) self.category = gui.List(box, model=RegModel(registry), stretch=1) self.category.connect('selection-changed', self.on_select_function) self.category.connect('item-activated', self.on_item_activated) rbox = gui.Box(box, 'vertical', stretch=2) toolbar = gui.Toolbar(rbox, stretch=0) toolbar.append(gui.Command('New', '', self.on_new, 'new.png')) toolbar.append(gui.Command('Delete', '', self.on_remove, 'remove.png')) toolbar.append(gui.Command('Save', '', self.on_save, 'save.png')) toolbar._widget.Realize() book = gui.Notebook(rbox) edit = gui.Box(book, 'vertical', page_label='edit') g = gui.Grid(edit, 2, 2, stretch=0, expand=True) g.layout.AddGrowableCol(1) gui.Label(g, 'Name', pos=(0, 0)) gui.Label(g, 'Parameters', pos=(1, 0)) self.name = gui.Text(g, pos=(0, 1), expand=True) self.params = gui.Text(g, pos=(1, 1), expand=True) # self.text = gui.Text(edit, multiline=True, stretch=1) self.text = gui.PythonEditor(edit, stretch=1) extra = gui.Box(book, 'vertical', page_label='extra') # self.extra = gui.Text(extra, multiline=True, stretch=1) self.extra = gui.PythonEditor(extra, stretch=1) self.functions = functions self.function = None
def run(surface): running = True clock = pygame.time.Clock() cursor = pygame.transform.scale(pygame.image.load("images/cursor.png") ,(16,28)) def_pos=500 button = gui.Button(surface,(100,30),(300,def_pos),(210,0,125),"Button") title = gui.Label(surface,"Fonts/JosefinSans-Bold.ttf",24,"GUI Graphical user interface",(0,0,0),(100,0)) lstbox = gui.ListBox(surface,["list item one","list item two","list item three","item four","item five"],(255,0,0),(200,200),(100,200)) rlstbox = gui.ListBox(surface,["listr item one","listr item two","listr item three","item four","item five"],(0,0,255),(200,200),(400,200)) ckbox = gui.CheckBox(surface,(255,0,0),['hello','aref','Jaffar'],(100,40)) txtbox = gui.textBox(surface,(255,0,0),(255,50,0),(0,100),(200,24)) def update(): button.update() title.update() lstbox.update() txtbox.update(); ckbox.update() rlstbox.update() while running: for event in pygame.event.get(): txtbox.event2(event) if event.type == pygame.QUIT: running = False if event.type == pygame.KEYDOWN: txtbox.press(event) if event.key == pygame.K_ESCAPE: running = False if event.key == pygame.K_UP: button.text.color=(255,0,0) button.text.recalc() if event.type == pygame.MOUSEBUTTONDOWN: txtbox.Click() lstbox.clicked() rlstbox.clicked() ckbox.clicked() if button.clicked(): lstbox.listt.pop() lstbox.listt.append("hello") lstbox.calc() ckbox.scolor=(0,0,255) surface.fill((255,255,255)) update() functions.set_cursor(surface,cursor) functions.update(clock,60) pygame.quit()
def show_label(self, position, text, text_size=15, color="black", timeout=3, id_=""): """ Creates text label on the screen. The label is stored in the internal gui_list list and gets rendered automatically. :param position: tuple with coordinates (x,y) of top left corner of the label :param text: string with text for the label :param text_size: integer text size :param color: tuple (R, G, B) with text color :param timeout: integer seconds for the label timeout. If equals 0, label won't timeout and should be hidden manually. :param id_: string ID of the label, should be unique for each GUI element :return: object of gui.Label """ label = gui.Label(self.screen, position, text, text_size, color, timeout, id_) self.gui_list.append(label) return label
def main(self): # the arguments are width - height - layoutOrientationOrizontal wid = gui.Widget(120, 100, False, 10) self.lbl = gui.Label(100, 30, 'Hello world!') self.bt = gui.Button(100, 30, 'Press me!') # setting the listener for the onclick event of the button self.bt.set_on_click_listener(self, 'on_button_pressed') # appending a widget to another, the first argument is a string key wid.append('1', self.lbl) wid.append('2', self.bt) # returning the root widget return wid
def createMainMenuSprites(self): label = gui.Label(self) label.set_fontSize(50) label.set_text("Skarcha") label.set_size((200, 70)) label.set_center((400, 100)) label.set_backgroundImg(label.COLOR, (255, 255, 255)) label.set_aa(True) label.set_fontName("Graphics/Menu/Fonts/BIRTH_OF_A_HERO.ttf") startGame = gui.GoTo(self) startGame.set_text("New Game") startGame.set_size((150, 40)) startGame.set_center((160, 200)) startGame.set_normBg(startGame.IMAGE, "Graphics/Menu/button.png") startGame.set_activeBg(startGame.IMAGE, "Graphics/Menu/button_active.png") startGame.set_clickedBg(startGame.IMAGE, "Graphics/Menu/button_clicked.png") startGame.set_aa(True) startGame.set_fontName("Graphics/Menu/Fonts/Harabara.ttf") settings = gui.GoTo(self) settings.set_goto(self.SETTINGS) settings.set_text("Settings") settings.set_size((150, 40)) settings.set_center((160, 300)) settings.set_normBg(settings.IMAGE, "Graphics/Menu/button.png") settings.set_activeBg(settings.IMAGE, "Graphics/Menu/button_active.png") settings.set_clickedBg(settings.IMAGE, "Graphics/Menu/button_clicked.png") settings.set_aa(True) settings.set_fontName("Graphics/Menu/Fonts/coolvetica_rg.ttf") quit = gui.Quit(self) quit.set_fontSize(40) quit.set_text("QUIT") quit.set_size((150, 40)) quit.set_center((160, 500)) quit.set_normBg(quit.IMAGE, "Graphics/Menu/button.png") quit.set_activeBg(quit.IMAGE, "Graphics/Menu/button_active.png") quit.set_clickedBg(quit.IMAGE, "Graphics/Menu/button_clicked.png") quit.set_aa(True) self.mainMenuGroup = pygame.sprite.Group(label, startGame, settings, quit)
def __init__(self, character, text, **kwargs): gui.ChatDialog.__init__(self, text, **kwargs) self.characterPortrait = gui.Image(parent=self, surface=character._spriteset[2][0], pos=(5, 5)) self.add(self.characterPortrait) self.characterName = gui.Label(parent=self, text=character.name) self.characterName.x = self.characterPortrait.right + 5 self.characterName.y = self.characterPortrait.y + self.characterPortrait.height / 2 - self.characterName.height / 2 self.add(self.characterName) self.textLabel.x = 5 self.textLabel.y = self.characterPortrait.bottom + 10 self.height = 30 + self.characterPortrait.height + self.textLabel.height
class Score: currentScore = 0 scoreString = str(currentScore) + ' ' scoreLabel = gui.Label(scoreString) fps = 1 time = 0 def changeScore(self, update): #update is an in self.currentScore += update # change the score value self.fps -= (0.02) self.scoreString = str(self.currentScore) self.scoreLabel.setText( self.scoreString) # change the score label display def changeTime(self): self.time += self.fps if self.time > getDuration(song): play(song) self.time = 0
def __init__(self, image): super().__init__(layout_width=gui.LayoutParams.FILL_PARENT, layout_height=gui.LayoutParams.FILL_PARENT, gravity=gui.Gravity.CENTER, bg_color=c.BLACK, bg_image=image) self.files = [(file, self.chosen) for file in resources.list_maps()] self.choose_label = gui.Label(_("Choose a map!"), f.MAIN_MENU, txt_color=c.ICE, bg_color=c.MENU_BG) self.menu = gui.Menu(self.files, f.MAIN, padding=(25, 25), die_when_done=False) self.back_btn = gui.Button(_("Go Back"), f.MAIN, callback=self.back, layout_gravity=gui.Gravity.BOTTOMRIGHT) self.add_children(self.choose_label, self.menu, self.back_btn)