예제 #1
0
    def __print_text_banner(self, filename):
        text = get_ascii_art(filename)
        text_lines = text.splitlines()
        leading_newlines = len(text_lines)
        for i in xrange(leading_newlines, -1, -1):
            self.clear()

            for j in xrange(i):
                self.print_text('')

            for j in xrange(leading_newlines - i):
                self.print_text(text_lines[j])

            time.sleep(0.2)

            # tell GTK to flush the textbuffer and refresh the textview
            while Gtk.events_pending():
                Gtk.main_iteration_do(False)
예제 #2
0
    def __print_text_banner(self, filename):
        text = get_ascii_art(filename)
        text_lines = text.splitlines()
        leading_newlines = len(text_lines)
        for i in xrange(leading_newlines, -1, -1):
            self.clear()

            for j in xrange(i):
                self.print_text('')

            for j in xrange(leading_newlines - i):
                self.print_text(text_lines[j])

            time.sleep(0.2)

            # tell GTK to flush the textbuffer and refresh the textview
            while Gtk.events_pending():
                Gtk.main_iteration_do(False)
예제 #3
0
    def __create_spell(self, name, locked=False, highlighted=False):
        '''
        Create the individual GUI for a spell.
        To create the icon, have the icon located at
        media/images/name.png

        Args:
            name (str): Name to be shown in the widget
            locked (bool): Whether we show the icon locked
                           i.e. with a padlock

        Returns:
            Gtk.Box: container widget for an individual spell
        '''

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        box.set_size_request(self.CMD_WIDTH, self.CMD_HEIGHT)
        box.set_margin_top(10)
        box.set_margin_left(10)
        box.set_margin_right(10)
        box.set_margin_bottom(10)

        icon_overlay = Gtk.Overlay()
        icon_overlay.set_size_request(80, 50)
        icon_overlay.set_opacity(0.99)
        if name != '...':
            icon_overlay.set_tooltip_markup(get_ascii_art(name + '_tooltip'))
        box.pack_start(icon_overlay, False, False, 0)

        icon_background = Gtk.EventBox()
        icon_background.get_style_context().add_class("spell_icon_background")
        icon_overlay.add(icon_background)

        label_background = Gtk.EventBox()
        label_background.get_style_context().add_class(
            "spell_label_background")
        box.pack_start(label_background, False, False, 0)

        if locked:
            filename = os.path.join(images_dir, "padlock.png")
            icon_background.get_style_context().add_class("locked")
            label_background.get_style_context().add_class("locked")

        else:
            filename = os.path.join(images_dir, name + ".png")

            if highlighted:
                highlight_box = Gtk.EventBox()
                highlight_box.add(
                    Gtk.Image.new_from_file(
                        os.path.join(images_dir, "overlay.gif")))
                icon_background.add(highlight_box)

        icon_box = Gtk.EventBox()
        icon_box.add(Gtk.Image.new_from_file(filename))
        icon_overlay.add_overlay(icon_box)

        label = Gtk.Label(name)
        label.get_style_context().add_class("spell_command")
        label.set_alignment(xalign=0.5, yalign=0.5)
        label_background.add(label)

        return box
예제 #4
0
    def __create_spell(self, name, locked=False, highlighted=False):
        '''
        Create the individual GUI for a spell.
        To create the icon, have the icon located at
        media/images/name.png

        Args:
            name (str): Name to be shown in the widget
            locked (bool): Whether we show the icon locked
                           i.e. with a padlock

        Returns:
            Gtk.Box: container widget for an individual spell
        '''

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        box.set_size_request(self.CMD_WIDTH, self.CMD_HEIGHT)
        box.set_margin_top(10)
        box.set_margin_left(10)
        box.set_margin_right(10)
        box.set_margin_bottom(10)

        icon_overlay = Gtk.Overlay()
        icon_overlay.set_size_request(80, 50)
        icon_overlay.set_opacity(0.99)
        if name != '...':
            icon_overlay.set_tooltip_markup(get_ascii_art(name + '_tooltip'))
        box.pack_start(icon_overlay, False, False, 0)

        icon_background = Gtk.EventBox()
        icon_background.get_style_context().add_class("spell_icon_background")
        icon_overlay.add(icon_background)

        label_background = Gtk.EventBox()
        label_background.get_style_context().add_class("spell_label_background")
        box.pack_start(label_background, False, False, 0)

        if locked:
            filename = os.path.join(images_dir, "padlock.png")
            icon_background.get_style_context().add_class("locked")
            label_background.get_style_context().add_class("locked")

        else:
            filename = os.path.join(images_dir, name + ".png")

            if highlighted:
                highlight_box = Gtk.EventBox()
                highlight_box.add(Gtk.Image.new_from_file(
                    os.path.join(images_dir, "overlay.gif")
                ))
                icon_background.add(highlight_box)

        icon_box = Gtk.EventBox()
        icon_box.add(Gtk.Image.new_from_file(filename))
        icon_overlay.add_overlay(icon_box)

        label = Gtk.Label(name)
        label.get_style_context().add_class("spell_command")
        label.set_alignment(xalign=0.5, yalign=0.5)
        label_background.add(label)

        return box