本文整理汇总了Python中gui.PopupBox.PopupBox类的典型用法代码示例。如果您正苦于以下问题:Python PopupBox类的具体用法?Python PopupBox怎么用?Python PopupBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PopupBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getMameItemInfoList
def getMameItemInfoList(mame_files, mame_cmd):
items = []
rm_files = []
print "Call MAME command : %s" % mame_cmd
# Only build the cache if it doesn't exis.
if not os.path.isfile(config.GAMES_MAME_CACHE):
waitmsg = PopupBox(text=_('Generating MAME cache, please wait.'))
waitmsg.show()
mame_ok = updateMameRomList(mame_cmd)
waitmsg.destroy()
if not mame_ok:
return (mame_files, [])
mameRomList = getMameRomList()
roms = mameRomList.getMameRoms()
for romfile in mame_files:
key = os.path.splitext(os.path.basename(romfile))[0]
if roms.has_key(key):
rom = roms[key]
info = { 'manufacturer': rom.manufacturer,
'name': rom.name,
'description': rom.description,
'year': rom.year,
'cloneof': rom.cloneof,
'romof': rom.romof }
items += [(rom.description, romfile, None, info)]
rm_files.append(romfile)
return (rm_files, items)
示例2: image_list
def image_list(parent, title, user):
"""Get the image list for a specific user"""
logger.log( 9, 'image_list(parent=%r, title=%r, user=%r)', parent, title, user)
items = []
web = 'http://www.flickr.com/services/rest/?method=flickr.people.getPublicPhotos&user_id=' + user + \
'&format=json&api_key=' + config.FLICKR_KEY + '&per_page=' + str(config.FLICKR_LIMIT) + \
'&page=1&extras=original_format'
url=urllib.urlopen(web)
flickr=url.read()
flickr=flickr.replace("jsonFlickrApi(","");
data = json.read(flickr[:-1])
for foto in data['photos']['photo']:
#items.append(ImageItem(y[1],parent,foto["title"]))
mi = menu.MenuItem(foto["title"], parent.showimage, 0)
mi.arg = (foto["title"],"http://farm3.static.flickr.com/" + foto["server"] + "/" + \
foto["id"] + "_" + foto["originalsecret"] + "_o.jpg",foto["id"])
imagen = 'http://farm3.static.flickr.com/' + foto['server'] + '/' + foto['id'] + '_' + foto['secret'] + '_m.jpg'
file = config.FLICKR_DIR + '/' + foto['id'].replace('-','_') + '_t.jpg'
if not os.path.exists(file):
box = PopupBox(_('Downloading thumbnail for picture "') + foto['title'] + '"', width=800)
box.show()
urllib.urlretrieve(imagen,file)
box.destroy()
mi.image = file
items.append(mi)
return items
示例3: create_podcast_menu
def create_podcast_menu(self, arg=None, menuw=None):
popup = PopupBox(text=_("Fetching podcast..."))
popup.show()
podcast_menu_items = []
for location in config.APODCAST_LOCATIONS:
url = location[1]
image_path = os.path.join(config.APODCAST_DIR, location[0], "cover.jpg")
if self.check_logo(image_path):
p = podcast()
p.open_rss(url)
p.rss_title()
name = p.rss_title
image_url = p.rss_image
self.download(image_url, image_path)
if len(config.APODCAST_DIR) == 0:
podcast_items += [menu.MenuItem(_("Set APODCAST_DIR in local_conf.py"), menwu.back_one_menu, 0)]
podcast_menu_items += [
menu.MenuItem(_(location[0]), action=self.create_podcast_submenu, arg=location, image=image_path)
]
popup.destroy()
podcast_main_menu = menu.Menu(_("AUDIO PODCAST"), podcast_menu_items)
menuw.pushmenu(podcast_main_menu)
menuw.refresh()
示例4: show_choices
def show_choices(self, menuw, info):
items = []
soup = BeautifulStoneSoup(info,selfClosingTags=['feat'])
results = soup.findAll('result')
for result in results[:20]:
# for performance reasons show the first possibilities only,
# the more sensible hits are at the beginning of the list
hid = result['hid']
title = result.titleTag.string.replace('&', '&')
artist = result.artistTag.nameTag.string.replace('&','&')
items.append(menu.MenuItem('%s - %s' % (title, artist),
action=self.fetch_lyric, arg=hid))
if len(items) > 0:
msgtext = _('No exact match. ')
msgtext+= _('Here are some sugestions.')
box = PopupBox(text = msgtext)
box.show()
time.sleep(2)
box.destroy()
choices_menu = menu.Menu(_('Choices'), items)
menuw.pushmenu(choices_menu)
else:
box = PopupBox(text= _('Lyrics not found, sorry...'))
box.show()
time.sleep(3)
box.destroy()
示例5: cover_create
def cover_create(self, arg=None, menuw=None):
"""
create cover file for the item
"""
import directory
box = PopupBox(text= _('getting data...'))
box.show()
#filename = os.path.splitext(self.item.filename)[0]
if self.item.type == 'audiocd':
filename = '%s/disc/metadata/%s.jpg' % (config.OVERLAY_DIR, self.item.info['id'])
elif self.item.type == 'dir':
filename = os.path.join(self.item.dir, 'cover.jpg')
else:
filename = '%s/cover.jpg' % (os.path.dirname(self.item.filename))
fp = urllib2.urlopen(str(arg))
m = vfs.open(filename,'wb')
m.write(fp.read())
m.close()
fp.close()
# try to crop the image to avoid ugly borders
try:
image = imlib2.open(filename)
width, height = image.size
image.crop((2, 2), (width-4, height-4)).save(filename)
util.cache_image(filename)
except Exception, why:
logger.warning(why)
示例6: create_podcast_submenu
def create_podcast_submenu(self, arg=None, menuw=None, image=None):
popup = PopupBox(text=_("Fetching podcasts..."))
popup.show()
url = arg[1]
p = podcast()
p.open_rss(url)
p.rss_title()
p.rss_count()
image = os.path.join(config.APODCAST_DIR, arg[0], "cover.jpg")
podcast_items = []
for pc_location in range(p.rss.count):
p.rss_item(pc_location)
podcast_item = ApodcastItem()
podcast_item.name = p.title
podcast_item.url = p.enclosure
podcast_item.type = "audio"
podcast_item.description = p.description
podcast_item.image = image
podcast_item.mplayer_options = ""
podcast_item.filename = os.path.join(config.APODCAST_DIR, arg[0], os.path.split(p.enclosure)[1])
podcast_item.network_play = 1
podcast_item.length = 0
podcast_item.remain = 0
podcast_item.elapsed = 0
podcast_item.info = {"album": "", "artist": "", "trackno": "", "title": ""}
podcast_items += [podcast_item]
popup.destroy()
if len(podcast_items) == 0:
podcast_items += [menu.MenuItem(_("No Podcast locations found"), menwu.back_one_menu, 0)]
podcast_sub_menu = menu.Menu(_("AUDIO PODCAST"), podcast_items)
menuw.pushmenu(podcast_sub_menu)
menuw.refresh()
示例7: search_lyrics
def search_lyrics(self, arg=None, menuw=None):
box = PopupBox(text=_('Searching lyrics...'))
box.show()
result_code = -1
try:
url = "http://api.leoslyrics.com/api_search.php?auth=%s&artist=%s&songtitle=%s"%(
LEOLYRICS_AUTH,
urllib.quote(self.item.info['artist'].encode('utf-8')),
urllib.quote(self.item.info['title'].encode('utf-8')))
logger.log( 9, url)
info = urllib2.urlopen(url).read()
result_code = re.search('.+<response code="(\d)">.+',info).group(1)
except:
print "Error searching for artist/title."
box.destroy()
if result_code == '0': #ok
#get the hid
filter_info = re.search('.+hid="(.+)" exactMatch="true".+', info)
if filter_info:
# there is a exact match
self.fetch_lyric(arg=filter_info.group(1), menuw=menuw)
else:
# open a submenu with choices
self.show_choices(menuw=menuw, info= info)
else:
box = PopupBox(text=_('Lyrics not found, sorry...'))
box.show()
time.sleep(2)
box.destroy()
示例8: cover_search_file
def cover_search_file(self, arg=None, menuw=None):
"""
search Amazon for this item
"""
logger.debug('cover_search_file(arg=%r, menuw=%r)', arg, menuw)
box = PopupBox(text=_('searching Amazon...'))
box.show()
album = self.item.getattr('album')
if not album:
album = self.item.getattr('title')
artist = self.item.getattr('artist')
# Maybe the search string need encoding to config.LOCALE
search_string = '%s %s' % (artist.encode(config.AMAZON_QUERY_ENCODING),
album.encode(config.AMAZON_QUERY_ENCODING))
search_string = re.sub('[\(\[].*[\)\]]', '', search_string)
logger.debug('search_string=%r', search_string)
try:
cover = amazon.ItemSearch(search_string, SearchIndex='Music', ResponseGroup='Images,ItemAttributes')
except amazon.AWSException, why:
box.destroy()
title = '\n'.join([artist, album])
dict_tmp = { 'artist': artist, 'album': album }
print '%(artist)s - %(album)s' % (dict_tmp)
print '%r' % why
box = PopupBox(text=artist+'\n'+album+'\n'+why[:40])
box.show()
time.sleep(2)
box.destroy()
return
示例9: fetchheadlinesfromurl
def fetchheadlinesfromurl(self):
headlines = []
popup = PopupBox(text=_('Fetching headlines...'))
popup.show()
try:
# parse the document
doc = util.feedparser.parse(self.url)
if doc.status < 400:
for entry in doc['entries']:
try:
title = Unicode(entry.title)
link = Unicode(entry.link)
if entry.has_key('content') and len(entry['content']) >= 1:
description = Unicode(entry['content'][0].value)
else:
description = Unicode(entry['summary_detail'].value)
headlines.append((title, link, description))
except AttributeError:
pass
else:
logger.debug('Error %s, getting %r', doc.status, self.url)
#write the file
if len(headlines) > 0:
pfile = os.path.join(self.cachedir, 'headlines-%i' % self.location_index)
util.save_pickle(headlines, pfile)
finally:
popup.destroy()
return headlines
示例10: selected_quality
def selected_quality(self, arg, menuw):
api, show, season, episode, host, quality = arg
self.video_item = None
self.menuw = menuw
self.file_object = episode
self.selected_host = host
self.selected_quality = quality
config.VIDEO_SHOW_DATA_DIR = '/media/disk/video'
self.file_path = os.path.join(config.VIDEO_SHOW_DATA_DIR, self.get_filename(episode))
box = PopupBox(text='Starting download... will start playing shortly')
box.show()
time.sleep(2)
box.destroy()
if os.path.exists(self.file_path):
# TODO: check file completition?
self.play()
return
url_open = UrlOpen()
url = self.file_object.get_subtitle_url(quality=self.selected_quality)
filename = self.file_path.replace(".mp4", ".srt")
url_open(url, filename=filename)
print episode.file_hosts[host][quality]
self.gui_manager.background_task(self.pre_download, self.play)
self.downloader = Downloaders.get(host, self.gui_manager, episode.file_hosts[host][quality])
self.downloader.process_url(None, self.file_path)
示例11: filmaffinity_create_fxd
def filmaffinity_create_fxd(self, arg=None, menuw=None):
"""
create fxd file for the item
"""
box = PopupBox(text=_('Fetching movie information'))
box.show()
#if this exists we got a cdrom/dvdrom
if self.item.media and self.item.media.devicename:
devicename = self.item.media.devicename
else:
devicename = None
self.getFilmAffinityPage(arg[0])
if self.disc_set:
self.setDiscset(devicename, None)
else:
if self.item.subitems:
for i in range(len(self.item.subitems)):
video = makeVideo('file', 'f%s' % i,
os.path.basename(self.item.subitems[i].filename),
device=devicename)
self.setVideo(video)
else:
video = makeVideo('file', 'f1', os.path.basename(self.item.filename),
device=devicename)
self.setVideo(video)
self.setFxdFile(os.path.splitext(self.item.filename)[0])
self.writeFxd()
self.filmaffinity_menu_back(menuw)
box.destroy()
示例12: get_feed_menu
def get_feed_menu(self, feed):
service = gdata.service.GDataService(server='gdata.youtube.com')
gfeed = service.GetFeed(feed)
box = PopupBox(text=_('Loading video list'))
box.show()
menu = YoutubeVideoMenu(service, gfeed, self)
box.destroy()
return menu
示例13: download_play
def download_play(self, arg=None, menuw=None):
pop = PopupBox("Descargando programa")
pop.show()
video = VideoItem(_fetch_image(arg["flv"]), self)
pop.destroy()
video.image = _fetch_image(arg["image"])
video.menuw = menuw
video.play()
示例14: make_menu
def make_menu(self, arg=None, menuw=None):
try:
menuw.pushmenu(menu.Menu('Albums',
[ AlbumItem(x, self, self.service) for x in self.service.getAlbums()]))
except MusicIPException, x:
pop = PopupBox(text=_(str(x)))
pop.show()
time.sleep(2)
pop.destroy()
return
示例15: wikisubtitles_download
def wikisubtitles_download(self, arg=None, menuw=None):
"Download subtitle .srt"
import directory
box = PopupBox(text=_('Downloading subtitle, please wait..'))
box.show()
urllib.urlretrieve(arg,self.srtdownload)
box.destroy()
box = PopupBox(text=_('Subtitle downloaded'))
box.show()
time.sleep(2)
box.destroy()
self.wikisubtitles_menu_back(menuw)