• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python trans_utils.i18n函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: do_disable_check

def do_disable_check():
    scrapers = relevant_scrapers()
    auto_disable = kodi.get_setting('auto-disable')
    check_freq = int(kodi.get_setting('disable-freq'))
    disable_thresh = int(kodi.get_setting('disable-thresh'))
    for cls in scrapers:
        last_check = db_connection.get_setting('%s_check' % (cls.get_name()))
        last_check = int(last_check) if last_check else 0
        tries = kodi.get_setting('%s_try' % (cls.get_name()))
        tries = int(tries) if tries else 0
        if tries > 0 and tries / check_freq > last_check / check_freq:
            kodi.set_setting('%s_check' % (cls.get_name()), str(tries))
            success_rate = calculate_success(cls.get_name())
            if success_rate < disable_thresh:
                if auto_disable == DISABLE_SETTINGS.ON:
                    kodi.set_setting('%s-enable' % (cls.get_name()), 'false')
                    kodi.notify(msg='[COLOR blue]%s[/COLOR] %s' % (i18n('scraper_disabled')), duration=5000)
                elif auto_disable == DISABLE_SETTINGS.PROMPT:
                    dialog = xbmcgui.Dialog()
                    line1 = i18n('disable_line1') % (cls.get_name(), 100 - success_rate, tries)
                    line2 = i18n('disable_line2')
                    line3 = i18n('disable_line3')
                    ret = dialog.yesno('SALTS', line1, line2, line3, i18n('keep_enabled'), i18n('disable_it'))
                    if ret:
                        kodi.set_setting('%s-enable' % (cls.get_name()), 'false')
开发者ID:foxwill,项目名称:salts,代码行数:25,代码来源:utils.py


示例2: get_resume_choice

def get_resume_choice(trakt_id, season, episode):
    if kodi.get_setting('trakt_bookmark') == 'true':
        resume_point = '%s%%' % (trakt_api.get_bookmark(trakt_id, season, episode))
        header = i18n('trakt_bookmark_exists')
    else:
        resume_point = format_time(db_connection.get_bookmark(trakt_id, season, episode))
        header = i18n('local_bookmark_exists')
    question = i18n('resume_from') % (resume_point)
    return xbmcgui.Dialog().yesno(header, question, '', '', i18n('start_from_beginning'), i18n('resume')) == 1
开发者ID:edwtjo,项目名称:salts,代码行数:9,代码来源:utils.py


示例3: get_resume_choice

def get_resume_choice(trakt_id, season, episode):
    if kodi.get_setting("trakt_bookmark") == "true":
        resume_point = "%s%%" % (trakt_api.get_bookmark(trakt_id, season, episode))
        header = i18n("trakt_bookmark_exists")
    else:
        resume_point = format_time(db_connection.get_bookmark(trakt_id, season, episode))
        header = i18n("local_bookmark_exists")
    question = i18n("resume_from") % (resume_point)
    return xbmcgui.Dialog().yesno(header, question, "", "", i18n("start_from_beginning"), i18n("resume")) == 1
开发者ID:fergyc,项目名称:tknorris-beta-repo,代码行数:9,代码来源:utils.py


示例4: choose_list

def choose_list(username=None):
    lists = trakt_api.get_lists(username)
    if username is None: lists.insert(0, {'name': 'watchlist', 'ids': {'slug': WATCHLIST_SLUG}})
    if lists:
        dialog = xbmcgui.Dialog()
        index = dialog.select(i18n('pick_a_list'), [list_data['name'] for list_data in lists])
        if index > -1:
            return lists[index]['ids']['slug']
    else:
        kodi.notify(msg=i18n('no_lists_for_user') % (username), duration=5000)
开发者ID:edwtjo,项目名称:salts,代码行数:10,代码来源:utils.py


示例5: choose_list

def choose_list(username=None):
    lists = trakt_api.get_lists(username)
    if username is None:
        lists.insert(0, {"name": "watchlist", "ids": {"slug": WATCHLIST_SLUG}})
    if lists:
        dialog = xbmcgui.Dialog()
        index = dialog.select(i18n("pick_a_list"), [list_data["name"] for list_data in lists])
        if index > -1:
            return lists[index]["ids"]["slug"]
    else:
        kodi.notify(msg=i18n("no_lists_for_user") % (username), duration=5000)
开发者ID:fergyc,项目名称:tknorris-beta-repo,代码行数:11,代码来源:utils.py


示例6: onClick

        def onClick(self, control):
            # print 'onClick: %s' % (control)
            if control == AUTH_BUTTON:
                if not self.__get_token():
                    kodi.notify(msg=i18n('pin_auth_failed'), duration=5000)
                    return
                self.auth = True

            if control == LATER_BUTTON:
                kodi.notify(msg=i18n('remind_in_24hrs'), duration=5000)
                kodi.set_setting('last_reminder', str(int(time.time())))

            if control == NEVER_BUTTON:
                kodi.notify(msg=i18n('use_addon_settings'), duration=5000)
                kodi.set_setting('last_reminder', '-1')

            if control in [AUTH_BUTTON, LATER_BUTTON, NEVER_BUTTON]:
                self.close()
开发者ID:SQL-MisterMagoo,项目名称:salts,代码行数:18,代码来源:gui_utils.py


示例7: parallel_get_url

def parallel_get_url(q, scraper, video):
    worker = threading.current_thread()
    log_utils.log('Worker: %s (%s) for %s url' % (worker.name, worker, scraper.get_name()), log_utils.LOGDEBUG)
    url = scraper.get_url(video)
    log_utils.log('%s returned url %s from %s' % (scraper.get_name(), url, worker), log_utils.LOGDEBUG)
    if not url: url = ''
    if url == FORCE_NO_MATCH:
        label = '[%s] [COLOR green]%s[/COLOR]' % (scraper.get_name(), i18n('force_no_match'))
    else:
        label = '[%s] %s' % (scraper.get_name(), url)
    related = {'class': scraper, 'url': url, 'name': scraper.get_name(), 'label': label}
    q.put(related)
开发者ID:edwtjo,项目名称:salts,代码行数:12,代码来源:utils.py


示例8: get_section_params

def get_section_params(section):
    section_params = {}
    section_params['section'] = section
    if section == SECTIONS.TV:
        section_params['next_mode'] = MODES.SEASONS
        section_params['folder'] = True
        section_params['video_type'] = VIDEO_TYPES.TVSHOW
        section_params['content_type'] = CONTENT_TYPES.TVSHOWS
        section_params['search_img'] = 'television_search.png'
        section_params['label_plural'] = i18n('tv_shows')
        section_params['label_single'] = i18n('tv_show')
    else:
        section_params['next_mode'] = MODES.GET_SOURCES
        section_params['folder'] = kodi.get_setting('source-win') == 'Directory' and kodi.get_setting('auto-play') == 'false'
        section_params['video_type'] = VIDEO_TYPES.MOVIE
        section_params['content_type'] = CONTENT_TYPES.MOVIES
        section_params['search_img'] = 'movies_search.png'
        section_params['label_plural'] = i18n('movies')
        section_params['label_single'] = i18n('movie')

    return section_params
开发者ID:edwtjo,项目名称:salts,代码行数:21,代码来源:utils.py


示例9: perform_auto_conf

def perform_auto_conf(responses):
    length = len(responses)
    TOTAL = 12
    if length < TOTAL:
        responses += [True] * (TOTAL - length)
        
    if responses[0]: kodi.set_setting('trakt_timeout', '60')
    if responses[1]: kodi.set_setting('calendar-day', '-1')
    if responses[2]: kodi.set_setting('calendar_time', '2')
    if responses[3]: kodi.set_setting('source_timeout', '20')
    if responses[4]: kodi.set_setting('include_watchlist_next', 'true')
    if responses[5]: kodi.set_setting('filter_direct', 'true')
    if responses[6]: kodi.set_setting('filter_unusable', 'true')
    if responses[7]: kodi.set_setting('show_debrid', 'true')
    if responses[8]: kodi.set_setting('source_results', '0')
    if responses[9]:
        kodi.set_setting('enable_sort', 'true')
        kodi.set_setting('sort1_field', '2')
        kodi.set_setting('sort2_field', '5')
        kodi.set_setting('sort3_field', '6')
        kodi.set_setting('sort4_field', '1')
        kodi.set_setting('sort5_field', '3')
        kodi.set_setting('sort6_field', '4')

    if responses[10]:
        tiers = ['Local', 'Furk.net', 'Premiumize.me', 'EasyNews', 'DD.tv', 'NoobRoom',
                 ['WatchHD', 'IFlix', 'MoviesPlanet', 'CyberReel', '9Movies', '123Movies', 'niter.tv', 'ororo.tv'],
                 ['movietv.to', 'StreamLord', 'tunemovie', 'afdah.org', 'xmovies8', 'xmovies8.v2', 'alluc.com'],
                 ['torba.se', 'IzlemeyeDeger', 'Rainierland', 'zumvo.com', 'PutMV', 'MiraDeTodo', 'beinmovie'],
                 ['SezonLukDizi', 'Dizimag', 'Dizilab', 'Dizigold', 'Diziay', 'Dizipas', 'OneClickTVShows'],
                 ['DDLValley', 'ReleaseBB', 'MyVideoLinks.eu', 'OCW', 'RLSSource.net', 'TVRelease.Net'],
                 ['IceFilms', 'PrimeWire', 'Flixanity', 'wso.ch', 'WatchSeries', 'UFlix.org', 'Putlocker', 'MovieHut'],
                 ['funtastic-vids', 'WatchFree.to', 'pftv', 'streamallthis.is', 'Movie4K', 'afdah', 'SolarMovie', 'yify-streaming'],
                 ['CouchTunerV2', 'CouchTunerV1', 'Watch8Now', 'yshows', 'TwoMovies.us', 'iWatchOnline', 'vidics.ch', 'pubfilm'],
                 ['OnlineMoviesIs', 'OnlineMoviesPro', 'ViewMovies', 'movie25', 'viooz.ac', 'view47', 'MoviesHD', 'wmo.ch'],
                 ['ayyex', 'stream-tv.co', 'clickplay.to', 'MintMovies', 'MovieNight', 'cmz', 'ch131', 'filmikz.ch'],
                 ['MovieTube', 'LosMovies', 'FilmStreaming.in', 'moviestorm.eu', 'MerDB'],
                 'MoviesOnline7']
    
        sso = []
        random_sso = kodi.get_setting('random_sso') == 'true'
        for tier in tiers:
            if isinstance(tier, basestring):
                sso.append(tier)
            else:
                if random_sso:
                    random.shuffle(tier)
                sso += tier
        kodi.set_setting('source_sort_order', '|'.join(sso))
    
    if responses[11]: reset_base_url()
    kodi.set_setting('filter-unknown', 'false')
    kodi.notify(msg=i18n('auto_conf_complete'))
开发者ID:SQL-MisterMagoo,项目名称:salts,代码行数:53,代码来源:gui_utils.py


示例10: parallel_get_url

def parallel_get_url(q, scraper, video):
    worker = threading.current_thread()
    log_utils.log("Worker: %s (%s) for %s url" % (worker.name, worker, scraper.get_name()), log_utils.LOGDEBUG)
    url = scraper.get_url(video)
    log_utils.log("%s returned url %s from %s" % (scraper.get_name(), url, worker), log_utils.LOGDEBUG)
    if not url:
        url = ""
    if url == FORCE_NO_MATCH:
        label = "[%s] [COLOR green]%s[/COLOR]" % (scraper.get_name(), i18n("force_no_match"))
    else:
        label = "[%s] %s" % (scraper.get_name(), url)
    related = {"class": scraper, "url": url, "name": scraper.get_name(), "label": label}
    q.put(related)
开发者ID:fergyc,项目名称:tknorris-beta-repo,代码行数:13,代码来源:utils.py


示例11: do_disable_check

def do_disable_check():
    auto_disable = kodi.get_setting("auto-disable")
    disable_limit = int(kodi.get_setting("disable-limit"))
    for cls in relevant_scrapers():
        setting = "%s_last_results" % (cls.get_name())
        fails = kodi.get_setting(setting)
        fails = int(fails) if fails else 0
        if fails >= disable_limit:
            if auto_disable == DISABLE_SETTINGS.ON:
                kodi.set_setting("%s-enable" % (cls.get_name()), "false")
                kodi.notify(msg="[COLOR blue]%s[/COLOR] %s" % (cls.get_name(), i18n("scraper_disabled")), duration=5000)
                kodi.set_setting(setting, "0")
            elif auto_disable == DISABLE_SETTINGS.PROMPT:
                dialog = xbmcgui.Dialog()
                line1 = i18n("disable_line1") % (cls.get_name(), fails)
                line2 = i18n("disable_line2")
                line3 = i18n("disable_line3")
                ret = dialog.yesno("SALTS", line1, line2, line3, i18n("keep_enabled"), i18n("disable_it"))
                if ret:
                    kodi.set_setting("%s-enable" % (cls.get_name()), "false")
                    kodi.set_setting(setting, "0")
                else:
                    kodi.set_setting(setting, "-1")
开发者ID:fergyc,项目名称:tknorris-beta-repo,代码行数:23,代码来源:utils.py


示例12: get_section_params

def get_section_params(section):
    section_params = {}
    section_params["section"] = section
    if section == SECTIONS.TV:
        section_params["next_mode"] = MODES.SEASONS
        section_params["folder"] = True
        section_params["video_type"] = VIDEO_TYPES.TVSHOW
        section_params["content_type"] = CONTENT_TYPES.TVSHOWS
        section_params["search_img"] = "television_search.png"
        section_params["label_plural"] = i18n("tv_shows")
        section_params["label_single"] = i18n("tv_show")
    else:
        section_params["next_mode"] = MODES.GET_SOURCES
        section_params["folder"] = (
            kodi.get_setting("source-win") == "Directory" and kodi.get_setting("auto-play") == "false"
        )
        section_params["video_type"] = VIDEO_TYPES.MOVIE
        section_params["content_type"] = CONTENT_TYPES.MOVIES
        section_params["search_img"] = "movies_search.png"
        section_params["label_plural"] = i18n("movies")
        section_params["label_single"] = i18n("movie")

    return section_params
开发者ID:fergyc,项目名称:tknorris-beta-repo,代码行数:23,代码来源:utils.py


示例13: __attempt_db_recovery

 def __attempt_db_recovery(self):
     self.__recovery = True
     header = i18n('recovery_header')
     if xbmcgui.Dialog().yesno(header, i18n('rec_mig_1'), i18n('rec_mig_2')):
         try: self.init_database('0.0.0')
         except Exception as e:
             log_utils.log('DB Migration Failed: %s' % (e), log_utils.LOGWARNING)
             if xbmcgui.Dialog().yesno(header, i18n('rec_reset_1'), i18n('rec_reset_2'), i18n('rec_reset_3')):
                 try: result = self.reset_db()
                 except Exception as e:
                     log_utils.log('Reset Failed: %s' % (e), log_utils.LOGWARNING)
                     kodi.notify(msg=i18n('reset_failed') % e, duration=5000)
                 else:
                     if result:
                         kodi.notify(msg=i18n('db_reset_success'))
开发者ID:edwtjo,项目名称:salts,代码行数:15,代码来源:db_utils.py


示例14: attempt_db_recovery

 def attempt_db_recovery(self):
     header = i18n('recovery_header')
     if xbmcgui.Dialog().yesno(header, i18n('rec_mig_1'), i18n('rec_mig_2')):
         try: self.init_database('0.0.0')
         except Exception as e:
             log_utils.log('DB Migration Failed: %s' % (e), log_utils.LOGWARNING)
             if self.db_type == DB_TYPES.SQLITE:
                 if xbmcgui.Dialog().yesno(header, i18n('rec_reset_1'), i18n('rec_reset_2'), i18n('rec_reset_3')):
                     try: self.reset_db()
                     except Exception as e:
                         log_utils.log('Reset Failed: %s' % (e), log_utils.LOGWARNING)
                         try: msg = i18n('reset_failed') % (e)
                         except: msg = 'Reset Failed: %s' % (e)
                     else:
                         msg = i18n('db_reset_success')
                     kodi.notify(msg=msg, duration=5000)
开发者ID:SQL-MisterMagoo,项目名称:salts,代码行数:16,代码来源:db_utils.py


示例15: download_media

def download_media(url, path, file_name):
    try:
        progress = int(ADDON.get_setting('down_progress'))
        import urllib2
        request = urllib2.Request(url)
        request.add_header('User-Agent', USER_AGENT)
        request.add_unredirected_header('Host', request.get_host())
        response = urllib2.urlopen(request)

        content_length = 0
        if 'Content-Length' in response.info():
            content_length = int(response.info()['Content-Length'])

        file_name = file_name.replace('.strm', get_extension(url, response))
        full_path = os.path.join(path, file_name)
        log_utils.log('Downloading: %s -> %s' % (url, full_path), xbmc.LOGDEBUG)

        path = xbmc.makeLegalFilename(path)
        if not xbmcvfs.exists(path):
            try:
                try: xbmcvfs.mkdirs(path)
                except: os.mkdir(path)
            except Exception as e:
                raise Exception(i18n('failed_create_dir'))

        file_desc = xbmcvfs.File(full_path, 'w')
        total_len = 0
        if progress:
            if progress == PROGRESS.WINDOW:
                dialog = xbmcgui.DialogProgress()
            else:
                dialog = xbmcgui.DialogProgressBG()

            dialog.create('Stream All The Sources', i18n('downloading') % (file_name))
            dialog.update(0)
        while True:
            data = response.read(CHUNK_SIZE)
            if not data:
                break

            if progress == PROGRESS.WINDOW and dialog.iscanceled():
                break

            total_len += len(data)
            if not file_desc.write(data):
                raise Exception('failed_write_file')

            percent_progress = (total_len) * 100 / content_length if content_length > 0 else 0
            log_utils.log('Position : %s / %s = %s%%' % (total_len, content_length, percent_progress), xbmc.LOGDEBUG)
            if progress == PROGRESS.WINDOW:
                dialog.update(percent_progress)
            elif progress == PROGRESS.BACKGROUND:
                dialog.update(percent_progress, 'Stream All The Sources')
        else:
            notify(msg=i18n('download_complete') % (file_name), duration=5000)
            log_utils.log('Download Complete: %s -> %s' % (url, full_path), xbmc.LOGDEBUG)

        file_desc.close()
        if progress:
            dialog.close()

    except Exception as e:
        log_utils.log('Error (%s) during download: %s -> %s' % (str(e), url, file_name), xbmc.LOGERROR)
        notify(msg=i18n('download_error') % (str(e), file_name), duration=5000)
开发者ID:s7eele,项目名称:tknorris-beta-repo,代码行数:64,代码来源:utils.py


示例16: download_media

def download_media(url, path, file_name):
    try:
        progress = int(kodi.get_setting("down_progress"))
        request = urllib2.Request(url)
        request.add_header("User-Agent", USER_AGENT)
        request.add_unredirected_header("Host", request.get_host())
        response = urllib2.urlopen(request)

        content_length = 0
        if "Content-Length" in response.info():
            content_length = int(response.info()["Content-Length"])

        file_name = file_name.replace(".strm", get_extension(url, response))
        full_path = os.path.join(path, file_name)
        log_utils.log("Downloading: %s -> %s" % (url, full_path), log_utils.LOGDEBUG)

        path = xbmc.makeLegalFilename(path)
        if not xbmcvfs.exists(path):
            try:
                try:
                    xbmcvfs.mkdirs(path)
                except:
                    os.mkdir(path)
            except Exception as e:
                raise Exception(i18n("failed_create_dir"))

        file_desc = xbmcvfs.File(full_path, "w")
        total_len = 0
        if progress:
            if progress == PROGRESS.WINDOW:
                dialog = xbmcgui.DialogProgress()
            else:
                dialog = xbmcgui.DialogProgressBG()

            dialog.create("Stream All The Sources", i18n("downloading") % (file_name))
            dialog.update(0)
        while True:
            data = response.read(CHUNK_SIZE)
            if not data:
                break

            if progress == PROGRESS.WINDOW and dialog.iscanceled():
                break

            total_len += len(data)
            if not file_desc.write(data):
                raise Exception("failed_write_file")

            percent_progress = (total_len) * 100 / content_length if content_length > 0 else 0
            log_utils.log(
                "Position : %s / %s = %s%%" % (total_len, content_length, percent_progress), log_utils.LOGDEBUG
            )
            if progress == PROGRESS.WINDOW:
                dialog.update(percent_progress)
            elif progress == PROGRESS.BACKGROUND:
                dialog.update(percent_progress, "Stream All The Sources")
        else:
            kodi.notify(msg=i18n("download_complete") % (file_name), duration=5000)
            log_utils.log("Download Complete: %s -> %s" % (url, full_path), log_utils.LOGDEBUG)

        file_desc.close()
        if progress:
            dialog.close()

    except Exception as e:
        log_utils.log("Error (%s) during download: %s -> %s" % (str(e), url, file_name), log_utils.LOGERROR)
        kodi.notify(msg=i18n("download_error") % (str(e), file_name), duration=5000)
开发者ID:fergyc,项目名称:tknorris-beta-repo,代码行数:67,代码来源:utils.py


示例17: get_pin

def get_pin():
    AUTH_BUTTON = 200
    LATER_BUTTON = 201
    NEVER_BUTTON = 202
    ACTION_PREVIOUS_MENU = 10
    ACTION_BACK = 92
    CENTER_Y = 6
    CENTER_X = 2
    
    class PinAuthDialog(xbmcgui.WindowXMLDialog):
        auth = False
        
        def onInit(self):
            self.pin_edit_control = self.__add_editcontrol(30, 240, 40, 450)
            self.setFocus(self.pin_edit_control)
            auth = self.getControl(AUTH_BUTTON)
            never = self.getControl(NEVER_BUTTON)
            self.pin_edit_control.controlUp(never)
            self.pin_edit_control.controlLeft(never)
            self.pin_edit_control.controlDown(auth)
            self.pin_edit_control.controlRight(auth)
            auth.controlUp(self.pin_edit_control)
            auth.controlLeft(self.pin_edit_control)
            never.controlDown(self.pin_edit_control)
            never.controlRight(self.pin_edit_control)
            
        def onAction(self, action):
            # print 'Action: %s' % (action.getId())
            if action == ACTION_PREVIOUS_MENU or action == ACTION_BACK:
                self.close()

        def onControl(self, control):
            # print 'onControl: %s' % (control)
            pass

        def onFocus(self, control):
            # print 'onFocus: %s' % (control)
            pass

        def onClick(self, control):
            # print 'onClick: %s' % (control)
            if control == AUTH_BUTTON:
                if not self.__get_token():
                    kodi.notify(msg=i18n('pin_auth_failed'), duration=5000)
                    return
                self.auth = True

            if control == LATER_BUTTON:
                kodi.notify(msg=i18n('remind_in_24hrs'), duration=5000)
                kodi.set_setting('last_reminder', str(int(time.time())))

            if control == NEVER_BUTTON:
                kodi.notify(msg=i18n('use_addon_settings'), duration=5000)
                kodi.set_setting('last_reminder', '-1')

            if control in [AUTH_BUTTON, LATER_BUTTON, NEVER_BUTTON]:
                self.close()
        
        def __get_token(self):
            pin = self.pin_edit_control.getText().strip()
            if pin:
                try:
                    trakt_api = Trakt_API(use_https=use_https, timeout=trakt_timeout)
                    result = trakt_api.get_token(pin=pin)
                    kodi.set_setting('trakt_oauth_token', result['access_token'])
                    kodi.set_setting('trakt_refresh_token', result['refresh_token'])
                    profile = trakt_api.get_user_profile(cached=False)
                    kodi.set_setting('trakt_user', '%s (%s)' % (profile['username'], profile['name']))
                    return True
                except Exception as e:
                    log_utils.log('Trakt Authorization Failed: %s' % (e), log_utils.LOGDEBUG)
                    return False
            return False
        
        # have to add edit controls programatically because getControl() (hard) crashes XBMC on them
        def __add_editcontrol(self, x, y, height, width):
            media_path = os.path.join(kodi.get_path(), 'resources', 'skins', 'Default', 'media')
            temp = xbmcgui.ControlEdit(0, 0, 0, 0, '', font='font12', textColor='0xFFFFFFFF', focusTexture=os.path.join(media_path, 'button-focus2.png'),
                                       noFocusTexture=os.path.join(media_path, 'button-nofocus.png'), _alignment=CENTER_Y | CENTER_X)
            temp.setPosition(x, y)
            temp.setHeight(height)
            temp.setWidth(width)
            self.addControl(temp)
            return temp
        
    dialog = PinAuthDialog('TraktPinAuthDialog.xml', kodi.get_path())
    dialog.doModal()
    if dialog.auth:
        kodi.notify(msg=i18n('trakt_auth_complete'), duration=3000)
    del dialog
开发者ID:SQL-MisterMagoo,项目名称:salts,代码行数:90,代码来源:gui_utils.py


示例18: do_auto_config

def do_auto_config():
    ACTION_PREVIOUS_MENU = 10
    ACTION_BACK = 92
    CONTINUE_BUTTON = 200
    CANCEL_BUTTON = 201

    starty = 60
    posx = 30
    gap = 35
    RADIO_BUTTONS = [
        i18n('set_trakt_timeout'),
        i18n('set_cal_start'),
        i18n('set_cal_airtime'),
        i18n('set_scraper_timeout'),
        i18n('set_wl_mne'),
        i18n('set_test_direct'),
        i18n('set_filter_unusable'),
        i18n('set_show_debrid'),
        i18n('set_no_limit'),
        i18n('set_source_sort'),
        i18n('set_sso'),
        i18n('set_reset_url'),
        i18n('select_all_none')]
    
    class AutoConfDialog(xbmcgui.WindowXMLDialog):
        def onInit(self):
            log_utils.log('onInit:', log_utils.LOGDEBUG)
            self.OK = False
            self.radio_buttons = []
            posy = starty
            for label in RADIO_BUTTONS:
                self.radio_buttons.append(self.__get_radio_button(posx, posy, label))
                posy += gap
            
            try: responses = json.loads(kodi.get_setting('prev_responses'))
            except: responses = [True] * len(self.radio_buttons)
            if len(responses) < len(self.radio_buttons):
                responses += [True] * (len(self.radio_buttons) - len(responses))
            
            self.addControls(self.radio_buttons)
            last_button = None
            for response, radio_button in zip(responses, self.radio_buttons):
                radio_button.setSelected(response)
                if last_button is not None:
                    radio_button.controlUp(last_button)
                    radio_button.controlLeft(last_button)
                    last_button.controlDown(radio_button)
                    last_button.controlRight(radio_button)
                last_button = radio_button

            continue_ctrl = self.getControl(CONTINUE_BUTTON)
            cancel_ctrl = self.getControl(CANCEL_BUTTON)
            self.radio_buttons[0].controlUp(cancel_ctrl)
            self.radio_buttons[0].controlLeft(cancel_ctrl)
            self.radio_buttons[-1].controlDown(continue_ctrl)
            self.radio_buttons[-1].controlRight(continue_ctrl)
            continue_ctrl.controlUp(self.radio_buttons[-1])
            continue_ctrl.controlLeft(self.radio_buttons[-1])
            cancel_ctrl.controlDown(self.radio_buttons[0])
            cancel_ctrl.controlRight(self.radio_buttons[0])
            
        def __get_radio_button(self, x, y, label):
            kwargs = {'font': 'font12', 'focusTexture': 'button-focus2.png', 'noFocusTexture': 'button-nofocus.png', 'focusOnTexture': 'radiobutton-focus.png',
                      'noFocusOnTexture': 'radiobutton-focus.png', 'focusOffTexture': 'radiobutton-nofocus.png', 'noFocusOffTexture': 'radiobutton-nofocus.png'}
            temp = xbmcgui.ControlRadioButton(x, y, 450, 30, label, **kwargs)
            return temp
            
        def onAction(self, action):
            # log_utils.log('Action: %s' % (action.getId()), log_utils.LOGDEBUG)
            if action == ACTION_PREVIOUS_MENU or action == ACTION_BACK:
                self.close()

        def onControl(self, control):
            # log_utils.log('onControl: %s' % (control), log_utils.LOGDEBUG)
            pass

        def onFocus(self, control):
            # log_utils.log('onFocus: %s' % (control), log_utils.LOGDEBUG)
            pass

        def onClick(self, control):
            # log_utils.log('onClick: %s' % (control), log_utils.LOGDEBUG)
            focus_button = self.getControl(control)
            if focus_button == self.radio_buttons[-1]:
                all_status = focus_button.isSelected()
                for button in self.radio_buttons:
                    button.setSelected(all_status)
            
            if control == CONTINUE_BUTTON:
                self.OK = True
                
            if control == CANCEL_BUTTON:
                self.OK = False

            if control == CONTINUE_BUTTON or control == CANCEL_BUTTON:
                self.close()
        
        def get_responses(self):
            return [bool(button.isSelected()) for button in self.radio_buttons]

#.........这里部分代码省略.........
开发者ID:SQL-MisterMagoo,项目名称:salts,代码行数:101,代码来源:gui_utils.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python transaction.abort函数代码示例发布时间:2022-05-27
下一篇:
Python helper.get_translation函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap