コード例 #1
0
 def on_copy_image(self, widget, cc):
     global data
     data = False
     cp = self.notebook.get_current_page()
     if cp == 1:
         copy_iitem_image = cc[-cp]
         tree = ET.parse('history.xml')
         root = tree.getroot()
         clipboard.clear()
         pixbuf0 = Pixbuf.new_from_file("images/"+copy_iitem_image)
         os.remove("images/"+copy_iitem_image)
         self.notebook.remove_page(cp)
         clipboard.set_image(pixbuf0)
     
     if cp > 1:
         copy_iitem_image = cc[-cp]
         tree = ET.parse('history.xml')
         root = tree.getroot()
         clipboard.clear()
         pixbuf0 = Pixbuf.new_from_file("images/"+copy_iitem_image)
         os.remove("images/"+copy_iitem_image)
         self.notebook.remove_page(cp)
         clipboard.set_image(pixbuf0)
     
     sleep(0.1)
     self.on_row_clicked2()
     self.destroy()
コード例 #2
0
ファイル: osprai.py プロジェクト: ridders/osprai
	def on_iconview_key_press_event(self, widget, event):
		to_remove = []
		cats = {48: 0, 49: 1, 50: 2, 51: 3, 52: 4, 53: 5, 54: 6, 55: 7, 56: 8, 57: 9} # the larger number is the keyval equvilent to the smaller number
		#What do cats use to make coffee? A purrcolator! XD 
		
		if event.keyval in cats:
			print("Key {0} has been pressed".format(cats[event.keyval]))
			
			for row in (self.temp_index):
				row_elements = row.split(",")

				for each in self.thumb_view.get_selected_items():
					path = gtk.TreePath(each) # thumb position (numeric value) within the gallery view
					treeiter = self.model.get_iter(path)
					value = self.model.get_value(treeiter, 1) # thumbnail path

					if value == row_elements[1] and row_elements[3] == "0":
						print("match found")
						print(row)
						to_remove.append(row) #takes a snaptshot of the row, adds to to_remove list for iteration and removal from self.temp_index later
						rep_str = (row)
						rep_str = rep_str.split(",") # prepares original row for category replacement
						new_str_seq = (rep_str[0],rep_str[1],rep_str[2],str(cats[event.keyval]))
						rep_str = ",".join(new_str_seq)
						print(rep_str)
						self.temp_index.append(rep_str)
					
			for row in self.temp_index[:]:
				row_elements = row.split(",")
				for each in to_remove:
					if each == row:
						self.temp_index.remove(row)
						print("row removed")
			print("temp index updated")
			to_remove[:] = []
			self.model.clear()
			
			print("Building new thumbs!")
			print(strftime("%Y-%m-%d %H:%M:%S", gmtime()))
			for line in self.temp_index[:40]:
				attribute = (line.split(","))
				thumb_loc = attribute[1]
				file_loc = attribute[2]
				category = attribute[3]

				if category == '0' and os.path.isfile(thumb_loc) == False: # !!!RESEARCH REQUIRED TO LOAD EXISTING FILE

					print("thumb does not exist")
					dir_parser.thumbs_generator(file_loc, thumb_loc)
					pixbuf = Pixbuf.new_from_file(thumb_loc)
					pixbuf = pixbuf.scale_simple(self.desired_width, self.desired_height, GdkPixbuf.InterpType.BILINEAR)
					self.model.append([pixbuf, thumb_loc])

				elif category == '0' and os.path.isfile(thumb_loc) == True:
					print("thumb does exist")
					pixbuf = Pixbuf.new_from_file(thumb_loc)
					pixbuf = pixbuf.scale_simple(self.desired_width, self.desired_height, GdkPixbuf.InterpType.BILINEAR)
					self.model.append([pixbuf, thumb_loc])
			print("new thumbs created!")
			print(strftime("%Y-%m-%d %H:%M:%S", gmtime()))
コード例 #3
0
    def loadAndCreateThumbnails(self):
        if not self.updating_gui:
            # sacamo el hilo que puede estar creando los thumnails para la pagina anterior porque ahora la vamos a
            # recreear
            self.salir_thread = True
            self.liststore.clear()
            self.lista_pendientes.clear()
            self.listaComics = self.query.limit(self.limit).offset(self.offset).all()
            print("Cantidad de comics: {}".format(len(self.listaComics)))

            self.iconview.set_model(self.liststore)
            self.iconview.set_pixbuf_column(0)
            self.iconview.set_text_column(1)
            self.cantidadThumnailsAGenerar = len(self.listaComics)
            self.cantidadThumnailsGenerados = 0
            self.label_contadores.set_text("0/{}".format(len(self.listaComics)))
            for index, comic in enumerate(self.listaComics):
                self.cantidadThumnailsGenerados += 1
                try:
                    nombreThumnail = self.pahThumnails + str(comic.id_comicbook) + '.jpg'
                    cover = None
                    if os.path.isfile(nombreThumnail):
                        try:
                            cover = Pixbuf.new_from_file(nombreThumnail)
                        except:
                            cover = Pixbuf.new_from_file(self.pahThumnails + "error_caratula.png")

                        #cover = Pixbuf.new_from_file(self.pahThumnails + "sin_caratula.jpg")
                        if comic.id_comicbook_info != '':
                            self.cataloged_pix.composite(cover,
                                                         cover.props.width - self.cataloged_pix.props.width,

                                                         cover.props.height - self.cataloged_pix.props.height,
                                                         self.cataloged_pix.props.width,
                                                         self.cataloged_pix.props.height,
                                                         cover.props.width - self.cataloged_pix.props.width,
                                                         cover.props.height - self.cataloged_pix.props.height,
                                                         1, 1,
                                                         3, 200)
                            cover.scale_simple(50, 10, 3)
                        self.liststore.append([cover, comic.getNombreArchivo(), index])
                    else:
                        cover = Pixbuf.new_from_file(self.pahThumnails + "sin_caratula.jpg")
                        iter = self.liststore.append([cover, comic.getNombreArchivo(), index])
                        self.lista_pendientes.append((iter, comic))
                except NotRarFile:
                    print('error en el archivo ' + comic.path)
                except BadRarFile:
                    print('error en el archivo ' + comic.path)

            self.thread_creacion_thumnails = threading.Thread(target=self.crear_thumnails_de_pagina_background)
            self.thread_creacion_thumnails.start()
            self.update_imagen_papelera()
コード例 #4
0
 def on_open_image2(self, widget, path, img_pop):
     # paths = self.get_selected_items()
     model = self.get_model()
     # if paths:
     #     path = paths[0]
     iter = model.get_iter(path)
     pixbuf_format, width, height = Pixbuf.get_file_info(model[iter][0])
     if height > 1080 or width > 1900:
         pixbuf = Pixbuf.new_from_file_at_scale(model[iter][0], 1900, 1080,
                                                True)
     else:
         pixbuf = Pixbuf.new_from_file(model[iter][0])
     # img = Gtk.Image.new_from_pixbuf(pixbuf)
     # img.show_all()
     # pb = img.get_pixbuf()
     # if pb.get_height() > 1080
     # scroll = Gtk.ScrolledWindow()
     # scroll.set_pre
     # scroll.add(img)
     # pop = Gtk.Window.new(1)
     # pop.add(img)
     # pop.set_position(3)
     # pop.show_all()
     # pop.connect('button-release-event', self.on_pop_click)
     # self.img_menu_item.set_image(img)
     img_pop.set_pixbuf(pixbuf)
     img_pop.popup()
コード例 #5
0
ファイル: gui_main.py プロジェクト: thomas-w-nl/fotoroulette
    def set_photo(self, response: str) -> bool:
        """
        Set the currently showed picture from a string

        Args:
          response: a string containing an (opencv) image
        """
        self._builder.get_object("FidgetSpinner").stop()
        picture_widget = self._builder.get_object("Picture")
        self._stack.set_visible_child_name("picture-view")

        pimage = Image.open(BytesIO(response))
        pimage.save(".temp_image.png")
        image = Pixbuf.new_from_file(".temp_image.png")
        os.remove(".temp_image.png")

        self._photos.append(image)

        picture_widget.set_from_pixbuf(image)
        if self._song_name is not None and SOUND:
            process = Process(target=play_sound, args=(self._song_name, ))
            process.start()
            self._song_pid = process.pid

            self._song_process.start()

        self.close_popup()
        return False
コード例 #6
0
def main():
    global browser
    global window

    frontend = frontend_fill()

    window = gtk.Window()
    window.connect('destroy', gtk.main_quit)
    window.set_title("Linux Lite Control Center")
    window.set_icon(Pixbuf.new_from_file("{0}/litecc.png".format(app_dir)))
    window.set_size_request(880, 660)
    # Valtam do we need to resize window?
    window.set_resizable(False)
    window.set_position(gtk.WindowPosition.CENTER),
    browser = webkit.WebView()
    swindow = gtk.ScrolledWindow()
    window.add(swindow)
    swindow.add(browser)
    window.show_all()
    browser.connect("navigation-requested", functions)
    browser.load_html_string(frontend, "file://{0}/frontend/".format(app_dir))
    # no right click menu
    settings = browser.get_settings()
    settings.set_property('enable-default-context-menu', False)
    browser.set_settings(settings)
    # Engage
    gtk.main()
コード例 #7
0
 def fit_image_window(self,widget):
    
     global imgloc
     
     global zoomout
     if imgloc == 0 :
       
         errorwindow = builder.get_object("error_message_box")
         errorwindow.set_transient_for(window)
         errorwindow.set_markup("<b>No Image loaded to the application</b>")
         errorwindow.format_secondary_markup("Add or Scan image to start scaling")
         errorwindow.show()
         return 0
     elif zoomout <3:
         pixbuf = Pixbuf.new_from_file(imgloc)
         height = pixbuf.get_height()
         width = pixbuf.get_width()
      
         zoomout = zoomout + 1
         pixbuf = pixbuf.scale_simple(width/zoomout,height/zoomout, InterpType.BILINEAR)
         img = builder.get_object("previmage")
         img.set_from_pixbuf(pixbuf)
     else :
         errorwindow = builder.get_object("error_message_box")
         errorwindow.set_transient_for(window)
         errorwindow.set_markup("<b>Zoom out maximum level reached</b>")
         errorwindow.format_secondary_markup("only 2 level of zoom out is available")
         errorwindow.show()
         return 0        
コード例 #8
0
ファイル: main.py プロジェクト: swag4swag/pybooru
 def setImage(self, fileName):
     if not self.settingsManager.resizeImage:
         mpixbuf = Pixbuf.new_from_file(fileName)
     else:
         mpixbuf = Pixbuf.new_from_file_at_scale(fileName, self.iCurWidth, self.iCurHeight, True)
     self.currentFile = fileName
     Gdk.threads_add_idle(GLib.PRIORITY_DEFAULT_IDLE, self.GtkSetImage, mpixbuf)
コード例 #9
0
ファイル: art.py プロジェクト: giannitedesco/funky
def load_plants():
	subdir = 'funkenschlagPics/kw'
	path = join(base_dir, subdir)
	fns = (
		'funkkart_03a.jpg', 'funkkart_04a.jpg',
		'funkkart_05a.jpg', 'funkkart_06a.jpg',
		'funkkart_07a.jpg', 'funkkart_08a.jpg',
		'funkkart_09a.jpg', 'funkkart_10a.jpg',
		'funkkart_11a.jpg', 'funkkart_12a.jpg',
		'funkkart_13a.jpg', 'funkkart_14a.jpg',
		'funkkart_15a.jpg', 'funkkart_16a.jpg',
		'funkkart_17a.jpg', 'funkkart_18a.jpg',
		'funkkart_19a.jpg', 'funkkart_20a.jpg',
		'funkkart_21a.jpg', 'funkkart_22a.jpg',
		'funkkart_23a.jpg', 'funkkart_24a.jpg',
		'funkkart_25a.jpg', 'funkkart_26a.jpg',
		'funkkart_27a.jpg', 'funkkart_28a.jpg',
		'funkkart_29a.jpg', 'funkkart_30a.jpg',
		'funkkart_31a.jpg', 'funkkart_32a.jpg',
		'funkkart_33a.jpg', 'funkkart_34a.jpg',
		'funkkart_35a.jpg', 'funkkart_36a.jpg',
		'funkkart_37a.jpg', 'funkkart_38a.jpg',
		'funkkart_39a.jpg', 'funkkart_40a.jpg',
		'funkkart_42a.jpg', 'funkkart_44a.jpg',
		'funkkart_46a.jpg', 'funkkart_50a.jpg',
		'stufe_3_a.jpg', 'blass.png', 'blocker.jpg'
	)

	out = []
	for fn in map(lambda x:join(path, x), fns):
		pix = Pixbuf.new_from_file(fn)
		#pix = pix.scale_simple(48, 48, InterpType.HYPER)
		out.append(pix)

	return tuple(out)
コード例 #10
0
ファイル: graphics_util.py プロジェクト: TanJay/core
def get_scaled_image(path,image_width):
    
    """
    Get a image scaled according to specified image_width.
    
    A new GDK Pixbuf is obtained for the given image path.
    New height of image is calculated according to specified image width.
    
    Pixbuf is scaled simply with parameters : 
                destination image_width
                destination image_height
                the interpolation of the transformation(GDK Interp_Type)
    
    @param : path (Image location)
    @param : image_width
    
    @return : scaled_pix
    """
    default_image_width = image_width
    try:
        pixbuf = Pixbuf.new_from_file(path)
    except Exception as msg:
        return get_scaled_image(p2psp_logo_path,image_width)
    pix_w = pixbuf.get_width()
    pix_h = pixbuf.get_height()
    new_h = (pix_h * default_image_width) / pix_w
    scaled_pix = pixbuf.scale_simple(default_image_width, new_h, 1)
    
    return scaled_pix
コード例 #11
0
    def open_about(self):
        logo_path = (f"{config.snap_root}/static/logo.svg"
                     if config.is_snap else "static/logo.svg")
        logo = Pixbuf.new_from_file(logo_path)

        about_dialog = Gtk.AboutDialog(
            transient_for=self,
            modal=True,
            logo=logo,
            program_name="Emote",
            title="About Emote",
            version=os.environ.get("SNAP_VERSION", "dev build"),
            authors=["Tom Watson"],
            artists=["Tom Watson, Matthew Wong"],
            documenters=["Irene Auñón"],
            copyright=f"© Tom Watson {datetime.now().year}",
            website_label="Source Code",
            website="https://github.com/tom-james-watson/emote",
            comments="Modern popup emoji picker",
            license_type=Gtk.License.GPL_3_0,
        )

        self.dialog_open = True
        about_dialog.present()
        about_dialog.connect("destroy", self.on_close_dialog)
コード例 #12
0
def main():
    global browser
    global window
    frontend = frontend_fill()
    window = gtk.Window()
    window.connect('destroy', gtk.main_quit)
    window.set_title(appname)
    window.set_icon(Pixbuf.new_from_file(app_icon))
    rootsize = tkinter.Tk()
    if rootsize.winfo_screenheight() > 700:
        window.set_resizable(True)
        window.set_size_request(890, 660)
    else:
        window.set_resizable(True)
        window.set_size_request(890, 500)
    window.set_position(gtk.WindowPosition.CENTER),
    browser = webkit.WebView()
    swindow = gtk.ScrolledWindow()
    window.add(swindow)
    swindow.add(browser)
    window.show_all()
    browser.connect("navigation-requested", functions)
    browser.load_html_string(frontend, "file://{0}/frontend/".format(app_dir))
    settings = browser.get_settings()
    settings.set_property('enable-default-context-menu', False)
    browser.set_settings(settings)
    gtk.main()
コード例 #13
0
    def search_worker(self, query):
        try:
            self.extmgr.search(query)
        except Exception as error:
            GLib.idle_add(self.show_error, error)
            GLib.idle_add(self.restore_search_button)

        for index, result in enumerate(self.extmgr.results):
            # Download the image into a buffer and render it with pixbuf
            try:
                img_buffer = self.extmgr.get_image(self.extmgr.get_uuid(index))
            except Exception as error:
                GLib.idle_add(self.show_error, error)
                GLib.idle_add(self.restore_search_button)

            # Check if the extension icon is local (faster searching)
            if img_buffer == None:
                pixbuf = Pixbuf.new_from_file(
                    os.path.join(os.path.dirname(__file__), "plugin.png"))
            else:
                img_buffer = Gio.MemoryInputStream.new_from_data(
                    img_buffer, None)
                pixbuf = Pixbuf.new_from_stream(img_buffer, None)
                pixbuf = pixbuf.scale_simple(32, 32, InterpType.BILINEAR)
            self.extmgr.results[index]["pixbuf"] = pixbuf
        GLib.idle_add(self.display_search_results)
コード例 #14
0
    def on_treeview_selection_monster_changed(self, widget, data=None):
        (model, pathlist) = widget.get_selected_rows()
        for path in pathlist:
            tree_iter = model.get_iter(path)
            name = model.get_value(tree_iter, 0)
            monster_info = self.monster.get_info(self.con, name)
            if monster_info:

                if monster_info["picture"]:
                    file = os.path.join(
                        "data", "monster", "pic", "".join(
                            (monster_info["picture"], ".png")))
                    pixbuf = Pixbuf.new_from_file(file)
                    self.image_monster.set_from_pixbuf(pixbuf)
                    self.entry_monster_pic.set_text(monster_info["picture"])
                else:
                    self.image_monster.clear()
                    self.entry_monster_pic.set_text("Sin Imagen")

                self.entry_monster_name.set_text(monster_info["name"])
                self.entry_monster_concept.set_text(monster_info["concept"])

                self.monster.set_stats_model(self.treeview_monster_actions,
                                             monster_info["action"],
                                             monster_info["actions"])
                self.monster.set_stats_model(
                    self.treeview_monster_insteractions,
                    monster_info["interaction"], monster_info["interactions"])
                self.monster.set_stats_model(self.treeview_monster_cognitions,
                                             monster_info["cognition"],
                                             monster_info["cognitions"])
コード例 #15
0
ファイル: about.py プロジェクト: muflone/gextractwinicons
 def __init__(self, winParent, show = False):
   # Retrieve the translators list
   translators = []
   for line in readlines(FILE_TRANSLATORS, False):
     if ':' in line:
       line = line.split(':', 1)[1]
     line = line.replace('(at)', '@').strip()
     if line not in translators:
       translators.append(line)
   # Load the user interface
   builder = Gtk.Builder()
   builder.add_from_file(FILE_UI_ABOUT)
   # Obtain widget references
   self.dialog = builder.get_object("dialogAbout")
   # Set various properties
   self.dialog.set_program_name(APP_NAME)
   self.dialog.set_version('Version %s' % APP_VERSION)
   self.dialog.set_comments(APP_DESCRIPTION)
   self.dialog.set_website(APP_URL)
   self.dialog.set_copyright(APP_COPYRIGHT)
   self.dialog.set_authors(['%s <%s>' % (APP_AUTHOR, APP_AUTHOR_EMAIL)])
   #self.dialog.set_license_type(Gtk.License.GPL_2_0)
   self.dialog.set_license('\n'.join(readlines(FILE_LICENSE, True)))
   self.dialog.set_translator_credits('\n'.join(translators))
   # Retrieve the external resources links
   for line in readlines(FILE_RESOURCES, False):
     resource_type, resource_url = line.split(':', 1)
     self.dialog.add_credit_section(resource_type, (resource_url,))
   icon_logo = Pixbuf.new_from_file(FILE_ICON)
   self.dialog.set_logo(icon_logo)
   self.dialog.set_transient_for(winParent)
   # Optionally show the dialog
   if show:
     self.show()
コード例 #16
0
 def __init__(self, winParent, show=False):
     # Retrieve the translators list
     translators = []
     for line in readlines(FILE_TRANSLATORS, False):
         if ':' in line:
             line = line.split(':', 1)[1]
         line = line.replace('(at)', '@').strip()
         if line not in translators:
             translators.append(line)
     # Load the user interface
     builder = Gtk.Builder()
     builder.add_from_file(FILE_UI_ABOUT)
     # Obtain widget references
     self.dialog = builder.get_object("dialogAbout")
     # Set various properties
     self.dialog.set_program_name(APP_NAME)
     self.dialog.set_version('Version %s' % APP_VERSION)
     self.dialog.set_comments(APP_DESCRIPTION)
     self.dialog.set_website(APP_URL)
     self.dialog.set_copyright(APP_COPYRIGHT)
     self.dialog.set_authors(['%s <%s>' % (APP_AUTHOR, APP_AUTHOR_EMAIL)])
     #self.dialog.set_license_type(Gtk.License.GPL_2_0)
     self.dialog.set_license('\n'.join(readlines(FILE_LICENSE, True)))
     self.dialog.set_translator_credits('\n'.join(translators))
     # Retrieve the external resources links
     for line in readlines(FILE_RESOURCES, False):
         resource_type, resource_url = line.split(':', 1)
         self.dialog.add_credit_section(resource_type, (resource_url, ))
     icon_logo = Pixbuf.new_from_file(FILE_ICON)
     self.dialog.set_logo(icon_logo)
     self.dialog.set_transient_for(winParent)
     # Optionally show the dialog
     if show:
         self.show()
コード例 #17
0
def main():
    global browser
    global window

    frontend = frontend_fill()

    window = gtk.Window()
    window.connect('destroy', gtk.main_quit)
    window.set_title("Linux Lite Control Center")
    window.set_icon(Pixbuf.new_from_file("{0}/litecc.png".format(app_dir)))
    window.set_size_request(870, 650)
    # Valtam do we need to resize window?
    window.set_resizable(False)
    window.set_position(gtk.WindowPosition.CENTER),
    browser = webkit.WebView()
    swindow = gtk.ScrolledWindow()
    window.add(swindow)
    swindow.add(browser)
    window.show_all()
    browser.connect("navigation-requested", functions)
    browser.load_html_string(frontend, "file://{0}/frontend/".format(app_dir))
    # no right click menu
    settings = browser.get_settings()
    settings.set_property('enable-default-context-menu', False)
    browser.set_settings(settings)
    # Engage
    gtk.main()
コード例 #18
0
ファイル: 04 Move Pixbuf.py プロジェクト: Acry/PyGObject-GTK
 def __init__(self, app):
     Gtk.Window.__init__(self, title="MovePixBuf", application=app)
     self.set_border_width(10)
     self.set_default_size(450, 450)
     self.set_icon_from_file(ICON_IMAGE)
     pb = Pixbuf.new_from_file(RED_APPLE)
     pix = Pix(pb, 50, 120)
     self.pix_list.append(pix)
     pix = Pix(pb, 150, 120)
     self.pix_list.append(pix)
     pix = Pix(pb, 250, 120)
     self.pix_list.append(pix)
     scrolled_window = Gtk.ScrolledWindow()
     scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC,
                                Gtk.PolicyType.AUTOMATIC)
     buf = Gtk.TextBuffer()
     buf.set_text(TEXT)
     textview = Gtk.TextView(buffer=buf)
     textview.set_wrap_mode(Gtk.WrapMode.WORD)
     scrolled_window.add(textview)
     textview.connect('draw', self.draw_cb)
     textview.connect("button-press-event", self.button_press_callback)
     textview.connect("button-release-event", self.button_release_callback)
     textview.connect("motion-notify-event", self.on_motion)
     # region CSS
     style_provider = Gtk.CssProvider()
     style_provider.load_from_path(CSS_FILE)
     context = textview.get_style_context()
     context.add_provider(style_provider,
                          Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
     # endregion
     self.add(scrolled_window)
コード例 #19
0
ファイル: art.py プロジェクト: giannitedesco/funky
def load_map(map_nr):
	subdir = 'localized/en/images/Funkenschlag/'
	path = join(base_dir, subdir)
	fns = ('usa.jpg', 'deut.jpg',
		'frankreich.jpg', 'italien.jpg', 'bw.jpg')
	pix = Pixbuf.new_from_file(join(path, fns[map_nr]))
	return pix
コード例 #20
0
ファイル: util.py プロジェクト: Jenselme/pympress
def load_icons():
    """
    Load pympress icons from the pixmaps directory (usually
    :file:`/usr/share/pixmaps` or something similar).

    :return: loaded icons
    :rtype: list of :class:`Gtk.gdk.Pixbuf`
    """

    # If pkg_resources fails, load from directory
    icon_path = "/usr/share/pixmaps/"
    icon_names = glob.glob(icon_path + "pympress*")
    if not icon_names:
        icon_path = "share/pixmaps/"
        icon_names = glob.glob(icon_path + "pympress*")
    icons = []
    for icon_name in icon_names:
        if os.path.splitext(icon_name)[1].lower() != ".png":
            continue

        # If pkg_resources fails, load from directory
        try:
            icon_pixbuf = Pixbuf.new_from_file(icon_name)
            icons.append(icon_pixbuf)
        except Exception as e:
            print(e)
    return icons
コード例 #21
0
def set_cover_from_tags(bean):
    try:
        ext = get_file_extension(bean.path)
        if ext == ".mp3":
            data = _get_pic_from_mp3(ID3(bean.path))
        elif ext == ".flac":
            data = _get_pic_from_flac(FLAC(bean.path))
        else:
            return None
        if data:
            filename = os.path.join(COVERS_DIR, str(crc32(bean.path)) + '.jpg')
            fd = NamedTemporaryFile()
            fd.write(data.data)
            pixbuf = Pixbuf.new_from_file(fd.name)
            pixbuf.savev(filename, "jpeg", ["quality"], ["90"])
            fd.close()
            bean.image = filename
            basename = os.path.splitext(os.path.basename(filename))[0]
            cache_dict = FCache().covers
            if basename in cache_dict:
                cache_dict[basename].append(bean.text)
            else:
                cache_dict[basename] = [bean.text]
            return filename

    except Exception, e:
        pass
コード例 #22
0
def get_scaled_image(path,image_width):
    
    """
    Get a image scaled according to specified image_width.
    
    A new GDK Pixbuf is obtained for the given image path.
    New height of image is calculated according to specified image width.
    
    Pixbuf is scaled simply with parameters : 
                destination image_width
                destination image_height
                the interpolation of the transformation(GDK Interp_Type)
    
    @param : path (Image location)
    @param : image_width
    
    @return : scaled_pix
    """
    default_image_width = image_width
    try:
        pixbuf = Pixbuf.new_from_file(path)
    except Exception as msg:
        return get_scaled_image(p2psp_logo_path,image_width)
    pix_w = pixbuf.get_width()
    pix_h = pixbuf.get_height()
    new_h = (pix_h * default_image_width) / pix_w
    scaled_pix = pixbuf.scale_simple(default_image_width, new_h, 1)
    
    return scaled_pix
コード例 #23
0
    def thread_scanning(self,flag,ip_range,start,end):		         
		for i in range(int(start),int(end)):
			ip=ip_range[0]+"."+ip_range[1]+"."+ip_range[2]+"."+str(i)
			proc1 = subprocess.Popen("arping -c 1 "+ip+" | head -n 2 | tail -n 1 | awk '{print $5,$6}'" , shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
			
			proc = subprocess.Popen("smbclient -NL "+ip, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
			str1=["",""]
			for line in proc1.stdout:
				str1 = line.replace("[","").replace("]","").split(" ")
				if str1[0]=="broadcast(s))":
					proc2 = subprocess.Popen("ifconfig | head -n 1 | awk '{print $5}'", shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
					for line2 in proc2.stdout:
					    str1[0]=line2.upper()
					str1[1]="0ms"
			
			for line in proc.stderr:
				if('Domain' in line):
				    hostname =line[line.find("[")+1:line.find("]")]
				    if hostname=="WORKGROUP":
						proc_nmblookup = subprocess.Popen("nmblookup -A "+ip+" | head -n 2 | tail -n 1 | awk '{print $1 }'", shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
						for line in proc_nmblookup.stdout:
							hostname=line.replace("\n","").upper()
				    pixbuf = Pixbuf.new_from_file("/usr/share/shareviewer/media/computer.png")
				    self.devices+=1
				    par = self.model.append(None ,[pixbuf,ip.strip(),hostname,str1[0].replace("\n",""),str1[1].replace("ms"," ms").replace("\n","")])	
				    break;
			for line1 in proc.stdout:
				if line1.find("Disk")!=-1:
			         share=line1.strip().replace("Disk","").replace("Printer Drivers","").replace("Remote Admin","").replace("Default share","").replace("\n","")
			         pixbuf = Gtk.IconTheme.get_default().load_icon("gtk-directory", 16, 0)
			         child = self.model.append(par,[pixbuf,share,"","",""]) 
			self.count+=1
コード例 #24
0
ファイル: impyh.py プロジェクト: daesdp/Impyh
    def dec_zoom(self,widget):
        if self.zoom_actual <= 6:
            self.zoom_actual = self.zoom_actual + 1

            if self.zoom_actual == 1:
                v_zoom = 1.0
            elif self.zoom_actual == 2:
                v_zoom = 1.5
            elif self.zoom_actual == 3:
                v_zoom = 2.0
            elif self.zoom_actual == 4:
                v_zoom = 2.5
            elif self.zoom_actual == 5:
                v_zoom = 3.0
            elif self.zoom_actual == 6:
                v_zoom = 3.5
            elif self.zoom_actual == 7:
                v_zoom = 4.0

            pixbuf = Pixbuf.new_from_file(self.v_item_actual)
            ancho_pixbuf = pixbuf.get_width()
            alto_pixbuf = pixbuf.get_height()
            ancho = ancho_pixbuf / v_zoom
            alto =  alto_pixbuf / v_zoom
            prev_pixbuf = pixbuf.scale_simple(ancho, alto, v_inter)
            self.image.set_from_pixbuf(prev_pixbuf)
            self.image.show()
コード例 #25
0
    def update_image():
        global _last_mod
        statbuf = os.stat("./fb.png")
        mod = statbuf.st_mtime
        img = None
        if statbuf.st_size == 0:
            return True

        if mod != _last_mod:
            try:
                img = Pixbuf.new_from_file("./fb.png")
            except Exception as e:
                print(e)
                return True

        _last_mod = mod
        if not img:
            return True

        width, height = WIN.get_size()
        i_height = img.get_height()
        scalar = i_height / float(height)
        img = img.scale_simple(int(height / scalar), height,
                               InterpType.BILINEAR)

        IMG.set_from_pixbuf(img)
        IMG.queue_draw()
        return True
コード例 #26
0
ファイル: impyh.py プロジェクト: daesdp/Impyh
    def best_zoom(self,widget):
        self.zoom_actual = 2
        rect = self.view_port_img.get_allocation()
        pixbuf = Pixbuf.new_from_file(self.v_item_actual)
        ancho_pixbuf = pixbuf.get_width()
        alto_pixbuf = pixbuf.get_height()

        if ancho_pixbuf > alto_pixbuf:
            ancho = int(rect.width - 4)
            relacion = (alto_pixbuf*100)/ancho_pixbuf
            alto = int(ancho * relacion/100)
        else:
            alto = int(rect.height - 4)
            relacion = (ancho_pixbuf*100 - 4)/alto_pixbuf
            ancho = int(alto * (relacion/100))

        if alto > rect.height:
            alto = int(rect.height - 4)
            relacion = (ancho_pixbuf*100 - 4)/alto_pixbuf
            ancho = int(alto * (relacion/100))
        elif ancho > rect.width:
            ancho = int(rect.width - 4)
            relacion = (alto_pixbuf*100)/ancho_pixbuf
            alto = int(ancho * relacion/100)

        prev_pixbuf = pixbuf.scale_simple(ancho, alto, v_inter)
        self.image.set_from_pixbuf(prev_pixbuf)
        self.image.show()
コード例 #27
0
ファイル: inktools.py プロジェクト: mc6312/inktools
    def load_sample_image(self, fname):
        """Загрузка изображения с образцом чернил в определитель цвета."""

        tmppbuf = Pixbuf.new_from_file(fname)

        self.pixbufCX = tmppbuf.get_width()
        self.pixbufCY = tmppbuf.get_height()

        # создаём новый, строго заданного формата, мало ли что там загрузилось
        self.pixbuf = Pixbuf.new(GdkPixbuf.Colorspace.RGB, False, 8, self.pixbufCX, self.pixbufCY)

        # на случай наличия альфа-канала в исходном изображении
        self.pixbuf.fill(0xffffffff)

        tmppbuf.composite(self.pixbuf,
            0, 0, self.pixbufCX, self.pixbufCY,
            0, 0, 1.0, 1.0,
            GdkPixbuf.InterpType.TILES, 255);

        self.pixbufPixels = self.pixbuf.get_pixels()
        self.pixbufChannels = self.pixbuf.get_n_channels()
        self.pixbufRowStride = self.pixbuf.get_rowstride()

        #self.swImgView.set_max_content_width(self.pixbufCX)
        #self.swImgView.set_max_content_height(self.pixbufCY)

        self.imgView.set_from_pixbuf(self.pixbuf)

        self.swImgView.get_hadjustment().set_value(0)
        self.swImgView.get_vadjustment().set_value(0)

        #
        self.lstoreSamples.clear()
        self.update_sample_count()
        self.compute_average_color()
コード例 #28
0
 def adjustImage(self, containerWidget, imgWidget, path):
     allocation = containerWidget.get_allocation()
     desired_width = allocation.width
     desired_height = allocation.height
     pixbuf = Pixbuf.new_from_file(path)
     pixbuf = pixbuf.scale_simple(desired_width, desired_height, 2)
     imgWidget.set_from_pixbuf(pixbuf)
コード例 #29
0
ファイル: App.py プロジェクト: subutux/gbdesktoppr
	def run(self):
		builder.get_object('spinner_overlay').show()
		url = "/".join([self.api.API_BASE,"users",self.user,"wallpapers"])
		data = json.loads(urllib2.urlopen(url).read())
		done = 0
		currWallpaperNr = 0;
		while not done:
			for wallpaper in data['response']:
				# print wallpaper
				currWallpaperNr = currWallpaperNr + 1;
				if currWallpaperNr == 1:
					txt = "Wallpaper"
				else:
					txt = "Wallpapers"

				self.headerBar.set_subtitle(str(currWallpaperNr) + " " + txt)
				if not os.path.isfile(self.CACHE_DIR + str(wallpaper['id'])):
					file = open(self.CACHE_DIR + str(wallpaper['id']),'w')
					file.write(urllib2.urlopen(wallpaper['image']['thumb']['url']).read())
					file.close()

				pxbf = Pixbuf.new_from_file(self.CACHE_DIR + str(wallpaper['id']))
				self.listStore.append([
					str(wallpaper["id"]),
					wallpaper["image"]["url"],
					pxbf])
			if not data['pagination']['next']:
				data['pagination']['next'] = data['pagination']['current']+1
			data = json.loads(urllib2.urlopen(url + "?page=" + str(data['pagination']['next'])).read())
			#print "> URL: %s\n> PAGE: %s \n ===========\n" % (url + "?page=" + str(data['pagination']['next']),str(data['pagination']['current'])), data['response']
			if len(data['response']) == 0:
				done = 1
				builder.get_object('spinner_overlay').hide()
コード例 #30
0
def main():
    global browser
    global window
    frontend = frontend_fill()
    window = gtk.Window()
    window.connect('destroy', gtk.main_quit)
    window.set_title(appname)
    window.set_icon(Pixbuf.new_from_file(app_icon))
    rootsize = tkinter.Tk()
    if rootsize.winfo_screenheight() > 700:
        window.set_resizable(False)
        window.set_size_request(800, 550)
    else:
        window.set_resizable(True)
        window.set_size_request(600, 500)
    window.set_position(gtk.WindowPosition.CENTER),
    browser = webkit.WebView()
    swindow = gtk.ScrolledWindow()
    window.add(swindow)
    swindow.add(browser)
    window.show_all()
    browser.connect("navigation-requested", functions)
    browser.load_html_string(frontend, "file://{0}/frontend/".format(app_dir))
    settings = browser.get_settings()
    settings.set_property('enable-default-context-menu', False)
    browser.set_settings(settings)
    gtk.main()
コード例 #31
0
def functions(view, frame, req, data=None):
    uri = req.get_uri()
    lllink, path = uri.split('://', 1)
    path = path.replace("%20", " ")
    if lllink == "file":
        return False
    elif lllink == "about":
        about = gtk.AboutDialog()
        about.set_program_name(appname)
        about.set_version(appver)
        about.set_copyright('Copyright Johnathan Jenkins 2016')
        about.set_wrap_license
        about.set_license(
            '''This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. ''')
        about.set_authors([
            "Johnathan 'ShaggyTwoDope'" +
            " Jenkins\n<*****@*****.**>\n",
            "Jerry Bezencon\n<*****@*****.**>\n",
            "Milos Pavlovic\n<*****@*****.**>\n",
            "Brian 'DarthLukan' Tomlinson\n<*****@*****.**>\n",
            "Josh Erickson\n<*****@*****.**>"
        ])
        about.set_comments("Control it all.")
        about.set_website("https://github.com/nixheads/nixcontrolcenter")
        about.set_logo(Pixbuf.new_from_file(app_icon))
        about.set_transient_for(window)
        about.run()
        about.destroy()
    elif lllink == "admin":
        subprocess.Popen(path, shell=True, executable='/bin/bash')
    elif lllink == "script":
        execute("{0}/scripts/{1}".format(app_dir, path))
    elif lllink == "help":
        webbrowser.open('file:///usr/share/doc/litemanual/index.html')
    elif lllink == "screenshot":
        os.system("/bin/bash -c 'scrot -u $HOME/nixccshot.png'")
        subprocess.Popen(['/bin/bash', '-c',
                          '/usr/share/nixcc/scripts/screenshot'])
    elif lllink == "report":
        subprocess.Popen(['/bin/bash', '-c', 'gksudo /usr/scripts/systemreport'
                          ])
    elif lllink == "update":
        subprocess.Popen(['gpk-update-viewer'
                          ])
    elif lllink == "refresh":
        reload()

    return True
コード例 #32
0
ファイル: osprai.py プロジェクト: ridders/osprai
def initial_thumbs_load(row, selection, width, height):
	items = (row.split(","))
	thumb_loc = items[1]
	file_loc = items[2]
	dir_parser.thumbs_generator(file_loc, thumb_loc)
	pixbuf = Pixbuf.new_from_file(thumb_loc)
	pixbuf = pixbuf.scale_simple(width, height, GdkPixbuf.InterpType.BILINEAR) #BILINEAR, HYPER, TILES, NEAREST
	return [pixbuf, thumb_loc]
コード例 #33
0
ファイル: impyh.py プロジェクト: daesdp/Impyh
 def orig_zoom(self,widget):
     self.zoom_actual = 1
     pixbuf = Pixbuf.new_from_file(self.v_item_actual)
     ancho_pixbuf = pixbuf.get_width()
     alto_pixbuf = pixbuf.get_height()
     prev_pixbuf = pixbuf.scale_simple(ancho_pixbuf, alto_pixbuf, v_inter)
     self.image.set_from_pixbuf(prev_pixbuf)
     self.image.show()
コード例 #34
0
ファイル: freshest.py プロジェクト: rwmpelstilzchen/freshest
    def __init__(self, profile="default"):
        try:
            confdir = os.environ["XDG_CONFIG_HOME"]
        except KeyError:
            confdir = os.path.join(os.environ["HOME"], ".config")
        self.profiledir = os.path.join(confdir, "freshest", profile)
        self.appsdir = os.path.join(self.profiledir, "applications/")
        self.listfile = os.path.join(self.profiledir, "list.json")
        self.conffile = os.path.join(self.profiledir, "config.json")

        if not os.path.isdir(self.profiledir):
            self.create_profile(self.profiledir)

        self.__desktop_files = self.update_list()

        f = open(self.conffile, "r")
        config = json.load(f)
        f.close()

        wintitle = "Freshest"
        if profile != "default":
            wintitle += " (" + profile + ")"
        self.__window = Gtk.Window(title=wintitle)
        self.__window.set_default_size(config["width"], config["height"])
        self.__window.move(config["x"], config["y"])

        scrolledwindow = Gtk.ScrolledWindow()

        liststore = Gtk.ListStore(Pixbuf, str)
        self.__iconview = Gtk.IconView.new()
        self.__iconview.set_model(liststore)
        self.__iconview.set_pixbuf_column(0)
        self.__iconview.set_text_column(1)
        self.__iconview.set_item_width(config["columnwidth"])
        self.__iconview.set_activate_on_single_click(True)

        for f in self.__desktop_files:
            x = DesktopEntry.DesktopEntry(filename=f)
            try:
                pixbuf = Gtk.IconTheme.get_default().load_icon(x.getIcon(), config["iconsize"], 0)
            except:
                try:
                    pixbuf = Pixbuf.new_from_file(x.getIcon())
                    pixbuf = pixbuf.scale_simple(config["iconsize"], config["iconsize"], GdkPixbuf.InterpType.NEAREST)
                except:
                    pixbuf = Gtk.IconTheme.get_default().load_icon("gtk-execute", config["iconsize"], 0)
            liststore.append([pixbuf, x.getName()])

        self.__iconview.connect("item-activated", self.on_item_activated)
        self.__window.connect("key_press_event", self.on_key_press)

        scrolledwindow.add(self.__iconview)

        self.__window.connect("destroy", lambda w: Gtk.main_quit())

        self.__window.add(scrolledwindow)
        self.__window.show_all()
コード例 #35
0
ファイル: Media.py プロジェクト: vaginessa/LucidGTK
	def display_image(self, im):
		self.imagef = im
		pb = Pixbuf.new_from_file(im)
		if pb.get_n_channels()>3:
			self.mainWin.notify('Sorry, Lucid-GTK doesn\'t currently support images with an alpha channel (such as PNG with transparency).\nIn order to use this image you need to flatten it to RGB in an image editor', color='red')
			return
		pb = self.check_im_size(pb)
		self.mainWin.imContainer.set_size(pb.get_width(),pb.get_height())
		self.mainWin.im.set_from_pixbuf(pb)
コード例 #36
0
def copy_image(f):
    assert os.path.exists(f), "File does not exist: %s" % f
    image = Pixbuf.new_from_file(f)

    atom = Gdk.atom_intern('CLIPBOARD', True)
    clipboard = Gtk.Clipboard.get(atom)
    clipboard.set_image(image)
    clipboard.store()
    sys.exit(1)
コード例 #37
0
ファイル: osprai.py プロジェクト: ridders/osprai
def thumbs_scale(row, selection, width, height):
	items = (row.split(","))
	thumb_loc = items[1]
	file_loc = items[2]
	category = items[3]
	if category == "0": # Only relevant to the 'Not done' category, will be required to be modified when other cats are viewable
		pixbuf = Pixbuf.new_from_file(thumb_loc)
		pixbuf = pixbuf.scale_simple(width, height, GdkPixbuf.InterpType.BILINEAR)
		return [pixbuf, thumb_loc]
コード例 #38
0
def functions(view, frame, req, data=None):
    uri = req.get_uri()
    lllink, path = uri.split('://', 1)
    path = path.replace("%20", " ")
    if lllink == "file":
        return False
    elif lllink == "about":
        about = gtk.AboutDialog()
        about.set_program_name(appname)
        about.set_version(appver)
        about.set_copyright('Copyright Johnathan Jenkins 2016')
        about.set_wrap_license
        about.set_license(
            '''This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. ''')
        about.set_authors([
            "Johnathan 'ShaggyTwoDope'" + " Jenkins\n<*****@*****.**>\n",
            "Jerry Bezencon\n<*****@*****.**>\n",
            "Milos Pavlovic\n<*****@*****.**>\n",
            "Brian 'DarthLukan' Tomlinson\n<*****@*****.**>\n",
            "Josh Erickson\n<*****@*****.**>"
        ])
        about.set_comments("Control it all.")
        about.set_website("https://github.com/nixheads/nixcontrolcenter")
        about.set_logo(Pixbuf.new_from_file(app_icon))
        about.set_transient_for(window)
        about.run()
        about.destroy()
    elif lllink == "admin":
        subprocess.Popen(path, shell=True, executable='/bin/bash')
    elif lllink == "script":
        execute("{0}/scripts/{1}".format(app_dir, path))
    elif lllink == "help":
        webbrowser.open('file:///usr/share/doc/litemanual/index.html')
    elif lllink == "screenshot":
        os.system("/bin/bash -c 'scrot -u $HOME/nixccshot.png'")
        subprocess.Popen(
            ['/bin/bash', '-c', '/usr/share/nixcc/scripts/screenshot'])
    elif lllink == "report":
        subprocess.Popen(
            ['/bin/bash', '-c', 'gksudo /usr/scripts/systemreport'])
    elif lllink == "update":
        subprocess.Popen(['gpk-update-viewer'])
    elif lllink == "refresh":
        reload()

    return True
コード例 #39
0
def copy_image(f):
    assert os.path.exists(f), "File does not exist: %s" % f
    image = Pixbuf.new_from_file(f)

    atom = Gdk.atom_intern('CLIPBOARD', True)
    clipboard = Gtk.Clipboard.get(atom)
    clipboard.set_image(image)
    clipboard.store()
    sys.exit(1)
コード例 #40
0
def set_pixbuf(widget, maps):
    path, image = get_active_text(widget)
    file = os.path.join(path, image)

    width = 320
    height = 240

    pixbuf = Pixbuf.new_from_file(file)
    #pixbuf = pixbuf.scale_simple(width, height, InterpType.BILINEAR)
    maps.set_from_pixbuf(pixbuf)
コード例 #41
0
 def _setLogo(self):
     '''
         Set the logo.
     '''
     logo = self.builder.get_object("Logo")
     logo_file = os.path.join(ConfigManager.getOverridesFolder(),
                              "logo.png")
     if not os.path.exists(logo_file):
         logo_file = os.path.join(ICONS_FOLDER, "logo.png")
     logo.set_from_pixbuf(Pixbuf.new_from_file(logo_file))
コード例 #42
0
def set_pixbuf(widget, maps):
    path, image = get_active_text(widget)
    file = os.path.join(path, image)

    width = 320
    height = 240

    pixbuf = Pixbuf.new_from_file(file)
    #pixbuf = pixbuf.scale_simple(width, height, InterpType.BILINEAR)
    maps.set_from_pixbuf(pixbuf)
コード例 #43
0
    def _show_game_popup(self, name: str, description: str, example_image: str,
                         song: str) -> Gtk.Window:
        self.window._song_name = song

        popup = self.window.show_popup("GameDialog")
        image = Pixbuf.new_from_file(example_image)
        self.window._builder.get_object("GameTitle").set_text(name)
        self.window._builder.get_object("GameDescription").set_text(
            description)
        self.window._builder.get_object("GameImage").set_from_pixbuf(image)
        return popup
コード例 #44
0
ファイル: gui.py プロジェクト: m1ch3al/sand
 def _set_wifi_status(self, inteface, status):
     image = Gtk.Image()
     if "disconnected" in status.lower():
         icon_filepath = pkg_resources.resource_filename(__name__, self.configuration["wifi-down-icon-filename"])
     else:
         icon_filepath = pkg_resources.resource_filename(__name__, self.configuration["wifi-up-icon-filename"])
     pixbuf = Pixbuf.new_from_file(icon_filepath)
     image.set_from_pixbuf(pixbuf.scale_simple(self.configuration["interface-status-dimension-x"],
                                               self.configuration["interface-status-dimension-y"], InterpType.BILINEAR))
     self.layout.put(image, self.configuration["left-padding-interface-status"], self.current_drawing_offset)
     self._images_interfaces_status[inteface] = image
コード例 #45
0
    def create_icon(self):
        label_description = Gtk.Label()
        label_description.set_markup("<span foreground='{}'><i><big><b>{}</b></big></i></span>".format(self._module_color, self.configuration["description"]))
        self.layout.put(label_description, self.configuration["description-position-x"], self.configuration["description-position-y"])

        image = Gtk.Image()
        icon_filepath = pkg_resources.resource_filename(__name__, self.configuration["icon-filename"])
        pixbuf = Pixbuf.new_from_file(icon_filepath)
        image.set_from_pixbuf(pixbuf.scale_simple(self.configuration["icon-dimension-x"],
                                                  self.configuration["icon-dimension-y"], InterpType.BILINEAR))
        self.layout.put(image, self.configuration["icon-position-x"], self.configuration["icon-position-y"])
コード例 #46
0
 def set_image_path(self, image_path):
     if self.image_path != image_path:
         self.image_path = image_path
         if image_path == "//":
             self.image_pixbuf = None
         elif image_path:
             image_path = Settings.Directory.get_full_path(image_path)
             try:
                 self.image_pixbuf = Pixbuf.new_from_file(image_path)
             except:
                 self.image_pixbuf = None
コード例 #47
0
ファイル: GneelightApp.py プロジェクト: vhsw/gneelight
    def do_activate(self):
        # We only allow a single window and raise any existing ones
        if not self.window:
            # Windows are associated with the application
            # when the last one is closed the application shuts down
            self.window = MainWindow(application=self, title=APP_NAME)

        self.window.present()
        self.window.show_all()
        icon = Pixbuf.new_from_file(APP_ICON)
        self.window.set_icon(icon)
コード例 #48
0
    def on_keywordField_activate(self, widget):
        searchString = widget.get_text()
        img_list = search_in_db(searchString)
        self.model.clear()
        for col in self.treeview.get_columns():
            self.treeview.remove_column(col)

        # print img_list.count()
        for img in img_list:

            im = Image.open(img['img_file_path'])
            # im.size
            # img_pixbuf = Pixbuf.new_from_file(img['img_file_path']).scale_simple(800,800,InterpType.BILINEAR)
            # image = Gtk.Image.new_from_pixbuf(img_pixbuf)
            # if(i%2==0):
            # self.imageGrid.attach(image,i%2,i,1,1)
            # else:
            # self.imageGrid.attach(image,0,i,1,1)
            # i=i+1

            # self.model.append([(Pixbuf.new_from_file(img['img_file_path'])),img['file_path']])#treeitr the index in liststore to which entry is done
            self.model.append([
                (Pixbuf.new_from_file(img['img_file_path'])).scale_simple(
                    900, (im.size[1] / im.size[0]) * 900,
                    InterpType.BILINEAR), img['file_path']
            ])  #treeitr the index in liststore to which entry is done
            # self.model.append([Pixbuf.new_from_file(img['img_file_path'],img['colorspace'],img['has_alpha'],img['bits_per_sample'],img['width'],img['height'],img['rowstride']),img['img_file_path']])#treeitr the index in liststore to which entry is done

        # print searchString
        # print "MODEL\n"
        # print self.model

        #HERE we connect with database and retrieve from it the various entries
        # and then we populate the list and display images.
        #after recieving things from Arnab's wrapper
    # model = Gtk.ListStore(Gtk.gdk.Pixbuf, str) #str will contain image-file-names
    #treeview = Gtk.TreeView(model) #need modifications when rendering
    # self.model.append([Pixbuf.new_from_data('data/media/background.png'),'data/media/background.png'])#treeitr the index in liststore to which entry is done
    # self.model.append([Pixbuf.new_from_file('data/media/download.jpg'),'data/media/download.jpg'])
    # self.model.append([Pixbuf.new_from_file('data/media/background.png'),Pixbuf.new_from_file('data/media/download.jpg')])

    # renderer.set_fixed_size(100)

        self.treeview.set_model(self.model)
        renderer = Gtk.CellRendererPixbuf()
        renderer.set_padding(10, 20)
        # rendere.set_
        column = Gtk.TreeViewColumn('', renderer, pixbuf=0)
        column.set_spacing(-1)
        # column.set_attribute()
        self.treeview.insert_column(column, 0)
        self.treeview.connect('button-press-event', self.button_press_event,
                              self)
コード例 #49
0
ファイル: omnisync_gtk.py プロジェクト: jandob/omniSync
    def show_about_dialog(self, widget):
        about_dialog = gtk.AboutDialog()

        about_dialog.set_logo(Pixbuf.new_from_file('icon.svg'))
        about_dialog.set_destroy_with_parent(True)
        about_dialog.set_program_name("OmniSync")
        about_dialog.set_website("http://github.com/jandob/omniSync")
        about_dialog.set_version("0.1")
        about_dialog.set_authors(["Janosch Dobler", "Torben Sickert"])

        about_dialog.run()
        about_dialog.destroy()
コード例 #50
0
ファイル: nowplaying.py プロジェクト: zjmichen/zmpc
  def fetch_image(self, url):
    basename = url.split("/")[-1]
    fname = os.path.join(self.app.cache_dir, basename)

    if not os.path.exists(fname):
      res = requests.get(url)
      f = open(fname, "wb")
      f.write(res.content)
      f.close()
      res.close()

    return Pixbuf.new_from_file(fname)
コード例 #51
0
ファイル: appletHelper.py プロジェクト: Odyseus/CinnamonTools
def copy_image_data(image_file_path):
    from gi.repository import Gdk
    from gi.repository.GdkPixbuf import Pixbuf

    assert os.path.exists(image_file_path), "File does not exist: %s" % image_file_path
    image = Pixbuf.new_from_file(image_file_path)

    atom = Gdk.atom_intern("CLIPBOARD", True)
    clipboard = Gtk.Clipboard.get(atom)
    clipboard.set_image(image)
    clipboard.store()

    raise SystemExit()
コード例 #52
0
    def _get_icon(self, icon):
        """Return icon from package as GdkPixbuf.Pixbuf.

        Extracts the image from package to a file, stores it in the icon cache
        if it's not in there yet and returns it. Otherwise just returns the
        image stored in the cache.

        """
        if icon not in self._icon_cache:
            filename = resource_filename(__name__, "images/%s" % icon)
            self._icon_cache[icon] = Pixbuf.new_from_file(filename)

        return self._icon_cache[icon]
コード例 #53
0
ファイル: art.py プロジェクト: giannitedesco/funky
def load_resources():
	subdir = 'funkenschlagPics'
	path = join(base_dir, subdir)
	fns = (
		'kohle.gif', 'oel.gif', 'muell.gif', 'uran.gif',
		'burn.gif', 'verfeuern.gif'
	)

	out = []
	for fn in map(lambda x:join(path, x), fns):
		pix = Pixbuf.new_from_file(fn)
		out.append(pix)

	return tuple(out)
コード例 #54
0
ファイル: app.py プロジェクト: homina/arch-manga
 def read_manga(self,manga_url, chapter, page=1):
     self.state = "read"
     url = '/'+manga_url+'/'+str(chapter)+'/'+str(page)
     img_url = image_url(default_manga,url)
     name = '/tmp/'+id_generator()
     response = requests.get(img_url, stream=True)
     with open(name, 'wb') as img:
         response.raw.decode_content = True
         shutil.copyfileobj(response.raw, img)
     del response
     pb = Pixbuf.new_from_file(name)
     self.image.set_from_pixbuf(pb)
     fill_container(self.box_container,self.image)
     self.show_all()
コード例 #55
0
ファイル: functions.py プロジェクト: jeremi360/Crowbar
def getIcon(name, mime = None, size = None):
    d = os.path.join(r, 'icons')
    
    if mime == None:
        mime = 'png'
        
    n = ".".join([name, mime])
    p = os.path.join(d, n)
    
    if size == None:
        i = Pixbuf.new_from_file(p)
    else:
        i = Pixbuf.new_from_file_at_scale(p, size, size, False)
        
    return i
コード例 #56
0
ファイル: meteo.py プロジェクト: HellTech/NAG_IoE_2016
	def menu_about_onclick(self, button):
		# Create AboutDialog object
		dialog = gtk.AboutDialog.new()
		dialog.set_transient_for(button.get_parent().get_parent())
		dialog.set_program_name("Meteostanice")
		dialog.set_version(meteo_config.version)
		dialog.add_credit_section("Authors:", ['30-HellTech (github.com/HellTech/NAG_IoE_2016)', 'SOŠ strojní a elektrotechnická Velešín (www.sosvel.cz)'])
		dialog.set_license_type(gtk.License.GPL_3_0)
		dialog.set_copyright('(c) SOŠ Velešín')
		dialog.set_website("https://github.com/HellTech/NAG_IoE_2016/tree/master/30_HellTech_1602_1/08_Meteostanice_GUI_v2")
		dialog.set_website_label("Github page")
		dialog.set_comments("Tato aplikace vznikla v rámci projektu Meteostanice.")
		dialog.set_logo(Pixbuf.new_from_file('meteo_logo.png'))
		dialog.run()
		dialog.destroy()
コード例 #57
0
ファイル: CreditsWindow.py プロジェクト: fdibaldassarre/mload
 def __init__(self, interface):
   self.interface = interface
   Gtk.AboutDialog.__init__(self)
   #self.set_transient_for( self.interface.main_window )
   self.set_position(Gtk.WindowPosition.CENTER)
   self.set_program_name(PROGRAM_NAME)
   self.set_version(PROGRAM_VERSION)
   self.set_comments("MLoad is a utility to download manga from online readers or other sources")
   self.set_authors([PROGRAM_AUTHOR])
   self.set_license_type(Gtk.License.GPL_3_0)
   
   logo_file = os.path.join( ICONS_FOLDER, 'logo.png')
   if os.path.exists(logo_file):
     self.set_logo(Pixbuf.new_from_file(logo_file))
   
   self.connect('delete-event', self.close)
コード例 #58
0
ファイル: impyh.py プロジェクト: daesdp/Impyh
    def clear_list(self,widget):
        self.liststore.clear()
        impyh_logo = Pixbuf.new_from_file(v_logo)
        self.image.set_from_pixbuf(impyh_logo)
        self.m_windows.show_all()

        msg_statusbar = self.status_bar.get_context_id("descripcion")
        self.status_bar.push(msg_statusbar, "  Deleted list")

        self.a_save.set_sensitive(False)
        self.a_msave.set_sensitive(False)
        self.a_zminc.set_sensitive(False)
        self.a_zmdec.set_sensitive(False)
        self.a_zmori.set_sensitive(False)
        self.a_zmbest.set_sensitive(False)
        self.a_clist.set_sensitive(False)
コード例 #59
0
ファイル: TestWindow.py プロジェクト: arnabgho/play-pdfs
    def on_keywordField_activate(self, widget):
        searchString =  widget.get_text()      
        img_list = search_in_db(searchString)
        self.model.clear()
        for col in self.treeview.get_columns():
            self.treeview.remove_column(col)
         
        # print img_list.count()
        for img in img_list:
                
            im=Image.open(img['img_file_path'])
            # im.size
            # img_pixbuf = Pixbuf.new_from_file(img['img_file_path']).scale_simple(800,800,InterpType.BILINEAR)
            # image = Gtk.Image.new_from_pixbuf(img_pixbuf)
            # if(i%2==0):
            # self.imageGrid.attach(image,i%2,i,1,1)
            # else:
                # self.imageGrid.attach(image,0,i,1,1)
            # i=i+1    

            # self.model.append([(Pixbuf.new_from_file(img['img_file_path'])),img['file_path']])#treeitr the index in liststore to which entry is done
            self.model.append([(Pixbuf.new_from_file(img['img_file_path'])).scale_simple(900,(im.size[1]/im.size[0])*900,InterpType.BILINEAR),img['file_path']])#treeitr the index in liststore to which entry is done
            # self.model.append([Pixbuf.new_from_file(img['img_file_path'],img['colorspace'],img['has_alpha'],img['bits_per_sample'],img['width'],img['height'],img['rowstride']),img['img_file_path']])#treeitr the index in liststore to which entry is done

        # print searchString
        # print "MODEL\n"
        # print self.model

        #HERE we connect with database and retrieve from it the various entries
        # and then we populate the list and display images. 
        #after recieving things from Arnab's wrapper
       # model = Gtk.ListStore(Gtk.gdk.Pixbuf, str) #str will contain image-file-names
        #treeview = Gtk.TreeView(model) #need modifications when rendering
        # self.model.append([Pixbuf.new_from_data('data/media/background.png'),'data/media/background.png'])#treeitr the index in liststore to which entry is done
        # self.model.append([Pixbuf.new_from_file('data/media/download.jpg'),'data/media/download.jpg'])
       # self.model.append([Pixbuf.new_from_file('data/media/background.png'),Pixbuf.new_from_file('data/media/download.jpg')])

        # renderer.set_fixed_size(100)

        self.treeview.set_model(self.model)
        renderer = Gtk.CellRendererPixbuf()
        renderer.set_padding(10,20)
        # rendere.set_
        column = Gtk.TreeViewColumn('',renderer, pixbuf=0)
        column.set_spacing(-1)
        # column.set_attribute()
        self.treeview.insert_column(column,0)