當前位置: 首頁>>代碼示例>>Python>>正文


Python TK_ROOT.after方法代碼示例

本文整理匯總了Python中tk_tools.TK_ROOT.after方法的典型用法代碼示例。如果您正苦於以下問題:Python TK_ROOT.after方法的具體用法?Python TK_ROOT.after怎麽用?Python TK_ROOT.after使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tk_tools.TK_ROOT的用法示例。


在下文中一共展示了TK_ROOT.after方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: check_cache

# 需要導入模塊: from tk_tools import TK_ROOT [as 別名]
# 或者: from tk_tools.TK_ROOT import after [as 別名]
def check_cache(zip_list):
    """Check to see if any zipfiles are invalid, and if so extract the cache."""
    global copy_process
    from BEE2_config import GEN_OPTS

    LOGGER.info('Checking cache...')

    cache_packs = GEN_OPTS.get_int('General', 'cache_pack_count')

    # We need to match the number of packages too, to account for removed ones.
    cache_stale = (len(packageLoader.packages) == cache_packs) or any(
        pack.is_stale()
        for pack in
        packageLoader.packages.values()
    )

    if not cache_stale:
        # We've already done the copying..
        LOGGER.info('Cache is still fresh, skipping extraction')
        done_callback()
        return

    copy_process = multiprocessing.Process(
        target=do_copy,
        args=(zip_list, currently_done),
    )
    copy_process.daemon = True
    LOGGER.info('Starting background extraction process!')
    copy_process.start()
    TK_ROOT.after(UPDATE_INTERVAL, update)
開發者ID:Coolasp1e,項目名稱:BEE2.4,代碼行數:32,代碼來源:extract_packages.py

示例2: start_copying

# 需要導入模塊: from tk_tools import TK_ROOT [as 別名]
# 或者: from tk_tools.TK_ROOT import after [as 別名]
def start_copying(zip_list):
    global copy_process
    copy_process = multiprocessing.Process(
        target=do_copy,
        args=(zip_list, currently_done),
    )
    copy_process.daemon = True
    LOGGER.info('Starting background process!')
    copy_process.start()
    TK_ROOT.after(UPDATE_INTERVAL, update)
開發者ID:SpyyZ158,項目名稱:BEE2.4,代碼行數:12,代碼來源:extract_packages.py

示例3: fx_blockable

# 需要導入模塊: from tk_tools import TK_ROOT [as 別名]
# 或者: from tk_tools.TK_ROOT import after [as 別名]
    def fx_blockable(sound: str) -> None:
        """Play a sound effect.

        This waits for a certain amount of time between retriggering sounds
        so they don't overlap.
        """
        global _play_repeat_sfx
        if play_sound and _play_repeat_sfx:
            fx(sound)
            _play_repeat_sfx = False
            TK_ROOT.after(75, _reset_fx_blockable)
開發者ID:BenVlodgi,項目名稱:BEE2.4,代碼行數:13,代碼來源:sound.py

示例4: play_sample

# 需要導入模塊: from tk_tools import TK_ROOT [as 別名]
# 或者: from tk_tools.TK_ROOT import after [as 別名]
        def play_sample(self, e=None):
            pass
            """Play a sample of music.

            If music is being played it will be stopped instead.
            """
            if self.cur_file is None:
                return

            if self.sample is not None:
                self.stop()
                return

            try:
                sound = pyglet.media.load(self.cur_file, streaming=False)
            # AVbin raises it's own error if the file isn't found..
            except (FileNotFoundError, pyglet.media.MediaFormatException):
                self.stop_callback()
                LOGGER.error('Sound sample not found: "{}"', self.cur_file)
                return  # Abort if music isn't found..

            self.sample = sound.play()
            self.after = TK_ROOT.after(
                int(sound.duration * 1000),
                self._finished,
            )
            self.start_callback()
開發者ID:Coolasp1e,項目名稱:BEE2.4,代碼行數:29,代碼來源:sound.py

示例5: flash_count

# 需要導入模塊: from tk_tools import TK_ROOT [as 別名]
# 或者: from tk_tools.TK_ROOT import after [as 別名]
def flash_count():
    """Flash the counter between 0 and 100 when on."""
    should_cont = False

    for var in (count_brush, count_entity, count_overlay):
        if not var.should_flash:
            continue  # Abort when it shouldn't be flashing

        if var.get() == 0:
            var.set(100)
        else:
            var.set(0)

        should_cont = True

    if should_cont:
        TK_ROOT.after(750, flash_count)
開發者ID:GLiTcH2,項目名稱:BEE2.4,代碼行數:19,代碼來源:CompilerPane.py

示例6: play_sample

# 需要導入模塊: from tk_tools import TK_ROOT [as 別名]
# 或者: from tk_tools.TK_ROOT import after [as 別名]
        def play_sample(self, e=None):
            pass
            """Play a sample of music.

            If music is being played it will be stopped instead.
            """
            if self.cur_file is None:
                return

            if self.sample is not None:
                self.stop()
                return

            with self.system:
                try:
                    file = self.system[self.cur_file]
                except (KeyError, FileNotFoundError):
                    self.stop_callback()
                    LOGGER.error('Sound sample not found: "{}"', self.cur_file)
                    return  # Abort if music isn't found..

            # TODO: Pyglet doesn't support direct streams, so we have to
            # TODO: extract sounds to disk first.

            fsystem = self.system.get_system(file)
            if isinstance(fsystem, RawFileSystem):
                # Special case, it's directly lying on the disk -
                # We can just pass that along.
                disk_filename = os.path.join(fsystem.path, file.path)
                LOGGER.info('Directly playing sample "{}"...', disk_filename)
            else:
                # In a filesystem, we need to extract it.
                # SAMPLE_WRITE_PATH + the appropriate extension.
                disk_filename = str(SAMPLE_WRITE_PATH.with_suffix(os.path.splitext(self.cur_file)[1]))
                LOGGER.info('Extracting music sample to "{}"...', disk_filename)
                with self.system.get_system(file), file.open_bin() as fsrc:
                    with open(disk_filename, 'wb') as fdest:
                        shutil.copyfileobj(fsrc, fdest)

            try:
                sound = pyglet.media.load(disk_filename, streaming=False)  # type: Source
            except MediaFormatException:
                self.stop_callback()
                LOGGER.exception('Sound sample not valid: "{}"', self.cur_file)
                return  # Abort if music isn't found..

            if self.start_time:
                try:
                    sound.seek(self.start_time)
                except CannotSeekException:
                    LOGGER.exception('Cannot seek in "{}"!', self.cur_file)

            self.sample = sound.play()
            self.after = TK_ROOT.after(
                int(sound.duration * 1000),
                self._finished,
            )
            self.start_callback()
開發者ID:BenVlodgi,項目名稱:BEE2.4,代碼行數:60,代碼來源:sound.py

示例7: enter_handler

# 需要導入模塊: from tk_tools import TK_ROOT [as 別名]
# 或者: from tk_tools.TK_ROOT import after [as 別名]
 def enter_handler(e):
     """Schedule showing the tooltip."""
     nonlocal event_id
     if targ_widget.tooltip_text:
         if hasattr(targ_widget, 'instate'):
             if not targ_widget.instate(('!disabled',)):
                 return
         event_id = TK_ROOT.after(
             delay,
             after_complete,
         )
開發者ID:Coolasp1e,項目名稱:BEE2.4,代碼行數:13,代碼來源:tooltip.py

示例8: update

# 需要導入模塊: from tk_tools import TK_ROOT [as 別名]
# 或者: from tk_tools.TK_ROOT import after [as 別名]
def update():
    """Check the progress of the copying until it's done.
    """
    progress_var.set(
        1000 * currently_done.value / res_count,
    )
    export_btn_text.set(
        'Extracting Resources ({!s}/{!s})...'.format(
            currently_done.value,
            res_count,
        )
    )
    if not copy_process.is_alive():
        # We've finished copying
        export_btn_text.set(
            'Export...'
        )
        done_callback()
    else:
        # Coninuously tell TK to re-run this, so we update
        # without deadlocking the CPU
        TK_ROOT.after(UPDATE_INTERVAL, update)
開發者ID:SpyyZ158,項目名稱:BEE2.4,代碼行數:24,代碼來源:extract_packages.py

示例9: enter_handler

# 需要導入模塊: from tk_tools import TK_ROOT [as 別名]
# 或者: from tk_tools.TK_ROOT import after [as 別名]
 def enter_handler(event):
     """Schedule showing the tooltip."""
     nonlocal event_id
     # noinspection PyUnresolvedReferences, PyProtectedMember
     if targ_widget._bee2_tooltip_text or targ_widget._bee2_tooltip_img is not None:
         # We know it has this method from above!
         # noinspection PyUnresolvedReferences
         if check_disabled and not targ_widget.instate(('!disabled',)):
             return
         event_id = TK_ROOT.after(
             delay,
             after_complete,
             event.x_root, event.y_root,
         )
開發者ID:BenVlodgi,項目名稱:BEE2.4,代碼行數:16,代碼來源:tooltip.py

示例10: ui_new_backup

# 需要導入模塊: from tk_tools import TK_ROOT [as 別名]
# 或者: from tk_tools.TK_ROOT import after [as 別名]
        width=11,
    ).grid(row=0, column=2)

    ttk.Button(
        toolbar_frame,
        text='.. As',
        command=ui_save_backup_as,
        width=5,
    ).grid(row=0, column=3)

    toolbar_frame.grid(row=0, column=0, columnspan=3, sticky='W')

    ui_new_backup()


if __name__ == '__main__':
    # Run this standalone.

    init_application()

    TK_ROOT.deiconify()

    def fix_details():
        # It takes a while before the detail headers update positions,
        # so delay a refresh call.
        TK_ROOT.update_idletasks()
        UI['game_details'].refresh()
    TK_ROOT.after(500, fix_details)

    TK_ROOT.mainloop()
開發者ID:Coolasp1e,項目名稱:BEE2.4,代碼行數:32,代碼來源:backup.py

示例11: block_fx

# 需要導入模塊: from tk_tools import TK_ROOT [as 別名]
# 或者: from tk_tools.TK_ROOT import after [as 別名]
 def block_fx():
     """Block fx_blockable() for a short time."""
     global _play_repeat_sfx
     _play_repeat_sfx = False
     TK_ROOT.after(50, _reset_fx_blockable)
開發者ID:BenVlodgi,項目名稱:BEE2.4,代碼行數:7,代碼來源:sound.py

示例12: next_error

# 需要導入模塊: from tk_tools import TK_ROOT [as 別名]
# 或者: from tk_tools.TK_ROOT import after [as 別名]
 def next_error():
     # Use False since functions return None usually
     if next(err_iterator, False) is not False:
         TK_ROOT.after(1000, next_error)
開發者ID:Coolasp1e,項目名稱:BEE2.4,代碼行數:6,代碼來源:logWindow.py

示例13: init

# 需要導入模塊: from tk_tools import TK_ROOT [as 別名]
# 或者: from tk_tools.TK_ROOT import after [as 別名]
if __name__ == '__main__':
    utils.init_logging()
    init(True, log_level=logging.DEBUG)

    # Generate a bunch of log messages to test the window.
    def errors():
        # Use a generator to easily run these functions with a delay.
        yield LOGGER.info('Info Message')
        yield LOGGER.critical('Critical Message')
        yield LOGGER.warning('Warning')

        try:
            raise ValueError('An error')
        except ValueError:
            yield LOGGER.exception('Error message')

        yield LOGGER.warning('Post-Exception warning')
        yield LOGGER.info('Info')
        yield LOGGER.debug('Debug Message')

    err_iterator = errors()

    def next_error():
        # Use False since functions return None usually
        if next(err_iterator, False) is not False:
            TK_ROOT.after(1000, next_error)

    TK_ROOT.after(1000, next_error)
    TK_ROOT.mainloop()
開發者ID:Coolasp1e,項目名稱:BEE2.4,代碼行數:31,代碼來源:logWindow.py


注:本文中的tk_tools.TK_ROOT.after方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。