当前位置: 首页>>代码示例>>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;未经允许,请勿转载。