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


Python tk_tools.TK_ROOT类代码示例

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


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

示例1: check_cache

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,代码行数:30,代码来源:extract_packages.py

示例2: exit_handler

 def exit_handler(e):
     """When the user leaves, cancel the event."""
     # We only want to cancel if the event hasn't expired already
     nonlocal event_id
     hide()
     if event_id is not None:
         TK_ROOT.after_cancel(
             event_id
         )
开发者ID:Coolasp1e,项目名称:BEE2.4,代码行数:9,代码来源:tooltip.py

示例3: start_copying

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,代码行数:10,代码来源:extract_packages.py

示例4: fx_blockable

    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,代码行数:11,代码来源:sound.py

示例5: stop

        def stop(self):
            """Cancel the music, if it's playing."""
            if self.sample is None:
                return

            self.sample.pause()
            self.sample = None
            self.stop_callback()

            if self.after is not None:
                TK_ROOT.after_cancel(self.after)
                self.after = None
开发者ID:Coolasp1e,项目名称:BEE2.4,代码行数:12,代码来源:sound.py

示例6: open_win

    def open_win(self, _=None, force_open=False):
        if self._readonly and not force_open:
            TK_ROOT.bell()
            return 'break'  # Tell tk to stop processing this event

        self.win.deiconify()
        self.win.lift(self.parent)
        self.win.grab_set()
        self.win.focus_force()  # Focus here to deselect the textbox

        utils.center_win(self.win, parent=self.parent)

        self.sel_item(self.selected)
        self.win.after(2, self.flow_items)
开发者ID:GLiTcH2,项目名称:BEE2.4,代码行数:14,代码来源:selectorWin.py

示例7: show_prop

def show_prop(widget, warp_cursor=False):
    """Show the properties window for an item.

    wid should be the UI.PalItem widget that represents the item.
    If warp_cursor is  true, the cursor will be moved relative to this window so
    it stays on top of the selected subitem.
    """
    global selected_item, selected_sub_item, is_open
    if warp_cursor and is_open:
        cursor_x, cursor_y = prop_window.winfo_pointerxy()
        off_x = cursor_x-prop_window.winfo_rootx()
        off_y = cursor_y-prop_window.winfo_rooty()
    else:
        off_x, off_y = None, None
    prop_window.deiconify()
    prop_window.lift(TK_ROOT)
    selected_item = widget.item
    selected_sub_item = widget
    is_open = True

    icon_widget = wid['subitem'][pos_for_item()]

    # Calculate the pixel offset between the window and the subitem in
    # the properties dialog, and shift if needed to keep it inside the
    # window
    loc_x, loc_y = utils.adjust_inside_screen(
        x=(
            widget.winfo_rootx()
            + prop_window.winfo_rootx()
            - icon_widget.winfo_rootx()
        ),
        y=(
            widget.winfo_rooty()
            + prop_window.winfo_rooty()
            - icon_widget.winfo_rooty()
        ),
        win=prop_window,
    )

    prop_window.geometry('+{x!s}+{y!s}'.format(x=loc_x, y=loc_y))
    prop_window.relX = loc_x-TK_ROOT.winfo_x()
    prop_window.relY = loc_y-TK_ROOT.winfo_y()

    if off_x is not None and off_y is not None:
        # move the mouse cursor
        prop_window.event_generate('<Motion>', warp=True, x=off_x, y=off_y)

    load_item_data()
开发者ID:SpyyZ158,项目名称:BEE2.4,代码行数:48,代码来源:contextWin.py

示例8: play_sample

        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,代码行数:27,代码来源:sound.py

示例9: init_application

def init_application():
    """Initialise the standalone application."""
    global window
    window = TK_ROOT
    TK_ROOT.title(
        _('BEEMOD {} - Backup / Restore Puzzles').format(utils.BEE_VERSION)
    )

    init()

    UI['bar'] = bar = tk.Menu(TK_ROOT)
    window.option_add('*tearOff', False)

    gameMan.load()
    ui_new_backup()

    # UI.py isn't present, so we use this callback
    gameMan.setgame_callback = load_game

    if utils.MAC:
        # Name is used to make this the special 'BEE2' menu item
        file_menu = menus['file'] = tk.Menu(bar, name='apple')
    else:
        file_menu = menus['file'] = tk.Menu(bar)
    file_menu.add_command(label=_('New Backup'), command=ui_new_backup)
    file_menu.add_command(label=_('Open Backup'), command=ui_load_backup)
    file_menu.add_command(label=_('Save Backup'), command=ui_save_backup)
    file_menu.add_command(label=_('Save Backup As'), command=ui_save_backup_as)

    bar.add_cascade(menu=file_menu, label=_('File'))

    game_menu = menus['game'] = tk.Menu(bar)

    game_menu.add_command(label=_('Add Game'), command=gameMan.add_game)
    game_menu.add_command(label=_('Remove Game'), command=gameMan.remove_game)
    game_menu.add_separator()

    bar.add_cascade(menu=game_menu, label=_('Game'))

    import helpMenu
    # Add the 'Help' menu here too.
    helpMenu.make_help_menu(bar)

    window['menu'] = bar

    gameMan.add_menu_opts(game_menu)
    gameMan.game_menu = game_menu
开发者ID:BenVlodgi,项目名称:BEE2.4,代码行数:47,代码来源:backup.py

示例10: flash_count

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,代码行数:17,代码来源:CompilerPane.py

示例11: play_sample

        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,代码行数:58,代码来源:sound.py

示例12: expand

def expand(_):
    """Expand the filter view."""
    global is_expanded
    is_expanded = True
    wid["expand_frame"].grid(row=2, column=0, columnspan=2, sticky="NSEW")
    wid["tag_list"]["height"] = TK_ROOT.winfo_height() / 48

    snd.fx("expand")
    UI.flow_picker()
开发者ID:BenVlodgi,项目名称:BEE2.4,代码行数:9,代码来源:tagsPane.py

示例13: enter_handler

 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,代码行数:11,代码来源:tooltip.py

示例14: open_win

    def open_win(self, e=None, force_open=False):
        if self._readonly and not force_open:
            TK_ROOT.bell()
            return 'break'  # Tell tk to stop processing this event

        self.win.deiconify()
        self.win.lift(self.parent)
        if self.modal:
            self.win.grab_set()
        self.win.focus_force()  # Focus here to deselect the textbox

        # If we have a sound sampler, hold the system open while the window
        # is so it doesn't snap open/closed while finding files.
        if self.sampler is not None and self.sampler_held_open is False:
            self.sampler_held_open = True
            self.sampler.system.open_ref()

        utils.center_win(self.win, parent=self.parent)

        self.sel_item(self.selected)
        self.win.after(2, self.flow_items)
开发者ID:BenVlodgi,项目名称:BEE2.4,代码行数:21,代码来源:selectorWin.py

示例15: show_more_info

 def show_more_info():
     url = selected_item.url
     if url is not None:
         try:
             webbrowser.open(url, new=OPEN_IN_TAB, autoraise=True)
         except webbrowser.Error:
             if messagebox.askyesno(
                     icon="error",
                     title="BEE2 - Error",
                     message='Failed to open a web browser. Do you wish for '
                             'the URL to be copied to the clipboard '
                             'instead?',
                     detail='"{!s}"'.format(url),
                     parent=prop_window
                     ):
                 LOGGER.info("Saving {} to clipboard!", url)
                 TK_ROOT.clipboard_clear()
                 TK_ROOT.clipboard_append(url)
         # Either the webbrowser or the messagebox could cause the
         # properties to move behind the main window, so hide it
         # so it doesn't appear there.
         hide_context(None)
开发者ID:GLiTcH2,项目名称:BEE2.4,代码行数:22,代码来源:contextWin.py


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