コード例 #1
0
 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)
コード例 #2
0
ファイル: tooltip.py プロジェクト: Stendec-UA/BEE2.4
 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
         )
コード例 #3
0
def start_copying(zip_list):
    global copy_process
    copy_process = multiprocessing.Process(
        target=do_copy,
        args=(zip_list, currently_done),
    )
    copy_process.daemon = True
    print(copy_process)
    print('Starting background process!')
    copy_process.start()
    TK_ROOT.after(UPDATE_INTERVAL, update)
コード例 #4
0
ファイル: selectorWin.py プロジェクト: Stendec-UA/BEE2.4
    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.flow_items()
        self.sel_item(self.selected)
コード例 #5
0
ファイル: contextWin.py プロジェクト: Stendec-UA/BEE2.4
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()
コード例 #6
0
ファイル: contextWin.py プロジェクト: Stendec-UA/BEE2.4
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()
コード例 #7
0
 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,
         )
コード例 #8
0
ファイル: tooltip.py プロジェクト: Stendec-UA/BEE2.4
 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,
         )
コード例 #9
0
ファイル: contextWin.py プロジェクト: Stendec-UA/BEE2.4
 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):
                 print("Saving " + url + "to clipboard!")
                 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)
コード例 #10
0
ファイル: contextWin.py プロジェクト: Stendec-UA/BEE2.4
 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
                     ):
                 print("Saving " + url + "to clipboard!")
                 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)
コード例 #11
0
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)
コード例 #12
0
ファイル: selectorWin.py プロジェクト: GiovanH/BEE2.4
                    break
            else:  # Not found
                self.suggested = None

        if self.suggested is not None:
            self.context_menu.entryconfig(
                self.item_list.index(self.suggested),
                font=self.sugg_font)
        self.set_disp()  # Update the textbox if needed
        self.flow_items()  # Refresh

if __name__ == '__main__':  # test the window if directly executing this file
    from tk_root import TK_ROOT
    lbl = ttk.Label(TK_ROOT, text="I am a demo window.")
    lbl.grid()
    TK_ROOT.geometry("+500+500")

    test_list = [
        Item(
            "SKY_BLACK",
            "Black",
            long_name="Darkness",
            icon="skies/black",
            authors=["Valve"],
            desc=[
                ('line', 'Pure black darkness. Nothing to see here.'),
                ],
            ),
        Item(
            "SKY_BTS",
            "BTS",
コード例 #13
0
ファイル: itemPropWin.py プロジェクト: xDadiKx/BEE2.4
    win.after(50, reset_sfx)

    widgets['titleLabel'].configure(text='Settings for "' + item_name + '"')
    win.title('BEE2 - ' + item_name)
    win.transient(master=parent)
    win.deiconify()
    win.lift(parent)
    win.grab_set()
    win.geometry(
        '+' + str(parent.winfo_rootx() - 30) +
        '+' + str(parent.winfo_rooty() - win.winfo_reqheight() - 30)
        )

# load the window if directly executing this file
if __name__ == '__main__':
    TK_ROOT.geometry('+250+250')

    def callback(vals):
        for key, value in sorted(vals.items()):
            print(key + ' = ' + repr(value))

    init(callback)
    all_vals = {
        'startup': '1',
        'toplevel': '4',
        'bottomlevel': '3',
        'angledpanelanimation': 'ramp_45_deg_open',
        'startenabled': '1',
        'startreversed': '0',
        'startdeployed': '1',
        'startactive': '1',
コード例 #14
0
ファイル: contextWin.py プロジェクト: Stendec-UA/BEE2.4
def follow_main(_=None):
    """Move the properties window to keep a relative offset to the main window.

    """
    prop_window.geometry('+'+str(prop_window.relX+TK_ROOT.winfo_x()) +
                         '+'+str(prop_window.relY+TK_ROOT.winfo_y()))
コード例 #15
0
ファイル: contextWin.py プロジェクト: Stendec-UA/BEE2.4
def follow_main(_=None):
    """Move the properties window to keep a relative offset to the main window.

    """
    prop_window.geometry('+' + str(prop_window.relX + TK_ROOT.winfo_x()) +
                         '+' + str(prop_window.relY + TK_ROOT.winfo_y()))
コード例 #16
0
ファイル: itemPropWin.py プロジェクト: Stendec-UA/BEE2.4
    block_sound = False
    win.after(50, reset_sfx)

    widgets['titleLabel'].configure(text='Settings for "' + item_name + '"')
    win.title('BEE2 - ' + item_name)
    win.transient(master=parent)
    win.deiconify()
    win.lift(parent)
    win.grab_set()
    win.geometry('+' + str(parent.winfo_rootx() - 30) + '+' +
                 str(parent.winfo_rooty() - win.winfo_reqheight() - 30))


# load the window if directly executing this file
if __name__ == '__main__':
    TK_ROOT.geometry('+250+250')

    def callback(vals):
        for key, value in sorted(vals.items()):
            print(key + ' = ' + repr(value))

    init(callback)
    all_vals = {
        'startup': '1',
        'toplevel': '4',
        'bottomlevel': '3',
        'angledpanelanimation': 'ramp_45_deg_open',
        'startenabled': '1',
        'startreversed': '0',
        'startdeployed': '1',
        'startactive': '1',
コード例 #17
0
ファイル: selectorWin.py プロジェクト: Stendec-UA/BEE2.4
                    self.suggested = item
                    break
            else:  # Not found
                self.suggested = None

        if self.suggested is not None:
            self.context_menu.entryconfig(
                self.item_list.index(self.suggested),
                font=self.sugg_font)
        self.set_disp()  # Update the textbox if needed
        self.flow_items()  # Refresh

if __name__ == '__main__':  # test the window if directly executing this file
    lbl = ttk.Label(TK_ROOT, text="I am a demo window.")
    lbl.grid()
    TK_ROOT.geometry("+500+500")

    test_list = [
        Item(
            "SKY_BLACK",
            "Black",
            long_name="Darkness",
            icon="skies/black",
            authors=["Valve"],
            desc=[
                ('line', 'Pure black darkness. Nothing to see here.'),
                ],
            ),
        Item(
            "SKY_BTS",
            "BTS",