def __init__ (self): gtk.Alignment.__init__(self,0,0,0,0) self.widgets = widgets = uistuff.GladeWidgets("taskers.glade") tasker = widgets["newGameTasker"] tasker.unparent() self.add(tasker) combo = ToggleComboBox() combo.addItem(_("White"), pixbuf_new_from_file(addDataPrefix("glade/white.png"))) combo.addItem(_("Black"), pixbuf_new_from_file(addDataPrefix("glade/black.png"))) combo.addItem(_("Random"), pixbuf_new_from_file(addDataPrefix("glade/random.png"))) combo.setMarkup("<b>", "</b>") widgets["colorDock"].add(combo) uistuff.keep(combo, "newgametasker_colorcombo") widgets['yourColorLabel'].set_mnemonic_widget(combo) # We need to wait until after engines have been discovered, to init the # playerCombos. We use connect_after to make sure, that newGameDialog # has also had time to init the constants we share with them. self.playerCombo = ToggleComboBox() widgets["opponentDock"].add(self.playerCombo) glock_connect_after(discoverer, "all_engines_discovered", self.__initPlayerCombo, widgets) widgets['opponentLabel'].set_mnemonic_widget(self.playerCombo) def on_skill_changed (scale): pix = newGameDialog.skillToIconLarge[int(scale.get_value())] widgets["skillImage"].set_from_pixbuf(pix) widgets["skillSlider"].connect("value-changed", on_skill_changed) on_skill_changed(widgets["skillSlider"]) widgets["startButton"].connect("clicked", self.startClicked) self.widgets["opendialog1"].connect("clicked", self.openDialogClicked)
def __init__(self, icon): from os.path import exists, abspath, join from gtk.gdk import pixbuf_new_from_file AboutDialog.__init__(self) self.set_icon(pixbuf_new_from_file(icon)) self.set_name("gtkpacman") self.set_version("2.0") self.set_copyright(_("Copyright (C)2005-2008 by Stefano Esposito.\nRights to copy, modify, and redistribute are granted under the GNU General Public License Terms")) self.set_comments(_("Gtk package manager based on pacman")) self.set_license(_("""gtkPacman 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. gtkPacman 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 St, Fifth Floor, Boston, MA 02110-1301 USA""")) self.set_website("http://gtkpacman.berlios.de") self.set_authors(["Stefano Esposito <*****@*****.**>"]) self.set_artists(["James D <*****@*****.**>"]) path = "/usr/share/gtkpacman/" if not exists(path): path = abspath("data/") fname = join(path, "icons/pacman.png") logo = pixbuf_new_from_file(fname) self.set_logo(logo)
def latex2pixbuf(permeable,out_txt,latex_type): """ Converting latex objects to RichTextImage """ try: # Set the working directory workdir = tempfile.gettempdir() if latex_type== "InlineEquation": latex_name='formula.png' origfilename=os.path.join(workdir,latex_name ) result_tag=math2png(out_txt[1:-1], origfilename,permeable) if result_tag is -1: result_tag=error2png(origfilename) tag="3" tex=out_txt[1:-1].encode() caption="" label="" if latex_type== "Footnote": latex_name='footnote.png' origfilename=os.path.join(workdir,latex_name ) result_tag=footnote2png(origfilename) tag="8" tex=out_txt[10:-1].encode() caption="" label="" if latex_type== "LaTeX": latex_name='latex.png' origfilename=os.path.join(workdir,latex_name ) result_tag=latex2png(out_txt, origfilename,permeable) if result_tag is -1: result_tag=error2png(origfilename) tag="7" tex=out_txt.encode() caption="" label="" if latex_type== "Citation": latex_name='cite.png' origfilename=os.path.join(workdir,latex_name ) result_tag=cite2png(out_txt[14:-1], origfilename,permeable) if result_tag is -1: result_tag=error2png(origfilename) tag="6" tex=out_txt[14:-1].encode() caption="" label="" if result_tag is not -1: img = RichTextImage() pixbuf=gdk.pixbuf_new_from_file(origfilename) pixbuf.save(origfilename,"png", {"tEXt::tag":tag,"tEXt::label":label,\ "tEXt::caption":caption,"tEXt::tex":tex}) img.set_from_pixbuf(gdk.pixbuf_new_from_file(origfilename.encode())) img.set_filename(latex_name) else: img=None finally: if os.path.exists(origfilename): os.remove(origfilename) return img
def latex2pixbuf(permeable, out_txt, latex_type): """ Converting latex objects to RichTextImage """ try: # Set the working directory workdir = tempfile.gettempdir() if latex_type == "InlineEquation": latex_name = 'formula.png' origfilename = os.path.join(workdir, latex_name) result_tag = math2png(out_txt[1:-1], origfilename, permeable) if result_tag is -1: result_tag = error2png(origfilename) tag = "3" tex = out_txt[1:-1].encode() caption = "" label = "" if latex_type == "Footnote": latex_name = 'footnote.png' origfilename = os.path.join(workdir, latex_name) result_tag = footnote2png(origfilename) tag = "8" tex = out_txt[10:-1].encode() caption = "" label = "" if latex_type == "LaTeX": latex_name = 'latex.png' origfilename = os.path.join(workdir, latex_name) result_tag = latex2png(out_txt, origfilename, permeable) if result_tag is -1: result_tag = error2png(origfilename) tag = "7" tex = out_txt.encode() caption = "" label = "" if latex_type == "Citation": latex_name = 'cite.png' origfilename = os.path.join(workdir, latex_name) result_tag = cite2png(out_txt[14:-1], origfilename, permeable) if result_tag is -1: result_tag = error2png(origfilename) tag = "6" tex = out_txt[14:-1].encode() caption = "" label = "" if result_tag is not -1: img = RichTextImage() pixbuf = gdk.pixbuf_new_from_file(origfilename) pixbuf.save(origfilename,"png", {"tEXt::tag":tag,"tEXt::label":label,\ "tEXt::caption":caption,"tEXt::tex":tex}) img.set_from_pixbuf(gdk.pixbuf_new_from_file( origfilename.encode())) img.set_filename(latex_name) else: img = None finally: if os.path.exists(origfilename): os.remove(origfilename) return img
def show_about_dialog(self, widget): about_dialog = gtk.AboutDialog() about_dialog.set_destroy_with_parent(True) about_dialog.set_name(appname) about_dialog.set_comments('A simple, lite update checker' ' for your tray.') about_dialog.set_website('https://github.com/nixheads/nixupdater') about_dialog.set_website_label('Website') about_dialog.set_icon(gdk.pixbuf_new_from_file(upgrade_icon)) about_dialog.set_logo(gdk.pixbuf_new_from_file(logo)) about_dialog.set_copyright('Copyright Johnathan Jenkins 2016') about_dialog.set_version(appver) about_dialog.set_authors(['Johnathan "ShaggyTwoDope" Jenkins']) about_dialog.set_wrap_license about_dialog.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_dialog.run() about_dialog.destroy()
def __init__(self): super(rshooterGui, self).__init__() self.start_builder() # Preparing the artwork win_icon = pixbuf_new_from_file("/home/gnu_d/Desktop/active_programs/olivers_colors/rainbow-shooter/rainbow_shooter/share/icons/rainbow_shooter.svg") win_icon = pixbuf_new_from_file(self.resourceman.get_images_file_path("rainbow_shooter", "svg")) self = self.builder.get_object("window1") # Setting the window icon. self.set_icon(win_icon) self.show_all()
def __init__(self, size=20): super(EyeArea, self).__init__() self._active = 0 self.eye_img = [ gdk.pixbuf_new_from_file('data/icons/edit.png'), gdk.pixbuf_new_from_file('data/icons/edit.png') ] self.set_size_request(self.eye_img[0].get_width(), self.eye_img[0].get_height()) self.connect('expose-event', self.draw)
def __init_attributes(self, editor): self.__editor = editor from os.path import join, split current_folder = split(globals()["__file__"])[0] glade_file = join(current_folder, "SymbolBrowser.glade") from gtk.gdk import pixbuf_new_from_file class_pixbuf = join(current_folder, "class.png") self.__class_pixbuf = pixbuf_new_from_file(class_pixbuf) function_pixbuf = join(current_folder, "function.png") self.__function_pixbuf = pixbuf_new_from_file(function_pixbuf) method_pixbuf = join(current_folder, "method.png") self.__method_pixbuf = pixbuf_new_from_file(method_pixbuf) from gtk.glade import XML self.__glade = XML(glade_file, "Window", "scribes") return
def trayUpdate(self, gdate=None, checkTrayMode=True): if checkTrayMode and self.trayMode < 1: return if gdate is None: gdate = localtime()[:3] if core.primaryMode==core.DATE_GREG: ddate = gdate else: ddate = core.convert(gdate[0], gdate[1], gdate[2], core.DATE_GREG, core.primaryMode) imagePath = ui.trayImageHoli if ui.todayCell.holiday else ui.trayImage ###################################### ''' import Image, ImageDraw, ImageFont im = Image.open(imagePath) w, h = im.size draw = ImageDraw.Draw(im) text = _(ddate[2]).decode('utf8') font = ImageFont.truetype('/usr/share/fonts/TTF/DejaVuSans.ttf', 15) fw, fh = font.getsize(text) draw.text( ((w-fw)/2, (h-fh)/2), text, font=font, fill=ui.trayTextColor, ) self.sicon.set_from_pixbuf(gdk.pixbuf_new_from_data(im.tostring(), gdk.COLORSPACE_RGB, True, 8, w, h, 4*w)) ''' try: pixbuf = gdk.pixbuf_new_from_file(imagePath) except: pixbuf = gdk.pixbuf_new_from_file(join(pixDir, 'tray-blue.png')) ##pixbuf.scale() #???????????? ###################### PUTTING A TEXT ON A PIXBUF pmap = pixbuf.render_pixmap_and_mask(alpha_threshold=127)[0] ## pixmap is also a drawable textLay = newTextLayout(self, _(ddate[2]), ui.trayFont) w, h = textLay.get_pixel_size() s = ui.traySize if ui.trayY0 == None: y = s/4+int((0.9*s-h)/2) else: y = ui.trayY0 pmap.draw_layout(pmap.new_gc(), (s-w)/2, y, textLay, gdk.Color(*ui.trayTextColor))## , foreground, background) self.trayPix.get_from_drawable(pmap, self.get_screen().get_system_colormap(), 0, 0, 0, 0, s, s) ###################################### self.sicon.set_from_pixbuf(self.trayPix) ###################################### set_tooltip(self.sicon, self.getTrayTooltip()) return True
def get_image_pixbuf(self): fp, file_name = tempfile.mkstemp('.jpg') os.write(fp, self.image) os.close(fp) pbuf = gdk.pixbuf_new_from_file(file_name) os.remove(file_name) return pbuf
def __init__(self): super(PyApp, self).__init__() self.set_title("logo") self.set_size_request(800, 600) self.set_position(gtk.WIN_POS_CENTER) self.connect("destroy", gtk.main_quit) pixbuf = gdk.pixbuf_new_from_file( "/root/workspace/EastedClient/EastedUI/bg.png") pixbuf1 = pixbuf.scale_simple(1280, 800, gdk.INTERP_BILINEAR) im = gtk.image_new_from_pixbuf(pixbuf1) fixed = gtk.Fixed() ima = gtk.Image() ima.set_from_file("/root/workspace/EastedClient/EastedUI/logo.png") _passwd_entry = gtk.Entry() _passwd_entry.set_editable(True) Passwd_label = gtk.Label("Account") Passwd_label.set_text(_passwd_entry.get_text()) Passwd_label.set_no_show_all(0) fixed.put(im, 0, 0) fixed.put(Passwd_label, 35, 100) fixed.put(_passwd_entry, 100, 100) fixed.put(ima, 200, 0) del pixbuf, pixbuf1 self.add(fixed) self.show_all()
def __init__(self): AboutDialog.__init__(self) self.set_skip_pager_hint(True) self.set_skip_taskbar_hint(True) program_name = 'Grafer' program_version = '0.2' website = 'http://grafer.googlecode.com/' logo = gdk.pixbuf_new_from_file(join(data_path, 'icons', 'grafer.svg')) authors = ['Fred Morcos <*****@*****.**>'] documenters = ['Fred Morcos <*****@*****.**>'] artists = [ 'Fred Morcos <*****@*****.**>', 'Laila Hassaballa <*****@*****.**>' ] self.set_program_name(program_name) self.set_version(program_version) self.set_logo(logo) self.set_website(website) self.set_website_label(website) self.set_authors(authors) self.set_documenters(documenters) self.set_artists(artists) self.set_license( 'Licensed under the GPLv3. See COPYING for more information.')
def on_inline_latex(self, window, tag): """Callback for inserting different latex objects based on tag""" widget = self._widget_focus.get(window, None) if isinstance(widget, gtk.TextView): # Following gets the notebook notebook = window.get_notebook() if notebook is None: return nodes = window.get_selected_nodes() if len(nodes) == 0: return else: sibling = nodes[0] datadir=self.get_base_dir() imfile=icons[tag] origfilename=os.path.join(datadir, imfile) img = RichTextImage() img.set_from_pixbuf(gdk.pixbuf_new_from_file(origfilename.encode())) widget.get_buffer().insert_image(img, imfile) image_path=os.path.join(sibling.get_path(), img.get_filename()) tagstr=_("%i") %(tag+3) ReLoad = Updating(sibling,window.get_viewer(),widget) dialog = dialog_latex.LaTeXDialog(ReLoad,tagstr,image_path) dialog.show()
def __init__(self, deferred, netclient): self.deferred = deferred self.netclient = netclient # load glade and connect it to self's dictionary for signal handling # This needs to happen as early as possible. self.glade = glade.XML(fs.gladefile) self.glade.signal_autoconnect(self) self._drawDefaultBackground() # graphics setup self.gw_Vellum.set_icon_from_file(fs('pixmaps', 'v.ico')) # set one button icon that isn't stock _hand_pb = gdk.pixbuf_new_from_file(fs('pixmaps', 'stock_stop.png')) _image = gtk.Image() _image.set_from_pixbuf(_hand_pb) _image.show() self.gw_pan_on.set_icon_widget(_image) # objects to be named later self.canvas = None self.model = None self.tool_active = None self.active_operation = None self.mini_operation = None # currently only zoom supported # stateful operations that have mouse interactivity self.operations = { 'pan_on': Pan, 'paint_on': Paint, 'magnify_on': Magnify, }
class LaTeXCommandProposal(Proposal): """ A proposal inserting a Template when activated """ icon = gdk.pixbuf_new_from_file(find_resource("icons/i_command.png")) def __init__(self, overlap, template, label): self._template = template self._label = label self._overlap = overlap @property def source(self): return self._template @property def label(self): return self._label @property def details(self): return None @property def overlap(self): return self._overlap
def __init_stock_id(self): # # generate a new stock id # # TODO: do we have to create the stock id every time? self.__stock_id = str(uuid1()) # see http://article.gmane.org/gmane.comp.gnome.gtk%2B.python/5119 # TODO: what is this strange construct for? stock_items = ( ((self.__stock_id, "", 0, 0, "")), ) gtk.stock_add(stock_items) factory = gtk.IconFactory() factory.add_default() # TODO: use IconSource, the Pixbuf is just fallback pixbuf = gdk.pixbuf_new_from_file(self.icon.path) icon_set = gtk.IconSet(pixbuf) factory.add(self.__stock_id, icon_set)
def do_open(self, widget, *data): '''Invokes the Open File dialog''' dialog = self.glade.get_widget('filechooserdialog1') # TODO GtkWarning: gtk_tree_model_get_iter: assertion `path != NULL' failed response = dialog.run() dialog.hide() if response == gtk.RESPONSE_OK: filename = dialog.get_filename() # Is the user opening a project? if os.path.basename(filename) == 'spritecaster.project': self.close_project() self.project_path = os.path.dirname(filename) self.project_file = open(filename, 'r+') print self.project_file.read() self.project_file.write('opening session again\n') # Not a project; must be an image else: # If we don't currently have a project open, this must only open a project! if not self.project_path and filename != 'spritecaster.project': self.alert('No project currently open. You must open or create a new project!') return self.pic = gdk.pixbuf_new_from_file(filename) self.myimage = MyImage(self.pic) self.drawing_area.queue_draw()
def editor_text(self): """Output text to editor buffer""" buf = self.editor.get_buffer() # Loading the image and its text chunks I=gdk.pixbuf_new_from_file(self._image_path) tag=I.get_option("tEXt::tag") caption=I.get_option("tEXt::caption") tex=I.get_option("tEXt::tex") label=I.get_option("tEXt::label") if tag==None: tag="0"; if label==None: label="" if caption==None: caption="" if tex==None: tex="" if self._TAG == "1": # add output text text=caption.encode("utf-8") buf.insert(buf.get_end_iter(), text) elif self._TAG == "2": # add output text text=label.encode("utf-8") buf.insert(buf.get_end_iter(), text) else: # add output text text=tex.encode("utf-8") buf.insert(buf.get_end_iter(), text)
def insert_image_from_file(self, imgfile, filename="image.png"): """Inserts an image from a file""" pixbuf = gdk.pixbuf_new_from_file(imgfile) img = RichTextImage() img.set_from_pixbuf(pixbuf) self.insert_image(img, filename)
def on_inline_latex(self, window, tag): """Callback for inserting different latex objects based on tag""" widget = self._widget_focus.get(window, None) if isinstance(widget, gtk.TextView): # Following gets the notebook notebook = window.get_notebook() if notebook is None: return nodes = window.get_selected_nodes() if len(nodes) == 0: return else: sibling = nodes[0] datadir = self.get_base_dir() imfile = icons[tag] origfilename = os.path.join(datadir, imfile) img = RichTextImage() img.set_from_pixbuf(gdk.pixbuf_new_from_file( origfilename.encode())) widget.get_buffer().insert_image(img, imfile) image_path = os.path.join(sibling.get_path(), img.get_filename()) tagstr = _("%i") % (tag + 3) ReLoad = Updating(sibling, window.get_viewer(), widget) dialog = dialog_latex.LaTeXDialog(ReLoad, tagstr, image_path) dialog.show()
def __getattr__(self, name): if name not in self.cache: try: pixbuf = gdk.pixbuf_new_from_file(join(self.dirname, name + '.png')) except gobject.GError, e: raise AttributeError, str(e) self.cache[name] = pixbuf
def __init__(self, icon): Window.__init__(self, WINDOW_TOPLEVEL) self.set_property("skip-taskbar-hint", True) self.set_property("destroy-with-parent", True) self.set_modal(True) self.set_position(WIN_POS_CENTER) self.vbox = VBox(False, 0) self.terminal = terminal() self.terminal.connect("child-exited", lambda _: self.close_button.show()) self.terminal.show() self.close_button = Button(stock=STOCK_CLOSE) self.close_button.connect("clicked", lambda _: self.destroy()) self.vbox.pack_start(self.terminal, False, False, 0) self.vbox.pack_start(self.close_button, False, False, 0) self.vbox.show() self.add(self.vbox) self.set_icon(pixbuf_new_from_file(icon))
class LaTeXChoiceProposal(Proposal): """ A proposal inserting a simple string when activated """ icon = gdk.pixbuf_new_from_file(find_resource("icons/i_choice.png")) def __init__(self, overlap, source, label, details): self._source = source self._details = details self._overlap = overlap self._label = label @property def source(self): return self._source @property def label(self): return self._label @property def details(self): return self._details @property def overlap(self): return self._overlap
def __init__(self, parent, icon): FileChooserDialog.__init__(self, _("Choose the buildscript"), parent, FILE_CHOOSER_ACTION_OPEN, (STOCK_OPEN, RESPONSE_ACCEPT, STOCK_CANCEL, RESPONSE_REJECT)) self.set_icon(pixbuf_new_from_file(icon))
def __init__(self): AboutDialog.__init__(self) self.set_skip_pager_hint(True) self.set_skip_taskbar_hint(True) program_name = 'gnome-shortcuts' program_version = '0.1' website = 'http://gnomeshortcuts.googlecode.com/' logo = pixbuf_new_from_file(join(data_path, 'icon.svg')) authors = ['Fred Morcos <*****@*****.**>'] documenters = ['Fred Morcos <*****@*****.**>'] artists = ['Fred Morcos <*****@*****.**>'] self.set_program_name(program_name) self.set_version(program_version) self.set_logo(logo) self.set_website(website) self.set_website_label(website) self.set_authors(authors) self.set_documenters(documenters) self.set_artists(artists) self.set_license( 'Licensed under the GPLv3. See COPYING for more information.')
def on_download_completed(self, o, code, item): """A new image has been downloaded.""" self.__ticker.set_ticking(False) self.__is_error = code != Downloader.OK self.__current_timestamp = item[DATE] self.__link.set_text(self.get_link_name(item)) self.__link.set_url(item[LINK]) self.__downloader = None self.__download_id = None if not self.__is_error: try: del self.__pixbuf except AttributeError: # Received destroy signal after download was initiated return try: self.__pixbuf = gdk.pixbuf_new_from_file(o.filename) except gobject.GError: self.__pixbuf = None self.__is_error = True self.update_size()
def set_background(path): # Note that the path is not unlinked, because gconf and xfconf set bg # asynchronously, so there's no way of knowing when the image will # actually be used if 'gsettings' in conf.bg_set_methods: ## GSettings - newer GNOME, Unity # Using gi.repository.Gio here directly is tricky alongside gimp's gtk2 from subprocess import call from urllib import quote call([ 'gsettings', 'set', 'org.gnome.desktop.background', 'picture-uri', 'file://{0}'.format(quote(path)) ]) if 'gconf' in conf.bg_set_methods: ## Gconf - older GNOME, XFCE/nautilus and such try: import gconf gconf = gconf.client_get_default() gconf.set_string( '/desktop/gnome/background/picture_filename', path ) except ImportError: pass if 'xfconf' in conf.bg_set_methods: ## Xfconf (via dbus interface) - XFCE/xfdesktop try: import dbus except ImportError: pass else: try: xfconf = dbus.Interface( dbus.SessionBus().get_object( 'org.xfce.Xfconf', '/org/xfce/Xfconf' ), dbus_interface='org.xfce.Xfconf' ) for k,v in xfconf.GetAllProperties('xfce4-desktop', '/backdrop').iteritems(): if k.endswith('/image-path'): xfconf.SetProperty('xfce4-desktop', k, path) except dbus.exceptions.DBusException: pass # no property/object/interface/etc if 'enlightenment' in conf.bg_set_methods: ## E17+ edbus interface try: import dbus except ImportError: pass else: try: edbus = dbus.SessionBus().get_object( 'org.enlightenment.wm.service', '/org/enlightenment/wm/RemoteObject' ) dxc, dyc = edbus.GetVirtualCount(dbus_interface='org.enlightenment.wm.Desktop') edbus = dbus.Interface( edbus, dbus_interface='org.enlightenment.wm.Desktop.Background' ) for dx, dy in it.product(xrange(dxc), xrange(dyc)): edbus.Add(0, dx, dy, path) except dbus.exceptions.DBusException: pass # no property/object/interface/etc if 'x-root-window' in conf.bg_set_methods: ## Paint X root window via pygtk pb = gdk.pixbuf_new_from_file(path) pm, mask = pb.render_pixmap_and_mask() win = gdk.get_default_root_window() win.set_back_pixmap(pm, False) win.clear() win.draw_pixbuf(gdk.GC(win), pb, 0, 0, 0, 0, -1, -1)
def load_pixbufs(self): self.room_tile = gdk.pixbuf_new_from_file('./images/ui/map_room.png') self.room_up = gdk.pixbuf_new_from_file('./images/ui/map_up.png') self.room_down = gdk.pixbuf_new_from_file('./images/ui/map_down.png') self.player_tile = gdk.pixbuf_new_from_file('./images/ui/map_player.png') self.ew_exit_tile = gdk.pixbuf_new_from_file('./images/ui/map_ew.png') self.ns_exit_tile = gdk.pixbuf_new_from_file('./images/ui/map_ns.png') self.sw_ne_exit_tile = gdk.pixbuf_new_from_file('./images/ui/map_sw_ne.png') self.ne_sw_exit_tile = gdk.pixbuf_new_from_file('./images/ui/map_ns.png') self.bg = gdk.pixbuf_new_from_file('./images/ui/map_bg.png')
def _set_default_icon(): import gtk from gtk import gdk import os.path def_icon = gdk.pixbuf_new_from_file( os.path.join(paths.DATA_DIR, 'pixmaps', 'mascot.png') ) gtk.window_set_default_icon_list(def_icon)
def __load_icon(self, icon): pixbuf = gdk.pixbuf_new_from_file(icon) w, h = pixbuf.get_width(), pixbuf.get_height() rate = max(w, h) / float(48) w = int(w / rate) h = int(h / rate) pixbuf = pixbuf.scale_simple(w, h, gdk.INTERP_BILINEAR) return pixbuf
def on_about(self, _widget): d = get_widget('about_dialog') d.set_transient_for(self.window_main) d.set_version(__version__) d.set_logo(gdk.pixbuf_new_from_file( path.join(data_dir, 'pixmaps', 'dreampie.png'))) d.run() d.destroy()
def load_preview(self): """Loads the brush preview as pixbuf into the brush.""" prefix = self.get_fileprefix() filename = prefix + '_prev.png' pixbuf = gdk.pixbuf_new_from_file(filename) self.preview = pixbuf self.remember_mtimes()
def append(self, imPath, label): if imPath=='': pix = None else: if not isabs(imPath): imPath = join(pixDir, imPath) pix = gdk.pixbuf_new_from_file(imPath) self.ls.append([pix, label])
def set_dock_icon(self): filename = self.get_icon_filename() if not filename: log.warn("Warning: cannot set dock icon, file not found!") return log("OSXTray.set_dock_icon() loading icon from %s", filename) pixbuf = gdk.pixbuf_new_from_file(filename) self.macapp.set_dock_icon_pixbuf(pixbuf)
def __getattr__(self, name): if name not in self.cache: try: pixbuf = gdk.pixbuf_new_from_file( join(self.dirname, name + '.png')) except gobject.GError, e: raise AttributeError, str(e) self.cache[name] = pixbuf
def __init__(self): gtk.HBox.__init__(self) ######### hbox = gtk.HBox() hbox.pack_start(gtk.Label(_('Category')+':'), 0, 0) ##### ls = gtk.ListStore(gdk.Pixbuf, str) combo = gtk.ComboBox(ls) ### cell = gtk.CellRendererPixbuf() combo.pack_start(cell, False) combo.add_attribute(cell, 'pixbuf', 0) ### cell = gtk.CellRendererText() combo.pack_start(cell, True) combo.add_attribute(cell, 'text', 1) ### ls.append([None, _('Custom')])## first or last FIXME for item in ui.eventTags: ls.append([ gdk.pixbuf_new_from_file(item.icon) if item.icon else None, item.desc ]) ### self.customItemIndex = 0 ## len(ls)-1 hbox.pack_start(combo, 0, 0) self.typeCombo = combo self.typeStore = ls ### vbox = gtk.VBox() vbox.pack_start(hbox, 0, 0) self.pack_start(vbox, 0, 0) ######### iconLabel = gtk.Label(_('Icon')) hbox.pack_start(iconLabel, 0, 0) self.iconSelect = IconSelectButton() hbox.pack_start(self.iconSelect, 0, 0) tagsLabel = gtk.Label(_('Tags')) hbox.pack_start(tagsLabel, 0, 0) hbox3 = gtk.HBox() self.tagButtons = [] for item in ui.eventTags: button = gtk.ToggleButton(item.desc) button.tagName = item.name self.tagButtons.append(button) hbox3.pack_start(button, 0, 0) self.swin = gtk.ScrolledWindow() self.swin.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_NEVER)## horizontal AUTOMATIC or ALWAYS FIXME self.swin.add_with_viewport(hbox3) self.pack_start(self.swin, 1, 1) self.customTypeWidgets = (iconLabel, self.iconSelect, tagsLabel, self.swin) ######### self.typeCombo.connect('changed', self.typeComboChanged) self.connect('scroll-event', self.scrollEvent) ######### self.show_all() hideList(self.customTypeWidgets)
def setup_icon(self): """Load the images that are going to be used as the applet's icon. """ self.icon_states = [] sz = self.applet.get_size() for i in range(0,14): path = os.path.join(images_path, "cpufreq-%s.svg" % i) pixbuf = gdk.pixbuf_new_from_file(path) pixbuf = gdk.pixbuf_new_from_file_at_size(path, pixbuf.get_width() * sz / pixbuf.get_height(), sz) self.icon_states.append(pixbuf)
def getImage(self, fn): if fn in self.images: return self.images[fn] try: img = gdk.pixbuf_new_from_file(fn) except Exception: img = None self.images[fn] = img return img
def __init__(self, parent, pacs, icon): Dialog.__init__(self, _("Warning!"), parent, DIALOG_MODAL | DIALOG_DESTROY_WITH_PARENT, (STOCK_YES, RESPONSE_YES, STOCK_NO, RESPONSE_REJECT)) self.set_icon(pixbuf_new_from_file(icon)) self._setup_tree(pacs) self._setup_layout()
def construct_icon(self, icon, width=None, height=None): """ Construct gtk.gdk.Pixbuf Icon """ if path.exists(icon): if width and height: return pixbuf_new_from_file_at_size(icon, width, height) else: return pixbuf_new_from_file(icon)
def _load_preview(self): """Loads the brush preview as pixbuf into the brush.""" assert self.name prefix = self.get_fileprefix() filename = prefix + "_prev.png" pixbuf = gdk.pixbuf_new_from_file(filename) self._preview = pixbuf self.remember_mtimes()
def __init__(self, parent, icon): Dialog.__init__(self, _("Search for.."), parent, DIALOG_MODAL | DIALOG_DESTROY_WITH_PARENT, (STOCK_OK, RESPONSE_ACCEPT, STOCK_CANCEL, RESPONSE_REJECT)) self.set_icon(pixbuf_new_from_file(icon)) self._setup_layout()
class SnippetProposal(Proposal): icon = gdk.pixbuf_new_from_file(find_resource("icons/snippet.png")) _color = Preferences().get("LightForeground", "#957d47") def __init__(self, snippet, overlap): self._snippet = snippet self._overlap = overlap self._details = None @property def source(self): """ @return: a subclass of Source to be inserted on activation """ # FIXME: separate between Snippet and LaTeXSnippet if self._snippet.packages is not None and len( self._snippet.packages) > 0: return LaTeXSource(Template(self._snippet.expression), self._snippet.packages) else: return Template(self._snippet.expression) @property def label(self): """ @return: a string (may be pango markup) to be shown in proposals popup """ return self._snippet.label @property def details(self): """ @return: a widget to be shown in details popup """ if self._details is None: self._details = "" for token in TemplateTokenizer(self._snippet.expression): if token.type == TemplateToken.LITERAL: self._details += token.value elif token.type == TemplateToken.PLACEHOLDER: self._details += "<span color='%s'>%s</span>" % ( self._color, token.value) elif token.type == TemplateToken.CURSOR: self._details += "<span color='%s'>•</span>" % self._color return self._details @property def overlap(self): """ @return: the number of overlapping characters from the beginning of the proposal and the prefix it was generated for """ return self._overlap
def __init__(self): super(InfoButton, self).__init__() path = os.path.join(constants.GFX_PATH, 'corner-info.svg') pixbuf = gdk.pixbuf_new_from_file(path) self.width = pixbuf.get_width() self.height = pixbuf.get_height() self._image = gtk.image_new_from_pixbuf(pixbuf) self._image.show() self.add(self._image)
def set_notifier_icon(self, notifier, icon): """Used to attach an icon on a notifier object.""" try: from gtk import gdk except ImportError: #TODO: raise a warning? raise RuntimeError('The gtk.gdk module is required to set an icon.') if icon is not None: if not isinstance(icon, gdk.Pixbuf): icon = gdk.pixbuf_new_from_file(icon) notifier.set_icon_from_pixbuf(icon)
def _drawDefaultBackground(self): # allocate the slate background self.bg = gdk.pixbuf_new_from_file(fs.background) # create a pixmap to put a tile into _pixmap = gdk.Pixmap(self.gw_viewport1.window, self.bg.get_width(), self.bg.get_height()) gc = _pixmap.new_gc() _pixmap.draw_pixbuf(gc, self.bg, 0, 0, 0, 0) # a kludge to make gw_viewport1 generate a new style object: self.gw_viewport1.modify_bg(gtk.STATE_NORMAL, gdk.Color(0xff0000)) # now modify the new style object self.gw_viewport1.style.bg_pixmap[gtk.STATE_NORMAL] = _pixmap
def __init__(self): window = gtk.Window(gtk.WINDOW_TOPLEVEL) notebook = gtk.Notebook() window.add(notebook) notebook.show() window.connect("destroy", lambda w: gtk.main_quit()) # Create the drawing area canvas = gnomecanvas.Canvas() canvas.set_center_scroll_region(False) canvas.set_size_request(200, 200) drawing_area = gtk.DrawingArea() notebook.append_page(canvas, gtk.Label("Canvas")) notebook.append_page(drawing_area, gtk.Label("Drawing Area")) notebook.connect("switch-page", self.switch, canvas) drawing_area.connect( "expose-event", self.expose_drawing, ) drawing_area.connect( "button-press-event", self.button_press, ) drawing_area.connect( "button-release-event", self.button_release, ) drawing_area.connect( "motion-notify-event", self.motion_notify, ) canvas.set_events(gdk.ALL_EVENTS_MASK) notebook.set_events(gdk.ALL_EVENTS_MASK) drawing_area.set_events(gdk.ALL_EVENTS_MASK) canvas.root().add("GnomeCanvasPixbuf", pixbuf=gdk.pixbuf_new_from_file("slatebg.png"), x=0, y=0) self.scraped = None self.last_brush = None self.duplicate = None window.show_all() gtk.main()
def Init(self): self.Selected = None self.tooltips = gtk.Tooltips() pixbuf = pixbuf_new_from_file(ARROW_IMAGE) newIconWidget = gtk.Image() newIconWidget.set_from_pixbuf(pixbuf) newIconWidget.show() self.ArrowButton = self.tbToolBox.get_nth_item(0) self.ArrowButton.connect("toggled", self.on_tbArrowBtn_toggled) self.ArrowButton.set_icon_widget(newIconWidget) self.ArrowButton.set_tooltip(self.tooltips, "Selection tool")
def register_stock_icons(): """ Register the stock icons used by the various classes in the module. """ factory = gtk.IconFactory() factory.add_default() for stock_id in [STOCK_ICON, STOCK_SET_STAR, STOCK_UNSET_STAR]: pixbuf = gdk.pixbuf_new_from_file( os.path.join(musicapplet.defs.PKG_DATA_DIR, "%s.png" % stock_id)) icon_set = gtk.IconSet(pixbuf) factory.add(stock_id, icon_set)
def _load_preview(self): """Loads the brush preview as pixbuf into the brush.""" assert self.name prefix = self._get_fileprefix() try: filename = prefix + '_prev.png' pixbuf = gdk.pixbuf_new_from_file(filename) except: logger.exception("Failed to load preview pixbuf, will fall back " "to default") pixbuf = None self._preview = pixbuf self._remember_mtimes()
def get_pixbuf(filename): try: if os.path.splitext(filename)[1].lower() == ".ora": ora = zipfile.ZipFile(filename) data = ora.read("Thumbnails/thumbnail.png") loader = gdk.PixbufLoader("png") loader.write(data) loader.close() return loader.get_pixbuf() else: return gdk.pixbuf_new_from_file(filename) except: # filename is a directory, or just nothing image-like return
def start_element_handler(tag, attr): global pl, stack current = top(stack) key = val = None if tag == "section": key = attr["name"] if key == "icons": val = dict() stack.append(val) elif tag == "icon": fbase = attr["file"] fname = find_file(fbase) key = attr["name"] if fname != None and key != None: val = dict() pb = gdk.pixbuf_new_from_file(fname) val["colorspace"] = pb.get_colorspace() val["alpha"] = pb.get_has_alpha() val["bps"] = pb.get_bits_per_sample() val["width"] = pb.get_width() val["height"] = pb.get_height() val["rowstride"] = pb.get_rowstride() val["data"] = plistlib.Data(pb.get_pixels()) elif fname == None: print >> sys.stderr, ("Error: No such icon file %s" % fbase) sys.exit(1) elif tag == "plist": fbase = attr["file"] fname = find_file(fbase) key = attr["name"] if fname != None and key != None: val = plistlib.readPlist(fname) elif fname == None: print >> sys.stderr, ("Error: No such plist file %s" % fbase) sys.exit(1) elif tag == "string": fbase = attr["file"] fname = find_file(fbase) key = attr["name"] if fname != None and key != None: try: ff = open(fname) val = ff.read() except Exception, err: print >> sys.stderr, ("Error: %s" % str(err)) sys.exit(1) elif fname == None: print >> sys.stderr, ("Error: No such string file %s" % fbase) sys.exit(1)