当前位置: 首页>>代码示例>>Python>>正文


Python wlw.WaitLoadWindow类代码示例

本文整理汇总了Python中quodlibet.qltk.wlw.WaitLoadWindow的典型用法代码示例。如果您正苦于以下问题:Python WaitLoadWindow类的具体用法?Python WaitLoadWindow怎么用?Python WaitLoadWindow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了WaitLoadWindow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plugin_songs

	def plugin_songs(self, songs):
		if not ConfirmAction(self.plugin_window,
			_('Set dacapo Lyric Flag'),
			_("Check {!s} files?").format(self.counter)
								  ).run():
			logging.debug("Verarbeitung abgebrochen!")
			return True
		logging.debug("Starte Verarbeitung!")
		win = WaitLoadWindow(
			self.plugin_window, len(songs),
			_("Suche nach Synchronisierten Texten.\n\n%(current)d/%(total)d Songs verarbeitet."))
		for song in songs:
			logging.debug(u'Song: %s hassynclyrics %s' % (song.list('title'), song.get('hassynclyrics')))
			if song.get("~filename", "").endswith(".flac"):
				flacFilePath = song.get("~filename", "")
				try:
					lyrics = self.getLrycs(flacFilePath)
					if(lyrics == False):
						song["hassynclyrics"] = '0'
					else:
						song["hassynclyrics"] = '1'
				except:
					return False
			if win.step():
				break
		win.destroy()
开发者ID:claw-strophobic,项目名称:dacapo,代码行数:26,代码来源:setLyricFlag.py

示例2: __ParsePlaylist

def __ParsePlaylist(name, plfilename, files, library):
    playlist = Playlist.new(PLAYLISTS, name, library=library)
    songs = []
    win = WaitLoadWindow(
        None, len(files),
        _("Importing playlist.\n\n%(current)d/%(total)d songs added."))
    for i, filename in enumerate(files):
        try: uri = URI(filename)
        except ValueError:
            # Plain filename.
            filename = os.path.realpath(os.path.join(
                os.path.dirname(plfilename), filename))
            if library and filename in library:
                songs.append(library[filename])
            else:
                songs.append(formats.MusicFile(filename))
        else:
            if uri.scheme == "file":
                # URI-encoded local filename.
                filename = os.path.realpath(os.path.join(
                    os.path.dirname(plfilename), uri.filename))
                if library and filename in library:
                    songs.append(library[filename])
                else:
                    songs.append(formats.MusicFile(filename))
            else:
                # Who knows! Hand it off to GStreamer.
                songs.append(formats.remote.RemoteFile(uri))
        if win.step(): break
    win.destroy()
    playlist.extend(filter(None, songs))
    return playlist
开发者ID:silkecho,项目名称:glowing-silk,代码行数:32,代码来源:playlists.py

示例3: test_plurals

 def test_plurals(self):
     with locale_numeric_conv():
         wlw = WaitLoadWindow(None, 1234, "At %(current)d of %(total)d")
         self.failUnlessEqual(wlw._label.get_text(), "At 0 of 1,234")
         while wlw.current < 1000:
             wlw.step()
         self.failUnlessEqual(wlw._label.get_text(), "At 1,000 of 1,234")
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:7,代码来源:test_qltk_wlw.py

示例4: TWaitLoadWindow

class TWaitLoadWindow(TestCase):

    class DummyConnector(Gtk.Window):
        count = 0

        def connect(self, *args):
            self.count += 1

        def disconnect(self, *args):
            self.count -= 1

        class Eater:
            def set_cursor(*args):
                pass

        window = Eater()

    def setUp(self):
        self.parent = self.DummyConnector()
        self.wlw = WaitLoadWindow(self.parent, 5, "a test")

    def test_none(self):
        wlw = WaitLoadWindow(None, 5, "a test")
        wlw.step()
        wlw.destroy()

    def test_plurals(self):
        with locale_numeric_conv():
            wlw = WaitLoadWindow(None, 1234, "At %(current)d of %(total)d")
            self.failUnlessEqual(wlw._label.get_text(), "At 0 of 1,234")
            while wlw.current < 1000:
                wlw.step()
            self.failUnlessEqual(wlw._label.get_text(), "At 1,000 of 1,234")

    def test_connect(self):
        self.failUnlessEqual(2, self.parent.count)
        self.wlw.destroy()
        self.failUnlessEqual(0, self.parent.count)

    def test_start(self):
        self.failUnlessEqual(0, self.wlw.current)
        self.failUnlessEqual(5, self.wlw.count)

    def test_step(self):
        self.failIf(self.wlw.step())
        self.failUnlessEqual(1, self.wlw.current)
        self.failIf(self.wlw.step())
        self.failIf(self.wlw.step())
        self.failUnlessEqual(3, self.wlw.current)

    def test_destroy(self):
        self.wlw.destroy()
        self.failUnlessEqual(0, self.parent.count)

    def tearDown(self):
        self.wlw.destroy()
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:56,代码来源:test_qltk_wlw.py

示例5: _do_trash_songs

def _do_trash_songs(parent, songs, librarian):
    dialog = TrashDialog.for_songs(parent, songs)
    resp = dialog.run()
    if resp != TrashDialog.RESPONSE_TRASH:
        return

    window_title = _("Moving %(current)d/%(total)d.")

    w = WaitLoadWindow(parent, len(songs), window_title)
    w.show()

    ok = []
    failed = []
    for song in songs:
        filename = song("~filename")
        try:
            trash.trash(filename)
        except trash.TrashError:
            failed.append(song)
        else:
            ok.append(song)
        w.step()
    w.destroy()

    if failed:
        ErrorMessage(parent,
            _("Unable to move to trash"),
            _("Moving one or more files to the trash failed.")
        ).run()

    if ok:
        librarian.remove(ok)
开发者ID:kriskielce88,项目名称:xn--ls8h,代码行数:32,代码来源:delete.py

示例6: _do_trash_files

def _do_trash_files(parent, paths):
    dialog = TrashDialog.for_files(parent, paths)
    resp = dialog.run()
    if resp != TrashDialog.RESPONSE_TRASH:
        return

    window_title = _("Moving %(current)d/%(total)d.")
    w = WaitLoadWindow(parent, len(paths), window_title)
    w.show()

    ok = []
    failed = []
    for path in paths:
        try:
            trash.trash(path)
        except trash.TrashError:
            failed.append(path)
        else:
            ok.append(path)
        w.step()
    w.destroy()

    if failed:
        ErrorMessage(parent,
            _("Unable to move to trash"),
            _("Moving one or more files to the trash failed.")
        ).run()
开发者ID:kriskielce88,项目名称:xn--ls8h,代码行数:27,代码来源:delete.py

示例7: _do_delete_songs

def _do_delete_songs(parent, songs, librarian):
    dialog = DeleteDialog.for_songs(parent, songs)
    resp = dialog.run()
    if resp != DeleteDialog.RESPONSE_DELETE:
        return

    window_title = _("Deleting %(current)d/%(total)d.")

    w = WaitLoadWindow(parent, len(songs), window_title)
    w.show()

    ok = []
    failed = []
    for song in songs:
        filename = song("~filename")
        try:
            os.unlink(filename)
        except EnvironmentError:
            failed.append(song)
        else:
            ok.append(song)
        w.step()
    w.destroy()

    if failed:
        ErrorMessage(parent,
            _("Unable to delete files"),
            _("Deleting one or more files failed.")
        ).run()

    if ok:
        librarian.remove(ok)
开发者ID:kriskielce88,项目名称:xn--ls8h,代码行数:32,代码来源:delete.py

示例8: _do_delete_files

def _do_delete_files(parent, paths):
    dialog = DeleteDialog.for_files(parent, paths)
    resp = dialog.run()
    if resp != DeleteDialog.RESPONSE_DELETE:
        return

    window_title = _("Deleting %(current)d/%(total)d.")

    w = WaitLoadWindow(parent, len(paths), window_title)
    w.show()

    ok = []
    failed = []
    for path in paths:
        try:
            os.unlink(path)
        except EnvironmentError:
            failed.append(path)
        else:
            ok.append(path)
        w.step()
    w.destroy()

    if failed:
        ErrorMessage(parent,
            _("Unable to delete files"),
            _("Deleting one or more files failed.")
        ).run()
开发者ID:kriskielce88,项目名称:xn--ls8h,代码行数:28,代码来源:delete.py

示例9: run

    def run(self):
        resp = super(DeleteDialog, self).run()
        if self.__askonly:
            self.destroy()
            return resp

        if resp == 1 or resp == gtk.RESPONSE_DELETE_EVENT: return []
        elif resp == 0: s = _("Moving %(current)d/%(total)d.")
        elif resp == 2: s = _("Deleting %(current)d/%(total)d.")
        else: return []
        files = self.__files
        w = WaitLoadWindow(self, len(files), s)
        removed = []

        if resp == 0:
            for filename in files:
                try:
                    trash.trash(filename)
                except trash.TrashError:
                    fn = util.escape(util.fsdecode(util.unexpand(filename)))
                    ErrorMessage(self, _("Unable to move to trash"),
                        (_("Moving <b>%s</b> to the trash failed.") %
                        fn)).run()
                    break
                removed.append(filename)
                w.step()
        else:
            for filename in files:
                try:
                    os.unlink(filename)
                except EnvironmentError, s:
                    try: s = unicode(s.strerror, const.ENCODING, 'replace')
                    except TypeError:
                        s = unicode(s.strerror[1], const.ENCODING, 'replace')
                    s = "\n\n" + s
                    fn = util.escape(util.fsdecode(util.unexpand(filename)))
                    ErrorMessage(
                        self, _("Unable to delete file"),
                        (_("Deleting <b>%s</b> failed.") % fn) + s).run()
                    break
                removed.append(filename)
                w.step()
开发者ID:silkecho,项目名称:glowing-silk,代码行数:42,代码来源:delete.py

示例10: plugin_songs

	def plugin_songs(self, songs):

		if (songs is None) or (len(songs) <= 0):
			return True

		self.shuffle = False
		if (len(songs) > 1) and not ConfirmAction(self.plugin_window,
			_(self.PLUGIN_NAME),
			_("Open {!s} files in dacapo?").format(len(songs)),
			parent=self
		).run():
			return True

		win = WaitLoadWindow(
			self.plugin_window, len(songs),
			_("Checking...\n\n%(current)d/%(total)d Songs done."))
		args = []
		if self.shuffle:
			args.append("-s")
		if (len(songs) > 1):
			args.append("-pl")
			f = tempfile.NamedTemporaryFile(delete=False)
			for song in songs:
				if song.get("~filename", "").endswith(".flac"):
					f.writelines(song.get("~filename", "")+"\n")
			f.close()
			args.append(f.name)
		else:
			for song in songs:
				if song.get("~filename", "").endswith(".flac"):
					args.append(song.get("~filename", ""))

		try:
			program = 'dacapo'
			print program,args
			subprocess.call([program]+args)
		except:
			win.destroy()
			self.printError()
			return False
		win.destroy()
开发者ID:claw-strophobic,项目名称:dacapo,代码行数:41,代码来源:openDacapo.py

示例11: plugin_songs

	def plugin_songs(self, songs):

		if (songs is None) or (len(songs) <= 0):
			return True

		if not ConfirmAction(self.plugin_window,
			_(self.PLUGIN_NAME),
			_("Check {!s} files?").format(len(songs))
								  ).run():
			return True

		win = WaitLoadWindow(
			self.plugin_window, len(songs),
			_("Counting pictures.\n\n%(current)d/%(total)d Songs done."))
		for song in songs:
			if song.get("~filename", "").endswith(".flac"):
				flacFilePath = song.get("~filename", "")
				try:
					self.countImages(song)
				except:
					win.destroy()
					self.printError()
					return False
			if win.step():
				break
		win.destroy()
开发者ID:claw-strophobic,项目名称:dacapo,代码行数:26,代码来源:countImages.py

示例12: __create_playlist

def __create_playlist(name, source_dir, files, library):
    playlist = FileBackedPlaylist.new(PLAYLISTS, name, library=library)
    print_d("Created playlist %s" % playlist)
    songs = []
    win = WaitLoadWindow(
        None, len(files),
        _("Importing playlist.\n\n%(current)d/%(total)d songs added."))
    win.show()
    for i, filename in enumerate(files):
        if not uri_is_valid(filename):
            # Plain filename.
            songs.append(_af_for(filename, library, source_dir))
        else:
            try:
                filename = uri2fsn(filename)
            except ValueError:
                # Who knows! Hand it off to GStreamer.
                songs.append(formats.remote.RemoteFile(filename))
            else:
                # URI-encoded local filename.
                songs.append(_af_for(filename, library, source_dir))
        if win.step():
            break
    win.destroy()
    playlist.extend(list(filter(None, songs)))
    return playlist
开发者ID:zsau,项目名称:quodlibet,代码行数:26,代码来源:util.py

示例13: TWaitLoadWindow

class TWaitLoadWindow(TestCase):

    class DummyConnector(Gtk.Window):
        count = 0

        def connect(self, *args):
            self.count += 1

        def disconnect(self, *args):
            self.count -= 1

        class Eater:
            def set_cursor(*args):
                pass

        window = Eater()

    def setUp(self):
        self.parent = self.DummyConnector()
        self.wlw = WaitLoadWindow(self.parent, 5, "a test")

    def test_none(self):
        wlw = WaitLoadWindow(None, 5, "a test")
        wlw.step()
        wlw.destroy()

    def test_connect(self):
        self.failUnlessEqual(2, self.parent.count)
        self.wlw.destroy()
        self.failUnlessEqual(0, self.parent.count)

    def test_start(self):
        self.failUnlessEqual(0, self.wlw.current)
        self.failUnlessEqual(5, self.wlw.count)

    def test_step(self):
        self.failIf(self.wlw.step())
        self.failUnlessEqual(1, self.wlw.current)
        self.failIf(self.wlw.step())
        self.failIf(self.wlw.step())
        self.failUnlessEqual(3, self.wlw.current)

    def test_destroy(self):
        self.wlw.destroy()
        self.failUnlessEqual(0, self.parent.count)

    def tearDown(self):
        self.wlw.destroy()
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:48,代码来源:test_qltk_wlw.py

示例14: plugin_songs

    def plugin_songs(self, songs):
        if os.system("ifp typestring"):
            qltk.ErrorMessage(
                None, _("No iFP device found"),
                _("Unable to contact your iFP device. Check "
                  "that the device is powered on and plugged "
                  "in, and that you have ifp-line "
                  "(http://ifp-driver.sf.net) installed.")).run()
            return True
        self.__madedir = []

        w = WaitLoadWindow(
            None, len(songs), _("Uploading %(current)d/%(total)d"))
        w.show()

        for i, song in enumerate(songs):
            if self.__upload(song) or w.step():
                w.destroy()
                return True
        else:
            w.destroy()
开发者ID:LudoBike,项目名称:quodlibet,代码行数:21,代码来源:ifp.py

示例15: plugin_songs

	def plugin_songs(self, songs):
		for song in songs:
			if song.get("~filename", "").endswith(".flac"):
				flacFilePath = os.path.dirname(os.path.abspath(song.get("~filename", "")));
				break

		choose = AddImageFileChooser(self.plugin_window, flacFilePath)
		files = choose.run()
		desc = choose.get_description()
		choose.destroy()

		if (files == None) or (len(files) <= 0):
			return True

		for file in files:
			contentType = mimetypes.guess_type(file) # get Mimetype
			mimeType = contentType[0]
			if (mimeType in self.JPG_MIMES) or (mimeType in self.PNG_MIMES):
				img = get_image_size(file)
				img.mime = mimeType
				img.type = choose.imgType
				if (len(desc) <= 0):
					img.desc = ntpath.basename(file)
				else:
					img.desc = desc
				self.imgFiles.append(img)

		if not ConfirmAction(self.plugin_window,
			_(self.PLUGIN_NAME),
			_("Add {!s} images as type \n\n<b>&gt;&gt; {!s} &lt;&lt;</b>\n\nto {!s} files?").format(
					len(files), choose.TYPE[choose.imgType], self.counter)
								  ).run():
			return True

		win = WaitLoadWindow(
			self.plugin_window, len(songs),
			_("Adding Image.\n\n%(current)d/%(total)d Songs done."))
		for song in songs:
			if song.get("~filename", "").endswith(".flac"):
				flacFilePath = song.get("~filename", "")
				try:
					self.setImage(song)
				except:
					win.destroy()
					printError()
					return False
			if win.step():
				break
		win.destroy()
开发者ID:claw-strophobic,项目名称:dacapo,代码行数:49,代码来源:addImage.py


注:本文中的quodlibet.qltk.wlw.WaitLoadWindow类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。