예제 #1
0
def tray():
    global icon, thread
    icon = None
    thread = None

    name = 'ED - Autopilot'
    icon = Icon(name=name, title=name)
    logo = Image.open(resource_path('src/logo.png'))
    icon.icon = logo

    icon.menu = Menu(
        MenuItem('Scan Off', set_state(0), checked=get_state(0), radio=True),
        MenuItem('Scan on Primary Fire',
                 set_state(1),
                 checked=get_state(1),
                 radio=True),
        MenuItem('Scan on Secondary Fire',
                 set_state(2),
                 checked=get_state(2),
                 radio=True), MenuItem('Exit', lambda: exit_action()))

    keyboard.add_hotkey('page up', start_action)
    keyboard.add_hotkey('page down', stop_action)

    icon.run(setup)
예제 #2
0
def tray():
    global icon, thread
    icon = None
    thread = None

    name = 'ED - Autopilot'
    icon = Icon(name=name, title=name)
    logo = Image.open(resource_path('src/logo.png'))
    icon.icon = logo

    icon.menu = Menu(MenuItem('Exit', lambda: exit_action()), )

    keyboard.add_hotkey('home', start_action)
    keyboard.add_hotkey('end', stop_action)

    icon.run(setup)
예제 #3
0
def update():
    releases_url = 'https://api.github.com/repos/skai2/EDAutopilot/releases'
    response = requests.get(releases_url)
    # Raise an exception if the API call fails.
    response.raise_for_status()
    data = response.json()
    try:
        latest_release = data[0]['tag_name']
    except Exception as e:
        print(e)
    if latest_release and latest_release != RELEASE:
        message = "There is a new version of EDAutopilot available!\nWould you like to go to the release download page?"
        root = tk.Tk()
        root.withdraw()
        root.tk.call('wm', 'iconphoto', root._w, tk.PhotoImage(file=resource_path('src/logo.png')))
        go_to_update = messagebox.askyesno("ED - Autopilot Update", message)
        if go_to_update:
            webbrowser.open_new(data[0]['html_url'])
            return True
    return False
예제 #4
0
파일: autopilot.py 프로젝트: dazzer169/daz
def update():
    releases_url = 'https://api.github.com/repos/skai2/EDAutopilot/releases'
    response = requests.get(releases_url)
    # Raise an exception if the API call fails.
    response.raise_for_status()
    data = response.json()
    try:
        latest_release = data[0]['tag_name']
    except Exception as e:
        print(e)
    if latest_release and latest_release != RELEASE:
        message = "There is a new version of EDAutopilot available!\nWould you like to go to the release download page?"
        root = tk.Tk()
        root.withdraw()
        root.tk.call('wm', 'iconphoto', root._w,
                     tk.PhotoImage(file=resource_path('src/logo.png')))
        go_to_update = messagebox.askyesno("ED - Autopilot Update", message)
        if go_to_update:
            webbrowser.open_new(data[0]['html_url'])
            return True
    return False
예제 #5
0
def tray():
    global icon, thread
    icon = None
    thread = None

    name = 'ED - Autopilot'
    icon = Icon(name=name, title=name)
    logo = Image.open(resource_path('src/logo.png'))
    icon.icon = logo

    icon.menu = Menu(
        MenuItem(
            'Scan Off',
            set_state(0),
            checked=get_state(0),
            radio=True
        ),
        MenuItem(
            'Scan on Primary Fire',
            set_state(1),
            checked=get_state(1),
            radio=True
        ),
        MenuItem(
            'Scan on Secondary Fire',
            set_state(2),
            checked=get_state(2),
            radio=True
        ),
        MenuItem('Exit', lambda : exit_action())
    )

    keyboard.add_hotkey('home', start_action)
    keyboard.add_hotkey('end', stop_action)

    icon.run(setup)
예제 #6
0
def create_window():
    window = Tk()
    window.title("EDAutopilot Settings")
    window.geometry('280x300')
    window.resizable(False, False)
    logger.debug(os.name)
    if "nt" == os.name:
        from dev_autopilot import resource_path
        window.iconbitmap(resource_path('src/logo.ico'))

    defaults = getOptions()

    def on_closing():
        if unsaved():
            confirm = askyesnocancel(
                title="Save On Close",
                message="Do you want to save before closing?",
                default=YES,
                icon='warning')
            if confirm:
                on_save()
            elif confirm is None:
                return False
        global curr_window
        curr_window = None
        window.destroy()

    window.protocol("WM_DELETE_WINDOW", on_closing)

    def toggleFSS():
        if dsState.get():
            fssCheck['state'] = NORMAL
        else:
            fssCheck['state'] = DISABLED

    dsState = BooleanVar()
    dsState.set(defaults['DiscoveryScan'])
    dsCheck = Checkbutton(window,
                          text='Automatic Discovery Scan',
                          var=dsState,
                          command=toggleFSS)
    dsCheck.place(relx=0.02, rely=0.02)

    fssState = BooleanVar()
    fssState.set(defaults['AutoFSS'])
    fssCheck = Checkbutton(
        window,
        text='Automatic FSS Scan\n (Currently waits for user to operate FSS)',
        var=fssState)
    fssCheck.place(relx=0.05, rely=0.09)

    startKeyLbl = Label(window, text='Start EDAutopilot Key:')
    startKeyLbl.place(relx=0.02, rely=0.23)

    def on_startKey():
        getKeyForBtn(startKeyBtn)

    startKeyBtn = Button(window,
                         text=defaults['StartKey'],
                         command=on_startKey,
                         width=20)
    startKeyBtn.place(relx=0.46, rely=0.22)

    startKeyLbl = Label(window, text='End EDAutopilot Key:')
    startKeyLbl.place(relx=0.02, rely=0.33)

    def on_endKey():
        getKeyForBtn(endKeyBtn)

    endKeyBtn = Button(window,
                       text=defaults['EndKey'],
                       command=on_endKey,
                       width=20)
    endKeyBtn.place(relx=0.46, rely=0.32)

    rtLbl = Label(window, text='Refuel threshold percentage:')
    rtLbl.place(relx=0.02, rely=0.43)

    def callback(strnum):
        return ((str.isdigit(strnum)) and (len(strnum) <= 3) and
                (0 <= int(strnum) <= 100)) or strnum == ""

    vcmd = (window.register(callback))

    refuelThreshold = Entry(window,
                            validate='all',
                            validatecommand=(vcmd, '%P'),
                            width=10,
                            justify='center')
    refuelThreshold.insert(0, defaults['RefuelThreshold'])
    refuelThreshold.place(relx=0.62, rely=0.44)

    def get_refuel_threshold(entry):
        if not entry:
            return defaults['RefuelThreshold']
        return str(int(
            entry.get()))  # Just to be triply sure it's an int in str form

    def unsaved():
        return str(fssState.get()) != defaults['AutoFSS'] or str(dsState.get()) != defaults['DiscoveryScan'] or \
               startKeyBtn['text'] != defaults['StartKey'] or endKeyBtn['text'] != defaults['EndKey'] or \
               get_refuel_threshold(refuelThreshold) != defaults['RefuelThreshold']

    def on_save():
        if not unsaved():
            return
        if str(fssState.get()) != defaults['AutoFSS']:
            setOption('AutoFSS', fssState.get())
        if str(dsState.get()) != defaults['DiscoveryScan']:
            setOption('DiscoveryScan', dsState.get())
        if startKeyBtn['text'] != defaults['StartKey']:
            setOption('StartKey', startKeyBtn['text'])
        if endKeyBtn['text'] != defaults['EndKey']:
            setOption('EndKey', endKeyBtn['text'])
        if get_refuel_threshold(
                refuelThreshold) != defaults['RefuelThreshold']:
            setOption('RefuelThreshold', get_refuel_threshold(refuelThreshold))

    saveBtn = Button(window, text="Save Settings", command=on_save)
    saveBtn.place(relx=0.70, rely=0.90)
    return window