Esempio n. 1
0
def _run_terms_window():
    def accept():
        config.set("eula", True)
        root.destroy()

    def disable_enable_button():
        accept_button.config(state=NORMAL if check_value.get() else DISABLED)

    root = Tk()
    message = f'I agree to the [Terms of Service and Privacy Policy]({web.get_terms_page()})'
    root.title("EULA")
    root.resizable(False, False)
    root.iconbitmap(helper.manifest_file('icon.ico'))

    f = Frame(root)
    canvas = Canvas(f, width=300, height=200)
    canvas.pack()
    root.image = Image.open(helper.manifest_file('fishybot_logo.png')).resize(
        (300, 200))
    root.image = ImageTk.PhotoImage(root.image)
    canvas.create_image(0, 0, anchor=NW, image=root.image)

    check_value = IntVar(0)

    g1 = Frame(f)
    Checkbutton(g1, command=disable_enable_button,
                variable=check_value).pack(side=LEFT)
    text = Text(g1,
                width=len(hyperlinkPattern.sub(r'\g<title>', message)),
                height=1,
                borderwidth=0,
                highlightthickness=0)
    text["background"] = root["background"]

    _format_hyper_link(text, message)
    text.config(state=DISABLED)
    text.pack(side=LEFT)
    g1.pack()

    f.pack(padx=(10, 10), pady=(20, 20))

    g2 = Frame(f)
    accept_button = Button(g2, text="Accept", command=accept)
    accept_button.grid(row=0, column=0)
    Button(g2, text="Deny", command=lambda: root.destroy()).grid(row=0,
                                                                 column=1)
    g2.pack(pady=(5, 0))
    disable_enable_button()

    root.mainloop()
Esempio n. 2
0
def show(currentversion, newversion, returns):
    top = Tk()
    top.title("A wild fishy update appeared!")
    top.iconbitmap(helper.manifest_file('icon.ico'))

    dialogLabel = Label(top, text="There is a new fishy update available ("+currentversion+"->"+newversion+"). Do you want to update now?")
    dialogLabel.grid(row=0, columnspan=2, padx=5, pady=5)

    cbVar = IntVar()
    dialogCheckbutton = Checkbutton(top, text="don't ask again", variable=cbVar)
    dialogCheckbutton.grid(row=1, columnspan=2, padx=5, pady=0)
    top.update()
    buttonWidth = int(dialogLabel.winfo_width()/2)-20

    def _clickYes():
        returns[0],returns[1]=True, False
        top.destroy()

    def _clickNo():
        returns[0],returns[1]=False, bool(cbVar.get())
        top.destroy()

    pixelVirtual = PhotoImage(width=1, height=1) # trick to use buttonWidth as pixels, not #symbols
    dialogBtnNo = Button(top, text="No " + str(chr(10005)),  fg='red4', command=_clickNo, image=pixelVirtual, width=buttonWidth, compound="c")
    dialogBtnNo.grid(row=2, column=0, padx=5, pady=5)
    dialogBtnYes = Button(top, text="Yes " + str(chr(10003)),  fg='green', command=_clickYes, image=pixelVirtual, width=buttonWidth, compound="c")
    dialogBtnYes.grid(row=2, column=1, padx=5, pady=5)
    dialogBtnYes.focus_set()

    top.protocol('WM_DELETE_WINDOW', _clickNo)

    top.update()
    top.mainloop()
Esempio n. 3
0
    def _event_loop(self):
        while True:
            key = self.outq.get()

            if key in Key:
                callback = self._hotkeys[key]
                if callback:
                    playsound(helper.manifest_file("beep.wav"), False)
                    callback()
            elif key == "stop":
                break

            time.sleep(0.1)
Esempio n. 4
0
def _create(gui: 'GUI'):
    engines = gui.engines

    gui._root = ThemedTk(theme="equilux", background=True)
    gui._root.title("Fishybot for Elder Scrolls Online")
    gui._root.iconbitmap(helper.manifest_file('icon.ico'))

    # region menu
    menubar = Menu(gui._root)

    filemenu = Menu(menubar, tearoff=0)

    login = web.is_logged_in()
    gui.login = IntVar()
    gui.login.set(1 if login > 0 else 0)
    state = DISABLED if login == -1 else ACTIVE
    filemenu.add_checkbutton(label="Login",
                             command=lambda: discord_login(gui),
                             variable=gui.login,
                             state=state)
    filemenu.add_command(label="Create Shortcut",
                         command=lambda: helper.create_shortcut(False))

    # filemenu.add_command(label="Create Anti-Ghost Shortcut", command=lambda: helper.create_shortcut(True))

    def _toggle_mode():
        config.set("dark_mode", not config.get("dark_mode", True))
        gui._start_restart = True

    dark_mode_var = IntVar()
    dark_mode_var.set(int(config.get('dark_mode', True)))
    filemenu.add_checkbutton(label="Dark Mode",
                             command=_toggle_mode,
                             variable=dark_mode_var)
    if config.get("dont_ask_update", False):
        filemenu.add_command(label="Update", command=helper.update)

    def installer():
        if filemenu.entrycget(4, 'label') == "Remove Chalutier":
            if helper.remove_addon(chalutier[0]) == 0:
                filemenu.entryconfigure(4, label="Install Chalutier")
        else:
            r = helper.install_addon(*chalutier)
            r += helper.install_addon(*lam2)
            if r == 0:
                filemenu.entryconfigure(4, label="Remove Chalutier")

    chaEntry = "Remove Chalutier" if helper.addon_exists(
        chalutier[0]) else "Install Chalutier"
    filemenu.add_command(label=chaEntry, command=installer)
    menubar.add_cascade(label="Options", menu=filemenu)

    debug_menu = Menu(menubar, tearoff=0)
    debug_menu.add_command(label="Check PixelVal",
                           command=lambda: gui.engine.check_pixel_val())

    debug_var = IntVar()
    debug_var.set(int(config.get('debug', False)))

    def keep_console():
        config.set("debug", bool(debug_var.get()))
        logging.debug("Restart to update the changes")

    debug_menu.add_checkbutton(label="Keep Console",
                               command=keep_console,
                               variable=debug_var)
    debug_menu.add_command(label="Restart", command=helper.restart)
    menubar.add_cascade(label="Debug", menu=debug_menu)

    help_menu = Menu(menubar, tearoff=0)
    help_menu.add_command(
        label="Need Help?",
        command=lambda: helper.open_web("http://discord.definex.in"))
    help_menu.add_command(
        label="Donate",
        command=lambda: helper.open_web("https://paypal.me/AdamSaudagar"))
    menubar.add_cascade(label="Help", menu=help_menu)

    gui._root.config(menu=menubar)
    # endregion

    # region console
    gui._console = Text(gui._root,
                        state='disabled',
                        wrap='none',
                        background="#707070",
                        fg="#ffffff")
    gui._console.pack(fill=BOTH, expand=True, pady=(15, 15), padx=(10, 10))
    gui._console.mark_set("sentinel", INSERT)
    gui._console.config(state=DISABLED)
    # endregion

    # region controls
    start_frame = Frame(gui._root)

    gui._engine_var = StringVar(start_frame)
    labels = list(engines.keys())
    last_started = config.get("last_started", labels[0])
    gui._engine_select = OptionMenu(start_frame, gui._engine_var, last_started,
                                    *labels)
    gui._engine_select.pack(side=LEFT)

    gui._config_button = Button(
        start_frame,
        text="⚙",
        width=0,
        command=lambda: engines[gui._engine_var.get()][0]())
    gui._config_button.pack(side=RIGHT)

    gui._start_button = Button(start_frame,
                               text=gui._get_start_stop_text(),
                               width=25,
                               command=gui.funcs.start_engine)
    gui._start_button.pack(side=RIGHT)

    start_frame.pack(padx=(10, 10), pady=(5, 15), fill=X)
    # endregion

    _apply_theme(gui)
    gui._root.update()
    gui._root.minsize(gui._root.winfo_width() + 10,
                      gui._root.winfo_height() + 10)
    if config.get("win_loc") is not None:
        gui._root.geometry(config.get("win_loc"))

    hotkey.set_hotkey(Key.F9, gui.funcs.start_engine)

    # noinspection PyProtectedMember
    def set_destroy():
        if gui._bot_running:
            if not messagebox.askyesno(
                    title="Quit?", message="Bot engine running. Quit Anyway?"):
                return

        config.set("win_loc", gui._root.geometry())
        gui._destroyed = True

    gui._root.protocol("WM_DELETE_WINDOW", set_destroy)
    gui._destroyed = False

    while True:
        gui._root.update()
        gui._clear_function_queue()
        if gui._start_restart:
            gui._root.destroy()
            gui._root.quit()
            gui._start_restart = False
            gui.create()
        if gui._destroyed:
            gui.engine.quit()
            break
        time.sleep(0.01)
Esempio n. 5
0
def _create(gui: 'GUI'):
    engines = gui.engines

    gui._root = ThemedTk(theme="equilux", background=True)
    gui._root.title("Fishybot for Elder Scrolls Online")

    gui._root.iconbitmap(helper.manifest_file('icon.ico'))

    # region menu
    menubar = Menu(gui._root)

    filemenu = Menu(menubar, tearoff=0)
    filemenu.add_command(label="Create Shortcut", command=helper.create_shortcut)

    def _toggle_mode():
        gui._config.set("dark_mode", not gui._config.get("dark_mode", True))
        gui._start_restart = True

    dark_mode_var = IntVar()
    dark_mode_var.set(int(gui._config.get('dark_mode', True)))
    filemenu.add_checkbutton(label="Dark Mode", command=_toggle_mode,
                             variable=dark_mode_var)

    menubar.add_cascade(label="File", menu=filemenu)

    debug_menu = Menu(menubar, tearoff=0)
    debug_menu.add_command(label="Check PixelVal",
                           command=lambda: gui.engine.check_pixel_val())

    debug_var = IntVar()
    debug_var.set(int(gui._config.get('debug', False)))

    def keep_console():
        gui._config.set("debug", bool(debug_var.get()))
        logging.debug("Restart to update the changes")

    debug_menu.add_checkbutton(label="Keep Console", command=keep_console, variable=debug_var)
    debug_menu.add_command(label="Restart", command=helper.restart)
    menubar.add_cascade(label="Debug", menu=debug_menu)

    help_menu = Menu(menubar, tearoff=0)
    help_menu.add_command(label="Need Help?", command=lambda: helper.open_web("http://discord.definex.in"))
    help_menu.add_command(label="Donate", command=lambda: helper.open_web("https://paypal.me/AdamSaudagar"))
    menubar.add_cascade(label="Help", menu=help_menu)

    gui._root.config(menu=menubar)
    # endregion

    # region console
    gui._console = Text(gui._root, state='disabled', wrap='none', background="#707070", fg="#ffffff")
    gui._console.pack(fill=BOTH, expand=True, pady=(15, 15), padx=(10, 10))
    gui._console.mark_set("sentinel", INSERT)
    gui._console.config(state=DISABLED)
    # endregion

    # region controls
    start_frame = Frame(gui._root)

    gui._engine_var = StringVar(start_frame)
    labels = list(engines.keys())
    last_started = gui._config.get("last_started", labels[0])
    gui._engine_select = OptionMenu(start_frame, gui._engine_var, last_started, *labels)
    gui._engine_select.pack(side=LEFT)

    gui._config_button = Button(start_frame, text="⚙", width=0, command=lambda: engines[gui._engine_var.get()][0]())
    gui._config_button.pack(side=RIGHT)

    gui._start_button = Button(start_frame, text=gui._get_start_stop_text(), width=25,
                               command=gui.funcs.start_engine)
    gui._start_button.pack(side=RIGHT)

    start_frame.pack(padx=(10, 10), pady=(5, 15), fill=X)
    # endregion

    _apply_theme(gui)
    gui._root.update()
    gui._root.minsize(gui._root.winfo_width() + 10, gui._root.winfo_height() + 10)

    hotkey.set_hotkey("f9", gui.funcs.start_engine)

    def set_destroy():
        gui._destroyed = True

    gui._root.protocol("WM_DELETE_WINDOW", set_destroy)
    gui._destroyed = False

    while True:
        gui._root.update()
        gui._clear_function_queue()
        if gui._start_restart:
            gui._root.destroy()
            gui._root.quit()
            gui._start_restart = False
            gui.create()
        if gui._destroyed:
            gui.engine.quit()
            break
        time.sleep(0.01)
Esempio n. 6
0
 def __init__(self, quit_callback, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.running = True
     self.quit_callback = quit_callback
     self.protocol("WM_DELETE_WINDOW", self.quit_top)
     self.iconbitmap(helper.manifest_file('icon.ico'))
Esempio n. 7
0
def _create(gui: 'GUI'):
    engines = gui.engines

    gui._root = ThemedTk(theme="equilux", background=True)
    gui._root.attributes('-alpha', 0.0)
    gui._root.title("Fishybot for Elder Scrolls Online")
    gui._root.iconbitmap(helper.manifest_file('icon.ico'))

    # region menu
    menubar = tk.Menu(gui._root)

    filemenu = tk.Menu(menubar, tearoff=0)

    login = web.is_logged_in()
    gui.login = tk.IntVar()
    gui.login.set(1 if login > 0 else 0)
    state = tk.DISABLED if login == -1 else tk.ACTIVE
    filemenu.add_checkbutton(label="Login",
                             command=lambda: discord_login(gui),
                             variable=gui.login,
                             state=state)
    filemenu.add_command(label="Create Shortcut",
                         command=lambda: helper.create_shortcut(False))

    # filemenu.add_command(label="Create Anti-Ghost Shortcut", command=lambda: helper.create_shortcut(True))

    def _toggle_mode():
        config.set("dark_mode", not config.get("dark_mode", True))
        gui._start_restart = True

    dark_mode_var = tk.IntVar()
    dark_mode_var.set(int(config.get('dark_mode', True)))
    filemenu.add_checkbutton(label="Dark Mode",
                             command=_toggle_mode,
                             variable=dark_mode_var)

    def update():
        config.delete("dont_ask_update")
        update_dialog.check_update(gui, True)

    filemenu.add_command(label="Update", command=update)

    def installer():
        if filemenu.entrycget(4, 'label') == "Remove FishyQR":
            if helper.remove_addon(fishyqr[0]) == 0:
                filemenu.entryconfigure(4, label="Install FishyQR")
        else:
            helper.install_required_addons(True)
            filemenu.entryconfigure(4, label="Remove FishyQR")

    chaEntry = "Remove FishyQR" if helper.addon_exists(
        fishyqr[0]) else "Install FishyQR"
    filemenu.add_command(label=chaEntry, command=installer)
    menubar.add_cascade(label="Options", menu=filemenu)

    debug_menu = tk.Menu(menubar, tearoff=0)
    debug_menu.add_command(label="Check QR Value",
                           command=lambda: gui.engine.check_qr_val())

    debug_var = tk.IntVar()
    debug_var.set(int(config.get('debug', False)))

    def keep_console():
        config.set("debug", bool(debug_var.get()))
        logging.debug("Restart to update the changes")

    debug_menu.add_checkbutton(label="Keep Console",
                               command=keep_console,
                               variable=debug_var)
    menubar.add_cascade(label="Debug", menu=debug_menu)

    help_menu = tk.Menu(menubar, tearoff=0)
    help_menu.add_command(
        label="Need Help?",
        command=lambda: helper.open_web(
            "https://github.com/fishyboteso/fishyboteso/wiki"))
    help_menu.add_command(
        label="Donate",
        command=lambda: helper.open_web("https://paypal.me/AdamSaudagar"))
    menubar.add_cascade(label="Help", menu=help_menu)

    gui._root.config(menu=menubar)
    # endregion

    # region console
    gui._console = tk.Text(gui._root,
                           state='disabled',
                           wrap='none',
                           background="#707070",
                           fg="#ffffff")
    gui._console.pack(fill=tk.BOTH, expand=True, pady=(15, 15), padx=(10, 10))
    gui._console.mark_set("sentinel", tk.INSERT)
    gui._console.config(state=tk.DISABLED)
    # endregion

    # region controls
    start_frame = ttk.Frame(gui._root)

    gui._engine_var = tk.StringVar(start_frame)
    labels = list(engines.keys())
    last_started = config.get("last_started", labels[0])
    gui._engine_select = ttk.OptionMenu(start_frame, gui._engine_var,
                                        last_started, *labels)
    gui._engine_select.pack(side=tk.LEFT)

    gui._config_button = ttk.Button(
        start_frame,
        text="⚙",
        width=0,
        command=lambda: engines[gui._engine_var.get()].config())
    gui._config_button.pack(side=tk.RIGHT)

    gui._start_button = ttk.Button(start_frame,
                                   text=gui._get_start_stop_text(),
                                   width=25,
                                   command=gui.funcs.start_engine)
    gui._start_button.pack(side=tk.RIGHT)

    start_frame.pack(padx=(10, 10), pady=(5, 15), fill=tk.X)
    # endregion

    _apply_theme(gui)
    gui._root.update()

    gui._root.minsize(gui._root.winfo_width() + 10,
                      gui._root.winfo_height() + 10)
    if config.get("win_loc") is not None:
        gui._root.geometry(config.get("win_loc").split(":")[-1])
        if config.get("win_loc").split(":")[0] == "zoomed":
            gui._root.update()
            gui._root.state("zoomed")

    hotkey.hook(Key.F9, gui.funcs.start_engine)

    # noinspection PyProtectedMember,PyUnresolvedReferences
    def set_destroy():
        if gui._bot_running:
            if not tk.messagebox.askyesno(
                    title="Quit?", message="Bot engine running. Quit Anyway?"):
                return

        if gui._root.state() == "zoomed":
            # setting it to normal first is done to keep user-changed geometry values
            gui._root.state("normal")
            config.set("win_loc", "zoomed" + ":" + gui._root.geometry())
        else:
            config.set("win_loc",
                       gui._root.state() + ":" + gui._root.geometry())

        gui._destroyed = True

    gui._root.protocol("WM_DELETE_WINDOW", set_destroy)
    gui._destroyed = False

    gui._root.update()
    gui._clear_function_queue()
    gui._root.after(0, gui._root.attributes, "-alpha", 1.0)
    gui.on_ready()
    while True:
        gui._root.update()
        gui._clear_function_queue()
        if gui._start_restart:
            gui._root.destroy()
            gui._root.quit()
            gui._start_restart = False
            gui.create()
        if gui._destroyed:
            gui.engine.quit_me()
            break
        time.sleep(0.01)