def __init__(self, player, bounds, font): super().__init__(bounds, None) self.money_count = Label(Rect(0, 0, 500, 500), Color('yellow'), font, '-') self.append_child(self.money_count) self.wood_count = Label(Rect(105, 0, 500, 500), Color('brown'), font, '-') self.append_child(self.wood_count) self.meat_count = Label(Rect(220, 0, 500, 500), Color('red'), font, '-/-') self.append_child(self.meat_count) self.player = player
def welcome(self): """ Welcome screen. """ header = Label('Bienvenue', color=BLACK, size='huge') message = Label('Appuyer pour commencer', color=BLACK, size='medium') self.container.add(header) self.container.add(message) def onClick(position): """ Window click callback. """ self.container.remove(header) self.container.remove(message) self.window.onWindowClick = None self.prompt('Voulez vous configurer la connection internet ?', lambda r: self.wifi(r)) self.window.onWindowClick = onClick
def get_hero(): global heroes global labels_heroes h_values = heroes.values() h_sum = sum(h_values) r = rand(h_sum) current_sum = 0 for key, value in heroes.items(): current_sum += value if (r < current_sum): print(key, '->', current_sum, 'random:', r) hero_name = key # create hero object if (hero_name == 'knight'): hero = knight() Player.heroes_objects.append(hero) print('knight created!') Player.own_heroes.append( hero_name) # add hero to player's own list of heroes Player.own_heroes_cnt += 1 msg = Label(screen, str(hero_name), 100, 200 + Player.own_heroes_cnt * 25, 16, (241, 196, 15)) labels_heroes.append(msg) print('Now you have in collection:', Player.own_heroes) break
def __init__(self, title, message, affirmative_label, decline_label="Cancel", width=500, modal=False): Dialog.__init__(self, title=title, width=width, modal=modal) scrollbox = ScrollArea(Label(markup=message, padding=5, overflow=pango.WrapMode.WORD), scroll_horizontal=False, border=0, margin=2, margin_right=3, height=150) affirmative = Button(affirmative_label, id="affirmative_button") affirmative.connect("on-click", self._on_button_click) decline = Button(decline_label, id="decline_button") decline.connect("on-click", self._on_button_click) self.box.contents = VBox([ scrollbox, HBox([HBox(), decline, affirmative], expand=False, padding=10) ])
def createSettings(self): """ Creates and configures widget for photo configuration. """ self.effects = self.camera.effects() self.currentEffect = 0 effectPanel = Panel(orientation='horizontal', padding=0) effectPanel.add(Image('resources/icons/filter.png')) container = Panel(orientation='horizontal', padding=10) prevEffect = Label('<', size='large') nextEffect = Label('>', size='large') self.effectLabel = Label(self.effects[self.currentEffect], size='large') container.add(prevEffect) container.add(self.effectLabel) container.add(nextEffect) effectPanel.add(container) self.sidebar.add(effectPanel)
def __init__(self, **kwargs): Renderer.__init__(self, **kwargs) self.label = Label(padding=self.padding, overflow=pango.EllipsizeMode.END) self.label.graphics = self.graphics self._prev_dict = {} self._editor = Entry()
def prompt(self, question, callback): """ Prompt screen (Yes / No question only) """ header = Label(question, color=BLACK, size='medium') panel = Panel(orientation='horizontal', padding=20) def createPromptCallback(callback, answer): def delegate(): self.container.remove(header) self.container.remove(panel) callback(answer) return delegate yes = Label(' Oui ', color=WHITE, background=GRAY, size='medium') no = Label(' Non ', color=WHITE, background=GRAY, size='medium') yes.onClick = createPromptCallback(callback, True) no.onClick = createPromptCallback(callback, False) panel.add(yes) panel.add(no) self.container.add(header) self.container.add(panel) self.window.invalidate()
def __init__(self, camera, size=(640, 480)): """ Default constructor. """ self.inCapture = False self.camera = camera self.window = Window(size=size) self.currentMode = PHOTO_MODE self.root = Panel(orientation='horizontal', ) self.sidebar = Panel(orientation='vertical', padding=10) self.mode = Panel(orientation='horizontal', padding=10) self.modeLabel = Label('Photo', size='large') self.bind()
def __init__(self): # Grap all the methods of View super().__init__(self) # Label for outputs self.label=Label(frame=self.bounds.inset(0, 4, 0, 36), flex='WH') # Only some configuration for better look self.label.font=('Charter',12) self.label.text_color ='#ffffff' self.background_color = '#319b9b' self.add_subview(self.label) # This updates the view delay(self.update,0.3)
def __init__(self, contact): # The popup's constructor's argument is a boolean specifying that it # auto-close itself when the user clicks outside of it. PopupPanel.__init__(self, True) inner = VerticalPanel() nameLabel = Label(contact.name) emailLabel = Label(contact.email) inner.add(nameLabel) inner.add(emailLabel) panel = HorizontalPanel() panel.setSpacing(4) panel.add(Image(contact.photo)) panel.add(inner) self.add(panel) self.setStyleName("mail-ContactPopup") nameLabel.setStyleName("mail-ContactPopupName") emailLabel.setStyleName("mail-ContactPopupEmail")
def check_gem_clicked(gem, mouse_x, mouse_y): global label_gems_cnt if gem.rect.collidepoint(mouse_x, mouse_y): print('[Gem clicked]') if Player.gems > 0: Player.gems -= 1 label_gems_cnt = Label(screen, str(Player.gems), 150, 20, 16, (241, 196, 15)) get_hero() print('Opened a gem. Gems remained:', Player.gems) else: print('No more gems to open!')
def init(): global screen global enemy global gem global label_gems global label_gems_cnt global label_team print("init()") # randomizer init random.seed() # pygame init pygame.init() screen = pygame.display.set_mode((Set.d_width, Set.d_height)) # game objects init enemy = Enemy(screen) gem = Gem(screen) label_gems = Label(screen, 'Gems:', 100, 20, 16, (241, 196, 15)) label_gems_cnt = Label(screen, str(Player.gems), 150, 20, 16, (241, 196, 15)) label_team = Label(screen, 'TEAM', 100, 200, 16, (241, 196, 15))
def __init__(self, image): super().__init__(self) x, y = get_screen_size() if x > y: img_view = Label() img_view.text = 'Only in vertical position' img_view.frame = (0, 0, x, 15) else: y /= 4.4 img_view = ImageView() img_view.image = image img_view.frame = (0, 0, x, y) self.add_subview(img_view) self.frame = (0, 0, x, y)
def onModuleLoad(self): b = Button("Click me", greet) RootPanel().add(b) if (1 or 0) and 0: RootPanel().add(Label("or FAILED")) else: RootPanel().add(Label("or OK")) if 0 & 1 == 0: RootPanel().add(Label("& OK")) else: RootPanel().add(Label("& FAILED")) if 1 | 1 != 1: RootPanel().add(Label("| FAILED")) else: RootPanel().add(Label("| OK"))
def create_options(self, options): self.drawed = False _y = self.y _x = self.x for opt in options: self.options.append({ "name": opt, "element": Label(text=opt, size=self.size, font_name=self.font_name, x=_x, y=_y, text_align=self.text_align, color=self.color) }) if self.horizontal: _x += self.offset else: _y += self.offset
def __init__(self): self.sStrings=[["foo0", "bar0", "baz0", "toto0", "tintin0"], ["foo1", "bar1", "baz1", "toto1", "tintin1"], ["foo2", "bar2", "baz2", "toto2", "tintin2"], ["foo3", "bar3", "baz3", "toto3", "tintin3"], ["foo4", "bar4", "baz4", "toto4", "tintin4"]] self.combo=ListBox() self.list=ListBox() self.echo=Label() self.combo.setVisibleItemCount(1) self.combo.addChangeListener(self) self.list.setVisibleItemCount(10) self.list.setMultipleSelect(True) for i in range(len(self.sStrings)): self.combo.addItem("List " + i) self.combo.setSelectedIndex(0) self.fillList(0) self.list.addChangeListener(self) horz = HorizontalPanel() horz.setVerticalAlignment(HasAlignment.ALIGN_TOP) horz.setSpacing(8) horz.add(self.combo) horz.add(self.list) panel = VerticalPanel() panel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT) panel.add(horz) panel.add(self.echo) self.setWidget(panel) self.echoSelection()
def onModuleLoad(self): self.l = Label() RootPanel().add(self.l) self.display()