python类Image()的实例源码

gu.py 文件源码 项目:Solfege 作者: RannyeriDev 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def create_stock_menu_item(stock, txt, callback, ag, accel_key, accel_mod):
    box = Gtk.HBox(False, 0)
    box.set_spacing(PAD_SMALL)
    im = Gtk.Image()
    im.set_from_stock(stock, Gtk.IconSize.MENU)
    item = Gtk.ImageMenuItem(txt)
    item.set_image(im)
    if accel_key != 0:
        item.add_accelerator('activate', ag, accel_key, accel_mod, Gtk.AccelFlags.VISIBLE)
    item.connect('activate', callback)
    return item
gu.py 文件源码 项目:Solfege 作者: RannyeriDev 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def create_png_image(fn):
    """
    Create an image by loading a png file from graphics dir
    """
    im = Gtk.Image()
    im.set_from_file(os.path.join('graphics', fn)+'.png')
    im.show()
    return im
gu.py 文件源码 项目:Solfege 作者: RannyeriDev 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def create_rhythm_image(rhythm):
    """
    rhythm : a string like 'c8 c8' or 'c8 c16 c16'
    The image returned is shown.
    """
    im = Gtk.Image()
    im.set_from_file(os.path.join('graphics', 'rhythm-%s.png' % (rhythm.replace(" ", ""))))
    im.show()
    return im
gu.py 文件源码 项目:Solfege 作者: RannyeriDev 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def make_warning(self):
        im = Gtk.Image()
        im.set_from_stock(Gtk.STOCK_DIALOG_WARNING, Gtk.IconSize.MENU)
        self.set_image(im)
        self.set_alignment(0.0, 0.5)
VCodeDialog.py 文件源码 项目:bcloud 作者: wangYanJava 项目源码 文件源码 阅读 40 收藏 0 点赞 0 评论 0
def __init__(self, parent, app, info):
        super().__init__(_('Verification..'), app.window,
                         Gtk.DialogFlags.MODAL,
                         (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                          Gtk.STOCK_OK, Gtk.ResponseType.OK))

        self.set_default_response(Gtk.ResponseType.OK)
        self.set_default_size(320, 200)
        self.set_border_width(10)
        self.app = app

        box = self.get_content_area()
        box.set_spacing(10)

        gutil.async_call(net.urlopen, info['img'],
                         {'Cookie': app.cookie.header_output()},
                         callback=self.update_img)
        self.img = Gtk.Image()
        box.pack_start(self.img, False, False, 0)

        self.entry = Gtk.Entry()
        self.entry.connect('activate',
                lambda *args: self.response(Gtk.ResponseType.OK))
        box.pack_start(self.entry, False, False, 0)

        box.show_all()
main_window.py 文件源码 项目:MokaPlayer 作者: vedard 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __create_flowbox(self, flowbox):
        self.logger.info('Creating Flowbox')
        start = time.perf_counter()

        image_loading_queue = []
        children = []

        order = AbstractPlaylist.OrderBy[self.userconfig['grid']['sort']['field']]
        desc = self.userconfig['grid']['sort']['desc']
        image_size = self.userconfig['flowbox']['image_size']
        margin = self.userconfig['flowbox']['margin']
        collections = self.current_playlist.collections(order, desc, self.txt_search.get_text())

        for child in flowbox.get_children():
            flowbox.remove(child)

        for item in collections:
            image = Gtk.Image()
            image.set_size_request(image_size, image_size)
            image.get_style_context().add_class('cover')
            image_loading_queue.append((image, item.Cover, image_size, image_size))

            if isinstance(item, Album):
                children.append(self.__create_album_flowboxitem(item, image, margin))
            elif isinstance(item, Artist):
                children.append(self.__create_artist_flowboxitem(item, image, margin))

        for child in children:
            flowbox.add(child)
        flowbox.show_all()

        image_helper.set_multiple_image(image_loading_queue)

        end = time.perf_counter()
        self.logger.info('Flowbox created in {:.3f} seconds'.format(end - start))
radare_toolbar.py 文件源码 项目:bokken 作者: thestr4ng3r 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _hide_tb_toggled(self, widget):
        if widget.get_active():
            self.main.tviews.term_nb.show()
            i = Gtk.Image()
            i.set_from_stock(Gtk.STOCK_GO_DOWN, Gtk.IconSize.MENU)
            widget.set_image(i)
        else:
            self.main.tviews.term_nb.hide()
            i = Gtk.Image()
            i.set_from_stock(Gtk.STOCK_GO_UP, Gtk.IconSize.MENU)
            widget.set_image(i)
throbber.py 文件源码 项目:bokken 作者: thestr4ng3r 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self):
        self.img_static = Gtk.Image()
        self.img_static.set_from_file(datafile_path('throbber_static.gif'))
        self.img_static.show()
        self.img_animat = Gtk.Image()
        self.img_animat.set_from_file(datafile_path('throbber_animat.gif'))
        self.img_animat.show()

        super(Throbber,self).__init__(self.img_static, "")
        self.set_sensitive(False)
main_button.py 文件源码 项目:bokken 作者: thestr4ng3r 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, text, menu):
        GObject.GObject.__init__(self)
        self.menu = menu
        hbox1 = Gtk.HBox()
        hbox2 = Gtk.HBox()
        icon = Gtk.Image()
        icon.set_from_file(datafile_path('bokken-small.svg'))
        hbox1.pack_start(icon, True, True, 3)
        label = Gtk.Label()
        label.set_markup("<b>"+ text + "</b>")
        hbox1.pack_start(label, True, True, 3)
        arrow = Gtk.Arrow(Gtk.ArrowType.DOWN, Gtk.ShadowType.IN)
        hbox1.pack_start(arrow, False, False, 3)
        hbox2.pack_start(hbox1, True, True, 0)

        # MEOW Text settings
        #attrs = Pango.AttrList()
        #attrs.change(Pango.AttrWeight(Pango.Weight.SEMIBOLD, 0, -1))
        #label.set_attributes(attrs)

        self.add(hbox2)
        self.set_relief(Gtk.ReliefStyle.NORMAL)
        self.set_can_focus(True)
        self.set_can_default(False)
        self.connect("toggled", self.on_toggled)

        for sig in "selection-done", "deactivate", "cancel":
            menu.connect(sig, self.on_menu_dismiss)
right_textview.py 文件源码 项目:bokken 作者: thestr4ng3r 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def create_seek_buttons(self):
        self.hbox = Gtk.HBox(False, 1)

        self.back = Gtk.Button()
        self.back_img = Gtk.Image()
        self.back_img.set_from_stock(Gtk.STOCK_GO_BACK, Gtk.IconSize.MENU)
        self.back.set_image(self.back_img)
        self.back.set_relief(Gtk.ReliefStyle.NONE)
        self.back.connect('clicked', self.do_seek, 'b')

        self.forward = Gtk.Button()
        self.forward_img = Gtk.Image()
        self.forward_img.set_from_stock(Gtk.STOCK_GO_FORWARD, Gtk.IconSize.MENU)
        self.forward.set_image(self.forward_img)
        self.forward.set_relief(Gtk.ReliefStyle.NONE)
        self.forward.connect('clicked', self.do_seek, 'f')

        self.seek = Gtk.Entry()
        self.seek.set_max_length(30)
        self.seek.set_icon_from_stock(1, Gtk.STOCK_JUMP_TO)
        self.seek.set_activates_default(True)
        self.seek.connect("activate", self.goto)
        self.seek.connect("icon-press", self.goto)
        self.seek.set_icon_tooltip_text(1, 'Go')

        self.hbox.pack_start(self.back, False, False, 0)
        self.hbox.pack_start(self.forward, False, False, 0)
        self.hbox.pack_start(self.seek, True, True, 0)

        return self.hbox
cheatsheet_dialog.py 文件源码 项目:bokken 作者: thestr4ng3r 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def popup_registers(self, widget):
        dialog = Gtk.Dialog('16-bit and 8-bit registers', self, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CLOSE,Gtk.ResponseType.CLOSE))
        ui.gtk3.common.set_bokken_icon(dialog)
        reg_img = Gtk.Image()
        reg_img.set_from_file(datafile_path('registers.png'))
        reg_label = Gtk.Label("The four primary general purpose registers (EAX, EBX, ECX and EDX)\nhave 16 and 8 bit overlapping aliases.")
        reg_label.set_alignment(0.1, 0.1)
        reg_label.set_padding (0, 3)
        dialog.vbox.pack_start(reg_label, False, False, 2)
        dialog.vbox.pack_start(reg_img, True, True, 2)
        dialog.show_all()
        dialog.run()
        dialog.destroy()
textviews.py 文件源码 项目:bokken 作者: thestr4ng3r 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _hide_tb_toggled(self, widget):
        if widget.get_active():
            self.main.topbuttons.hide()
            self.main.mbar.hide()
            i = Gtk.Image()
            i.set_from_stock(Gtk.STOCK_GO_DOWN, Gtk.IconSize.MENU)
            widget.set_image(i)
        else:
            self.main.topbuttons.show()
            self.main.mbar.show()
            i = Gtk.Image()
            i.set_from_stock(Gtk.STOCK_GO_UP, Gtk.IconSize.MENU)
            widget.set_image(i)
graph.py 文件源码 项目:bokken 作者: thestr4ng3r 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def generate_thumbnail(self, dotcode):
        #size = self.tree.allocation.width
        size = self.side_hb.get_allocated_width()
        tmp_dot = tempfile.NamedTemporaryFile(delete = False)
        tmp_dot.write(dotcode)
        tmp_dot.close()

        cmd = "dot -Tpng " + tmp_dot.name + " > " + tmp_dot.name + ".png" 
        os.system(cmd)

        im = Image.open(tmp_dot.name + ".png")
        im.convert('RGBA')
        im.thumbnail([size,size], Image.ANTIALIAS)
        #im.save(tmp_dot.name + ".png.thumbnail", "JPEG")

        # Add white backgound as image is transparent
        offset_tuple = (im.size[0], im.size[1])
        final_thumb = Image.new(mode='RGBA',size=offset_tuple, color=(255,255,255,0))
        final_thumb.paste(im)
        final_thumb.save(tmp_dot.name + ".png.thumbnail", "PNG")

        self.fill_preview(tmp_dot.name + ".png.thumbnail")

        os.remove(tmp_dot.name)
        os.remove(tmp_dot.name + ".png")
        os.remove(tmp_dot.name + ".png.thumbnail")
graph.py 文件源码 项目:bokken 作者: thestr4ng3r 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def create_preview(self):
        # Create Image window for graph preview
        self.preview = Gtk.Image()
        self.preview.show()
left_buttons.py 文件源码 项目:bokken 作者: thestr4ng3r 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def _hide_tb_toggled(self, widget):
        if widget.get_active():
            self.main.topbuttons.main_tb.hide()
            i = Gtk.Image()
            i.set_from_stock(Gtk.STOCK_GO_DOWN, Gtk.IconSize.MENU)
            widget.set_image(i)
        else:
            self.main.topbuttons.main_tb.show()
            i = Gtk.Image()
            i.set_from_stock(Gtk.STOCK_GO_UP, Gtk.IconSize.MENU)
            widget.set_image(i)
opencv_gtk_gui_dev1.py 文件源码 项目:ghetto_omr 作者: pohzhiee 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self,parent):
        Gtk.Grid.__init__(self)
        self.set_border_width(10)

        self.vbox = Gtk.VBox(spacing=6)
        self.vbox = Gtk.Box(spacing=6)
        self.add(self.vbox)

        self.button1 = Gtk.ToggleButton("Button1")
        self.button1.connect("toggled", self.on_button_toggled, "1")
        self.button1.set_active(True)
        #self.button1img = Gtk.Image.new_from_icon_name("filenew", Gtk.IconSize.MENU)
        #self.button1.set_image(self.button1img)

        self.vbox.pack_start(self.button1, True, True, 0)

        self.button2 = Gtk.ToggleButton("Button 2")
        self.button2.connect("toggled", self.on_button_toggled, "2")
        self.vbox.pack_start(self.button2, True, True, 0)

        self.button3 = Gtk.ToggleButton("Button 3")
        self.button3.connect("toggled", self.on_button_toggled, "3")
        self.vbox.pack_start(self.button3, True, True, 0)

        self.attach(self.button1, 0, 0, 1, 1)
        self.attach(self.button2, 1, 0, 3, 1)
        self.attach(self.button3, 2, 0, 1, 1)
opencv_gtk_gui_dev1.py 文件源码 项目:ghetto_omr 作者: pohzhiee 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def on_button_press(self, w, e):

        if e.type == Gdk.EventType.BUTTON_PRESS \
                and e.button == 1: #Left Button
            self.coords.append([e.x, e.y])

        if e.type == Gdk.EventType.BUTTON_PRESS \
                and e.button == 3: #Right Button
            self.queue_draw()


            # class image(Gtk.Image):
#     def __init__(self, parent):
#         x
functions.py 文件源码 项目:poseidon 作者: sidus-dev 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def is_image_valid(file):

    try: Image.open(file)
    except IOError: return False
    return True
functions.py 文件源码 项目:poseidon 作者: sidus-dev 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def make_icon(filename):

    icon = Gtk.Image()
    icon.set_from_file("{}{}".format(icns, filename))

    return icon
icons_utils.py 文件源码 项目:nautilus-folder-icons 作者: bil-elmoussaoui 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __init__(self):
        Gtk.Image.__init__(self)
        self.props.icon_size = Image.SIZE


问题


面经


文章

微信
公众号

扫码关注公众号