本文整理汇总了Python中quodlibet.util.bold函数的典型用法代码示例。如果您正苦于以下问题:Python bold函数的具体用法?Python bold怎么用?Python bold使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bold函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __drag_data_received
def __drag_data_received(self, view, ctx, x, y, sel, tid, etime):
view.emit_stop_by_name('drag-data-received')
targets = [
("text/uri-list", 0, DND_URI_LIST),
("text/x-moz-url", 0, DND_MOZ_URL)
]
targets = [Gtk.TargetEntry.new(*t) for t in targets]
view.drag_dest_set(Gtk.DestDefaults.ALL, targets, Gdk.DragAction.COPY)
if tid == DND_URI_LIST:
uri = sel.get_uris()[0]
elif tid == DND_MOZ_URL:
uri = sel.data.decode('utf16', 'replace').split('\n')[0]
else:
ctx.finish(False, False, etime)
return
ctx.finish(True, False, etime)
feed = Feed(uri.encode("ascii", "replace"))
feed.changed = feed.parse()
if feed:
self.__feeds.append(row=[feed])
AudioFeeds.write()
else:
ErrorMessage(
self, _("Unable to add feed"),
_("%s could not be added. The server may be down, "
"or the location may not be an audio feed.") %
util.bold(util.escape(feed.uri))).run()
示例2: __refresh_space
def __refresh_space(self, device):
try:
space, free = device.get_space()
except NotImplementedError:
self.__device_space.set_text("")
self.__progress.hide()
else:
used = space - free
fraction = float(used) / space
self.__device_space.set_markup(
_("%(used-size)s used, %(free-size)s available") %
{"used-size": util.bold(util.format_size(used)),
"free-size": util.bold(util.format_size(free))})
self.__progress.set_fraction(fraction)
self.__progress.set_text("%.f%%" % round(fraction * 100))
self.__progress.show()
示例3: __check_device
def __check_device(self, device, message):
if not device.is_connected():
qltk.WarningMessage(
self, message,
_("%s is not connected.") %
util.bold(util.escape(device['name']))
).run()
return False
return True
示例4: open_location
def open_location(self, action):
name = GetStringDialog(self, _("Add a Location"),
_("Enter the location of an audio file:"),
okbutton=Gtk.STOCK_ADD).run()
if name:
if not util.uri_is_valid(name):
ErrorMessage(
self, _("Unable to add location"),
_("%s is not a valid location.") % (
util.bold(util.escape(name)))).run()
elif not app.player.can_play_uri(name):
ErrorMessage(
self, _("Unable to add location"),
_("%s uses an unsupported protocol.") % (
util.bold(util.escape(name)))).run()
else:
if name not in self.__library:
self.__library.add([RemoteFile(name)])
示例5: __eject
def __eject(self, button):
model, iter = self.__view.get_selection().get_selected()
if iter:
device = model[iter][0]
status = device.eject()
if status is not True:
msg = _("Ejecting %s failed.") % util.bold(device['name'])
if status:
msg += "\n\n%s" % status
qltk.ErrorMessage(self, _("Unable to eject device"), msg).run()
示例6: __copy_songs
def __copy_songs(self, songs):
model, iter = self.__view.get_selection().get_selected()
if not iter:
return False
device = model[iter][0]
if not self.__check_device(device, _("Unable to copy songs")):
return False
self.__busy = True
wlb = self.__statusbar
wlb.setup(
len(songs),
_("Copying %(song)s") % {'song': '<b>%(song)s</b>'},
{'song': ''})
wlb.show()
for song in songs:
label = util.escape(song('~artist~title'))
if wlb.step(song=label):
wlb.hide()
break
space, free = device.get_space()
if free < os.path.getsize(song['~filename']):
wlb.hide()
qltk.WarningMessage(
self, _("Unable to copy song"),
_("There is not enough free space for this song.")
).run()
break
status = device.copy(self, song)
if isinstance(status, AudioFile):
try:
self.__cache[device.bid].append(song)
except KeyError:
pass
self.__refresh_space(device)
else:
msg = _("%s could not be copied.") % util.bold(label)
if type(status) == unicode:
msg += "\n\n" + util.escape(status)
qltk.WarningMessage(self, _("Unable to copy song"), msg).run()
if device.cleanup and not device.cleanup(wlb, 'copy'):
pass
else:
wlb.hide()
self.__busy = False
return True
示例7: __new_feed
def __new_feed(self, activator):
feed = AddFeedDialog(self).run()
if feed is not None:
feed.changed = feed.parse()
if feed:
self.__feeds.append(row=[feed])
AudioFeeds.write()
else:
ErrorMessage(
self, _("Unable to add feed"),
_("%s could not be added. The server may be down, "
"or the location may not be an audio feed.") %
util.bold(util.escape(feed.uri))).run()
示例8: __delete_songs
def __delete_songs(self, songs):
model, iter = self.__view.get_selection().get_selected()
if not iter:
return False
device = model[iter][0]
if not self.__check_device(device, _("Unable to delete songs")):
return False
dialog = DeleteDialog.for_songs(self, songs)
if dialog.run() != DeleteDialog.RESPONSE_DELETE:
return False
self.__busy = True
wlb = self.__statusbar
wlb.setup(
len(songs),
_("Deleting %(song)s") % {"song": "<b>%(song)s</b>"},
{'song': ''})
wlb.show()
for song in songs:
label = util.escape(song('~artist~title'))
if wlb.step(song=label):
wlb.hide()
break
status = device.delete(self, song)
if status is True:
try:
self.__cache[device.bid].remove(song)
except (KeyError, ValueError):
pass
self.__refresh_space(device)
else:
msg = _("%s could not be deleted.") % util.bold(label)
if type(status) == unicode:
msg += "\n\n%s" % status
qltk.WarningMessage(
self, _("Unable to delete song"), msg).run()
if device.cleanup and not device.cleanup(wlb, 'delete'):
pass
else:
wlb.hide()
self.__busy = False
示例9: schedule_change
def schedule_change(self, album):
if self.delay:
srcid = GLib.timeout_add(1000 * self.delay,
self.change_album, album)
if notif is None:
return
task = notif.Task(_("Random Album"),
_("Waiting to start %s") %
util.bold(util.escape(album("album"))),
stop=lambda: GLib.source_remove(srcid))
def countdown():
for i in range(10 * self.delay):
task.update(i / (10. * self.delay))
yield True
task.finish()
yield False
GLib.timeout_add(100, next, countdown())
else:
self.change_album(album)
示例10: __drag_data_received
def __drag_data_received(self, widget, ctx, x, y, sel, tid, etime):
assert tid == DND_URI_LIST
uris = sel.get_uris()
dirs = []
error = False
for uri in uris:
try:
uri = URI(uri)
except ValueError:
continue
if uri.is_filename:
loc = os.path.normpath(uri.filename)
if os.path.isdir(loc):
dirs.append(loc)
else:
loc = os.path.realpath(loc)
if loc not in self.__library:
self.__library.add_filename(loc)
elif app.player.can_play_uri(uri):
if uri not in self.__library:
self.__library.add([RemoteFile(uri)])
else:
error = True
break
Gtk.drag_finish(ctx, not error, False, etime)
if error:
ErrorMessage(
self, _("Unable to add songs"),
_("%s uses an unsupported protocol.") % util.bold(uri)).run()
else:
if dirs:
copool.add(
self.__library.scan, dirs,
cofuncid="library", funcid="library")
示例11: test_format
def test_format(self):
self.assertEqual(util.bold("foo"), "<b>foo</b>")
self.assertEqual(util.italic("foo"), "<i>foo</i>")
self.assertEqual(util.monospace("foo"), "<tt>foo</tt>")