def change_direction_image(self, GroupTransition): # don't change direction of a mask if self.type != "transition": return # get a reference to the 2 main canvas objects & theme theme = self.parent.parent.project.theme # get the direction image canvasImageTrans = self.get_canvas_child(GroupTransition, "trans_direction") if self.reverse: # DOWN imgTrans = gtk.image_new_from_file( "%s/libreshot/themes/%s/transition_down.png" % (self.parent.parent.project.form.libreshot_path, theme)) canvasImageTrans.set_properties(pixbuf=imgTrans.get_pixbuf()) else: # UP imgTrans = gtk.image_new_from_file( "%s/libreshot/themes/%s/transition_up.png" % (self.parent.parent.project.form.libreshot_path, theme)) canvasImageTrans.set_properties(pixbuf=imgTrans.get_pixbuf())
def __init__(self, ydmg): gtk.HBox.__init__(self) self.base = ydmg self.pageid = DEV_ID self.callback = ydmg.select_page '''symbol''' try: logo = gtk.image_new_from_file(ICON + "logo_%s.png" % locale.getlocale()[0]) except: logo = gtk.image_new_from_file(ICON + "logo_en_US.png") align = self.define_align(logo, 0.0, 0.5) #set_padding(padding_top, padding_bottom, padding_left, padding_right) align.set_padding(0, 0, 20, 0) self.pack_start(align, False, False) button_box = gtk.HBox() align = self.define_align(button_box, 0.0, 0.5) self.pack_start(align) device_button = self.draw_button(_("DetectOn"), ICON + "device.png", DEV_ID) button_box.pack_start(device_button, False, False, 8) driver_button = self.draw_button(_("DriveOn"), ICON + "driver.png", DRI_ID) button_box.pack_start(driver_button, False, False, 8) test_button = self.draw_button(_("Reviews"), ICON + "test.png", TEST_ID) button_box.pack_start(test_button, False, False, 8)
def on_audio_click(self, item, target, event): # get the parent left group parent_group = item.get_parent() if self.play_audio == True: # Load Hover Over imgTrack_Left_Hover = gtk.image_new_from_file( "%s/openshot/themes/%s/speaker_mute.png" % (self.parent.project.form.openshot_path, self.parent.project.theme) ) item.set_properties(pixbuf=imgTrack_Left_Hover.get_pixbuf()) # update play audio variable self.play_audio = False else: # Load normal image imgTrack_Left_Hover = gtk.image_new_from_file( "%s/openshot/themes/%s/speaker.png" % (self.parent.project.form.openshot_path, self.parent.project.theme) ) item.set_properties(pixbuf=imgTrack_Left_Hover.get_pixbuf()) # update play audio variable self.play_audio = True # mark project as modified self.parent.project.set_project_modified(is_modified=True, refresh_xml=True, type=_("Changed audio of track")) return False
def on_tray_icon_popup(self, icon, event_button, event_time): menu = gtk.Menu() if self.props.visible: # Hide ----------------------------------------------------------------- m_hide = gtk.ImageMenuItem(_("Hide")) img = gtk.image_new_from_file(image_path('hide.png')) img.show() m_hide.set_image(img) menu.append(m_hide) m_hide.connect('activate', lambda w: self.hide()) else: # Show ----------------------------------------------------------------- m_show = gtk.ImageMenuItem(_("Show")) img = gtk.image_new_from_file(image_path('show.png')) img.show() m_show.set_image(img) menu.append(m_show) m_show.connect('activate', lambda w: self.show()) # Separator ------------------------------------------------------------ menu.append(gtk.SeparatorMenuItem()) # Quit ----------------------------------------------------------------- m_quit = gtk.ImageMenuItem(_("Quit")) img = gtk.image_new_from_icon_name('application-exit', gtk.ICON_SIZE_MENU) img.show() m_quit.set_image(img) menu.append(m_quit) m_quit.connect('activate', self.on_quit) menu.show_all() menu.popup(None, None, None, event_button, event_time)
def make_icon (self, column, cell, model, iter): icon = None uid = model.get_value (iter, 2) user = self.office.get_user (long (uid)) icons_dir = self.office.get_user_icons_dir () if user.has_key ('pic_square_local'): icon_path = "%s/%s" % (icons_dir, user['pic_square_local']) icon = gtk.image_new_from_file (icon_path) else: img_file = pkg_resources.resource_filename \ (__name__, "data/images/q_silhouette.gif") icon = gtk.image_new_from_file (img_file) try: pixbuf = icon.get_pixbuf () except: logging.debug ("no icon: comment.py:116 [%s]" % icon_path) img_file = pkg_resources.resource_filename \ (__name__, "data/images/q_silhouette.gif") icon = gtk.image_new_from_file (img_file) pixbuf = icon.get_pixbuf () scaled_buf = \ pixbuf.scale_simple \ (COMMENT_ICON_SIZE, COMMENT_ICON_SIZE, gtk.gdk.INTERP_BILINEAR) cell.set_property ('pixbuf', scaled_buf)
def on_focus_in(self, item, target, event): isinstance(item, goocanvas.Image) id = item.get_data("id") if event.button == 3: # show the track popup menu self.parent.project.form.mnuTrack1.showmnu(event, self) if id == "normal": # Load Hover Over imgTrack_Left_Hover = gtk.image_new_from_file( "%s/openshot/themes/%s/Track_Left_Hover.png" % (self.parent.project.form.openshot_path, self.parent.project.theme) ) item.set_properties(pixbuf=imgTrack_Left_Hover.get_pixbuf()) item.set_data("id", "hover") else: # Load normal image imgTrack_Left_Hover = gtk.image_new_from_file( "%s/openshot/themes/%s/Track_Left.png" % (self.parent.project.form.openshot_path, self.parent.project.theme) ) item.set_properties(pixbuf=imgTrack_Left_Hover.get_pixbuf()) item.set_data("id", "normal") return False
def initComponents(self): main_box=gtk.VBox(False, 2) self.add(main_box) main_box.show() backup_button = gtk.Button(_("Backup")) backup_button.set_size_request(150, -1) backup_icon = gtk.image_new_from_file(common.get_icon_path("backup.png")) backup_button.set_image(backup_icon) main_box.pack_start(backup_button, False, False, 2) backup_button.show() backup_icon.show() backup_button.connect("clicked", self._controller.start_backup) restore_button = gtk.Button(_("Restore")) restore_button.set_size_request(150, -1) restore_icon = gtk.image_new_from_file(common.get_icon_path("restore.png")) restore_button.set_image(restore_icon) main_box.pack_start(restore_button, False, False, 2) restore_button.show() restore_icon.show() restore_button.connect("clicked", self._controller.start_restore) button_box = gtk.HBox(False, 2) main_box.pack_end(button_box, False, False) button_box.show() close_button = gtk.Button(_("Close")) button_box.pack_end(close_button, False, False, 2) close_button.show() close_button.connect("clicked", self._controller.close)
def create_status_bar(self): sbarbox = gtk.HBox(False, 0) # Buttons button_focus = gtk.ToggleButton("Focus") ico_focus = gtk.image_new_from_file("icons/system-search.png") button_focus.set_image(ico_focus) button_focus.set_active(True) button_focus.connect("clicked", self._on_button_click) self.button_fullscreen = gtk.ToggleButton("Fullscreen") ico_fullscreen = gtk.image_new_from_file("icons/view-fullscreen.png") self.button_fullscreen.set_image(ico_fullscreen) self.button_fullscreen.connect("clicked", self._on_button_click) self.button_actions = {} self.button_actions[button_focus] = self.focus self.button_actions[self.button_fullscreen] = self.fullscreen sbar_wc = gtk.Statusbar() context_id = sbar_wc.get_context_id("main_window") sbar_wc.push(context_id, "wc") sbarbox.pack_start(button_focus, False, False, 0) sbarbox.pack_start(self.button_fullscreen, False, False, 0) sbarbox.pack_end(sbar_wc, True, True, 0) return sbarbox
def on_audio_click (self, item, target, event): # Left button if event.button == 1: # get a reference to the language translate method _ = self.parent.project.translate # get the parent left group parent_group = item.get_parent() if self.play_audio == True: # Load Hover Over imgTrack_Left_Hover = gtk.image_new_from_file("%s/openshot/themes/%s/speaker_mute.png" % (self.parent.project.form.openshot_path, self.parent.project.theme)) imgTrack_Left_Hover.set_tooltip_text(_("Sound Deactivated")) item.set_properties(widget = imgTrack_Left_Hover) # update play audio variable self.play_audio = False else: # Load normal image imgTrack_Left_Hover = gtk.image_new_from_file("%s/openshot/themes/%s/speaker.png" % (self.parent.project.form.openshot_path, self.parent.project.theme)) imgTrack_Left_Hover.set_tooltip_text(_("Sound Activated")) item.set_properties(widget = imgTrack_Left_Hover) # update play audio variable self.play_audio = True # mark project as modified self.parent.project.set_project_modified(is_modified=True, refresh_xml=True, type=_("Changed audio of track")) return False
def initGui(self): self.builder = gtk.Builder() self.builder.add_from_file(os.path.join('gui', 'glade', 'MainWindow.glade')) self.window = self.builder.get_object('MainWindow') self.window.show() try: self.status = self.mxit.settings['status'] self.builder.get_object('statusEntry').set_text(self.status) except KeyError: self.builder.get_object('statusEntry').set_text('Click here to change your status') self.builder.get_object('presenceItem').set_image(gtk.image_new_from_file(os.path.join('gui', 'images', 'presence', '1.png'))) self.mxit.contactStore = ContactList(self.builder.get_object('ContactListTreeView'), self.mxit) self.builder.connect_signals(self) self.initMenuIcons() try: if not self.mxit.settings.has_key('rememberMood') or self.mxit.settings['rememberMood']: self.mood = self.mxit.settings['lastmood'] if not int(self.mood) == 0: mood = MOODS[self.mood] message = SetMoodMessage(int(self.mood), self.mxit) self.mxit.sendMsg(message) self.builder.get_object('moodItem').set_image(gtk.image_new_from_file(os.path.join(MOOD_IMAGES_BASE_DIR, '%s.png' % mood))) except KeyError: #We ain't got no mood pass
def load_icons(self): icons = {} icons_path = 'icons' if os.path.isdir(config_icons): icons_path = config_icons icons['add_sibling'] = gtk.image_new_from_file(os.path.join(icons_path, "add_sibling.png")) icons['add_child'] = gtk.image_new_from_file(os.path.join(icons_path, "add_child.png")) return icons
def initMenuIcons(self): for item in ['happy', 'sad', 'excited', 'invincible', 'hot', 'angry', 'grumpy', 'sick', 'inlove', 'sleepy']: self.builder.get_object('%sItem' % item).set_image(gtk.image_new_from_file(os.path.join(MOOD_IMAGES_BASE_DIR, '%s.png' % item))) for item in ['online', 'away', 'busy']: self.builder.get_object('%sItem' % item).set_image(gtk.image_new_from_file(os.path.join(PRESENCE_IMAGES_BASE_DIR, '%s.png' % item))) self.builder.get_object('moodItem').set_image(gtk.image_new_from_file(os.path.join(MOOD_IMAGES_BASE_DIR, 'none.png')))
def __init__(self, icon_type, dri_tuple): gtk.EventBox.__init__(self) self.set_eventbox(self) '''icons''' if icon_type == "display": icon = gtk.image_new_from_file(ICON + "card.png") elif icon_type == "network": icon = gtk.image_new_from_file(ICON + "net.png") elif icon_type == "multimedia": icon = gtk.image_new_from_file(ICON + "sound.png") else: icon = gtk.image_new_from_file(ICON + "usb.png") align = self.define_align(icon) align.set_padding(5, 5, 0, 0) item_box = gtk.HBox() item_box.pack_start(align, False, False, 10) '''vbox --> (name_label,sum_label)''' vbox = gtk.VBox(False, 4) align = self.define_align(vbox, 0, 0.5, 1.0) item_box.pack_start(align) '''pkg info''' pkgname = dri_tuple[1][0] name_label = gtk.Label() name_label.set_markup("<span font_desc='10'><b>%s</b></span>" % pkgname) name_label.set_alignment(0, 0) vbox.pack_start(name_label, False, False) pkgsum = dri_tuple[1][2] self.sum_label = gtk.Label() self.sum_label.set_markup("<span font_desc='10'>%s</span>" % pkgsum) self.sum_label.set_alignment(0, 0) self.sum_label.set_tooltip_text(pkgsum) vbox.pack_start(self.sum_label) '''action button''' pkgmod = dri_tuple[0] button = ActionButton(pkgname, pkgmod) button.connect("focus-in-event", self.get_focus) button.connect("focus-out-event", self.lose_focus) align = self.define_align(button, 0.0, 0.5, 1.0) item_box.pack_end(align, False, False, 15) '''pkg version''' pkgver = dri_tuple[1][1] ver_label = gtk.Label() ver_label.set_markup("<span font_desc='10'>%s</span>" % pkgver) item_box.pack_end(ver_label, False, False, 20) '''ebox --> item_box --> (vbox,button,ver_label)''' #self.item = self.default_ebox() self.connect("size-allocate", self.label_align) self.add(item_box)
def image_from_url(self,url,fname): """return a gtk.Image from url""" #~ cache img to speed up loading cachedir = self.get_cachedir() if url: ext = '.'+url[url.rindex('.')+1:].lower() if ext not in ['.jpg','.png']: ext = '.jpg' fname = str(fname)+ext cachefile = cachedir+fname if os.path.exists(cachefile): #~ cache hit pb = gtk.gdk.pixbuf_new_from_file(cachefile) pbs = pb.scale_simple(48,48,0) return gtk.image_new_from_pixbuf(pbs) fp = urllib.urlopen(url) pbl = gtk.gdk.PixbufLoader() data = fp.read() #~ read url into pixbuf if pbl.write(data): pb = pbl.get_pixbuf() try: pbs = pb.scale_simple(48,48,0) except: try: fp.close() pbl.close() except: pass print('could not scale image for %s '% fname) return gtk.image_new_from_file('blank.jpg') #~ pbs = pb #~ create image from pixbuf image = gtk.Image() image.set_from_pixbuf(pbs) #~ save cached copy if ext != '.png': pb.save(cachefile,"jpeg") else: pb.save(cachefile,"png") try: pbl.close() except: print('%s truncated or incomplete.' % url) else: #~ todo: make this a broken image print('broken image for %s'%fname) image = gtk.image_new_from_file('blank.jpg') fp.close() else: print('no url for image%'%fname) image = gtk.image_new_from_file('blank.jpg') return image
def image_from_url(self, url, fname): """return a gtk.Image from url""" #~ cache img to speed up loading cachedir = self.get_cachedir() if url: ext = '.' + url[url.rindex('.') + 1:].lower() if ext not in ['.jpg', '.png']: ext = '.jpg' fname = str(fname) + ext cachefile = cachedir + fname if os.path.exists(cachefile): #~ cache hit pb = gtk.gdk.pixbuf_new_from_file(cachefile) pbs = pb.scale_simple(48, 48, 0) return gtk.image_new_from_pixbuf(pbs) fp = urllib.urlopen(url) pbl = gtk.gdk.PixbufLoader() data = fp.read() #~ read url into pixbuf if pbl.write(data): pb = pbl.get_pixbuf() try: pbs = pb.scale_simple(48, 48, 0) except: try: fp.close() pbl.close() except: pass print('could not scale image for %s ' % fname) return gtk.image_new_from_file('blank.jpg') #~ pbs = pb #~ create image from pixbuf image = gtk.Image() image.set_from_pixbuf(pbs) #~ save cached copy if ext != '.png': pb.save(cachefile, "jpeg") else: pb.save(cachefile, "png") try: pbl.close() except: print('%s truncated or incomplete.' % url) else: #~ todo: make this a broken image print('broken image for %s' % fname) image = gtk.image_new_from_file('blank.jpg') fp.close() else: print('no url for image%' % fname) image = gtk.image_new_from_file('blank.jpg') return image
def get_media_files_panel(media_list_view, add_cb, del_cb, col_changed_cb, proxy_cb, filtering_cb): # Create buttons and connect signals add_media_b = gtk.Button(_("Add")) del_media_b = gtk.Button(_("Delete")) add_media_b.connect("clicked", add_cb, None) del_media_b.connect("clicked", del_cb, None) add_media_b.set_tooltip_text(_("Add Media File to Bin")) del_media_b.set_tooltip_text(_("Delete Media File from Bin")) proxy_b = gtk.Button() proxy_b.set_image(gtk.image_new_from_file(respaths.IMAGE_PATH + "proxy_button.png")) proxy_b.connect("clicked", proxy_cb, None) proxy_b.set_tooltip_text(_("Render Proxy Files For Selected Media")) gui.proxy_button = proxy_b columns_img = gtk.image_new_from_file(respaths.IMAGE_PATH + "columns.png") adj = gtk.Adjustment(value=editorpersistance.prefs.media_columns, lower=MEDIA_PANEL_MIN_ROWS, upper=MEDIA_PANEL_MAX_ROWS, step_incr=1) spin = gtk.SpinButton(adj) spin.set_numeric(True) spin.set_size_request(40, 30) spin.connect("changed", col_changed_cb) all_pixbuf = gtk.gdk.pixbuf_new_from_file(respaths.IMAGE_PATH + "show_all_files.png") audio_pixbuf = gtk.gdk.pixbuf_new_from_file(respaths.IMAGE_PATH + "show_audio_files.png") graphics_pixbuf = gtk.gdk.pixbuf_new_from_file(respaths.IMAGE_PATH + "show_graphics_files.png") video_pixbuf = gtk.gdk.pixbuf_new_from_file(respaths.IMAGE_PATH + "show_video_files.png") imgseq_pixbuf = gtk.gdk.pixbuf_new_from_file(respaths.IMAGE_PATH + "show_imgseq_files.png") pattern_pixbuf = gtk.gdk.pixbuf_new_from_file(respaths.IMAGE_PATH + "show_pattern_producers.png") files_filter_launcher = guicomponents.ImageMenuLaunch(filtering_cb, [all_pixbuf, video_pixbuf, audio_pixbuf, graphics_pixbuf, imgseq_pixbuf, pattern_pixbuf], 20, 22) files_filter_launcher.pixbuf_x = 3 files_filter_launcher.pixbuf_y = 9 gui.media_view_filter_selector = files_filter_launcher buttons_box = gtk.HBox(False,1) buttons_box.pack_start(add_media_b, True, True, 0) buttons_box.pack_start(del_media_b, True, True, 0) buttons_box.pack_start(proxy_b, False, False, 0) buttons_box.pack_start(guiutils.get_pad_label(4, 4), False, False, 0) buttons_box.pack_start(columns_img, False, False, 0) buttons_box.pack_start(spin, False, False, 0) buttons_box.pack_start(files_filter_launcher.widget, False, False, 0) panel = gtk.VBox() panel.pack_start(buttons_box, False, True, 0) panel.pack_start(media_list_view, True, True, 0) out_align = gtk.Alignment(0.5, 0.5, 1.0, 1.0) out_align.set_padding(4, 4, 0, 4) out_align.add(panel) return out_align
def _init_components(self): self.tasks_hbox = gtk.HBox() self.pack_start(self.tasks_hbox, True, True, 2) self.tasks_hbox.show() self.task_list_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) self.task_list_cell = gtk.CellRendererText() self.task_list_cell.set_property('background-gdk', gtk.gdk.Color(red=50000, green=50000, blue=50000)) self.task_list_column = gtk.TreeViewColumn(_("Task list"), self.task_list_cell, markup=1) self.task_list_id_cell = gtk.CellRendererText() self.task_list_id_column = gtk.TreeViewColumn('Id', self.task_list_id_cell, markup=0) self.task_list_id_column.set_visible(False) self.tasks_scoll_window = gtk.ScrolledWindow() self.tasks_hbox.pack_start(self.tasks_scoll_window, True, True, 2) self.tasks_scoll_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.tasks_scoll_window.show() self.task_list = gtk.TreeView(self.task_list_store) selection = self.task_list.get_selection() selection.set_mode(gtk.SELECTION_SINGLE) self.tasks_scoll_window.add(self.task_list) # pack_start(self.task_list, True, True, 2) self.task_list.show() self.task_list.append_column(self.task_list_id_column) self.task_list.append_column(self.task_list_column) self.task_button_vbox = gtk.VBox() self.tasks_hbox.pack_start(self.task_button_vbox, False, False, 2) self.task_button_vbox.show() self.task_add_button = gtk.Button() button_icon = gtk.image_new_from_file(common.get_icon_path("plus.png")) self.task_add_button.set_image(button_icon) self.task_add_button.set_tooltip_text(_("Add a new task")) self.task_button_vbox.pack_start(self.task_add_button, False, False, 2) self.task_add_button.show() self.task_edit_button = gtk.Button() button_icon = gtk.image_new_from_file(common.get_icon_path("settings.png")) self.task_edit_button.set_image(button_icon) self.task_edit_button.set_tooltip_text(_("Edit task")) self.task_button_vbox.pack_start(self.task_edit_button, False, False, 2) self.task_edit_button.show() self.task_del_button = gtk.Button() button_icon = gtk.image_new_from_file(common.get_icon_path("minus.png")) self.task_del_button.set_image(button_icon) self.task_del_button.set_tooltip_text(_("Remove task")) self.task_button_vbox.pack_start(self.task_del_button, False, False, 2) self.task_del_button.show()
def __init__( self ): self.process = None; self.window = gtk.Window( gtk.WINDOW_TOPLEVEL ) self.window.connect( "destroy", self.destroy) self.window.set_border_width( 10 ) self.window.set_title( 'OpenPhotoBooth Control' ) self.window.resize( 300, 1 ) table = gtk.Table( 4, 2, True ) self.theme_combo = gtk.combo_box_new_text() for theme in os.listdir( 'static/themes/' ): if theme != 'template' and os.path.isdir( 'static/themes/' + theme ): self.theme_combo.append_text( theme ) self.theme_combo.set_active( 0 ) table.attach( self.theme_combo, 0, 2, 1, 2 ) self.theme_combo.show() self.status_label = gtk.Label( 'Click "Start" To Run Server' ) table.attach( self.status_label, 0, 2, 0, 1 ) self.status_label.show() self.start_button = gtk.Button( "Start" ) self.start_button.connect( "clicked", self.start, None ) self.start_button.set_image( gtk.image_new_from_file( 'icons/media-playback-start.png' ) ) table.attach( self.start_button, 0, 1, 2, 3 ) self.start_button.show() self.stop_button = gtk.Button( "Stop" ) self.stop_button.connect( "clicked", self.stop, None ) self.stop_button.set_sensitive( False ) self.stop_button.set_image( gtk.image_new_from_file( 'icons/media-playback-stop.png' ) ) table.attach( self.stop_button, 1, 2, 2, 3 ) self.stop_button.show() about_button = gtk.Button( "About" ) about_button.connect( "clicked", self.about, None ) about_button.set_image( gtk.image_new_from_file( 'icons/help-browser.png' ) ) table.attach( about_button, 0, 1, 3, 4 ) about_button.show() quit_button = gtk.Button( "Quit" ) quit_button.connect( "clicked", self.destroy, None ) quit_button.set_image( gtk.image_new_from_file( 'icons/process-stop.png' ) ) table.attach( quit_button, 1, 2, 3, 4 ) quit_button.show() self.window.add( table ) table.show() self.window.show()
def __init__(self): super(PlayButton, self).__init__() self.set_relief(gtk.RELIEF_NONE) self.set_focus_on_click(False) self.modify_bg(gtk.STATE_ACTIVE, COLOR_BLACK) path = os.path.join(constants.GFX_PATH, "media-play.png") self._play_image = gtk.image_new_from_file(path) path = os.path.join(constants.GFX_PATH, "media-pause.png") self._pause_image = gtk.image_new_from_file(path) self.set_play()
def __init__(self): super(PlayButton, self).__init__() self.set_relief(gtk.RELIEF_NONE) self.set_focus_on_click(False) self.modify_bg(gtk.STATE_ACTIVE, COLOR_BLACK) path = os.path.join(constants.GFX_PATH, 'media-play.png') self._play_image = gtk.image_new_from_file(path) path = os.path.join(constants.GFX_PATH, 'media-pause.png') self._pause_image = gtk.image_new_from_file(path) self.set_play()
def win(self): if self.playing == "whites": dialog_image = gtk.image_new_from_file("white_king.svg") string_displayed = _("Whites win!") else: dialog_image = gtk.image_new_from_file("black_king.svg") string_displayed = _("Blacks win!") dialog = gtk.Dialog(string_displayed, None, gtk.DIALOG_MODAL, (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) dialog_label = gtk.Label(string_displayed) dialog_image.show() dialog_label.show() dialog.vbox.pack_start(dialog_image) dialog.vbox.pack_start(dialog_label) dialog.run() dialog.destroy()
def add_text(self, data_dict, version): '''data_dict ontains text to be added. Key will be the title Value will be... well, the value :)''' self.box = gtk.HBox(False, 1) self._statusbar.pack_start(self.box, False, False, 1) ellipsize = pango.ELLIPSIZE_NONE for element in data_dict.keys(): # Element icon if element == 'processor': _icon = gtk.image_new_from_file( os.path.dirname(__file__) + os.sep + 'data' + os.sep + 'processor_small.png') self.box.pack_start(_icon, False, False, 0) else: _icon = gtk.image_new_from_stock(self.icons[element], gtk.ICON_SIZE_MENU) self.box.pack_start(_icon, False, False, 0) # Element label label = gtk.Label() label.set_markup('<b>' + element.capitalize() + ':</b>') label.set_padding(1, 5) label.set_max_width_chars(len(element) + 1) label.set_single_line_mode(True) label.set_ellipsize(ellipsize) self.box.pack_start(label, True, True, 1) # Element content label = gtk.Label(str(data_dict[element])) label.set_padding(1, 5) label.set_max_width_chars(len(str(data_dict[element]))) label.set_single_line_mode(True) label.set_ellipsize(ellipsize) self.box.pack_start(label, True, True, 1) sep = gtk.VSeparator() self.box.pack_start(sep, True, True, 1) if version: _icon = gtk.image_new_from_file( os.path.dirname(__file__) + os.sep + 'data' + os.sep + 'bokken-small.svg') self.pack_start(_icon, False, False, 1) label = gtk.Label() label.set_markup('<b>Bokken ' + version + '</b> (' + self.uicore.backend.capitalize() + ')') label.set_padding(3, 3) self.pack_end(label, False) self.show_all()
def _build_menuitem(menuitem): '''build a menu item from a abstract.Menu.Item''' gtk_menuitem = gtk.ImageMenuItem(menuitem.text) if menuitem.is_stock(): image = gtk.image_new_from_stock( stock.map_stock(menuitem.image, gtk.STOCK_MISSING_IMAGE), gtk.ICON_SIZE_MENU) gtk_menuitem.set_image(image) elif menuitem.is_image_path(): image = gtk.image_new_from_file(menuite.get_image_path(), gtk.ICON_SIZE_MENU) gtk_menuitem.set_image(image) if menuitem.accel: special_keys = 0 if menuitem.accel.ctrl: special_keys = special_keys | gtk.gdk.CONTROL_MASK if menuitem.accel.alt: special_keys = special_keys | gtk.gdk.MOD1_MASK gtk_menuitem.add_accelerator('activate', accel_group, ord(menuitem.accel.key), special_keys, gtk.ACCEL_VISIBLE) gtk_menuitem.connect('activate', _menu_item_cb, menuitem) menuitem.signal_connect("enabled", _set_sensitive, gtk_menuitem, True) menuitem.signal_connect("disabled", _set_sensitive, gtk_menuitem, False) return gtk_menuitem
def test_cpu(self): icon = gtk.image_new_from_file(ICON + "CPU.png") vbox = gtk.VBox() label = gtk.Label() label.set_alignment(0, 0) label.set_markup("<span foreground='#1C242D' font_desc='10'><b>%s</b></span>" % _("CPU performance")) vbox.pack_start(label, False, False) label = gtk.Label() label.set_alignment(0, 0) label.set_markup( "<span font_desc='10'>%s</span>" % _("Test CPU data operation ability, the smaller the data processing ability of CPU stronger.") ) vbox.pack_start(label, False, False) ebox = None if os.path.isfile(TEST_Z) and os.path.getsize(TEST_Z): data = open(TEST_Z).read() value = re.findall("cpu = (.*)", data)[0] ebox = gtk.EventBox() ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#FFFFFF")) ebox.connect("expose_event", self.expose_ebox, ICON + "val_bg.png") label = gtk.Label() label.set_markup("<span foreground='#FFFFFF' font_desc='10'>%s</span>" % value) ebox.add(label) return icon, vbox, ebox
def test_cpu(self): icon = gtk.image_new_from_file(ICON + "CPU.png") vbox = gtk.VBox() label = gtk.Label() label.set_alignment(0, 0) label.set_markup( "<span foreground='#1C242D' font_desc='10'><b>%s</b></span>" % _("CPU performance")) vbox.pack_start(label, False, False) label = gtk.Label() label.set_alignment(0, 0) label.set_markup("<span font_desc='10'>%s</span>" % _( "Test CPU data operation ability, the smaller the data processing ability of CPU stronger." )) vbox.pack_start(label, False, False) ebox = None if os.path.isfile(TEST_Z) and os.path.getsize(TEST_Z): data = open(TEST_Z).read() value = re.findall("cpu = (.*)", data)[0] ebox = gtk.EventBox() ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#FFFFFF")) ebox.connect("expose_event", self.expose_ebox, ICON + "val_bg.png") label = gtk.Label() label.set_markup( "<span foreground='#FFFFFF' font_desc='10'>%s</span>" % value) ebox.add(label) return icon, vbox, ebox
def test_card(self): icon = gtk.image_new_from_file(ICON + "CARD.png") vbox = gtk.VBox() label = gtk.Label() label.set_alignment(0, 0) label.set_markup("<span foreground='#1C242D' font_desc='10'><b>%s</b></span>" % _("Card performance")) vbox.pack_start(label, False, False) label = gtk.Label() label.set_alignment(0, 0) label.set_markup( "<span font_desc='10'>%s</span>" % _( "Test graphics screen refresh rate, the results of the larger the screen the more smooth the better game support." ) ) vbox.pack_start(label, False, False) ebox = None if os.path.isfile(TEST_Z) and os.path.getsize(TEST_Z): data = open(TEST_Z).read() value = re.findall("card = (.*)", data)[0] ebox = gtk.EventBox() ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#FFFFFF")) ebox.connect("expose_event", self.expose_ebox, ICON + "val_bg.png") label = gtk.Label() label.set_markup("<span foreground='#FFFFFF' font_desc='10'>%s</span>" % value) ebox.add(label) return icon, vbox, ebox
def unlock_tray(self, is_showing_dlg=[False]): try: from hashlib import sha1 as sha_hash except ImportError: from sha import new as sha_hash log.debug("Show tray lock dialog") if is_showing_dlg[0]: return is_showing_dlg[0] = True entered_pass = gtk.Entry(25) entered_pass.set_activates_default(True) entered_pass.set_width_chars(25) entered_pass.set_visibility(False) tray_lock = gtk.Dialog(title="", parent=self.window.window, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK)) tray_lock.set_default_response(gtk.RESPONSE_OK) tray_lock.set_has_separator(False) tray_lock.set_border_width(5) hbox = gtk.HBox(spacing=5) image = gtk.image_new_from_file(deluge.common.get_pixmap("lock48.png")) image.set_alignment(0.5, 0.0) hbox.pack_start(image, False) vbox = gtk.VBox(spacing=5) hbox.pack_start(vbox, False) label = gtk.Label("<b><big>%s</big></b>" % _("Deluge is password protected!")) label.set_use_markup(True) label.set_alignment(0.0, 0.5) label.set_line_wrap(True) vbox.pack_start(label, False) tlabel = gtk.Label("<i>%s</i>" % _("Enter your password to continue")) tlabel.set_use_markup(True) tlabel.set_alignment(0.0, 0.5) tlabel.set_line_wrap(True) vbox.pack_start(tlabel, False) vbox.pack_start(entered_pass) tray_lock.vbox.pack_start(hbox) def on_response(dialog, response_id): if response_id == gtk.RESPONSE_OK: if self.config["tray_password"] == sha_hash(entered_pass.get_text()).hexdigest(): self.window.present() tray_lock.destroy() is_showing_dlg[0] = False tray_lock.connect("response", on_response) tray_lock.show_all()
def create_filepath_hbox(self, label, value, trace, sensitivity_group, constraints=None): hbox_main = gtk.HBox() label_text = gtk.Label(label.title()) label_text.set_alignment(0, 0.5) label_text.set_padding(8, 8) entry_filepath = gtk.Entry() entry_filepath.set_text(value) button_select_folder = gtk.ToolButton( gtk.image_new_from_file( os.path.join(definitions.ICONS_DIR, "open_small.png"))) button_select_folder.connect("clicked", self.select_file, entry_filepath) hbox_main.pack_start(label_text) hbox_main.pack_start(entry_filepath) hbox_main.pack_start(button_select_folder) self.plugin_config_widgets.append(entry_filepath) self.plugin_config_traces.append(trace) sensitivity_group.append(label_text) sensitivity_group.append(entry_filepath) sensitivity_group.append(button_select_folder) return hbox_main
def test_wio(self): icon = gtk.image_new_from_file(ICON + "DISK.png") vbox = gtk.VBox() label = gtk.Label() label.set_alignment(0, 0) label.set_markup( "<span foreground='#1C242D' font_desc='10'><b>%s</b></span>" % _("Disk write performance")) vbox.pack_start(label, False, False) label = gtk.Label() label.set_alignment(0, 0) label.set_markup("<span font_desc='10'>%s</span>" % _( "Test hard disk write performance, the results of the greater of hard disk write the faster." )) vbox.pack_start(label, False, False) ebox = None if os.path.isfile(TEST_Z) and os.path.getsize(TEST_Z): data = open(TEST_Z).read() value = re.findall("w-io = (.*)", data)[0] ebox = gtk.EventBox() ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#FFFFFF")) ebox.connect("expose_event", self.expose_ebox, ICON + "val_bg.png") label = gtk.Label() label.set_markup( "<span foreground='#FFFFFF' font_desc='10'>%s/s</span>" % value) ebox.add(label) return icon, vbox, ebox
def __init__(self): super(Splash, self).__init__() # These two lines are required here to make sure that unity shows the # correct information in the menu self.set_icon_from_file(W3AF_ICON) self.set_title('w3af - 0wn the Web') vbox = gtk.VBox() self.add(vbox) # content splash = os.path.join(ROOT_PATH, 'core', 'ui', 'gui', 'data', 'splash.png') img = gtk.image_new_from_file(splash) vbox.pack_start(img) self.label = gtk.Label() vbox.pack_start(self.label) # Splash screen doesn't have decoration (at least where supported) # https://github.com/andresriancho/w3af/issues/9084 if not MacOSX.is_current_platform(): self.set_decorated(False) # color and position color = gtk.gdk.color_parse('#f2f2ff') self.modify_bg(gtk.STATE_NORMAL, color) self.set_position(gtk.WIN_POS_CENTER) self.set_size_request(644, 315) # ensure it is rendered immediately self.show_all() while gtk.events_pending(): gtk.main_iteration()
def __init__(self, parent): self._num = 0.0 self._den = 0 gtk.Window.__init__(self) self._progress = gtk.ProgressBar() exposong.log.debug("Initializing the splash screen.") vbox = gtk.VBox() self.set_title(_("Loading ExpoSong")) self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_SPLASHSCREEN) self.set_position(gtk.WIN_POS_CENTER) self.set_transient_for(parent) self.set_modal(True) # TODO This takes a while to show... not sure why. img = gtk.image_new_from_file(os.path.join(RESOURCE_PATH, 'exposong.png')) img.show_all() vbox.pack_start(img) self._progress.set_text(_('Loading, Please Wait.')) self._progress.set_fraction(0.0) vbox.pack_start(self._progress, True, False, 0) self.add(vbox) self.show_all()
def test_card(self): icon = gtk.image_new_from_file(ICON + "CARD.png") vbox = gtk.VBox() label = gtk.Label() label.set_alignment(0, 0) label.set_markup( "<span foreground='#1C242D' font_desc='10'><b>%s</b></span>" % _("Card performance")) vbox.pack_start(label, False, False) label = gtk.Label() label.set_alignment(0, 0) label.set_markup("<span font_desc='10'>%s</span>" % _( "Test graphics screen refresh rate, the results of the larger the screen the more smooth the better game support." )) vbox.pack_start(label, False, False) ebox = None if os.path.isfile(TEST_Z) and os.path.getsize(TEST_Z): data = open(TEST_Z).read() value = re.findall("card = (.*)", data)[0] ebox = gtk.EventBox() ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#FFFFFF")) ebox.connect("expose_event", self.expose_ebox, ICON + "val_bg.png") label = gtk.Label() label.set_markup( "<span foreground='#FFFFFF' font_desc='10'>%s</span>" % value) ebox.add(label) return icon, vbox, ebox
def __init__(self): gtk.Button.__init__(self) self.set_relief(gtk.RELIEF_NONE) self.set_focus_on_click(False) self.modify_bg(gtk.STATE_ACTIVE, COLOR_BLACK) path = os.path.join(constants.GFX_PATH, "media-record.png") self._rec_image = gtk.image_new_from_file(path) path = os.path.join(constants.GFX_PATH, "media-record-red.png") self._rec_red_image = gtk.image_new_from_file(path) path = os.path.join(constants.GFX_PATH, "media-insensitive.png") self._insensitive_image = gtk.image_new_from_file(path) self.set_normal()
def __init__(self): gtk.Window.__init__(self) self.set_title("ejemplo loco") self.set_default_size(400, 300) self.set_border_width(4) self.count = 0 vbox = gtk.VBox() bbox = gtk.HButtonBox() self.label = gtk.Label("hola mundo") image = gtk.image_new_from_file("winlogo.gif") ok_btn = gtk.Button(stock=gtk.STOCK_OK) cancel_btn = gtk.Button(stock=gtk.STOCK_CANCEL) bbox.pack_start(ok_btn) bbox.pack_start(cancel_btn) vbox.pack_start(self.label, True, True) vbox.pack_start(image, False) vbox.pack_start(bbox, False) self.add(vbox) vbox.show_all() self.connect('delete-event', gtk.main_quit) ok_btn.connect('clicked', self._on_ok_clicked) cancel_btn.connect('clicked', gtk.main_quit)
def __init__(self): super(Splash, self).__init__() # These two lines are required here to make sure that unity shows the # correct information in the menu self.set_icon_from_file(W3AF_ICON) self.set_title('w3af - 0wn the Web') vbox = gtk.VBox() self.add(vbox) # content img = gtk.image_new_from_file('core/ui/gui/data/splash.png') vbox.pack_start(img) self.label = gtk.Label() vbox.pack_start(self.label) # color and position self.set_decorated(False) color = gtk.gdk.color_parse('#f2f2ff') self.modify_bg(gtk.STATE_NORMAL, color) self.set_position(gtk.WIN_POS_CENTER) self.set_size_request(644, 315) # ensure it is rendered immediately self.show_all() while gtk.events_pending(): gtk.main_iteration()
def pop_up(self): for message in self.messages: item = gtk.ImageMenuItem() # the true label is set after with set_markup() if isinstance(message, DirectMessage): item.set_label( message.sender ) # used to track who sent the message in order to reply it. elif isinstance(message, Tweet): item.set_label(message.uid) # used to retweet the tweet item.set_image( gtk.image_new_from_file( os.path.abspath("./data/message_%s.png" % message.network))) text = "<b>%s</b>\n%s" % (message.sender, message.text) item.get_children()[0].set_markup(text) if self.callback: # for tweets posted by the user, there is not callback to be set item.connect('activate', self.callback) self.append(item) # add a separator if mail is not last in list if self.messages.index(message) != len(self.messages) - 1: separator = gtk.SeparatorMenuItem() self.append(separator) self.show_all() self.popup(parent_menu_shell=None, parent_menu_item=None, func=self.get_xy, data=(400, 400), button=1, activate_time=0)
def __init__(self): super(Splash, self).__init__() # These two lines are required here to make sure that unity shows the # correct information in the menu self.set_icon_from_file(W3AF_ICON) self.set_title('w3af - 0wn the Web') vbox = gtk.VBox() self.add(vbox) # content splash = os.path.join(ROOT_PATH, 'core', 'ui', 'gui', 'data', 'splash.png') img = gtk.image_new_from_file(splash) vbox.pack_start(img) self.label = gtk.Label() vbox.pack_start(self.label) # color and position self.set_decorated(False) color = gtk.gdk.color_parse('#f2f2ff') self.modify_bg(gtk.STATE_NORMAL, color) self.set_position(gtk.WIN_POS_CENTER) self.set_size_request(644, 315) # ensure it is rendered immediately self.show_all() while gtk.events_pending(): gtk.main_iteration()
def __init_values(self): hseparator_color = [(0, ("#777777", 0.0)), (0.5, ("#000000", 0.3)), (1, ("#777777", 0.0)) ] self.height = 0 self.size_check = False self.hbox = gtk.HBox() self.title_image = gtk.image_new_from_file(os.path.join(image_path, "image/usb/usb_label.png")) self.title_label = gtk.Label(_("Storage Device")) #self.title_label.connect("expose-event", self.title_label_expose_event) self.title_label_ali = gtk.Alignment(0, 0, 0, 0) self.title_label_ali.set_padding(0, 0, 0, 0) self.title_label_ali.add(self.title_label) self.hbox.pack_start(self.title_image, False, False) self.hbox.pack_start(self.title_label_ali, True, True) self.h_separator_top = HSeparator(hseparator_color, 0, 0) self.h_separator_ali = gtk.Alignment(1, 1, 1, 1) self.h_separator_ali.set_padding(5, 10, 0, 0) self.h_separator_ali.add(self.h_separator_top) self.monitor_vbox = gtk.VBox() self.vbox = gtk.VBox() self.vbox.pack_start(self.hbox, False, False) self.vbox.pack_start(self.h_separator_ali, True, True) self.vbox.pack_start(self.monitor_vbox, True, True) self._ask_confirmed = False self.monitor = gio.VolumeMonitor() self.op = gio.MountOperation()
def about_dialog(name, version, copyright, comments, license, website, authors, translators, logo_path): '''show an about dialog of the application: * title: the title of the window * name: the name of the appliaction * version: version as string * copyright: the name of the copyright holder * comments: a description of the application * license: the license text * website: the website url * authors: a list or tuple of strings containing the contributors * translators: a string containing the translators ''' def close_about(widget, response_id): if response_id == gtk.RESPONSE_CANCEL: widget.destroy() about = gtk.AboutDialog() about.set_name(name) about.set_version(version) about.set_copyright(copyright) about.set_comments(comments) about.connect('response', close_about) about.set_license(license) about.set_website(website) about.set_authors(authors) about.set_translator_credits(translators) icon = gtk.image_new_from_file(logo_path) about.set_icon(icon) about.set_logo(icon) about.run()
def __init__(self): gtk.Window.__init__(self, gtk.WINDOW_POPUP) self.set_position(gtk.WIN_POS_CENTER) vbox = gtk.VBox() vbox.set_border_width(4) self.add(vbox) self.image = gtk.image_new_from_file( os.path.join(PIXMAPS_DIR, "pm-logo.png")) self.label = gtk.Label("<span size='x-large'><b>" \ "PacketManipulator %s" \ "</b></span>" % PM_VERSION) self.label.set_use_markup(True) hbox = gtk.HBox() hbox.set_spacing(20) hbox.pack_start(self.image, False, False) hbox.pack_start(self.label) self.progress = gtk.ProgressBar() self.progress.set_text("Loading modules ...") vbox.pack_start(hbox) vbox.pack_start(self.progress, False, False) self.finished = False gobject.timeout_add(200, self.__pulse_bar)
def add_macro(self, config_name, modulename, classname, methodname, help, image_path, run_macro): """Add a macro to the macro menu.""" macro_address = '/TopMenuBar/Metadata' macro_menu = self.uimanager.get_widget(macro_address).get_submenu() if methodname == rose.macro.VALIDATE_METHOD: all_v_item = self.uimanager.get_widget(macro_address + "/All V") all_v_item.set_sensitive(True) config_menu_name = config_name.replace('/', ':').replace('_', '__') config_label_name = config_name.split('/')[-1].replace('_', '__') label = rose.config_editor.TOP_MENU_METADATA_MACRO_CONFIG.format( config_label_name) config_address = macro_address + '/' + config_menu_name config_item = self.uimanager.get_widget(config_address) if config_item is None: actiongroup = self.uimanager.get_action_groups()[0] if actiongroup.get_action(config_menu_name) is None: actiongroup.add_action(gtk.Action(config_menu_name, label, None, None)) new_ui = """<ui><menubar name="TopMenuBar"> <menu action="Metadata"> <menuitem action="{0}"/></menu></menubar> </ui>""".format(config_menu_name) self.macro_ids.append(self.uimanager.add_ui_from_string(new_ui)) config_item = self.uimanager.get_widget(config_address) if image_path is not None: image = gtk.image_new_from_file(image_path) config_item.set_image(image) if config_item.get_submenu() is None: config_item.set_submenu(gtk.Menu()) macro_fullname = ".".join([modulename, classname, methodname]) macro_fullname = macro_fullname.replace("_", "__") if methodname == rose.macro.VALIDATE_METHOD: stock_id = gtk.STOCK_DIALOG_QUESTION else: stock_id = gtk.STOCK_CONVERT macro_item = gtk.ImageMenuItem(stock_id=stock_id) macro_item.set_label(macro_fullname) macro_item.set_tooltip_text(help) macro_item.show() macro_item._run_data = [config_name, modulename, classname, methodname] macro_item.connect("activate", lambda i: run_macro(*i._run_data)) config_item.get_submenu().append(macro_item) if (methodname == rose.macro.VALIDATE_METHOD): for item in config_item.get_submenu().get_children(): if hasattr(item, "_rose_all_validators"): return False all_item = gtk.ImageMenuItem(gtk.STOCK_DIALOG_QUESTION) all_item._rose_all_validators = True all_item.set_label(rose.config_editor.MACRO_MENU_ALL_VALIDATORS) all_item.set_tooltip_text( rose.config_editor.MACRO_MENU_ALL_VALIDATORS_TIP) all_item.show() all_item._run_data = [config_name, None, None, methodname] all_item.connect("activate", lambda i: run_macro(*i._run_data)) config_item.get_submenu().prepend(all_item)
def _mkbrushbt(self, frame, brush): if brush.icon: icon_image = gtk.image_new_from_file(brush.icon) pixbuf = icon_image.get_pixbuf() width = pixbuf.get_property('width') height = pixbuf.get_property('height') else: self._drawbrush.set_from_brush(brush) width = 128 height = 60 buf = self._drawbrush.paint_rgb_preview( width, height, fmt=_pixbuf.FORMAT_RGBA8_NOA) pixbuf = gdk.pixbuf_new_from_data(buf, gdk.COLORSPACE_RGB, True, 8, buf.width, buf.height, buf.stride) icon_image = gtk.image_new_from_pixbuf(pixbuf) bt = gtk.ToggleButton() bt.set_image(icon_image) bt.set_size_request(width + 15, height + 5) bt.show_all() bt.connect('clicked', self._on_brush_bt_clicked) bt.connect('button-release-event', self._on_brush_bt_released) bt.brush = brush bt.bt2 = None # button in another page if it has been added t = frame.table x = t.count % TABLE_WIDTH y = t.count / TABLE_WIDTH frame.table.attach(bt, x, x + 1, y, y + 1, gtk.FILL, gtk.FILL, 1, 1) t.count += 1 return bt
def __init__(self): gtk.Button.__init__(self) self.set_relief(gtk.RELIEF_NONE) self.set_focus_on_click(False) self.modify_bg(gtk.STATE_ACTIVE, COLOR_BLACK) path = os.path.join(constants.GFX_PATH, 'media-record.png') self._rec_image = gtk.image_new_from_file(path) path = os.path.join(constants.GFX_PATH, 'media-record-red.png') self._rec_red_image = gtk.image_new_from_file(path) path = os.path.join(constants.GFX_PATH, 'media-insensitive.png') self._insensitive_image = gtk.image_new_from_file(path) self.set_normal()
def __init_values(self): hseparator_color = [(0, ("#777777", 0.0)), (0.5, ("#000000", 0.3)), (1, ("#777777", 0.0))] self.height = 0 self.size_check = False self.hbox = gtk.HBox() self.title_image = gtk.image_new_from_file(os.path.join(image_path, "image/usb/usb_label.png")) self.title_label = gtk.Label(_("Storage Device")) # self.title_label.connect("expose-event", self.title_label_expose_event) self.title_label_ali = gtk.Alignment(0, 0, 0, 0) self.title_label_ali.set_padding(0, 0, 0, 0) self.title_label_ali.add(self.title_label) self.hbox.pack_start(self.title_image, False, False) self.hbox.pack_start(self.title_label_ali, True, True) self.h_separator_top = HSeparator(hseparator_color, 0, 0) self.h_separator_ali = gtk.Alignment(1, 1, 1, 1) self.h_separator_ali.set_padding(5, 10, 0, 0) self.h_separator_ali.add(self.h_separator_top) self.monitor_vbox = gtk.VBox() self.vbox = gtk.VBox() self.vbox.pack_start(self.hbox, False, False) self.vbox.pack_start(self.h_separator_ali, True, True) self.vbox.pack_start(self.monitor_vbox, True, True) self._ask_confirmed = False self.monitor = gio.VolumeMonitor() self.op = gio.MountOperation()
def test_wio(self): icon = gtk.image_new_from_file(ICON + "DISK.png") vbox = gtk.VBox() label = gtk.Label() label.set_alignment(0, 0) label.set_markup("<span foreground='#1C242D' font_desc='10'><b>%s</b></span>" % _("Disk write performance")) vbox.pack_start(label, False, False) label = gtk.Label() label.set_alignment(0, 0) label.set_markup( "<span font_desc='10'>%s</span>" % _("Test hard disk write performance, the results of the greater of hard disk write the faster.") ) vbox.pack_start(label, False, False) ebox = None if os.path.isfile(TEST_Z) and os.path.getsize(TEST_Z): data = open(TEST_Z).read() value = re.findall("w-io = (.*)", data)[0] ebox = gtk.EventBox() ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#FFFFFF")) ebox.connect("expose_event", self.expose_ebox, ICON + "val_bg.png") label = gtk.Label() label.set_markup("<span foreground='#FFFFFF' font_desc='10'>%s/s</span>" % value) ebox.add(label) return icon, vbox, ebox
def __init__(self, inbox): gtk.Menu.__init__(self) # get all mail from inbox for mail in inbox: # create label menu with markups string = '<b>' + html_escape(mail['author']) + ':</b>\n' # check if mail has subject / title if mail['title'] == None or len(mail['title']) == 0: string += '<i>(' + _('No Subject') + ')</i>' elif len(mail['title']) > 80: string += html_escape(mail['title'][:77]) + '...' else: string += html_escape(mail['title']) menu_item = gtk.ImageMenuItem() # the true label is set after with set_markup() menu_item.set_label('') try: menu_item.set_image(gtk.image_new_from_file('./img/menu-gmail.png')) except: menu_item.set_image(gtk.Image.new_from_file('./img/menu-gmail.png')) menu_item.get_children()[0].set_markup(string) menu_item.url = mail['link'] menu_item.connect('activate', self.open_mail, mail) self.append(menu_item) menu_item.show() # add a separator if mail is not last in list if inbox.index(mail) != len(inbox) - 1: sep = gtk.SeparatorMenuItem() self.append(sep) sep.show() self.show()
def enable(self): self.relevant_sections = [Section.VIDEO_UNCUT, Section.VIDEO_CUT, Section.ARCHIVE] self.toolbutton = self.gui.main_window.add_toolbutton(gtk.image_new_from_file(self.get_path('play.png')), 'Abspielen', self.relevant_sections) self.toolbutton.connect('clicked', self.on_play_clicked) self.row_activate_id = self.gui.main_window.builder.get_object('treeview_files').connect('row-activated', self.on_row_activated)
def Render(self): # get the previous track from the parent sequence (if any) pixels_per_second = self.parent.get_pixels_per_second() y_top = 22 # get a reference to the 2 main canvas objects & theme theme = self.parent.project.theme canvas_left = self.parent.project.form.TimelineCanvas_Left canvas_right = self.parent.project.form.TimelineCanvas_Right # Add an item to the goocanvas root_left = canvas_left.get_root_item() root_right = canvas_right.get_root_item() # load marker image imgMarker = gtk.image_new_from_file( "%s/libreshot/themes/%s/marker.png" % (self.parent.project.form.libreshot_path, theme)) imgMarker_Width = imgMarker.get_pixbuf().get_width() offset = float(imgMarker_Width) / float(2.0) # determine position x = pixels_per_second * self.position_on_track # Add Left Image to Group image1 = goocanvas.Image(parent=root_right, pixbuf=imgMarker.get_pixbuf(), x=x - offset, y=y_top) # attach button click event to marker image image1.connect("button_press_event", self.on_marker_press)
def add_macro(self, config_name, modulename, classname, methodname, help_, image_path, run_macro): """Add a macro to the macro menu.""" macro_address = '/TopMenuBar/Metadata' self.uimanager.get_widget(macro_address).get_submenu() if methodname == rose.macro.VALIDATE_METHOD: all_v_item = self.uimanager.get_widget(macro_address + "/All V") all_v_item.set_sensitive(True) config_menu_name = config_name.replace('/', ':').replace('_', '__') config_label_name = config_name.split('/')[-1].replace('_', '__') label = rose.config_editor.TOP_MENU_METADATA_MACRO_CONFIG.format( config_label_name) config_address = macro_address + '/' + config_menu_name config_item = self.uimanager.get_widget(config_address) if config_item is None: actiongroup = self.uimanager.get_action_groups()[0] if actiongroup.get_action(config_menu_name) is None: actiongroup.add_action(gtk.Action(config_menu_name, label, None, None)) new_ui = """<ui><menubar name="TopMenuBar"> <menu action="Metadata"> <menuitem action="{0}"/></menu></menubar> </ui>""".format(config_menu_name) self.macro_ids.append(self.uimanager.add_ui_from_string(new_ui)) config_item = self.uimanager.get_widget(config_address) if image_path is not None: image = gtk.image_new_from_file(image_path) config_item.set_image(image) if config_item.get_submenu() is None: config_item.set_submenu(gtk.Menu()) macro_fullname = ".".join([modulename, classname, methodname]) macro_fullname = macro_fullname.replace("_", "__") if methodname == rose.macro.VALIDATE_METHOD: stock_id = gtk.STOCK_DIALOG_QUESTION else: stock_id = gtk.STOCK_CONVERT macro_item = gtk.ImageMenuItem(stock_id=stock_id) macro_item.set_label(macro_fullname) macro_item.set_tooltip_text(help_) macro_item.show() macro_item._run_data = [config_name, modulename, classname, methodname] macro_item.connect("activate", lambda i: run_macro(*i._run_data)) config_item.get_submenu().append(macro_item) if (methodname == rose.macro.VALIDATE_METHOD): for item in config_item.get_submenu().get_children(): if hasattr(item, "_rose_all_validators"): return False all_item = gtk.ImageMenuItem(gtk.STOCK_DIALOG_QUESTION) all_item._rose_all_validators = True all_item.set_label(rose.config_editor.MACRO_MENU_ALL_VALIDATORS) all_item.set_tooltip_text( rose.config_editor.MACRO_MENU_ALL_VALIDATORS_TIP) all_item.show() all_item._run_data = [config_name, None, None, methodname] all_item.connect("activate", lambda i: run_macro(*i._run_data)) config_item.get_submenu().prepend(all_item)
def new_page(self, tab_name, tab_image, page): """""" vbox = gtk.VBox() vbox.pack_start(gtk.image_new_from_file(tab_image)) vbox.pack_start(gtk.Label(tab_name)) vbox.show_all() self.notebook.append_page(page, vbox) self.notebook.set_tab_label_packing(page, True, True, gtk.PACK_START)
def __init__(self): gtk.EventBox.__init__(self) self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#ededed")) '''logo''' logo = gtk.image_new_from_file("res/top.png") align = self.define_align(logo) align.set_padding(20, 20, 20, 0) self.add(align)
def get_image_button(img_file_name, width, height): button = gtk.Button() icon = gtk.image_new_from_file(respaths.IMAGE_PATH + img_file_name) button_box = gtk.HBox() button_box.pack_start(icon, False, False, 0) button.add(button_box) button.set_size_request(width, height) return button
def __init__(self): super(PlayButton, self).__init__() self.set_relief(gtk.RELIEF_NONE) self.set_focus_on_click(False) self.modify_bg(gtk.STATE_ACTIVE, Constants.color_black.gColor) path = os.path.join(Constants.GFX_PATH, 'media-play.png') self._play_image = gtk.image_new_from_file(path) self.set_image(self._play_image)
def _create_monitor_buttons(self): # Monitor switch buttons self.sequence_editor_b = gtk.RadioButton(None) #, _("Timeline")) self.sequence_editor_b.set_mode(False) self.sequence_editor_b.set_image( gtk.image_new_from_file(IMG_PATH + "timeline_button.png")) self.sequence_editor_b.connect( "clicked", lambda w, e: self._monitor_switch_handler(w), None) self.sequence_editor_b.set_size_request(100, 25) self.clip_editor_b = gtk.RadioButton( self.sequence_editor_b) #,_("Clip")) self.clip_editor_b.set_mode(False) self.clip_editor_b.set_image( gtk.image_new_from_file(IMG_PATH + "clip_button.png")) self.clip_editor_b.connect( "clicked", lambda w, e: self._monitor_switch_handler(w), None) self.clip_editor_b.set_size_request(100, 25)
def __init__(self, view_editor): gtk.ToggleButton.__init__(self) icon = gtk.image_new_from_file(respaths.IMAGE_PATH + "guides_view_switch.png") self.set_image(icon) self.view_editor = view_editor self.set_active(True) self.connect("clicked", lambda w: self._clicked())