コード例 #1
0
    def __init__(self):
        gtk.Toolbar.__init__(self)
        self._back = ToolButton('go-previous')
        self._back.set_tooltip(_('Back'))
        self._back.props.sensitive = False
        self._back.connect('clicked', self._go_back_cb)
        self.insert(self._back, -1)
        self._back.show()

        self._forward = ToolButton('go-next')
        self._forward.set_tooltip(_('Forward'))
        self._forward.props.sensitive = False
        self._forward.connect('clicked', self._go_forward_cb)
        self.insert(self._forward, -1)
        self._forward.show()

        num_page_item = gtk.ToolItem()

        self._num_page_entry = gtk.Entry()
        self._num_page_entry.set_text('0')
        self._num_page_entry.set_alignment(1)
        self._num_page_entry.connect('insert-text',
                                     self._num_page_entry_insert_text_cb)
        self._num_page_entry.connect('activate',
                                     self._num_page_entry_activate_cb)

        self._num_page_entry.set_width_chars(4)

        num_page_item.add(self._num_page_entry)
        self._num_page_entry.show()

        self.insert(num_page_item, -1)
        num_page_item.show()

        total_page_item = gtk.ToolItem()

        self._total_page_label = gtk.Label()

        label_attributes = pango.AttrList()
        label_attributes.insert(pango.AttrSize(14000, 0, -1))
        label_attributes.insert(pango.AttrForeground(65535, 65535, 65535, 0, -1))
        self._total_page_label.set_attributes(label_attributes)

        self._total_page_label.set_text(' / 0')
        total_page_item.add(self._total_page_label)
        self._total_page_label.show()

        self.insert(total_page_item, -1)
        total_page_item.show()

        downloaded_item = gtk.ToolItem()
        self._downloaded_label = gtk.Label()
        self._downloaded_label.set_attributes(label_attributes)

        self._downloaded_label.set_text('')
        downloaded_item.add(self._downloaded_label)
        self._downloaded_label.show()

        self.insert(downloaded_item, -1)
        downloaded_item.show()
コード例 #2
0
    def __init__(self, CFG):
        gtk.Fixed.__init__(self)

        msg_titulo = _("Welcome to the Install Wizard")
        msg_intro = _("With this wizard you can easily install Canaima \
GNU/Linux on your computer. We invite you to follow the instructions \
displayed on screen.")

        attr = pango.AttrList()
        size = pango.AttrSize(20000, 0, -1)
        attr.insert(size)

        self.lbltitulo = gtk.Label(msg_titulo)
        self.lbltitulo.set_size_request(640, 80)
        self.lbltitulo.set_alignment(0, 0)
        self.lbltitulo.set_attributes(attr)
        self.lbltitulo.set_line_wrap(True)
        #self.lbltitulo.set_selectable(True)
        self.put(self.lbltitulo, 50, 90)

        self.lblintro = gtk.Label(msg_intro)
        self.lblintro.set_size_request(640, 40)
        self.lblintro.set_alignment(0, 0)
        self.lblintro.set_line_wrap(True)
        #self.lblintro.set_selectable(True)
        self.put(self.lblintro, 50, 170)

        self.set_flags(gtk.CAN_FOCUS)
        atk_acc_vd(self, msg_titulo + " " + msg_intro)
コード例 #3
0
    def __init__(self):
        gtk.Toolbar.__init__(self)
        self.back = ToolButton('go-previous')
        self.back.set_tooltip(_('Back'))
        self.back.props.sensitive = False
        palette = self.back.get_palette()
        self.prev_page = MenuItem(text_label=_("Previous page"))
        palette.menu.append(self.prev_page)
        self.prev_page.show_all()
        self.back.connect('clicked', self.go_back_cb)
        self.prev_page.connect('activate', self.go_back_cb)
        self.insert(self.back, -1)
        self.back.show()

        self.forward = ToolButton('go-next')
        self.forward.set_tooltip(_('Forward'))
        self.forward.props.sensitive = False
        palette = self.forward.get_palette()
        self.next_page = MenuItem(text_label=_("Next page"))
        palette.menu.append(self.next_page)
        self.next_page.show_all()
        self.forward.connect('clicked', self.go_forward_cb)
        self.next_page.connect('activate', self.go_forward_cb)
        self.insert(self.forward, -1)
        self.forward.show()

        num_page_item = gtk.ToolItem()

        self._num_page_entry = gtk.Entry()
        self._num_page_entry.set_text('0')
        self._num_page_entry.set_alignment(1)
        self._num_page_entry.connect('insert-text',
                                     self._num_page_entry_insert_text_cb)
        self._num_page_entry.connect('activate',
                                     self._num_page_entry_activate_cb)

        self._num_page_entry.set_width_chars(4)

        num_page_item.add(self._num_page_entry)
        self._num_page_entry.show()

        self.insert(num_page_item, -1)
        num_page_item.show()

        total_page_item = gtk.ToolItem()

        self._total_page_label = gtk.Label()

        label_attributes = pango.AttrList()
        label_attributes.insert(pango.AttrSize(14000, 0, -1))
        label_attributes.insert(
            pango.AttrForeground(65535, 65535, 65535, 0, -1))
        self._total_page_label.set_attributes(label_attributes)

        self._total_page_label.set_text(' / 0')
        total_page_item.add(self._total_page_label)
        self._total_page_label.show()

        self.insert(total_page_item, -1)
        total_page_item.show()
コード例 #4
0
ファイル: ecomundoactivity.py プロジェクト: godiard/ecomundo
    def __init__(self,handle):
        activity.Activity.__init__(self,handle)
        
        self.set_title("Ecomundo")
        print "Init activity Ecomundo"
        #print os.path.abspath(__file__)

        self.createToolbox()
        
        hBox = gtk.HBox(False, 0)
        self.set_canvas(hBox)
        
        self.drawingarea1 = gtk.DrawingArea()
        self.drawingarea1.set_size_request(World.SIZE_WORLD,World.SIZE_WORLD)
        self.drawingarea1.show()

        hBox.pack_start(self.drawingarea1, False, False, 0)
        
        notebook = gtk.Notebook()
        
        print hBox.get_screen().get_width()
        #
        
        notebook.set_size_request(hBox.get_screen().get_width() - World.SIZE_WORLD,-1)
        hBox.pack_start(notebook, False, False, 0)

        label_attributes = pango.AttrList()
        label_attributes.insert(pango.AttrSize(10000, 0, -1))
        label_attributes.insert(pango.AttrForeground(65535, 65535, 65535, 0, -1))
        
        # En la primera pagina del notebook pongo los datos del experimento
        icon_experiment = Icon(icon_name="experiment", icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)
        self.createExperimentControls(notebook,icon_experiment,label_attributes)
        
        # En la segunda pagina del notebook pongo los datos de los conejos
        icon_rabbit = Icon(icon_name="rabbit", icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)
        self.createAnimalControls(notebook,_('Rabbit features'), icon_rabbit,world.rabbit_data,label_attributes)

        # En la tercera pagina del notebook pongo los datos de los zorros
        icon_fox = Icon(icon_name="fox", icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)
        self.createAnimalControls(notebook,_('Fox features'), icon_fox,world.fox_data,label_attributes)

        # En la cuarta ponemos los parametros de clima
        icon_rain = Icon(icon_name="rain", icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)
        self.createRainControls(notebook,icon_rain,label_attributes)

        print "antes de initWorld"
        initWorld()
        print "antes de init Green"
        initGreen()
        print "antes de init Animals"
        initAnimals()

        hBox.resize_children()
        hBox.show_all()

        self.drawingarea1.connect('expose-event', self.onDrawingAreaExposed)
コード例 #5
0
ファイル: combi_dro.py プロジェクト: zhhuihust/linuxcnc
 def _set_attributes(self, bgcolor, fgcolor, size, weight):
     attr = pango.AttrList()
     bg_color = pango.AttrBackground(bgcolor[0], bgcolor[1], bgcolor[2], 0, -1)
     attr.insert(bg_color)
     size_attr = pango.AttrSize(size[0], size[1], size[2])
     attr.insert(size_attr)
     weight_attr = pango.AttrWeight(weight[0], weight[1], weight[2])
     attr.insert(weight_attr)
     fg_color = pango.AttrForeground(fgcolor[0], fgcolor[1], fgcolor[2], 0, 13)
     attr.insert(fg_color)
     return attr
コード例 #6
0
    def __init__(self, weh):
        super(GTKstrip, self).__init__()
        self.label = "GTKstrip"

        chars = "ESKISTLFÜNFZEHNZWANZIGDREIVIERTELTGNACHVORJMHALBQZWÖLFPZWEINSIEBENKDREIRHFÜNFELFNEUNVIERWACHTZEHNRSBSECHSFMUHR...."
        #chars = chars + "------------------------------------------------------------"
        #chars = chars + "------------------------------------------------------------"

        self.labels = []
        self.colors = []
        self.brightness = 180

        self.weh = weh

        self.win = gtk.Window(gtk.WINDOW_TOPLEVEL)

        self.win.connect("delete_event", self.delete_event)
        self.win.connect("destroy", self.destroy)
        self.win.connect("key_press_event", self.key_press_event)

        table = gtk.Table(11, 11, True)

        x = 0
        y = 0
        for i in unicode(chars):
            label = gtk.Label(i)
            self.labels.append(label)
            self.colors.append(Color(0, 0, 0))

            table.attach(label, x, x + 1, y, y + 1, FILL, FILL)

            x += 1
            if x == 11:
                x = 0
                y += 1

            attrs = pango.AttrList()
            # attrs.insert(pango.AttrLanguage("de"))
            attrs.insert(pango.AttrForeground(0, 0, 0))
            FONTSIZE = 15
            attrs.insert(pango.AttrSize(FONTSIZE * 1000))
            attrs.insert(pango.AttrBackground(0, 0, 0))
            label.set_attributes(attrs)

            label.show()

        color = gtk.gdk.color_parse('#000000')
        self.win.modify_bg(gtk.STATE_NORMAL, color)
        self.win.add(table)
        self.win.show_all()
コード例 #7
0
def Description(c, box, text):
    style = pango.AttrList()
    size = pango.AttrSize(8000, 0, -1)
    style.insert(size)

    description = gtk.Label()
    description.set_markup(text)
    description.set_line_wrap(True)
    description.set_size_request(window_width - box.get_border_width() * 4, -1)
    description.set_attributes(style)

    box.pack_start(description, expand, fill, padding)

    return description
コード例 #8
0
    def make_table_title(self, title):
        """ set a Table title : play with pango"""
        label = gtk.Label()
        label.set_text(title)
        attrs = pango.AttrList()
        attrs.insert(pango.AttrWeight(pango.WEIGHT_BOLD, 0, -1))
        attrs.insert(pango.AttrSize(18000, 0, -1))
        label.set_attributes(attrs)

        # positionning of label
        label.set_alignment(xalign=0.5, yalign=0.5)  # center
        # Insert label into the upper left quadrant of the table
        label.show()
        return label
コード例 #9
0
ファイル: screenkey.py プロジェクト: yozol/mkcast
    def set_window_size(self, setting):
        """Set window and label size."""
        window_width = self.screen_width
        window_height = -1

        window_height = setting * self.screen_height / 100

        attr = pango.AttrList()
        attr.change(pango.AttrSize((50 * window_height / 100) * 1000, 0, -1))
        attr.change(pango.AttrFamily(self.options['font'], 0, -1))
        attr.change(pango.AttrWeight(pango.WEIGHT_BOLD, 0, -1))
        attr.change(pango.AttrForeground(*self.options['color']))

        self.label.set_attributes(attr)
        self.resize(window_width, window_height)
コード例 #10
0
 def set_attr(layout):
     attr = pango.AttrList()
     size = pango.AttrSize(int(11.5 * pango.SCALE), 0, -1)
     attr.insert(size)
     if customAttr and customAttr.attributes_dict:
         attributes_dict = customAttr.attributes_dict
      
         if attributes_dict.has_key("regex_include_match"):
             start, end = attributes_dict["regex_include_match"]
             pango_color = pango.AttrBackground(self.include_color.red, self.include_color.green, 
                                                self.include_color.blue, start, end)
             attr.insert(pango_color)
         if attributes_dict.has_key("regex_exclude_match"):
             start, end = attributes_dict["regex_exclude_match"]
             pango_color = pango.AttrForeground(self.exclude_color.red, self.exclude_color.green, 
                                                self.exclude_color.blue, start, end)
             attr.insert(pango_color)
     layout.set_attributes(attr)
コード例 #11
0
ファイル: dialogs.py プロジェクト: jonathanrelf/idjc
    def __init__(self, dial_group = None, window_group = None,
                                    window_title = "", additional_text = None,
                                    actionok = None, actioncancel = None):

        gtk.Dialog.__init__(self, window_title, None,
                        gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL,
                        gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
        if window_group is not None:
            window_group.add_window(self)
        self.set_resizable(False)
        self.connect("close", self.respond, actionok, actioncancel)
        self.connect("response", self.respond, actionok, actioncancel)
        self.connect("window-state-event", self.window_attn)
        self.set_default_response(gtk.RESPONSE_OK)
        
        hbox = gtk.HBox(False, 20)
        hbox.set_border_width(20)
        self.vbox.pack_start(hbox, True, True, 0)
        hbox.show()
        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG)
        hbox.pack_start(image, True, True, 0)
        image.show()
        vbox = gtk.VBox()
        vbox.set_spacing(8)
        hbox.pack_start(vbox, True, True, 0)
        vbox.show()
        
        if additional_text is not None:
            if type(additional_text) is str:
                additional_text = additional_text.splitlines()
            for each in additional_text:
                label = gtk.Label()
                attrlist = pango.AttrList()
                attrlist.insert(pango.AttrSize(12500, 0, len(each)))
                label.set_attributes(attrlist)
                label.set_text(each)
                vbox.add(label)
                label.show()
        if dial_group is not None:
            dial_group.add(self)
        self.dial_group = dial_group
コード例 #12
0
    def set_window_size(self, setting):
        """Set window and label size."""
        window_width = self.screen_width
        window_height = -1

        if setting == SIZE_LARGE:
            window_height = 24 * self.screen_height / 100
        if setting == SIZE_MEDIUM:
            window_height = 12 * self.screen_height / 100
        if setting == SIZE_SMALL:
            window_height = 8 * self.screen_height / 100

        attr = pango.AttrList()
        attr.change(pango.AttrSize((50 * window_height / 100) * 1000, 0, -1))
        attr.change(pango.AttrFamily("Sans", 0, -1))
        attr.change(pango.AttrWeight(pango.WEIGHT_BOLD, 0, -1))
        attr.change(pango.AttrForeground(65535, 65535, 65535, 0, -1))

        self.label.set_attributes(attr)
        self.resize(window_width, window_height)
コード例 #13
0
ファイル: title.py プロジェクト: alnvdl/oks
 def __init__(self, parent_window, actions_label):
     gtk.EventBox.__init__(self)
     self.label = gtk.Label()
     self.button_actions = ButtonMenu(parent_window, actions_label)
     
     attributes = pango.AttrList()
     attributes.insert(pango.AttrWeight(700, 0, -1))
     attributes.insert(pango.AttrSize(16000, 0, -1))
     self.label.set_attributes(attributes)
     self.label.set_ellipsize(pango.ELLIPSIZE_END)
     self.label.set_alignment(0.0, 0.5)
     self.label.set_padding(2, 0)
     
     hbox = gtk.HBox()
     hbox.pack_start(self.label)
     hbox.pack_start(self.button_actions, False, False)
     self.add(hbox)
     
     self.connect("realize", self.on_realize)
     self.show_all()
コード例 #14
0
    def _generate_thumb_with_text(self):
        """ Generate the text on the pixbuf """
        # This technique is used to compose image with text
        # create a pixmap with the data of the pixbuf then insert text
        # cf. pygtk FAQ  How do I draw a text [or something else] on a gtk.gdk.pixbuf? for mor explication
        # (http://faq.pygtk.org/index.py?req=show&file=faq08.020.htp )

        pixmap, mask = self._pixbuf_thumb.render_pixmap_and_mask()

        # graphic context and Drawarea any created to allow generation of pixbuf composition
        gc = pixmap.new_gc()
        area = gtk.DrawingArea()
        # create pango layout
        self.pangolayout = area.create_pango_layout("")

        # extract only the image name without extenstion
        text_buffer, ext = os.path.splitext(self._name)
        text_buffer = " " + text_buffer + " "
        self.pangolayout.set_text(text_buffer)
        # set text attributes
        attrs = pango.AttrList()
        attrs.insert(pango.AttrFamily(LCONST.THUMB_TEXT_FAMILY, 0, -1))
        attrs.insert(pango.AttrStyle(pango.STYLE_ITALIC, 0, -1))
        attrs.insert(
            pango.AttrForeground(LCONST.THUMB_TEXT_COLOR[0],
                                 LCONST.THUMB_TEXT_COLOR[1],
                                 LCONST.THUMB_TEXT_COLOR[2], 0, -1))
        attrs.insert(pango.AttrBackground(0, 0, 0, 0, -1))
        attrs.insert(pango.AttrSize(LCONST.THUMB_TEXT_SIZE, 0, -1))
        self.pangolayout.set_attributes(attrs)

        # compute text layout position and set it on pixmap
        (w, h) = (self._pixbuf_thumb.get_width(),
                  self._pixbuf_thumb.get_height())
        (lw, lh) = self.pangolayout.get_pixel_size()
        pixmap.draw_layout(gc, (w - lw) // 2, (h - lh - 2), self.pangolayout)

        # function get_from_drawable gets the the pixbuf from the pixmap
        # no need to affect resuly to a new pisbuf: self._pixbuf_thumb is changed whe get_from_drawable is used
        self._pixbuf_thumb.get_from_drawable(pixmap, pixmap.get_colormap(), 0,
                                             0, 0, 0, -1, -1)
コード例 #15
0
    def on_configure(self, _, event):
        window_height = event.height
        attr = pango.AttrList()
        attr.change(pango.AttrSize(int(self.options['fontsize']) * 1000, 0, -1))
        attr.change(pango.AttrFamily(self.options['font'], 0, -1))
        attr.change(pango.AttrWeight(pango.WEIGHT_BOLD, 0, -1))

        fgcolor = gtk.gdk.color_parse(self.fg)
        attr.change(pango.AttrForeground(
            fgcolor.red, fgcolor.green, fgcolor.blue, 0, -1))

        self.pos_x = event.x
        self.pos_y = event.y

        if self.timer:
            self.timer.cancel()

        self.timer = Timer(self.options['timeout'], self.on_timeout)
        self.timer.start()

        self.label.set_attributes(attr)
コード例 #16
0
def IconButton(c, box, icon, text_1, text_2, width, height, margin, f_1, p_1):
    hbox = gtk.HBox()
    hbox.set_border_width(margin)

    button = gtk.Button()
    button.set_size_request(width, height)
    button.connect("clicked", f_1, *p_1)

    inbox = gtk.VBox()
    inbox.set_border_width(5)

    image = gtk.Image()
    image.set_from_file(icon)

    attr = pango.AttrList()
    size = pango.AttrSize(20000, 0, -1)
    attr.insert(size)

    title = gtk.Label()
    title.set_markup(text_1)
    title.set_justify(gtk.JUSTIFY_CENTER)
    title.set_attributes(attr)

    description = gtk.Label()
    description.set_markup(text_2)
    description.set_line_wrap(True)
    description.set_justify(gtk.JUSTIFY_CENTER)

    inbox.pack_start(image, False, False, 0)
    inbox.pack_start(title, False, False, 0)
    inbox.pack_start(gtk.HSeparator(), False, False, 5)
    inbox.pack_start(description, False, False, 0)
    button.add(inbox)

    hbox.pack_start(button, False, False, 0)
    box.pack_start(hbox, False, False, 0)

    return button
コード例 #17
0
ファイル: mintMenu.py プロジェクト: mkeane/mintmenu
    def SetHeadingStyle(self, items):
        for item in items:
            if item not in self.headingsToColor:
                self.headingsToColor.append(item)

        HeadingStyle = pango.AttrList()
        attr = pango.AttrSize(12000, 0, -1)
        HeadingStyle.insert(attr)

        if self.usecustomcolor:
            headingcolor = gtk.gdk.color_parse(self.customheadingcolor)
            attr = pango.AttrForeground(headingcolor.red, headingcolor.green,
                                        headingcolor.blue, 0, -1)
            HeadingStyle.insert(attr)


#               else:
#                       headingcolor = self.window.rc_get_style().bg[ gtk.STATE_SELECTED ]

        attr = pango.AttrWeight(pango.WEIGHT_BOLD, 0, -1)
        HeadingStyle.insert(attr)

        for item in items:
            item.set_attributes(HeadingStyle)
コード例 #18
0
    def __init__(self, exaile, doubanfm_plugin):
        self.exaile = exaile
        self.dbfm_plugin = doubanfm_plugin

        self.builder = gtk.Builder()
        self.builder.add_from_file(get_resource_path('doubanfm_mode.ui'))

        self.builder.connect_signals({
            'on_bookmark_button_clicked':
            self.on_bookmark_button_clicked,
            'on_skip_button_clicked':
            self.on_skip_button_clicked,
            'on_delete_button_clicked':
            self.on_delete_button_clicked,
            'on_go_home_button_clicked':
            self.on_go_home_button_clicked,
            'on_item_setting_clicked':
            self.on_button_setting_clicked,
            'on_item_album_clicked':
            self.on_button_album_clicked,
            'on_item_report_clicked':
            self.on_button_report_clicked,
            'on_menu_toggle':
            self.on_menu_toggle,
            'on_quit':
            self.on_quit,
            'on_pausebutton_clicked':
            self.on_pausebutton_clicked,
            'on_recommend_song':
            self.on_recommend_song,
            'on_share_sina':
            self.on_share_sina,
            'on_share_renren':
            self.on_share_renren,
            'on_share_kaixin001':
            self.on_share_kaixin001,
            'on_share_twitter':
            self.on_share_twitter,
            'on_share_fanfou':
            self.on_share_fanfou,
            'on_copy_permalink':
            self.on_copy_permalink,
        })

        self.window = self.builder.get_object('doubanfm_mode_window')
        self.window.connect('destroy', self.hide)

        volume = settings.get_option('player/volume', 1)

        self.volume_control = playback.VolumeControl(player.PLAYER)
        self.builder.get_object('hbox2').pack_start(self.volume_control)

        self.cover_box = self.builder.get_object('cover_eventbox1')
        self.info_area = info.TrackInfoPane(player.PLAYER)
        self.cover = cover.CoverWidget(self.cover_box, player.PLAYER)
        #        self.cover_box.add(self.cover)

        self.track_title_label = self.builder.get_object('track_title_label')
        attr = pango.AttrList()
        attr.change(pango.AttrWeight(pango.WEIGHT_BOLD, 0, 800))
        attr.change(pango.AttrSize(12500, 0, 600))
        self.track_title_label.set_attributes(attr)
        self.track_info_label = self.builder.get_object('track_info_label')

        self.bookmark_button = self.builder.get_object('bookmark_button')
        self.trash_button = self.builder.get_object('delete_button')
        self.skip_button = self.builder.get_object('skip_button')
        self.pause_button = self.builder.get_object('pause_button')

        self.popup_menu = self.builder.get_object('moremenu')

        self.report_menuitem = self.builder.get_object('menuitem1')
        self.album_menuitem = self.builder.get_object('menuitem2')
        self.recmd_menuitem = self.builder.get_object('menuitem10')

        self.sensitive_widgets = [
            self.bookmark_button,
            self.trash_button,
            self.skip_button,
            self.pause_button,
            self.report_menuitem,
            self.album_menuitem,
            self.recmd_menuitem,
        ]

        self.progress_bar = playback.PlaybackProgressBar(player.PLAYER)
        self.builder.get_object('vbox2').pack_start(self.progress_bar)

        self.visible = False
        self.active = False

        self._build_channel_menu()

        event.add_callback(self.on_playback_start, 'playback_track_start',
                           player.PLAYER)
        event.add_callback(self.on_playback_stop, 'playback_track_end',
                           player.PLAYER)
        event.add_callback(self.on_pausebutton_toggled,
                           'playback_toggle_pause', player.PLAYER)
        event.add_callback(self.on_tag_update, 'track_tags_changed')
        self._toggle_id = self.exaile.gui.main.connect('main-visible-toggle',
                                                       self.toggle_visible)

        ## added for 0.3.2
        self._init_alpha()
コード例 #19
0
ファイル: text2img.py プロジェクト: ynapp/tess_school
def generate_images(opts,args):
    # Set up variables for drawing space
    width = 2550 # Will resize to match text; default 8.5"x11" @ 300dpi
    height = 3300
    MARGIN_X = 300
    MARGIN_Y = 300
    LINE_SPACE = 35 #TODO: Command-line opts
    LANG = "ka"
    TESS_LANG = "kat"
    # Set up decent spacing for box files
    attrs = pango.AttrList() #TODO: Command line opts or config
    attrs.insert(pango.AttrLanguage(LANG,0,-1))
    attrs.insert(pango.AttrLetterSpacing(10000,0,-1))
    attrs.insert(pango.AttrSize(48000,0,-1))
    attrs.insert(pango.AttrFallback(False,0,-1))
    attrs.insert(pango.AttrStyle(pango.STYLE_NORMAL,0,-1))
    attrs.insert(pango.AttrWeight(pango.WEIGHT_NORMAL,0,-1))
    attrs.insert(pango.AttrUnderline(pango.UNDERLINE_NONE,0,-1))

    # Instantiate Cairo surface and context
    surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
    context = pangocairo.CairoContext(cairo.Context(surf))

    # Instantiate PangoCairo context
    context.set_antialias(cairo.ANTIALIAS_SUBPIXEL)

    #get font families:
    font_map = pangocairo.cairo_font_map_get_default()

    # to see family names:
    if opts.list_fonts:
        print [f.get_name() for f in font_map.list_families()]
        return

    # Set up pango layout
    layout = context.create_layout()
    layout.set_attributes(attrs)
    layout.set_width((width+MARGIN_X)*pango.SCALE)
    layout.set_spacing(LINE_SPACE*pango.SCALE)

    #print layout.get_width()

    # Read text from file TODO: Command line argument
    # TODO: Multiple files print to multiple image documents
    text = ''
    with codecs.open(opts.input_file) as text_file:
        for line in text_file:
            text += line + '\n'

    font_names = args

    # (variant, reset,"desc")
    #Font variants is an array of tuples consisting of: (AttrStyle, InverseAttrStyle, Name)
    font_variants = [
        (pango.AttrStyle(pango.STYLE_NORMAL,0,-1),pango.AttrStyle(pango.STYLE_NORMAL,0,-1),"")]

    #Add other stylings based on command-line options
    if opts.italic:
        font_variants.append((pango.AttrStyle(pango.STYLE_ITALIC,0,-1),pango.AttrStyle(pango.STYLE_NORMAL,0,-1),"italic"))
    if opts.bold:
        font_variants.append((pango.AttrWeight(pango.WEIGHT_HEAVY,0,-1),pango.AttrWeight(pango.WEIGHT_NORMAL,0,-1),"bold"))
    if opts.underline:
        font_variants.append((pango.AttrUnderline(pango.UNDERLINE_SINGLE,0,-1),pango.AttrUnderline(pango.UNDERLINE_NONE,0,-1),"underline"))

    #Generate pages for each font name and variation.
    for fn in font_names:
        for fvar in font_variants:
            # Change to a new variant
            attrs.change(fvar[0])
            layout.set_attributes(attrs)

            # Change to a new font
            fontname = fn
            font = pango.FontDescription(fontname + " 25")
            
            layout.set_font_description(font)
            layout.set_text(text)

            (ink, logical) = layout.get_pixel_extents()

            # If layout exceeds size of surface, change surface size
            if logical[2] > (width-MARGIN_X) or logical[3] > (height-MARGIN_Y):
                width = logical[2]+MARGIN_X
                height = logical[3]+MARGIN_Y
                surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
                context = pangocairo.CairoContext(cairo.Context(surf))
                context.update_layout(layout)

            #draw a background rectangle:
            context.rectangle(0,0,width,height)
            context.set_source_rgb(1, 1, 1)
            context.fill()

            # Translate context so that desired text upperleft corner is at 0,0
            context.translate(50,25)
            context.set_source_rgb(0, 0, 0)

            context.update_layout(layout)
            context.show_layout(layout)

            # Write to image 
            # TODO: Specify outfile on command line
            #print fontname
            #print fvar[2]
            with open(TESS_LANG+"."+fontname+fvar[2]+".exp0.png", "wb") as image_file:
                    surf.write_to_png(image_file)

            attrs.change(fvar[1])
            layout.set_attributes(attrs)
コード例 #20
0
    def __init__(self, img, *args):
        self.img = img
        self.x1, self.y1, self.x2, self.y2 = 0, 0, 0, 0
        self.changed = False  # decides a redraw of the arrow
        self.miss = True  # to enconter only once a missing element

        self.headSize = 60  # side of the winghead in PX
        self.wingAngle = 25  # angle from arrow direction to the side in °
        self.brush = 11.0  # generated brush size

        self.choice_i = argmenu[2]  # index of arrow rendering choice
        if self.choice_i > 3:  # style with circle choice
            self.slider3 = 50
            self.a3min = 0
            self.a3max = 200
        else:  # style with gradient choice
            self.slider3 = 0  # value of third slider
            self.a3min = -25  # initial min limit for slider3
            self.a3max = +25  # initial max limit for slider3

        self.segment_cr = 1  # segment counter
        self.arrow_cr = 1  # arrow counter
        self.l_arrow = 0.1  # arrow length
        self.theta = 0  # arrow orientation angle in °
        self.direct = True  # arrow from first point to second if True

        # Make a new GIMP layer to draw on
        self.layer = gimp.Layer(img, _("AC_arrow #1"), img.width, img.height,
                                RGBA_IMAGE, 100, NORMAL_MODE)
        img.add_layer(self.layer, 0)
        # Verifies that it start at 1, not the case if we close and resume later
        if version[1] == start_minver:
            name_layer = pdb.gimp_drawable_get_name(self.layer)
        elif version[1] > start_minver:
            name_layer = pdb.gimp_item_get_name(self.layer)
        if name_layer != _("AC_arrow #1"):
            ind_past = name_layer.find('#') + 1
            self.arrow_cr = int(name_layer[ind_past:])

        # Create the dialog
        win = gtk.Window.__init__(self, *args)
        self.set_title(_("Arrow tool for GIMP"))
        self.set_keep_above(
            True)  # keep the window on top when it looses focus

        # The window manager quit signal:
        self.connect("destroy", gtk.main_quit)

        # Make the UI
        self.set_border_width(10)
        vbox = gtk.VBox(spacing=6, homogeneous=False)
        self.add(vbox)
        title_line = _("Arrows creator  \n")
        prompt_line = _("  To start: choose colours and path tool in design mode;")\
                +_("\nplace now two path anchors (nodes) by clicking at future")\
                +_("\narrow tail and head on the canvas (avoid closing the path).")\
                +_("\n An arrow should appear, then adjust values in this window.")\
                +_("\nIf not and you have followed the above, see end of status line.")\
                +_("\n You should move those anchors for the rest of the session.")\
                +_("\n To change the active arrow colour(s) and/or stroke path")\
                +_("\nafter it's drawn: change it in GIMP and a thing in the arrow.\n")
        # about 46 car. per line in 'label'

        self.label = gtk.Label(title_line + prompt_line)

        # Change attributes of the label first line
        attr = pango.AttrList()
        fg_color = pango.AttrForeground(0, 0, 65535, 0, len(title_line))
        size = pango.AttrSize(17000, 0, 20)
        bold = pango.AttrWeight(pango.WEIGHT_ULTRABOLD, 0, len(title_line))
        attr.insert(fg_color)
        attr.insert(size)
        attr.insert(bold)
        self.label.set_attributes(attr)
        vbox.add(self.label)

        separator = gtk.HSeparator()
        vbox.pack_start(separator, expand=False)

        table = gtk.Table(rows=3, columns=2, homogeneous=False)
        table.set_col_spacings(10)
        vbox.add(table)

        # Arrowhead size
        label = gtk.Label(_("Arrowing size (PX)"))
        label.set_alignment(xalign=0.0, yalign=1.0)
        table.attach(label, 0, 1, 0, 1, xoptions=gtk.FILL, yoptions=0)
        adj = gtk.Adjustment(self.headSize, 0, 200, 1)
        adj.connect("value_changed", self.headsize_cb)
        scale = gtk.HScale(adj)
        scale.set_digits(0)
        scale.set_has_tooltip(True)
        scale.set_tooltip_text(_("arrow head side, 0 means no head"))
        table.attach(scale, 1, 2, 0, 1)

        # Arrowhead angle
        label = gtk.Label(_(u"Arrowing angle (°)"))
        label.set_alignment(xalign=0.0, yalign=1.0)
        table.attach(label, 0, 1, 1, 2, xoptions=gtk.FILL, yoptions=0)
        adj = gtk.Adjustment(self.wingAngle, 1, 80, 1)
        adj.connect("value_changed", self.headangle_cb)
        scale = gtk.HScale(adj)
        scale.set_digits(0)
        scale.set_has_tooltip(True)
        scale.set_tooltip_text(_("angle of a head wing in relation")\
                                +_("\nto head direction"))
        table.attach(scale, 1, 2, 1, 2)

        # Arrowshaft width
        label = gtk.Label(_("Brush size (radius,PX)\n for '%s'") % brush_name)
        label.set_alignment(xalign=0.0, yalign=1.0)
        table.attach(label, 0, 1, 2, 3, xoptions=gtk.FILL, yoptions=0)
        adj = gtk.Adjustment(self.brush, 1.0, 25, 2.0, 2.0)
        pdb.gimp_brush_set_radius(brush_name, self.brush)
        adj.connect("value_changed", self.brush_cb)
        scale = gtk.HScale(adj)
        scale.set_digits(0)
        scale.set_has_tooltip(True)
        scale.set_tooltip_text(_("for the plug-in generated brush,")\
                +_("\nit controls the shaft thickness."))
        table.attach(scale, 1, 2, 2, 3)

        # Fourth variable to be change by combo_box
        self.label3 = gtk.Label(_("Nr of gradient, shaft"))
        if version[1] > start_minver:
            self.label3.set_label(_("Gradient in shaft"))
        if self.choice_i > 3:
            self.label3.set_label(_("Tail circle (radius,PX)"))
        self.label3.set_alignment(xalign=0.0, yalign=1.0)
        table.attach(self.label3, 0, 1, 3, 4, xoptions=gtk.FILL, yoptions=0)
        self.adj = gtk.Adjustment(self.slider3, self.a3min, self.a3max, 1)
        self.adj.connect("value_changed", self.slider3_cb)
        self.adj.connect("changed", self.slider3_lim)
        scale = gtk.HScale(self.adj)
        scale.set_digits(0)
        scale.set_has_tooltip(True)
        scale.set_tooltip_text(_("the adjustment purpose can change")\
                +_("\naccording to the arrow type"))
        table.attach(scale, 1, 2, 3, 4)

        table = gtk.Table(rows=1, columns=2, homogeneous=False)
        table.set_col_spacings(10)
        vbox.add(table)

        # Make a combo-box for options (independent choice for shaft and head?)
        choices = [
            _("Assegai style"),  #0
            _("Square cut the shaft"),  #1
            _("Measuring arrow"),  #2
            _("Notched arrow"),  #3
            # from here third slider control the radius of a circle
            _("Labelling arrow"),  #4
            _("Arrow with disk joint"),  #5
            _("Arrow from the stroke path")
        ]  #6
        # shaft only if choice is with head=0
        vbox2 = gtk.VBox(spacing=8)
        vbox2.set_border_width(10)
        vbox.pack_start(vbox2)
        combo_box = gtk.combo_box_new_text()
        combo_box.set_wrap_width(1)
        for i in range(len(choices)):
            combo_box.append_text("%d- %s" % (i, choices[i]))
        combo_box.set_active(self.choice_i)
        combo_box.set_has_tooltip(True)
        combo_box.set_tooltip_text(_("choice of arrow or segment type"))
        combo_box.connect("changed", self.choice_i_cb)
        table.attach(combo_box, 0, 1, 0, 1)

        rbtn = gtk.CheckButton(_("Invert"))
        rbtn.connect("toggled", self.direction_cb, None)
        rbtn.set_has_tooltip(True)
        rbtn.set_tooltip_text(_("inverse arrow direction"))
        table.attach(rbtn, 1, 2, 0, 1)

        separator = gtk.HSeparator()
        vbox.pack_start(separator, expand=False)

        # Show the actual arrow info
        self.states = [
            _("waiting for anchors           "),  #0
            _("edit"),  #1
            _("open the path (try Back-Space)"),  #2
            _("needs two anchors "),  #3
            _("new localization"),  #4
            _("anchor outside canvas!"),  #5
            _("don't control that brush"),  #6
            _("block by identical anchors"),  #7
            _("completing the previous op."),  #8
            _("won't work for that image!")
        ]  #9
        #"placer votre sélection"
        arrow_label = stub % (self.segment_cr, self.arrow_cr) + self.states[0]
        l_label = len(arrow_label)
        attr1 = pango.AttrList()
        fg_color1 = pango.AttrForeground(30000, 20000, 0, 0, len(stub) - 2)
        fg_color2 = pango.AttrForeground(0, 22000, 30000,
                                         len(stub) - 2, l_label)
        size = pango.AttrSize(11500, 0, l_label)
        attr1.insert(fg_color1)
        attr1.insert(fg_color2)
        attr1.insert(size)

        self.label2 = gtk.Label(arrow_label)
        self.label2.set_alignment(0.0, 0.0)
        self.label2.set_attributes(attr1)
        self.label2.set_has_tooltip(True)
        self.label2.set_tooltip_text(_("info and state of current op"))
        vbox.add(self.label2)

        # Make the dialog buttons box
        separator = gtk.HSeparator()
        vbox.pack_start(separator, expand=False)
        hbox = gtk.HBox(spacing=20)

        btn = gtk.Button(_("Next segment"))
        btn.connect("pressed", self.next_seg)
        btn.set_has_tooltip(True)
        btn.set_tooltip_text(_("Mainly to produce a multi-segmented")\
                    +_("\nor many arrows on the previous layer"))
        hbox.add(btn)

        btn = gtk.Button(_("Next arrow"))
        btn.connect("pressed", self.next_arrow)
        btn.set_has_tooltip(True)
        btn.set_tooltip_text(_("Create a new arrow layer"))
        hbox.add(btn)

        self.btnc = gtk.Button(_("Close"))
        self.btnc.connect("pressed", self.press_close)
        hbox.add(self.btnc)

        vbox.add(hbox)
        self.show_all()

        self.update(*args)
コード例 #21
0
    def __init__(self, title, q_button_a, q_button_b, q_view, q_label, q_win,
                 event):

        window = gtk.Window()
        window.set_border_width(0)
        window.set_title(title)
        window.set_position(gtk.WIN_POS_CENTER_ALWAYS)
        window.set_size_request(700, 470)
        window.set_resizable(False)
        window.set_icon_from_file(BAR_ICON)
        window.connect("destroy", self.disable_close)
        window.connect("delete-event", self.disable_close)

        box = gtk.Fixed()
        window.add(box)

        attr = pango.AttrList()
        size = pango.AttrSize(20000, 0, -1)
        attr.insert(size)

        str_message = _('Canaima installation has been completed')
        message = gtk.Label(str_message)
        message.set_size_request(640, 40)
        message.set_alignment(0, 0)
        message.set_line_wrap(True)
        message.set_attributes(attr)
        box.put(message, 50, 200)

        str_intro = _('You can keep trying Canaima pressing "Restart Later" \
or enjoy your installed operating system by pressing "Restart Now".')
        intro = gtk.Label(str_intro)
        intro.set_size_request(640, 40)
        intro.set_alignment(0, 0)
        intro.set_line_wrap(True)
        box.put(intro, 50, 250)

        view = webkit.WebView()
        view.set_size_request(700, 430)
        box.put(view, 0, 0)

        linea = gtk.HSeparator()
        linea.set_size_request(700, 5)
        box.put(linea, 0, 435)

        label = gtk.Label()
        label.set_justify(gtk.JUSTIFY_CENTER)
        label.set_size_request(700, 20)
        box.put(label, 0, 440)

        button_a = gtk.Button()
        button_a.set_size_request(150, 30)
        button_a.set_label(_('Restart Later'))
        button_a.connect('clicked', self.close)
        box.put(button_a, 390, 440)

        button_b = gtk.Button()
        button_b.set_size_request(150, 30)
        button_b.set_label(_('Restart Now'))
        button_b.connect('clicked', self.reboot)
        box.put(button_b, 540, 440)

        box.set_flags(gtk.CAN_FOCUS)
        atk_acc_vd(box, str_message + ". " + str_intro)

        window.show_all()

        button_a.hide()
        button_b.hide()

        q_view.put(view)
        q_label.put(label)
        q_win.put(window)
        q_button_a.put(button_a)
        q_button_b.put(button_b)
        event.set()

        self.view = view
コード例 #22
0
ファイル: arrowdesigner.py プロジェクト: makoehr/gimp-plugins
    def __init__ (self, img, *args):
        self.img = img
        self.x1, self.y1, self.x2, self.y2 = 0, 0, 0, 0

        self.direction = DIREC_N
        self.changed = False
        self.arrowsize = 30
        self.arrowangle = 25
        self.num_grad = 0

        # Make a new GIMP layer to draw on
        self.layer = gimp.Layer(img, "arrow", img.width, img.height,
                                RGBA_IMAGE, 100, NORMAL_MODE)
        img.add_layer(self.layer, 0)

        # Create the dialog
        win = gtk.Window.__init__(self, *args)
        self.set_title("GIMP arrow tool")

        # Mac may have a problem with the window disappearing below
        # the image window. But on small screens, the window is big
        # enough that it can block a lot of the image window.
        # Ideally, it would be nice to make sure it's initially
        # on top, but then let the user hide it later.
        # Or make a checkbox for it in the dialog, but that would
        # make the dialog even bigger.
        #self.set_keep_above(True) # keep the window on top

        # Obey the window manager quit signal:
        self.connect("destroy", gtk.main_quit)

        # Make the UI
        self.set_border_width(10)
        vbox = gtk.VBox(spacing=10, homogeneous=False)
        self.add(vbox)
        label = gtk.Label("Arrow designer  by Akkana Peck\nMake a rectangular selection. Will use active colors, brush and gradient.")

        # Change color of the label first line R. B.
        attr = pango.AttrList()
        fg_color = pango.AttrForeground(0, 0, 65535, 0, 30)
        size = pango.AttrSize(17000, 0, 14)
        bold = pango.AttrWeight(pango.WEIGHT_ULTRABOLD, 0, 14)
        attr.insert(fg_color)
        attr.insert(size)
        attr.insert(bold)
        label.set_attributes(attr)

        vbox.add(label)
        label.show()

        table = gtk.Table(rows=3, columns=2, homogeneous=False)
        table.set_col_spacings(10)
        vbox.add(table)

        # Arrow size and sharpness
        label = gtk.Label("Arrowhead size (px)")
        label.set_alignment(xalign=0.0, yalign=1.0)
        table.attach(label, 0, 1, 0, 1, xoptions=gtk.FILL, yoptions=0)
        label.show()
        adj = gtk.Adjustment(self.arrowsize, 1, 400, 1)
        adj.connect("value_changed", self.arrowsize_cb)
        scale = gtk.HScale(adj)
        scale.set_digits(0)
        table.attach(scale, 1, 2, 0, 1)
        scale.show()

        label = gtk.Label("Arrowhead angle (°)")
        label.set_alignment(xalign=0.0, yalign=1.0)
        table.attach(label, 0, 1, 1, 2, xoptions=gtk.FILL, yoptions=0)
        label.show()
        adj = gtk.Adjustment(self.arrowangle, 1, 80, 1)
        adj.connect("value_changed", self.arrowangle_cb)
        scale = gtk.HScale(adj)
        scale.set_digits(0)
        table.attach(scale, 1, 2, 1, 2)
        scale.show()

        label = gtk.Label("Gradient repetitions")
        label.set_alignment(xalign=0.0, yalign=1.0)
        table.attach(label, 0, 1, 2, 3, xoptions=gtk.FILL, yoptions=0)
        label.show()
        adj = gtk.Adjustment(self.num_grad, 0, 50, 1)
        adj.connect("value_changed", self.num_grad_cb)
        scale = gtk.HScale(adj)
        scale.set_digits(0)
        table.attach(scale, 1, 2, 2, 3)
        scale.show()

        table.show()

        # Selector for arrow direction
        hbox = gtk.HBox(spacing=5)

        btn = gtk.RadioButton(None, "N")
        btn.set_active(True)
        btn.connect("toggled", self.direction_cb, DIREC_N)
        hbox.add(btn)
        btn.show()
        btn = gtk.RadioButton(btn, "NE")
        btn.connect("toggled", self.direction_cb, DIREC_NE)
        hbox.add(btn)
        btn.show()
        btn = gtk.RadioButton(btn, "E")
        btn.connect("toggled", self.direction_cb, DIREC_E)
        hbox.add(btn)
        btn.show()
        btn = gtk.RadioButton(btn, "SE")
        btn.connect("toggled", self.direction_cb, DIREC_SE)
        hbox.add(btn)
        btn.show()
        btn = gtk.RadioButton(btn, "S")
        btn.connect("toggled", self.direction_cb, DIREC_S)
        hbox.add(btn)
        btn.show()
        btn = gtk.RadioButton(btn, "SW")
        btn.connect("toggled", self.direction_cb, DIREC_SW)
        hbox.add(btn)
        btn.show()
        btn = gtk.RadioButton(btn, "W")
        btn.connect("toggled", self.direction_cb, DIREC_W)
        hbox.add(btn)
        btn.show()
        btn = gtk.RadioButton(btn, "NW")
        btn.connect("toggled", self.direction_cb, DIREC_NW)
        hbox.add(btn)
        btn.show()

        vbox.add(hbox)
        hbox.show()

        # Make the dialog buttons box
        hbox = gtk.HBox(spacing=20)

        btn = gtk.Button("Next arrow")
        btn.connect("pressed", self.next_arrow)
        hbox.add(btn)
        btn.show()

        btn = gtk.Button("Close")
        btn.connect("clicked", self.close_window)
        hbox.add(btn)
        btn.show()

        vbox.add(hbox)
        hbox.show()
        vbox.show()
        self.show()

        timeout_add(300, self.update, self)

        return win
コード例 #23
0
 def get_calculated_rect(self, context, rect):
     angle = 2 * math.pi * self._rotation / 360.0
     
     if self._context == None:
         label = gtk.Label()
         self._context = label.create_pango_context()          
     pango_context = self._context
     
     attrs = pango.AttrList()
     attrs.insert(pango.AttrWeight(self._weight, 0, len(self._text)))
     attrs.insert(pango.AttrStyle(self._slant, 0, len(self._text)))
     attrs.insert(pango.AttrUnderline(self._underline, 0,
                     len(self._text)))
     if self._size != None:
         attrs.insert(pango.AttrSize(1000 * self._size, 0,
                         len(self._text)))
     
     if self._layout == None:
         self._layout = pango.Layout(pango_context)
     layout = self._layout
     if self._markup:
         layout.set_markup(self._text)
     else:
         layout.set_text(self._text)
         layout.set_attributes(attrs)
     
     #find out where to draw the layout and calculate the maximum width
     width = rect.width * math.cos(angle) + rect.height * math.sin(angle)
     if self._anchor in [ANCHOR_BOTTOM_LEFT, ANCHOR_TOP_LEFT,
                         ANCHOR_LEFT_CENTER]:
         width = rect.width - self._position[0]
     elif self._anchor in [ANCHOR_BOTTOM_RIGHT, ANCHOR_TOP_RIGHT,
                             ANCHOR_RIGHT_CENTER]:
         width = self._position[0]
     
     text_width, text_height = layout.get_pixel_size()
     width = min(width, self._max_width)
     
     if self._wrap:
         layout.set_wrap(pango.WRAP_WORD_CHAR)
     layout.set_width(int(1000 * width))
     
     #======================================================================
     text_width, text_height = layout.get_pixel_size()
     anchor = self._anchor
     x, y = self._position
 
     #anchor translation
     tx, ty = 0, 0
     ttx, tty = 0, 0
     if anchor == ANCHOR_BOTTOM_LEFT:
         tx = text_height * math.sin(angle)
         ty = text_height * math.cos(angle)
         ttx = 0
         tty = text_height
     elif anchor == ANCHOR_TOP_LEFT:
         tx = 0
         ty = 0
     elif anchor ==  ANCHOR_TOP_RIGHT:
         tx = text_width * math.cos(angle)
         ty = -text_width * math.sin(angle)
         ttx = text_width
         tty = 0
     elif anchor == ANCHOR_BOTTOM_RIGHT:
         tx = text_width * math.cos(angle) + text_height * math.sin(angle)
         ty = -text_width * math.sin(angle) + text_height * math.cos(angle)
         ttx = text_width
         tty = text_height
     elif anchor == ANCHOR_CENTER:
         tx = (text_width * math.cos(angle) + text_height * math.sin(angle)) / 2
         ty = (-text_width * math.sin(angle) + text_height * math.cos(angle)) / 2
         ttx = text_width / 2
         tty = text_height / 2
     elif anchor == ANCHOR_TOP_CENTER:
         tx = text_width * math.cos(angle) / 2
         ty = -text_width * math.sin(angle) / 2
         ttx = text_width / 2
         tty = 0
     elif anchor == ANCHOR_BOTTOM_CENTER:
         tx = text_width * math.cos(angle) / 2 + text_height * math.sin(angle)
         ty = -text_width * math.sin(angle) / 2 + text_height * math.cos(angle)
         ttx = text_width / 2
         tty = text_height
     elif anchor == ANCHOR_LEFT_CENTER:
         tx = text_height * math.sin(angle) / 2
         ty = text_height * math.cos(angle) / 2
         ttx = 0
         tty = text_height / 2
     elif anchor == ANCHOR_RIGHT_CENTER:
         tx = text_width * math.cos(angle) + text_height * math.sin(angle) / 2
         ty = -text_width * math.sin(angle) + text_height * math.cos(angle) / 2
         ttx = text_width
         tty = text_height / 2
     
     #calculate the bounding rect
     real_x = x - ttx
     real_y = y - tty
     top_left = real_x, real_y
     bottom_left = real_x , real_y + text_height
     bottom_right = real_x + text_width, real_y + text_height
     top_right = real_x + text_width, real_y
     
     offset = x, y
     
     n_top_left = rotate_vector(offset, top_left, angle)
     n_bottom_left = rotate_vector(offset, bottom_left, angle)
     n_bottom_right = rotate_vector(offset, bottom_right, angle)
     n_top_right = rotate_vector(offset, top_right, angle)
     
     alloc_x_min = int(min(n_top_left[0], n_bottom_left[0], n_bottom_right[0],
                         n_top_right[0]))
     alloc_x_max = int(max(n_top_left[0], n_bottom_left[0], n_bottom_right[0],
                         n_top_right[0]))
     alloc_y_min = int(min(n_top_left[1], n_bottom_left[1], n_bottom_right[1],
                         n_top_right[1]))
     alloc_y_max = int(max(n_top_left[1], n_bottom_left[1], n_bottom_right[1],
                         n_top_right[1]))
                         
     rect = gtk.gdk.Rectangle(alloc_x_min, alloc_y_min,
                                 alloc_x_max - alloc_x_min,
                                 alloc_y_max - alloc_y_min)
     return rect
コード例 #24
0
ファイル: label.py プロジェクト: almuza/xen
    def get_calculated_dimensions(self, context, rect):
        angle = 2 * math.pi * self._rotation / 360.0

        if self._context == None:
            label = gtk.Label()
            self._context = label.create_pango_context()
        pango_context = self._context

        attrs = pango.AttrList()
        attrs.insert(pango.AttrWeight(self._weight, 0, len(self._text)))
        attrs.insert(pango.AttrStyle(self._slant, 0, len(self._text)))
        attrs.insert(pango.AttrUnderline(self._underline, 0, len(self._text)))
        if self._size != None:
            attrs.insert(pango.AttrSize(1000 * self._size, 0, len(self._text)))

        if self._layout == None:
            self._layout = pango.Layout(pango_context)
        layout = self._layout

        layout.set_text(self._text)
        layout.set_attributes(attrs)

        #find out where to draw the layout and calculate the maximum width
        width = rect.width
        if self._anchor in [
                ANCHOR_BOTTOM_LEFT, ANCHOR_TOP_LEFT, ANCHOR_LEFT_CENTER
        ]:
            width = rect.width - self._position[0]
        elif self._anchor in [
                ANCHOR_BOTTOM_RIGHT, ANCHOR_TOP_RIGHT, ANCHOR_RIGHT_CENTER
        ]:
            width = self._position[0]

        text_width, text_height = layout.get_pixel_size()
        width = width * math.cos(angle)
        width = min(width, self._max_width)

        if self._wrap:
            layout.set_wrap(pango.WRAP_WORD_CHAR)
        layout.set_width(int(1000 * width))

        x, y = get_text_pos(layout, self._position, self._anchor, angle)

        if not self._fixed:
            #Find already drawn labels that would intersect with the current one
            #and adjust position to avoid intersection.
            text_width, text_height = layout.get_pixel_size()
            real_width = abs(text_width * math.cos(angle)) + abs(
                text_height * math.sin(angle))
            real_height = abs(text_height * math.cos(angle)) + abs(
                text_width * math.sin(angle))

            other_labels = get_registered_labels()
            this_rect = gtk.gdk.Rectangle(int(x), int(y), int(real_width),
                                          int(real_height))
            for label in other_labels:
                label_rect = label.get_allocation()
                intersection = this_rect.intersect(label_rect)
                if intersection.width == 0 and intersection.height == 0:
                    continue

                y_diff = 0
                if label_rect.y <= y and label_rect.y + label_rect.height >= y:
                    y_diff = y - label_rect.y + label_rect.height
                elif label_rect.y > y and label_rect.y < y + real_height:
                    y_diff = label_rect.y - real_height - y
                y += y_diff

        #calculate the dimensions
        text_width, text_height = layout.get_pixel_size()
        real_width = abs(text_width * math.cos(angle)) + abs(
            text_height * math.sin(angle))
        real_height = abs(text_height * math.cos(angle)) + abs(
            text_width * math.sin(angle))
        return real_width, real_height
コード例 #25
0
    def create_new_toolbar(self):
        toolbar_box = ToolbarBox()

        activity_button = MyActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, 0)
        activity_button.show()

        self.connect('go-fullscreen', \
            self.__view_toolbar_go_fullscreen_cb)

        self.back = ToolButton('go-previous')
        self.back.set_tooltip(_('Back'))
        self.back.props.sensitive = False
        palette = self.back.get_palette()
        self.menu_prev_page = MenuItem(text_label=_("Previous page"))
        palette.menu.append(self.menu_prev_page)
        self.menu_prev_page.show_all()
        self.back.connect('clicked', self.go_back_cb)
        self.menu_prev_page.connect('activate', self.go_back_cb)
        toolbar_box.toolbar.insert(self.back, -1)
        self.back.show()

        self.forward = ToolButton('go-next')
        self.forward.set_tooltip(_('Forward'))
        self.forward.props.sensitive = False
        palette = self.forward.get_palette()
        self.menu_next_page = MenuItem(text_label=_("Next page"))
        palette.menu.append(self.menu_next_page)
        self.menu_next_page.show_all()
        self.forward.connect('clicked', self.go_forward_cb)
        self.menu_next_page.connect('activate', self.go_forward_cb)
        toolbar_box.toolbar.insert(self.forward, -1)
        self.forward.show()

        num_page_item = gtk.ToolItem()
        self.num_page_entry = gtk.Entry()
        self.num_page_entry.set_text('0')
        self.num_page_entry.set_alignment(1)
        self.num_page_entry.connect('insert-text',
                                    self.__new_num_page_entry_insert_text_cb)
        self.num_page_entry.connect('activate',
                                    self.__new_num_page_entry_activate_cb)
        self.num_page_entry.set_width_chars(4)
        num_page_item.add(self.num_page_entry)
        self.num_page_entry.show()
        toolbar_box.toolbar.insert(num_page_item, -1)
        num_page_item.show()

        total_page_item = gtk.ToolItem()
        self.total_page_label = gtk.Label()

        label_attributes = pango.AttrList()
        label_attributes.insert(pango.AttrSize(14000, 0, -1))
        label_attributes.insert(
            pango.AttrForeground(65535, 65535, 65535, 0, -1))
        self.total_page_label.set_attributes(label_attributes)

        self.total_page_label.set_text(' / 0')
        total_page_item.add(self.total_page_label)
        self.total_page_label.show()
        toolbar_box.toolbar.insert(total_page_item, -1)
        total_page_item.show()

        spacer = gtk.SeparatorToolItem()
        toolbar_box.toolbar.insert(spacer, -1)
        spacer.show()

        self._zoom_out = ToolButton('zoom-out')
        self._zoom_out.set_tooltip(_('Zoom out'))
        self._zoom_out.connect('clicked', self._zoom_out_cb)
        toolbar_box.toolbar.insert(self._zoom_out, -1)
        self._zoom_out.props.sensitive = False
        self._zoom_out.show()

        self._zoom_in = ToolButton('zoom-in')
        self._zoom_in.set_tooltip(_('Zoom in'))
        self._zoom_in.connect('clicked', self._zoom_in_cb)
        toolbar_box.toolbar.insert(self._zoom_in, -1)
        self._zoom_in.props.sensitive = True
        self._zoom_in.show()

        self._fullscreen = ToolButton('view-fullscreen')
        self._fullscreen.set_tooltip(_('Fullscreen'))
        self._fullscreen.connect('clicked', self._fullscreen_cb)
        toolbar_box.toolbar.insert(self._fullscreen, -1)
        self._fullscreen.show()

        separator = gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        stop_button = StopButton(self)
        stop_button.props.accelerator = '<Ctrl><Shift>Q'
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()
コード例 #26
0
    def __init__(self, self_ventana_principal, self_seccion_stock):

        if self_seccion_stock.tipo_producto == "merceria":
            self.liststore_elejido = self_seccion_stock.total_liststore_productos[
                0]
        elif self_seccion_stock.tipo_producto == "lana":
            self.liststore_elejido = self_seccion_stock.total_liststore_productos[
                1]
        elif self_seccion_stock.tipo_producto == "ropa":
            self.liststore_elejido = self_seccion_stock.total_liststore_productos[
                2]
        elif self_seccion_stock.tipo_producto == "regaleria":
            self.liststore_elejido = self_seccion_stock.total_liststore_productos[
                3]
        elif self_seccion_stock.tipo_producto == "jugueteria":
            self.liststore_elejido = self_seccion_stock.total_liststore_productos[
                4]
        elif self_seccion_stock.tipo_producto == "santeria":
            self.liststore_elejido = self_seccion_stock.total_liststore_productos[
                5]
        elif self_seccion_stock.tipo_producto == "bijouterie":
            self.liststore_elejido = self_seccion_stock.total_liststore_productos[
                6]

        icono = "../Imagenes/fusa_icon.png"
        self_ventana_principal.window.set_sensitive(False)
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("delete_event", self.delete_event,
                            self_ventana_principal)
        self.window.set_title("Actualizar Producto")
        self.window.set_resizable(False)
        self.window.set_position(gtk.WIN_POS_CENTER)
        #self.window.set_icon(gtk.gdk.pixbuf_new_from_file(icono) )
        self.window.set_size_request(700, 400)
        image_fondo = gtk.Image()
        #image_fondo.set_from_file("../Imagenes/background2.svg")

        self.fixed_generales = gtk.Fixed()
        self.fixed_generales.add(image_fondo)
        self.window.add(self.fixed_generales)

        atributos = pango.AttrList()
        atributos.insert(pango.AttrSize(14000, 0, -1))
        atributos.insert(pango.AttrWeight(700, 0, -1))

        fuente_entrys = "Sans 13"
        font_entry = pango.FontDescription(fuente_entrys)

        self.tipo_producto = gtk.Label("Tipo de Producto : ")
        self.tipo_producto.set_attributes(atributos)
        self.fixed_generales.put(self.tipo_producto, 20, 30)

        self.entry_tipo_producto = gtk.Entry()
        self.entry_tipo_producto.modify_font(font_entry)
        self.fixed_generales.put(self.entry_tipo_producto, 190, 28)
        self.entry_tipo_producto.set_property("editable", 0)

        self.entry_tipo_producto.set_text(self_seccion_stock.tipo_producto)

        self.codigo_producto = gtk.Label("Codigo : ")
        self.codigo_producto.set_attributes(atributos)
        self.fixed_generales.put(self.codigo_producto, 385, 30)

        self.entry_codigo_producto = gtk.Entry()
        self.entry_codigo_producto.modify_font(font_entry)
        self.entry_codigo_producto.set_size_request(210, 30)
        self.entry_codigo_producto.set_property("editable", 0)
        self.fixed_generales.put(self.entry_codigo_producto, 470, 28)

        self.entry_codigo_producto.set_text(
            self_seccion_stock.datos_seleccionados_productos[2])

        titulo_labels_generales = ("Ganancia : ", "Stock Inicial : ",
                                   "Stock Disponible : ",
                                   "Punto Reposicion : ")
        #labels_cordenadaY_generales=(102,172,242,312)
        labels_cordenadaY_generales = (102, 152, 202, 252)
        self.labels_generales = []
        for x in range(4):
            self.labels_generales.append(gtk.Label(titulo_labels_generales[x]))
            self.labels_generales[x].set_attributes(atributos)
            self.fixed_generales.put(self.labels_generales[x], 180,
                                     labels_cordenadaY_generales[x])

        self.pin_generales = []
        adj_generales = []
        #coordenadasY=(100,170,240,310)
        coordenadasY = (100, 150, 200, 250)
        if self_seccion_stock.tipo_producto == "merceria" or self_seccion_stock.tipo_producto == "lana":
            for x in range(4):
                adj_generales.append(
                    gtk.Adjustment(value=0,
                                   lower=0,
                                   upper=999,
                                   step_incr=0.1,
                                   page_incr=0.1,
                                   page_size=0))
                self.pin_generales.append(
                    gtk.SpinButton(adjustment=adj_generales[x],
                                   climb_rate=1.0,
                                   digits=2))
                self.pin_generales[x].set_numeric(True)
                self.pin_generales[x].set_size_request(120, 28)
                #self.pin_generales[x].set_max_length(3)
                font_spin_generales = pango.FontDescription(fuente_entrys)
                self.pin_generales[x].modify_font(font_spin_generales)
                self.fixed_generales.put(self.pin_generales[x], 390,
                                         coordenadasY[x])
        else:
            for x in range(4):
                adj_generales.append(
                    gtk.Adjustment(value=0,
                                   lower=0,
                                   upper=999,
                                   step_incr=1,
                                   page_incr=1,
                                   page_size=0))
                self.pin_generales.append(
                    gtk.SpinButton(adjustment=adj_generales[x],
                                   climb_rate=1.0,
                                   digits=0))
                self.pin_generales[x].set_numeric(True)
                self.pin_generales[x].set_size_request(120, 28)
                #self.pin_generales[x].set_max_length(3)
                font_spin_generales = pango.FontDescription(fuente_entrys)
                self.pin_generales[x].modify_font(font_spin_generales)
                self.fixed_generales.put(self.pin_generales[x], 390,
                                         coordenadasY[x])

        b = len(self_seccion_stock.datos_seleccionados_productos)
        self.fila_seleccionada = self_seccion_stock.datos_seleccionados_productos[
            b - 1]

        if self_seccion_stock.tipo_producto != "ropa":
            self.pin_generales[0].set_value(
                self.liststore_elejido.get_value(self.fila_seleccionada,
                                                 6))  #ganancia
            self.pin_generales[1].set_value(
                self.liststore_elejido.get_value(self.fila_seleccionada,
                                                 7))  #stk ini
            self.pin_generales[2].set_value(
                self.liststore_elejido.get_value(self.fila_seleccionada,
                                                 8))  #stk dis
            self.pin_generales[3].set_value(
                self.liststore_elejido.get_value(self.fila_seleccionada,
                                                 9))  #pnt rep
        else:
            self.pin_generales[0].set_value(
                self.liststore_elejido.get_value(self.fila_seleccionada, 7))
            self.pin_generales[1].set_value(
                self.liststore_elejido.get_value(self.fila_seleccionada, 8))
            self.pin_generales[2].set_value(
                self.liststore_elejido.get_value(self.fila_seleccionada, 9))
            self.pin_generales[3].set_value(
                self.liststore_elejido.get_value(self.fila_seleccionada, 10))

            #botones
        self.botones_totales = []
        imagenes = []
        ruta_imagenes = ("../Images/boton_aceptar.png",
                         "../Images/boton_cerrar.png")

        for x in range(2):
            imagenes.append(gtk.Image())
            self.botones_totales.append(gtk.Button())
            self.botones_totales[x].set_property("relief", 2)
            #self.botones_totales[x].set_property("can-focus",0)
            self.botones_totales[x].set_size_request(120, 40)
            imagenes[x].set_from_file(ruta_imagenes[x])
            self.botones_totales[x].add(imagenes[x])

        self.botones_totales[0].connect("clicked", self.actualizar,
                                        self_seccion_stock,
                                        self_ventana_principal)
        self.botones_totales[1].connect("clicked", self.destroy,
                                        self_ventana_principal)
        self.vbox1 = gtk.VBox(False, 0)
        self.vbox1.set_size_request(700, 40)

        botonera = gtk.HButtonBox()
        botonera.set_property("layout-style", 1)
        self.vbox1.pack_start(botonera, False, False, 2)
        botonera.pack_start(self.botones_totales[0], False, True, 0)
        botonera.pack_start(self.botones_totales[1], False, True, 0)

        self.fixed_generales.put(self.vbox1, 0, 350)

        self.window.show_all()
コード例 #27
0
    def __init__(self, widget, self_seccion_stock, self_ventana_principal):
        self.codigo = []
        self.codigos_repetidos = ["l", "L", "r", "R"]
        object = self_ventana_principal.window
        object.set_sensitive(False)
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_size_request(1131, 600)
        self.window.set_position(gtk.WIN_POS_CENTER)
        self.window.set_title("Busqueda de productos")
        self.window.set_resizable(False)
        self.window.connect("delete-event", self.delete_event, object)
        self.fixed = gtk.Fixed()

        img = gtk.Image()

        self.fixed.add(img)
        self.window.add(self.fixed)

        atributos = pango.AttrList()
        atributos.insert(pango.AttrSize(12400, 0, -1))
        atributos.insert(pango.AttrWeight(1200, 0, -1))

        label_codigo = gtk.Label("Codigo : ")
        label_descripcion = gtk.Label("Descripcion : ")
        label_cantidad = gtk.Label("Cantidad : ")

        label_codigo.set_attributes(atributos)
        label_descripcion.set_attributes(atributos)
        label_cantidad.set_attributes(atributos)

        fuente_entrys = "Sans 13"
        font_entry = pango.FontDescription(fuente_entrys)

        self.entry = gtk.Entry()
        self.entry_descripcion = gtk.Entry()
        self.entry_cantidad = gtk.Entry()

        self.entry.modify_font(font_entry)
        self.entry_descripcion.modify_font(font_entry)
        self.entry_cantidad.modify_font(font_entry)

        self.fixed.put(self.entry, 150, 20)
        self.fixed.put(self.entry_descripcion, 480, 20)
        self.fixed.put(self.entry_cantidad, 750, 20)

        self.fixed.put(label_codigo, 80, 25)
        self.fixed.put(label_descripcion, 370, 25)
        self.fixed.put(label_cantidad, 660, 25)

        self.button_ma = gtk.Button()
        self.button_ma.set_property("relief", 2)
        imagen_boton_cerrar = gtk.Image()
        imagen_boton_cerrar.set_from_file("../Images/boton_cerrar.png")
        self.button_ma.add(imagen_boton_cerrar)
        self.fixed.put(self.button_ma, 990, 550)

        #agrego a una lista informacion de la bd

        self.button_ma.connect("clicked", self.salir, object)
        self.entry.connect("changed", self.mostrar, 'codigo')
        self.entry.connect("activate", self.verificar_codigo, 'codigo')
        self.entry_cantidad.connect("activate", self.cargar,
                                    self_seccion_stock)

        #--------------------------------------------------------------------------------------------------------------
        self.scroll_win = gtk.ScrolledWindow()
        self.scroll_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.scroll_win.set_size_request(1111, 470)
        self.fixed.put(self.scroll_win, 10, 70)

        self.liststore = gtk.ListStore(str, int, str, str, float, float, str,
                                       str, str, str, str, 'gboolean')
        self.treeview = gtk.TreeView(self.liststore)
        rules_hint = self.treeview.get_rules_hint()
        self.treeview.set_rules_hint(True)

        self.scroll_win.add(self.treeview)

        self.columnpb = gtk.TreeViewColumn("")
        self.column1 = gtk.TreeViewColumn("Codigo")
        self.column2 = gtk.TreeViewColumn("Descripcion")
        self.column3 = gtk.TreeViewColumn("Costo")
        self.column4 = gtk.TreeViewColumn("Precio")
        self.column5 = gtk.TreeViewColumn("Stock inicial")
        self.column6 = gtk.TreeViewColumn("Stock disponible")
        self.column7 = gtk.TreeViewColumn("punto de reposicion")
        self.column8 = gtk.TreeViewColumn("Reponer")

        self.treeview.append_column(self.columnpb)
        self.treeview.append_column(self.column1)
        self.treeview.append_column(self.column2)
        self.treeview.append_column(self.column3)
        self.treeview.append_column(self.column4)
        self.treeview.append_column(self.column5)
        self.treeview.append_column(self.column6)
        self.treeview.append_column(self.column7)

        self.cell = gtk.CellRendererText()
        self.cellpb = gtk.CellRendererPixbuf()

        self.cell.set_property("cell background", "#71ACE2")
        self.cell.set_property('size',
                               14000)  #solo le da el tamaño a las celdas xd
        self.cell.set_property('weight',
                               700)  #seria el "grosor" de la fuente :P
        self.cellpb.set_property("cell background", "#71ACE2")

        self.columnpb.pack_start(self.cellpb, True)
        self.column1.pack_start(self.cell, True)
        self.column2.pack_start(self.cell, True)
        self.column3.pack_start(self.cell, True)
        self.column4.pack_start(self.cell, True)
        self.column5.pack_start(self.cell, True)
        self.column6.pack_start(self.cell, True)
        self.column7.pack_start(self.cell, True)

        self.treeview.set_search_column(1)
        self.treeview.set_search_column(2)
        self.treeview.set_search_column(3)
        self.treeview.set_search_column(4)
        self.treeview.set_search_column(5)
        self.treeview.set_search_column(6)
        self.treeview.set_search_column(7)

        self.column1.set_sort_column_id(2)
        self.column2.set_sort_column_id(3)
        self.column3.set_sort_column_id(4)
        self.column4.set_sort_column_id(5)
        self.column5.set_sort_column_id(6)
        self.column6.set_sort_column_id(7)
        self.column7.set_sort_column_id(8)

        self.columnpb.set_expand(True)
        self.column1.set_expand(True)
        self.column2.set_expand(True)
        self.column3.set_expand(True)
        self.column4.set_expand(True)
        self.column5.set_expand(True)
        self.column6.set_expand(True)
        self.column7.set_expand(True)

        self.column1.set_resizable(True)
        self.column2.set_resizable(True)
        self.column3.set_resizable(True)
        self.column4.set_resizable(True)
        self.column5.set_resizable(True)
        self.column6.set_resizable(True)
        self.column7.set_resizable(True)

        self.lista_columnas = []
        self.lista_columnas.append(self.columnpb)
        self.lista_columnas.append(self.column1)
        self.lista_columnas.append(self.column2)
        self.lista_columnas.append(self.column3)
        self.lista_columnas.append(self.column4)
        self.lista_columnas.append(self.column5)
        self.lista_columnas.append(self.column6)
        self.lista_columnas.append(self.column7)

        self.lista_columnas.append(self.cell)
        self.lista_columnas.append(self.cellpb)

        self.setear_filas()

        self.window.show_all()
コード例 #28
0
    def __init__(self, handle, create_jobject=True):
        "The entry point to the Activity"
        activity.Activity.__init__(self, handle)
        self.selected_journal_entry = None
        self.selected_path = None
        self.update_log_entries = ''
        self.close_requested = False
        
        canvas = gtk.Notebook()
        canvas.props.show_border = True
        canvas.props.show_tabs = True
        canvas.show()
        
        self.ls_journal = gtk.ListStore(gobject.TYPE_STRING, 
                gobject.TYPE_UINT64, 
                gobject.TYPE_STRING,  
                gobject.TYPE_PYOBJECT)
        self.tv_journal = gtk.TreeView(self.ls_journal)
        self.tv_journal.set_rules_hint(True)
        self.tv_journal.set_search_column(COLUMN_TITLE)
        self.selection_journal = self.tv_journal.get_selection()
        self.selection_journal.set_mode(gtk.SELECTION_SINGLE)
        self.selection_journal.connect("changed", self.selection_journal_cb)
        renderer = gtk.CellRendererText()
        renderer.set_property('wrap-mode', gtk.WRAP_WORD)
        renderer.set_property('wrap-width', 500)
        renderer.set_property('width', 500)
        self.col_journal = gtk.TreeViewColumn(_('Title'), renderer, 
                                              text=COLUMN_TITLE)
        self.col_journal.set_sort_column_id(COLUMN_TITLE)
        self.tv_journal.append_column(self.col_journal)
        
        size_renderer = gtk.CellRendererText()
        size_renderer.set_property('width', 100)
        size_renderer.set_property('alignment', pango.ALIGN_RIGHT)
        size_renderer.set_property('xalign', 0.8)
        self.col_size = gtk.TreeViewColumn(_('Size (KB)'), size_renderer, 
                                           text=COLUMN_SIZE)
        self.col_size.set_sort_column_id(COLUMN_SIZE)
        self.tv_journal.append_column(self.col_size)
        
        mime_renderer = gtk.CellRendererText()
        mime_renderer.set_property('width', 200)
        self.col_mime = gtk.TreeViewColumn(_('MIME Type'), mime_renderer, 
                                           text=COLUMN_MIME)
        self.col_mime.set_sort_column_id(COLUMN_MIME)
        self.tv_journal.append_column(self.col_mime)
        
        self.list_scroller_journal = gtk.ScrolledWindow(
                        hadjustment=None, vadjustment=None)
        self.list_scroller_journal.set_policy(
                    gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.list_scroller_journal.add(self.tv_journal)
        
        label_attributes = pango.AttrList()
        label_attributes.insert(pango.AttrSize(14000, 0, -1))
        label_attributes.insert(pango.AttrForeground(65535, 65535, 65535, 0, -1))

        tab1_label = gtk.Label(_("Journal"))
        tab1_label.set_attributes(label_attributes)
        tab1_label.show()
        self.tv_journal.show()
        self.list_scroller_journal.show()
        
        column_table = gtk.Table(rows=1,  columns=2,  homogeneous = False)
        
        image_table = gtk.Table(rows=2,  columns=2,  homogeneous=False)
        self.image = gtk.Image()
        image_table.attach(self.image, 0, 2, 0, 1, xoptions=gtk.FILL|gtk.SHRINK, 
                           yoptions=gtk.FILL|gtk.SHRINK, xpadding=10, ypadding=10)

        self.dimension_label = gtk.Label("")
        image_table.attach(self.dimension_label,  0, 2, 1, 2,  xoptions=gtk.SHRINK,
                             yoptions=gtk.SHRINK,  xpadding=10,  ypadding=10)

        self.btn_resize = gtk.Button(_("Resize To Width"))
        self.btn_resize.connect('button_press_event',  
                              self.resize_button_press_event_cb)
        image_table.attach(self.btn_resize,  0, 1, 2, 3,  xoptions=gtk.SHRINK,
                             yoptions=gtk.SHRINK,  xpadding=10,  ypadding=10)

        self.resize_width_entry = gtk.Entry(max=4)
        image_table.attach(self.resize_width_entry, 1, 2, 2, 3, 
                           xoptions=gtk.SHRINK, 
                           yoptions=gtk.SHRINK, xpadding=10, ypadding=10)
        self.resize_width_entry.set_text('600')
        self.resize_width_entry.connect('key_press_event', 
                                    self.resize_key_press_event_cb)

        self.btn_save = gtk.Button(_("Save"))
        self.btn_save.connect('button_press_event',  
                              self.save_button_press_event_cb)
        image_table.attach(self.btn_save,  0, 1, 3, 4,  xoptions=gtk.SHRINK,
                             yoptions=gtk.SHRINK,  xpadding=10,  ypadding=10)
        self.btn_save.props.sensitive = False
        self.btn_save.show()

        self.btn_delete = gtk.Button(_("Delete"))
        self.btn_delete.connect('button_press_event',  
                                self.delete_button_press_event_cb)
        image_table.attach(self.btn_delete,  1, 2, 3, 4,  xoptions=gtk.SHRINK,
                            yoptions=gtk.SHRINK,  xpadding=10,  ypadding=10)
        self.btn_delete.props.sensitive = False
        self.btn_delete.show()

        entry_table = gtk.Table(rows=3, columns=2, 
                                homogeneous=False)

        title_label = gtk.Label(_("Title"))
        entry_table.attach(title_label, 0, 1, 0, 1, 
                           xoptions=gtk.SHRINK, 
                           yoptions=gtk.SHRINK, 
                           xpadding=10, ypadding=10)
        title_label.show()
      
        self.title_entry = gtk.Entry(max=0)
        entry_table.attach(self.title_entry, 1, 2, 0, 1, 
                           xoptions=gtk.FILL|gtk.SHRINK, 
                           yoptions=gtk.SHRINK, xpadding=10, ypadding=10)
        self.title_entry.connect('key_press_event',  
                                 self.key_press_event_cb)
        self.title_entry.show()
    
        description_label = gtk.Label(_("Description"))
        entry_table.attach(description_label, 0, 1, 1, 2, 
                           xoptions=gtk.SHRINK, 
                           yoptions=gtk.SHRINK, 
                           xpadding=10, ypadding=10)
        description_label.show()
        
        self.description_textview = gtk.TextView()
        self.description_textview.set_wrap_mode(gtk.WRAP_WORD)
        entry_table.attach(self.description_textview, 1, 2, 1, 2, 
                           xoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK, 
                           yoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK, 
                           xpadding=10, ypadding=10)
        self.description_textview.props.accepts_tab = False
        self.description_textview.connect('key_press_event', 
                                          self.key_press_event_cb)
        self.description_textview.show()

        tags_label = gtk.Label(_("Tags"))
        entry_table.attach(tags_label, 0, 1, 2, 3, 
                           xoptions=gtk.SHRINK, 
                           yoptions=gtk.SHRINK, 
                           xpadding=10, ypadding=10)
        tags_label.show()
        
        self.tags_textview = gtk.TextView()
        self.tags_textview.set_wrap_mode(gtk.WRAP_WORD)
        entry_table.attach(self.tags_textview, 1, 2, 2, 3, 
                           xoptions=gtk.FILL, 
                           yoptions=gtk.EXPAND|gtk.FILL, 
                           xpadding=10, ypadding=10)
        self.tags_textview.props.accepts_tab = False
        self.tags_textview.connect('key_press_event', 
                                    self.key_press_event_cb)
        self.tags_textview.show()
        
        entry_table.show()

        scroller_image = gtk.ScrolledWindow(
                                                 hadjustment=None, vadjustment=None)
        scroller_image.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        scroller_image.add_with_viewport(image_table)
        scroller_image.show()
        
        self.scroller_entry = gtk.ScrolledWindow(
                                                 hadjustment=None, vadjustment=None)
        self.scroller_entry.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.scroller_entry.add_with_viewport(entry_table)
        self.scroller_entry.show()
        
        column_table.attach(scroller_image,  0, 1, 0, 1,  
                            xoptions=gtk.FILL|gtk.EXPAND|gtk.SHRINK,  
                            yoptions=gtk.FILL|gtk.EXPAND|gtk.SHRINK, 
                            xpadding=10,  ypadding=10)

        column_table.attach(self.scroller_entry,  1, 2, 0, 1,  
                            xoptions=gtk.FILL|gtk.EXPAND|gtk.SHRINK,  
                            yoptions=gtk.FILL|gtk.EXPAND|gtk.SHRINK, 
                            xpadding=10,  ypadding=10)
                            
        image_table.show()
        column_table.show()
        self.btn_resize.hide()
        self.resize_width_entry.hide()

        vbox = gtk.VBox(homogeneous=True,  spacing=5)
        vbox.pack_start(column_table)
        vbox.pack_end(self.list_scroller_journal)

        canvas.append_page(vbox,  tab1_label)
 
        self._filechooser = gtk.FileChooserWidget(
            action=gtk.FILE_CHOOSER_ACTION_OPEN, backend=None)
        self._filechooser.set_current_folder("/media")
        self.copy_button = gtk.Button(_("Copy File To The Journal"))
        self.copy_button.connect('clicked',  self.create_journal_entry)
        self.copy_button.show()
        self._filechooser.set_extra_widget(self.copy_button)
        preview = gtk.Image()
        self._filechooser.set_preview_widget(preview)
        self._filechooser.connect("update-preview", 
                                  self.update_preview_cb, preview)
        tab2_label = gtk.Label(_("Files"))
        tab2_label.set_attributes(label_attributes)
        tab2_label.show()
        canvas.append_page(self._filechooser,  tab2_label)

        self.set_canvas(canvas)
        self.show_all()
        self.btn_resize.hide()
        self.resize_width_entry.hide()
        self.dimension_label.hide()
        
        toolbox = activity.ActivityToolbox(self)
        activity_toolbar = toolbox.get_activity_toolbar()
        activity_toolbar.keep.props.visible = False
        activity_toolbar.share.props.visible = False
        self.set_toolbox(toolbox)
        toolbox.show()

        self.load_journal_table()

        bus = dbus.SessionBus()
        remote_object = bus.get_object(DS_DBUS_SERVICE, DS_DBUS_PATH)
        _datastore = dbus.Interface(remote_object, DS_DBUS_INTERFACE)
        _datastore.connect_to_signal('Created', self.datastore_created_cb)
        _datastore.connect_to_signal('Updated', self.datastore_updated_cb)
        _datastore.connect_to_signal('Deleted', self.datastore_deleted_cb)

        self.selected_journal_entry = None
コード例 #29
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)

        self.set_title("Ecomundo")
        print "Init activity Ecomundo"
        #print os.path.abspath(__file__)

        toolbox = activity.ActivityToolbox(self)
        self.toolbar = gtk.Toolbar()

        toolbox.add_toolbar(_('Ecomundo'), self.toolbar)
        self.toolbar.show()
        self.set_toolbox(toolbox)
        toolbox.show()

        self.btnNew = ToolButton('reload')
        self.btnNew.connect('clicked', self.onBtNewClicked)
        self.toolbar.insert(self.btnNew, -1)
        self.btnNew.show()

        self.btPlay = ToolButton('next')
        self.btPlay.connect('clicked', self.onBtPlayClicked)
        self.toolbar.insert(self.btPlay, -1)
        self.btPlay.show()

        self.btStop = ToolButton('process-stop')
        self.btStop.connect('clicked', self.onBtStopClicked)
        self.toolbar.insert(self.btStop, -1)
        self.btStop.show()

        self.btStop.props.sensitive = False
        self.btPlay.props.sensitive = True

        toolbox.set_current_toolbar(1)

        hBox = gtk.HBox(False, 0)
        self.set_canvas(hBox)

        self.drawingarea1 = gtk.DrawingArea()
        self.drawingarea1.set_size_request(
            World.SIZE_WORLD + (2 * World.MARGEN),
            World.SIZE_WORLD + (2 * World.MARGEN))
        self.drawingarea1.show()

        hBox.pack_start(self.drawingarea1, False, True, 5)

        table = gtk.Table(rows=4, columns=2, homogeneous=False)
        hBox.pack_start(table, False, False, 5)

        label_attributes = pango.AttrList()
        label_attributes.insert(pango.AttrSize(14000, 0, -1))
        label_attributes.insert(
            pango.AttrForeground(65535, 65535, 65535, 0, -1))

        lbTitle = gtk.Label()
        lbTitle.set_attributes(label_attributes)
        lbTitle.set_text(_('Initial Values'))
        #table.attach(lbTitle, 0, 1, 0, 1,yoptions=gtk.SHRINK,xpadding=5)
        table.attach(lbTitle, 0, 2, 0, 1, yoptions=gtk.SHRINK, xpadding=10)

        lbGreen = gtk.Label()
        lbGreen.set_attributes(label_attributes)
        lbGreen.set_text(_('Green'))
        table.attach(lbGreen,
                     0,
                     1,
                     1,
                     2,
                     yoptions=gtk.SHRINK,
                     xoptions=gtk.SHRINK,
                     xpadding=10)

        adjGreen = gtk.Adjustment(10, 1, 400, 1, 1, 0)
        self.spbGreen = gtk.SpinButton(adjustment=adjGreen,
                                       climb_rate=1.0,
                                       digits=2)
        table.attach(self.spbGreen,
                     1,
                     2,
                     1,
                     2,
                     yoptions=gtk.SHRINK,
                     xoptions=gtk.SHRINK,
                     ypadding=10)

        lbRabbit = gtk.Label()
        lbRabbit.set_attributes(label_attributes)
        lbRabbit.set_text(_('Rabbits'))
        table.attach(lbRabbit,
                     0,
                     1,
                     2,
                     3,
                     yoptions=gtk.SHRINK,
                     xoptions=gtk.SHRINK,
                     xpadding=10)

        adjRabbit = gtk.Adjustment(10, 1, 400, 1, 1, 0)
        self.spbRabbit = gtk.SpinButton(adjustment=adjRabbit,
                                        climb_rate=1.0,
                                        digits=2)
        table.attach(self.spbRabbit,
                     1,
                     2,
                     2,
                     3,
                     yoptions=gtk.SHRINK,
                     xoptions=gtk.SHRINK,
                     ypadding=10)

        lbFox = gtk.Label()
        lbFox.set_attributes(label_attributes)
        lbFox.set_text(_('Foxs'))
        table.attach(lbFox,
                     0,
                     1,
                     3,
                     4,
                     yoptions=gtk.SHRINK,
                     xoptions=gtk.SHRINK,
                     xpadding=10)

        adjFox = gtk.Adjustment(10, 1, 400, 1, 1, 0)
        self.spbFox = gtk.SpinButton(adjustment=adjFox,
                                     climb_rate=1.0,
                                     digits=2)
        table.attach(self.spbFox,
                     1,
                     2,
                     3,
                     4,
                     yoptions=gtk.SHRINK,
                     xoptions=gtk.SHRINK,
                     ypadding=10)

        print "test resize"
        print "antes de initWorld"
        initWorld()
        print "antes de init Green"
        initGreen()
        print "antes de init Animals"
        initAnimals()

        hBox.resize_children()
        hBox.show_all()

        self.drawingarea1.connect('expose-event', self.onDrawingAreaExposed)
コード例 #30
0
    def __init__(self, self_seccion_stock, self_ventana_principal):
        self_ventana_principal.window.set_sensitive(False)
        icono = "../Images/fusa_icon.png"
        self.window = gtk.Window()
        self.window.set_position(gtk.WIN_POS_CENTER)
        self.window.set_resizable(False)
        self.window.set_title("Administrar Base De Datos Stock")
        self.window.set_icon(gtk.gdk.pixbuf_new_from_file(icono))
        self.window.set_size_request(620, 400)
        self.window.connect("delete_event", self.cerrar,
                            self_ventana_principal)

        image_fondo = gtk.Image()
        #image_fondo.set_from_file("../Images/fondo_amdBD.png")

        fixed_principal = gtk.Fixed()
        fixed_principal.add(image_fondo)
        self.window.add(fixed_principal)

        atributos = pango.AttrList()
        atributos.insert(pango.AttrSize(11000, 0, -1))
        atributos.insert(pango.AttrWeight(1200, 0, -1))

        label = gtk.Label()
        label.set_markup("<b>Base de Datos Stock</b>")
        label.set_use_markup(True)
        frame = gtk.Frame()
        frame.set_label_widget(label)
        frame.set_property("shadow-type", 4)
        frame.set_size_request(600, 310)
        fixed_principal.put(frame, 10, 30)
        fixed_frame = gtk.Fixed()
        frame.add(fixed_frame)

        self.button_backup = gtk.Button("Realizar Backup")

        self.radio_crear = gtk.RadioButton(None, "Crear")
        self.radio_crear.set_property("tooltip-text",
                                      "Crear una nueva Base de Datos")
        self.radio_especificar = gtk.RadioButton(self.radio_crear,
                                                 "Especificar")
        self.radio_especificar.set_property(
            "tooltip-text", "Buscar una Base de Datos existente")
        self.radio_otras = gtk.RadioButton(self.radio_crear, "Backup")
        self.radio_otras.set_property(
            "tooltip-text",
            "Indique el lugar donde desea \nrealizar el Backup")

        fixed_frame.put(self.button_backup, 410, 70)

        self.button_cerrar = gtk.Button("Cerrar")
        #self.button_cerrar.set_property("relief",2)
        self.button_cerrar.set_size_request(90, 40)

        fixed_principal.put(self.button_cerrar, 520, 355)
        fixed_frame.put(self.radio_crear, 40, 30)
        fixed_frame.put(self.radio_especificar, 250, 30)
        fixed_frame.put(self.radio_otras, 400, 30)

        self.button_buscar = gtk.Button("Buscar...")
        fixed_frame.put(self.button_buscar, 260, 70)

        self.vbox = gtk.VBox(False, 0)

        label_nombre = gtk.Label("Nombre : ")
        self.entry_new_BD = gtk.Entry(12)

        self.hcaja_crear = gtk.HBox()
        self.hcaja_crear.set_size_request(200, 40)
        self.hcaja_crear.set_property("homogeneous", 0)
        self.hcaja_crear.pack_start(label_nombre, False, True, 1)
        self.hcaja_crear.pack_start(self.entry_new_BD, True, True, 1)
        self.vbox.pack_start(self.hcaja_crear, False, True, 1)

        fixed_ruta = gtk.Fixed()
        self.frame_ruta = gtk.Frame("Ruta de Archivo")
        self.frame_ruta.set_property("shadow-type", 4)
        self.frame_ruta.set_size_request(200, 130)
        self.frame_ruta.add(fixed_ruta)

        self.radio_predeterminada = gtk.RadioButton(None, "Predeterminada")
        self.radio_indicar = gtk.RadioButton(self.radio_predeterminada,
                                             "Indicar")
        self.radio_indicar.set_property(
            "tooltip-text",
            "Especifique la ruta donde desea\nalojar la nueva Base de Datos")
        self.button_indicar = gtk.Button("Indicar Ruta")
        self.button_indicar.set_size_request(90, 25)

        fixed_ruta.put(self.radio_predeterminada, 20, 10)
        fixed_ruta.put(self.radio_indicar, 20, 60)
        fixed_ruta.put(self.button_indicar, 100, 60)

        self.vbox.pack_start(self.frame_ruta, False, True, 1)

        self.aceptar_BD = gtk.Button("Aceptar")
        self.vbox.pack_start(self.aceptar_BD, False, True, 1)

        fixed_frame.put(self.vbox, 40, 70)

        self.button_buscar.connect("clicked", self.buscarBD,
                                   self_seccion_stock)
        self.button_indicar.connect("clicked", self.indicarBD)

        self.radio_crear.connect("toggled", self.elijio_crear)
        self.radio_especificar.connect("toggled", self.elijio_especificar)
        self.radio_otras.connect("toggled", self.elijio_otras)

        self.radio_predeterminada.connect("toggled", self.desactivar_indicar)
        self.radio_indicar.connect("toggled", self.activar_indicar)

        self.entry_new_BD.connect("changed", self.entry_teclas)

        self.button_backup.connect("clicked", self.realizar_backup)

        self.button_cerrar.connect("clicked", self.cerrar_boton,
                                   self_ventana_principal)

        self.button_buscar.set_sensitive(False)
        self.button_indicar.set_sensitive(False)
        self.aceptar_BD.set_sensitive(False)
        self.frame_ruta.set_sensitive(False)
        self.hcaja_crear.set_sensitive(False)

        self.button_cerrar.set_property("is-focus", 1)
        self.radio_otras.set_active(True)

        self.window.show_all()