コード例 #1
0
    def cache_musicscreen(self):
        self.musicscreen_cache = {}
        self.musicplayer.trackdata_changed = False

        if self.musicplayer.image != None:
            albumart_image_size = (self.ui.display_size[0] * .25,
                                   self.ui.display_size[1] * .5)
            self.musicscreen_cache["albumart_image"] = gui.Image(
                self.musicplayer.image, albumart_image_size)
        else:
            self.musicscreen_cache["albumart_image"] = gui.Image(
                pygame.Surface((1, 1), flags=pygame.SRCALPHA))

        self.musicscreen_cache[
            "albumart_image"].Position = self.ui.calculate_position(
                (0, 4), self.musicscreen_cache["albumart_image"].Surface,
                "center", "left")

        track = self.musicplayer.title
        trackfont_size = self.ui.calculate_font_size(4)

        self.musicscreen_cache["track_text"] = gui.Text(
            track, trackfont_size, font=self.ui.boldfont_file, wrapwidth=16)
        self.musicscreen_cache[
            "track_text"].Position = self.ui.calculate_position(
                (0, 0), self.musicscreen_cache["track_text"].Surface, "center",
                "left")

        self.musicscreen_cache["track_text"].Position = (
            self.musicscreen_cache["albumart_image"].Position[0] +
            self.musicscreen_cache["albumart_image"].Surface.get_size()[0] *
            1.05, self.musicscreen_cache["track_text"].Position[1])

        artistfont_size = self.ui.calculate_font_size(3)
        self.musicscreen_cache["artist_text"] = gui.Text(
            self.musicplayer.artist,
            artistfont_size,
            font=self.ui.basefont_file)

        artist_text_y = self.musicscreen_cache["track_text"].Position[1] - (
            self.ui.display_size[1] * 0.08)
        self.musicscreen_cache["artist_text"].Position = (
            self.musicscreen_cache["track_text"].Position[0], artist_text_y)

        self.musicscreen_cache["album_text"] = gui.Text(
            self.musicplayer.album,
            artistfont_size,
            font=self.ui.basefont_file)
        album_text_y = ((self.ui.display_size[1] * 0.03) +
                        self.musicscreen_cache["track_text"].Rect.bottom)
        self.musicscreen_cache["album_text"].Position = (
            self.musicscreen_cache["track_text"].Position[0], album_text_y)
コード例 #2
0
ファイル: kid_window.py プロジェクト: fdanesse/saludame
    def __init__(self, container, left_bottom, frame_rate, windows_controller,
                 event, character):

        rect = pygame.Rect((0, 0), (300, 559))
        rect.bottomleft = left_bottom

        self.visible = True

        gui.Window.__init__(self, container, rect, frame_rate,
                            windows_controller, "external_character")

        self.time_span = event.message_time_span

        self.character = character  # Main character (Kid)

        self.external_character = gui.Image(self.rect,
                                            pygame.Rect((13, 179), (273, 380)),
                                            1, event.person_path, True)

        if (event.person_path == os.path.join(BASEPATH,
                                              "assets/characters/mother.png")
                or event.person_path == os.path.join(
                    BASEPATH, "assets/characters/father.png")):
            self.apply_mappings()

        self.external_character.keep_dirty = True
        self.add_child(self.external_character)

        message_balloon = MessageBalloon(self.rect, pygame.Rect(0, 0, 1, 1), 1,
                                         self.windows_controller, 'B')
        message_balloon.set_text(event.person_message)
        self.add_window(message_balloon)
コード例 #3
0
 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)
コード例 #4
0
    def update_content(self,
                       title="Verdadero o Falso",
                       text="",
                       image=os.path.join(
                           BASEPATH, "assets/challenges/ninio_normal.png")):
        self.title.text = title
        self.title.refresh()
        self.text.parse_lines(text)
        self.text.prepare_text_block()

        self.remove_child(self.image)
        self.image = gui.Image(self.rect, pygame.Rect(640, 240, 80, 80), 1,
                               image)
        self.add_child(self.image)
コード例 #5
0
ファイル: actordialog.py プロジェクト: mavroskardia/oworld
    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
コード例 #6
0
 def __init__(self, _unit: Unit, **kwargs) -> None:
     super().__init__(wait=False,
                      gravity=Gravity.CENTER,
                      allowed_events=[p.MOUSEBUTTONDOWN, p.KEYDOWN],
                      **kwargs)
     self.unit = _unit
     self.gained_exp = _unit.exp_prev + _unit.gained_exp()
     self.image = gui.Image(_unit.image,
                            die_when_done=False,
                            bg_color=c.MENU_BG)
     self.bar = gui.LifeBar(max=99,
                            value=_unit.exp_prev,
                            blocks_per_row=100,
                            block_size=(2, 10),
                            life_color=c.YELLOW)
     self.label = gui.Label(_("EXP: {experience}") + "\t" +
                            _("LV: {level}"),
                            f.SMALL,
                            txt_color=c.YELLOW)
     self.label.format(**_unit.__dict__)
     self.add_children(self.image, self.bar, self.label)
     self.time = 0
コード例 #7
0
    def __init__(self,
                 container,
                 rect,
                 frame_rate,
                 windows_controller,
                 challenges_creator,
                 text_intro,
                 text_result_good,
                 text_result_bad,
                 slide=None,
                 bg_color=(0, 0, 0)):
        gui.Window.__init__(self, container, rect, frame_rate,
                            windows_controller, "info_challenge_window",
                            bg_color)

        self.set_bg_image(os.path.join(BASEPATH,
                                       "assets/windows/window_2.png"))
        self.challenges_creator = challenges_creator

        self.rect = rect

        self.btn_continue = utilities.get_accept_button(
            self.rect, pygame.Rect((400, 500), (1, 1)), _("Continue"),
            self._cb_button_click_continue)
        self.add_button(self.btn_continue)

        # Texts
        self.title = gui.Text(rect, 40, 40, 1, "Verdadero o Falso", 45,
                              TITLE_COLOR)
        self.text = gui.TextBlock(rect, 40, 120, 1, "", 35, TEXT_COLOR,
                                  "normal", False)
        self.image = gui.Image(
            rect, pygame.Rect(640, 240, 80, 80), 1,
            os.path.join(BASEPATH, "assets/challenges/ninio_normal.png"))

        self.add_child(self.title)
        self.add_child(self.text)
        self.add_child(self.image)
コード例 #8
0
ファイル: panel_window.py プロジェクト: fdanesse/saludame
    def set_weather(self):
        if self.weather_widget:
            self.remove_child(self.weather_widget)

        current_weather = self.windows_controller.game_man.current_weather
        file_path = current_weather[3]
        self.weather_widget = gui.Image(self.rect, pygame.Rect(51, 34, 1, 1),
                                        1, file_path)
        self.add_child(self.weather_widget)
        self.weather_widget.set_dirty()

        info = "%s \n" % (current_weather[1])

        effect = self.windows_controller.game_man.environment_effect
        if effect:
            for eff in effect.effect_status_list:
                bar_label = effect.bars_controller.get_bar_label(eff[0])
                if eff[1] > 0:
                    info += "+ %s \n" % (bar_label)
                else:
                    info += "- %s \n" % (bar_label)

        self.weather_widget.set_super_tooltip(info)
コード例 #9
0
ファイル: buscar.py プロジェクト: oscarvogel/abmpyafipws
                           text='Nro Doc',
                           width=100,
                           represent="%s",
                           align="right")
            gui.ListColumn(name=u'nombre_cliente', text='Cliente', width=150)

        gui.Button(label=u'Salir',
                   name='close',
                   sizer_border=4,
                   top=nTop,
                   left='510')

        gui.Image(
            name='imgsistema',
            height='36',
            left='17',
            top=nTop,
            width='238',
            filename='sistemas-agiles.png',
        )
        gui.Image(
            name='imgpyafip',
            height='50',
            left='665',
            top=nTop,
            width='100',
            filename='logo-pyafipws.png',
        )

    gui.StatusBar(
        name='statusbar_15_91',
        text=u'Servicio Web Factura Electr\xf3nica mercado interno (WSFEv1)',
コード例 #10
0
ファイル: Example.py プロジェクト: lukasz1985/PySmallGui
def main():

    pygame.init()
    screen = pygame.display.set_mode((800, 600))

    input = gui.Input()

    the_gui = gui.Gui(input)

    input.addMouseListener(the_gui)
    input.addKeyboardListener(the_gui)

    box = gui.Box()
    box.setPosition(0, 0)
    box.setDimensions(10, 10)

    box.setPaddings(Pad(1, 2, 3, 4))
    box.setBorders(Pad(10, 10, 4, 4))
    box.setMargins(Pad(9, 10, 11, 12))

    container = gui.Container()
    the_gui.addWidget(container)
    container.addWidget(box)

    content_area = box.getContentArea()
    padded_area = box.getPaddedArea()
    bordered_area = box.getBorderedArea()
    whole_area = box.getWholeArea()

    # Testing parenting:
    frame = gui.Frame()
    frame.setPosition(0, 0)
    #frame.setMargins(EqualPad(4))
    frame.setBorders(EqualPad(1))
    frame.setPaddings(Pad(2, 2, 20, 2))
    frame.setDimensions(200, 200)
    #frame.setLayout(gui.GridLayout(3,4))
    #frame.setLayout(gui.GridLayout(2, 4, Align.TOP))
    frame.setLayout(gui.VerticalLayout())
    the_gui.addWidget(frame)

    for i in range(0, 8):

        box = gui.Box()
        box.setPosition(0, 0)
        #size = 10 + random.randint(0,4)

        width = i * 5
        height = i * 5

        box.setBorders(Pad(1, 1, 1, 1))
        box.setMargins(Pad(5, 5, 5, 5))
        frame.addWidget(box)
        box.setDimensions(width, height)

    # Testing clipping:
    frame = gui.Frame()
    frame.setPosition(340, 0)

    frame.setMargins(Pad(4, 4, 4, 4))
    frame.setBorders(Pad(1, 1, 1, 1))
    frame.setDimensions(80, 200)
    frame.setPaddings(EqualPad(15))
    the_gui.addWidget(frame)

    inner_frame = gui.Frame()
    inner_frame.setPosition(40, 0)
    inner_frame.setMargins(Pad(4, 4, 4, 4))
    inner_frame.setBorders(Pad(1, 1, 1, 1))
    inner_frame.setDimensions(180, 100)
    frame.addWidget(inner_frame)

    inner_frame.setLayout(gui.GridLayout(3, 5))

    for i in range(0, 12):
        col = i % 3
        row = i / 3

        box2 = gui.Box()
        box2.setPosition(0, 0)
        #size = 10 + random.randint(0,4)

        width = col * 10
        height = row * 5

        box2.setDimensions(width, height)
        box2.setBorders(Pad(1, 1, 1, 1))
        box2.setMargins(Pad(5, 5, 5, 5))
        inner_frame.addWidget(box2)

    img = gui.loadImage("res/aircraft.png")
    image_widget = gui.Image(img)
    image_widget.setPosition(0, 0)
    image_widget.setBorders(Pad(3, 3, 3, 3))
    image_widget.setDimensions(100, 100)
    inner_frame.addWidget(image_widget)

    # Testing ImageButton
    img_default = gui.loadImage("res/truck.png")
    img_pressed = gui.loadImage("res/truck_bnw.png")
    img_button = gui.ImageButton(img_default, img_pressed)
    img_button.setPosition(20, 200)
    img_button.setDimensions(30, 30)
    the_gui.addWidget(img_button)

    # Testing elements alignment:

    frame = gui.Frame()
    frame.setDimensions(200, 200)
    frame.setLayout(gui.GridLayout(2, 6))
    frame.setPosition(0, 300)
    the_gui.addWidget(frame)

    run = True
    while (run):
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False
            input.handleEvent(event)

        screen.fill((255, 255, 255))
        the_gui.draw(screen)
        pygame.display.flip()

    pygame.quit()
コード例 #11
0
ファイル: consultas.py プロジェクト: oscarvogel/abmpyafipws
 with gui.MenuBar(name='menubar_83_155', ):
     with gui.Menu(name='menu_114', ):
         gui.MenuItemSeparator(name='menuitemseparator_130', )
 gui.StatusBar(
     name='statusbar_15_91',
     text=u'Servicio Web Factura Electr\xf3nica mercado interno (WSFEv1)',
 )
 with gui.Panel(
         label=u'',
         name='panel',
         image='',
 ):
     gui.Image(
         name='image_507_571',
         height='36',
         left='17',
         top='545',
         width='238',
         filename='sistemas-agiles.png',
     )
     gui.Image(
         name='image_33_540',
         height='50',
         left='665',
         top='532',
         width='100',
         filename='logo-pyafipws.png',
     )
     with gui.ListView(
             name='listado',
             height='353',
             left='7',
コード例 #12
0
 def set_image(self, image):
     if not isinstance(image, pygame.Surface):
         image = pygame.image.load(image).convert_alpha()
     image = gui.Image(self.rect, pygame.Rect(500, 40, 20, 20), 1, image)
     self.add_child(image)
コード例 #13
0
    def main(self):
        verticalContainer = gui.Widget(640, 680, False, 10)

        horizontalContainer = gui.Widget(620, 620, True, 10)

        subContainerLeft = gui.Widget(340, 530, False, 10)
        self.img = gui.Image(100, 100, './res/logo.png')

        self.table = gui.Table(300, 200)
        row = gui.TableRow()
        item = gui.TableTitle()
        item.append(str(id(item)), 'ID')
        row.append(str(id(item)), item)
        item = gui.TableTitle()
        item.append(str(id(item)), 'First Name')
        row.append(str(id(item)), item)
        item = gui.TableTitle()
        item.append(str(id(item)), 'Last Name')
        row.append(str(id(item)), item)
        self.table.append(str(id(row)), row)
        self.add_table_row(self.table, '101', 'Danny', 'Young')
        self.add_table_row(self.table, '102', 'Christine', 'Holand')
        self.add_table_row(self.table, '103', 'Lars', 'Gordon')
        self.add_table_row(self.table, '104', 'Roberto', 'Robitaille')
        self.add_table_row(self.table, '105', 'Maria', 'Papadopoulos')

        # the arguments are	width - height - layoutOrientationOrizontal
        subContainerRight = gui.Widget(240, 560, False, 10)

        self.lbl = gui.Label(200, 30, 'This is a LABEL!')

        self.bt = gui.Button(200, 30, 'Press me!')
        # setting the listener for the onclick event of the button
        self.bt.set_on_click_listener(self, 'on_button_pressed')

        self.txt = gui.TextInput(200, 30)
        self.txt.set_text('This is a TEXTAREA')
        self.txt.set_on_change_listener(self, 'on_text_area_change')

        self.spin = gui.SpinBox(200, 30)
        self.spin.set_on_change_listener(self, 'on_spin_change')

        self.btInputDiag = gui.Button(200, 30, 'Open InputDialog')
        self.btInputDiag.set_on_click_listener(self, 'open_input_dialog')

        self.btFileDiag = gui.Button(200, 30, 'File Selection Dialog')
        self.btFileDiag.set_on_click_listener(self,
                                              'open_fileselection_dialog')

        self.btUploadFile = gui.FileUploader(200, 30, './')
        self.btUploadFile.set_on_success_listener(self,
                                                  'fileupload_on_success')
        self.btUploadFile.set_on_failed_listener(self, 'fileupload_on_failed')

        self.listView = gui.ListView(300, 120)
        self.listView.set_on_selection_listener(self, "list_view_on_selected")
        li0 = gui.ListItem(279, 20, 'Danny Young')
        li1 = gui.ListItem(279, 20, 'Christine Holand')
        li2 = gui.ListItem(279, 20, 'Lars Gordon')
        li3 = gui.ListItem(279, 20, 'Roberto Robitaille')
        self.listView.append('0', li0)
        self.listView.append('1', li1)
        self.listView.append('2', li2)
        self.listView.append('3', li3)

        self.dropDown = gui.DropDown(200, 20)
        c0 = gui.DropDownItem(200, 20, 'DropDownItem 0')
        c1 = gui.DropDownItem(200, 20, 'DropDownItem 1')
        self.dropDown.append('0', c0)
        self.dropDown.append('1', c1)
        self.dropDown.set_on_change_listener(self, 'drop_down_changed')

        self.slider = gui.Slider(200, 20, 10, 0, 100, 5)
        self.slider.set_on_change_listener(self, 'slider_changed')

        self.colorPicker = gui.ColorPicker(200, 20, '#ffbb00')
        self.colorPicker.set_on_change_listener(self, 'color_picker_changed')

        self.date = gui.Date(200, 20, '2015-04-13')
        self.date.set_on_change_listener(self, 'date_changed')

        # appending a widget to another, the first argument is a string key
        subContainerRight.append('1', self.lbl)
        subContainerRight.append('2', self.bt)
        subContainerRight.append('3', self.txt)
        subContainerRight.append('4', self.spin)
        subContainerRight.append('5', self.btInputDiag)
        subContainerRight.append('5_', self.btFileDiag)
        subContainerRight.append(
            '5__',
            gui.FileDownloader(200, 30, 'download test', './res/logo.png'))
        subContainerRight.append('5___', self.btUploadFile)
        subContainerRight.append('6', self.dropDown)
        subContainerRight.append('7', self.slider)
        subContainerRight.append('8', self.colorPicker)
        subContainerRight.append('9', self.date)
        self.subContainerRight = subContainerRight

        subContainerLeft.append('0', self.img)
        subContainerLeft.append('1', self.table)
        subContainerLeft.append('2', self.listView)

        horizontalContainer.append('0', subContainerLeft)
        horizontalContainer.append('1', subContainerRight)

        menu = gui.Menu(620, 40)
        m1 = gui.MenuItem(100, 40, 'File')
        m2 = gui.MenuItem(100, 40, 'View')
        m2.set_on_click_listener(self, 'menu_view_clicked')
        m11 = gui.MenuItem(100, 40, 'Save')
        m12 = gui.MenuItem(100, 40, 'Open')
        m12.set_on_click_listener(self, 'menu_open_clicked')
        m111 = gui.MenuItem(100, 40, 'Save')
        m111.set_on_click_listener(self, 'menu_save_clicked')
        m112 = gui.MenuItem(100, 40, 'Save as')
        m112.set_on_click_listener(self, 'menu_saveas_clicked')

        menu.append('1', m1)
        menu.append('2', m2)
        m1.append('11', m11)
        m1.append('12', m12)
        m11.append('111', m111)
        m11.append('112', m112)

        verticalContainer.append('0', menu)
        verticalContainer.append('1', horizontalContainer)

        # returning the root widget
        return verticalContainer
コード例 #14
0
# --- gui2py designer generated code starts ---

with gui.Window(
        name='mywin',
        title=u'gui2py minimal app',
        resizable=True,
        height='496px',
        width='400px',
        image='',
):
    gui.Image(
        name=u'robot_background',
        height='302',
        left='0',
        top='-6',
        width='363',
        fgcolor=u'#4C4C4C',
        filename=u'robot.png',
    )
    gui.Label(
        name=u'ir_distance',
        height='17',
        left='170',
        top='120',
        width='60',
        bgcolor=u'#F2F1F0',
        fgcolor=u'#4C4C4C',
        text=u'0 inches',
    )
    gui.Label(