當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。