Exemplo n.º 1
0
class Tray:
    def __init__(self, hover_text, tray_options):
        self.sys_tray_icon = SysTrayIcon(None, hover_text,
                                         convert_to_tuple(tray_options))
        self.sys_tray_icon.start()

    def set_icon(self, icon):
        self.sys_tray_icon.update(icon=icon)
Exemplo n.º 2
0
class WinTray():
    def __init__(self):
        icon_path = os.path.join(os.path.dirname(__file__), "imgs", "logo.ico")
        self.systray = SysTrayIcon(icon_path, "bf-facilities", 
            self.make_menu(), on_quit = self.on_quit)
            # , left_click=self.on_show, right_click=self.on_right_click)

        reg_path = r'Software\Microsoft\Windows\CurrentVersion\Internet Settings'
        self.before_quit = None
        # self.INTERNET_SETTINGS = winreg.OpenKey(winreg.HKEY_CURRENT_USER, reg_path, 0, winreg.KEY_ALL_ACCESS)

    def on_right_click(self):
        self.systray.update(menu=self.make_menu())
        self.systray._show_menu()

    def make_menu(self):
        return (
            ('Open', None, self.on_show), 
            ('dialogs', None, self.dialog_yes_no)
            )

    def on_show(self, widget=None, data=None):
        self.show_control_web()

    def show_control_web(self, widget=None, data=None):
        host_port = 8098
        webbrowser.open("http://127.0.0.1:%s/" % host_port)

    def on_quit(self, widget, data=None):
        # module_init.stop_all()
        if self.before_quit is not None:
            self.before_quit()

    def serve_forever(self):
        self.systray.start()

    def dialog_yes_no(self, msg="msg", title="Title", data=None, callback=None):
        res = MessageBox(text = "msg", caption = "title", flags = 1)
        # Yes:1 No:2
        if callback:
            callback(data, res)
        return res
Exemplo n.º 3
0
                    link,
                    icon_path=app_ico,
                    duration=5)    
 while flag_exit is False:
     if is_stop == False:
         if GetWindowText(GetForegroundWindow()) != "World of Warcraft":
             if wait_mes == 5:
                 wait_mes = 0
                 toaster.show_toast(app,
                                    "Waiting for World of Warcraft"
                                    + " as active window",
                                    icon_path='wow-fish-bot.ico',
                                    duration=5)                  
             # print("Waiting for World of Warcraft as active window")
             systray.update(
                 hover_text=app
                 + " - Waiting for World of Warcraft as active window")
             wait_mes += 1
             time.sleep(2)
         else:
             systray.update(hover_text=app)
             rect = GetWindowRect(GetForegroundWindow())
             
             if is_block == False:
                 lastx = 0
                 lasty = 0
                 pyautogui.press('1')
                 # print("Fish on !")
                 new_cast_time = time.time()
                 is_block = True
                 time.sleep(2)
Exemplo n.º 4
0
class WindowsSystemTray(object):
    def __init__(self):
        self.image_dir = os.path.join(plexpy.PROG_DIR, 'data/interfaces/',
                                      plexpy.CONFIG.INTERFACE, 'images')
        self.icon = os.path.join(self.image_dir, 'logo-circle.ico')

        if plexpy.UPDATE_AVAILABLE:
            self.hover_text = common.PRODUCT + ' - Update Available!'
            self.update_title = 'Check for Updates - Update Available!'
        else:
            self.hover_text = common.PRODUCT
            self.update_title = 'Check for Updates'

        if plexpy.CONFIG.LAUNCH_STARTUP:
            launch_start_icon = os.path.join(self.image_dir, 'check-solid.ico')
        else:
            launch_start_icon = None
        if plexpy.CONFIG.LAUNCH_BROWSER:
            launch_browser_icon = os.path.join(self.image_dir,
                                               'check-solid.ico')
        else:
            launch_browser_icon = None

        self.menu = [['Open Tautulli', None, self.tray_open, 'default'],
                     ['', None, 'separator', None],
                     [
                         'Start Tautulli at Login', launch_start_icon,
                         self.tray_startup, None
                     ],
                     [
                         'Open Browser when Tautulli Starts',
                         launch_browser_icon, self.tray_browser, None
                     ], ['', None, 'separator', None],
                     [self.update_title, None, self.tray_check_update, None],
                     ['Restart', None, self.tray_restart, None]]
        if not plexpy.FROZEN:
            self.menu.insert(6, ['Update', None, self.tray_update, None])

        self.tray_icon = SysTrayIcon(self.icon,
                                     self.hover_text,
                                     self.menu,
                                     on_quit=self.tray_quit)

    def start(self):
        logger.info("Launching Windows system tray icon.")
        try:
            self.tray_icon.start()
        except Exception as e:
            logger.error("Unable to launch system tray icon: %s." % e)

    def shutdown(self):
        self.tray_icon.shutdown()

    def update(self, **kwargs):
        self.tray_icon.update(**kwargs)

    def tray_open(self, tray_icon):
        plexpy.launch_browser(plexpy.CONFIG.HTTP_HOST, plexpy.HTTP_PORT,
                              plexpy.HTTP_ROOT)

    def tray_startup(self, tray_icon):
        plexpy.CONFIG.LAUNCH_STARTUP = not plexpy.CONFIG.LAUNCH_STARTUP
        set_startup()

    def tray_browser(self, tray_icon):
        plexpy.CONFIG.LAUNCH_BROWSER = not plexpy.CONFIG.LAUNCH_BROWSER
        set_startup()

    def tray_check_update(self, tray_icon):
        versioncheck.check_update()

    def tray_update(self, tray_icon):
        if plexpy.UPDATE_AVAILABLE:
            plexpy.SIGNAL = 'update'
        else:
            self.hover_text = common.PRODUCT + ' - No Update Available'
            self.update_title = 'Check for Updates - No Update Available'
            self.menu[5][0] = self.update_title
            self.update(hover_text=self.hover_text, menu_options=self.menu)

    def tray_restart(self, tray_icon):
        plexpy.SIGNAL = 'restart'

    def tray_quit(self, tray_icon):
        plexpy.SIGNAL = 'shutdown'

    def change_tray_update_icon(self):
        if plexpy.UPDATE_AVAILABLE:
            self.hover_text = common.PRODUCT + ' - Update Available!'
            self.update_title = 'Check for Updates - Update Available!'
        else:
            self.hover_text = common.PRODUCT + ' - No Update Available'
            self.update_title = 'Check for Updates'
        self.menu[5][0] = self.update_title
        self.update(hover_text=self.hover_text, menu_options=self.menu)

    def change_tray_icons(self):
        if plexpy.CONFIG.LAUNCH_STARTUP:
            launch_start_icon = os.path.join(self.image_dir, 'check-solid.ico')
        else:
            launch_start_icon = None
        if plexpy.CONFIG.LAUNCH_BROWSER:
            launch_browser_icon = os.path.join(self.image_dir,
                                               'check-solid.ico')
        else:
            launch_browser_icon = None
        self.menu[2][1] = launch_start_icon
        self.menu[3][1] = launch_browser_icon
        self.update(menu_options=self.menu)
Exemplo n.º 5
0
                           0))  # color background =  white  with transparency
    d = ImageDraw.Draw(img)

    #add text to the image
    font_type = ImageFont.truetype("arial.ttf", fontSize)
    d.text((x, y), str(temp) + "°", fill=(255, 255, 255), font=font_type)

    img.save(image)

    updateTime = datetime.datetime.fromtimestamp(
        time.time()).strftime('%Y-%m-%d %H:%M:%S')

    #generate text for overlay
    hover_text = (city.title() + " Weather\nCurrent Temperature: " +
                  str(temperature) + "°" + operator + " (" +
                  str(convertTemp(temperature)) + "°" + convOper + ")"
                  "\nFeels like: " + str(feelslike) + "°" + operator + " (" +
                  str(convertTemp(feelslike)) + "°" + convOper +
                  ")\nLast Updated: " + updateTime)

    # display image in systray
    menu_options = (("Settings", None, launch_SettingsWindow), )
    if n == 1:
        systray = SysTrayIcon(image, hover_text, menu_options)
        systray.start()
    else:
        systray.update(icon=image, hover_text=hover_text)
    time.sleep(30)
    n += 1
systray.shutdown()
Exemplo n.º 6
0
                   fill='Black')
canvas.create_text(130,
                   265,
                   text="RealFeel :" + r'   ' + real_feel(),
                   font=('Google Sans', 15),
                   fill='Black')


def gui_hide(systray):
    base.withdraw()


def gui_show(systray):
    base.deiconify()


def die(systray):
    base.destroy()


menu_options = (
    ("Show GUI", None, gui_show),
    ('Hide GUI', None, gui_hide),
    ('Kill GUI', None, die),
)
systray = SysTrayIcon('tray/{}.ico'.format(icon), "Weather", menu_options)
systray.start()
systray.update(hover_text=roundoff + r' ' + city)

base.mainloop()
Exemplo n.º 7
0
def sync_it(stray):
    """Perform syncing of the two folders Glo.scr_fldr and Glo.dest_fldr."""
    if Glo.src_fldr == '':
        messagebox.showerror(
            'ERROR', 'Please set the source folder\n'
            'from the Sync It "Settings" menu first,\n\n'
            'or load a previously saved profile.')
        return

    if Glo.dest_fldr == '':
        messagebox.showerror(
            'ERROR', 'Please set the destination folder\n'
            'from the Sync It "Settings" menu first,\n\n'
            'or load a previously saved profile.')
        return

    if Glo.src_fldr == Glo.dest_fldr:
        messagebox.showerror(
            'ERROR', 'Source and destination folders are the same!\n\n'
            'Please select two different folders to sync\n'
            'from the Sync It "Settings" menu.')
        return

    truncate_fldr_names()

    ask_yn = messagebox.askyesno(
        'Question:', 'Sync these two folders?'
        '\n\n' + str(Glo.limit_src) + ''
        '\n' + str(Glo.limit_dest) + '\n\n'
        'Purge files: ' + str(Glo.purge_status) + '\n')
    if ask_yn is False:
        return

    # Switch to red icon display.
    stray.update(icon='sync-it-red.ico')

    msg_box(stray)

    # Clear old log data.
    with open('syncit.log', 'w+'):
        pass

    # Clear tmp last log data.
    with open('lastlog.log', 'w+'):
        pass

    # Perform the actual syncing.
    if Glo.sync_purge:
        sync(Glo.src_fldr, Glo.dest_fldr, 'sync', logger=my_log, purge=True)
    else:
        sync(Glo.src_fldr, Glo.dest_fldr, 'sync', logger=my_log, purge=False)

    # Create new empty log.
    with open('lastlog.log', 'w+'):
        pass

    msg_log = ''

    with open('syncit.log', 'r') as f:
        logtext = f.readlines()

    with open('lastlog.log', 'w+') as f:
        for line in logtext:
            line = re.sub(r'[\x00-\x1F]+', '', line)  # Strip some non ascii.
            msg = (line)
            f.write(msg)
            msg_log = msg_log + msg + '\n'

    Glo.custom_mbox.destroy()

    # Switch back to original icon display.
    stray.update(icon='sync-it.ico')

    messagebox.showinfo(
        'Sync It Info', 'Sync It V0.60\n\n'
        'Sync completed.\n\n' + str(msg_log))

    os.chdir(Glo.default_dir)
Exemplo n.º 8
0
class MainService:
    def __init__(self, notificationService, gitService):
        self.CHECK_ICO = StringService.getIcons('success')
        self.ERROR_ICO = StringService.getIcons('error')
        self.CHANGE_ICO = StringService.getIcons('warning')

        self.notificationService = notificationService
        self.gitService = gitService
        self.isGitReminderStarted = False
        self.threads = []

        self.countStatusDirty = 0
        self.countStatusError = 0
        self.countStatusOk = 0

    def startSystray(self):
        a = StringService.getIcons('success')

        try:
            menu_options = (
                (APP_NAME, self.CHECK_ICO, (
                    ('Start', None, self.startGitReminderFromSystray),
                    ('Stop', None, self.stopGitReminderFromSystray),
                    ('Restart', None, self.restartGitReminderFromSystray),
                )),
                ("Status", None, self.status),
                ("About", None, self.about),
            )
            self.systray = SysTrayIcon(self.CHECK_ICO,
                                       STATUS_OK,
                                       menu_options,
                                       on_quit=self.on_quit_callback)
            self.systray.start()
        except:
            self.notificationService.showToastNotification(
                APP_NAME, "Start: FAILED", self.ERROR_ICO)
            sys.exit()

    def startGitReminderFromSystray(self, systray):
        self.startGitReminder()

    def startGitReminder(self):
        if self.isGitReminderStarted:
            self.notificationService.showToastNotification(
                APP_NAME, "is already started", self.CHECK_ICO)
        else:
            configService = ConfigService(self.notificationService)
            self.noGitRepos = False
            self.dirtyGitRepos = False

            self.countStatusDirty = 0
            self.countStatusError = 0
            self.countStatusOk = 0

            for repo in configService.readConf():
                if self.gitService.isGitRepo(repo):
                    if self.gitService.isRepoDirty(repo):
                        self.countStatusDirty += 1
                        self.updateSystrayInfo()
                        self.startThreadwithRepo(repo)
                    else:
                        self.countStatusOk += 1
                        self.startThreadwithRepo(repo)
                        self.updateSystrayInfo()
                else:
                    self.countStatusError += 1
                    self.updateSystrayInfo()

            self.notificationService.showToastNotification(
                APP_NAME, "is started", self.CHECK_ICO)

            self.isGitReminderStarted = True

    def startThreadwithRepo(self, repo):
        thread = Thread(target=self.profileThreads, args=(repo, ))
        self.threads += [thread]
        thread.start()

    def profileThreads(self, repo):
        mins = int(repo.sleeptime) * 60
        currentTime = 0
        while self.isGitReminderStarted:
            if currentTime == mins:
                nowTime = datetime.now()
                targetTime = datetime(nowTime.year, nowTime.month, nowTime.day,
                                      int(profile.reminderTimeHour),
                                      int(profile.reminderTimeMin))
                if targetTime < nowTime:
                    self.startCheckProfile(profile)
                currentTime = 0

            time.sleep(1)
            currentTime += 1

    def stopGitReminderFromSystray(self, systray):
        self.stopGitReminder()

    def stopGitReminder(self):
        if not self.isGitReminderStarted:
            self.notificationService.showToastNotification(
                APP_NAME, "is already stopped", self.CHECK_ICO)
        else:
            self.isGitReminderStarted = False
            for x in self.threads:
                x.join()
            self.threads = []
            self.notificationService.showToastNotification(
                APP_NAME, "is stopped", self.CHECK_ICO)
            self.systrayUpdate(CHECK_ICO, STATUS_NOT_RUNNING)

    def restartGitReminder(self):
        self.stopGitReminder()
        self.startGitReminder()

    def restartGitReminderFromSystray(self, systray):
        self.restartGitReminder()

    def status(self, systray):
        if self.isGitReminderStarted:
            self.notificationService.showToastNotification(
                APP_NAME, "is started", self.CHECK_ICO)
        else:
            self.notificationService.showToastNotification(
                APP_NAME, "is stopped", self.CHECK_ICO)

    def updateSystrayInfo(self):
        if self.countStatusError > 0:
            self.systrayUpdate(
                self.ERROR_ICO,
                StringService.getMessages('systray_status_error').format(
                    self.countStatusError))
        elif self.countStatusDirty > 0:
            self.systrayUpdate(
                self.CHANGE_ICO,
                StringService.getMessages('systray_status_dirty').format(
                    self.countStatusDirty))
        else:
            self.systrayUpdate(
                self.CHECK_ICO,
                StringService.getMessages('systray_status_ok').format(
                    self.countStatusOk))

    def systrayUpdate(self, ico, status):
        self.systray._create_window
        self.systray.update(ico, status)

    def about(self, systray):
        webbrowser.open(StringService.getMetaInfos('about'))

    def on_quit_callback(self, systray):
        pass
        # search for the higsest completed stage and set the state
        for idx, stage in enumerate(stages):
            # print(stage)
            if stage.get("completed"):
                state = ParcelState(idx+1)

        # in case the state has changed, notify the user and update the
        # tray-icon
        # print(state)
        # print(old_state)
        if state != old_state:
            # print(state)
            icon = f"{state.value}.ico"
            toaster.show_toast("Update from your parcel!", \
                f"New state: {stage}", icon_path=icon, duration=10)
            systray.update(icon=icon)

        # update tray tooltip
        interval = tat.get("pointInTimeInterval")
        parse = lambda t: datetime.datetime.strptime(t, "%Y-%m-%dT%H:%M:%S%z")
        try:
            from_ = parse(interval.get("from"))
            to_ = parse(interval.get("to"))
            systray.update(hover_text=\
                f"{from_.strftime('%H:%M')}-{to_.strftime('%H:%M (%d/%m)')}")
        except Exception:
            systray.update(hover_text=f"Tijdsvlak niet beschikbaar")

        # wait 10 second not to overflow the server with requests.
        time.sleep(10)
Exemplo n.º 10
0
from time import sleep
from infi.systray import SysTrayIcon
from ctypes import WinDLL
hllDll = WinDLL("User32.dll")
status = hllDll.GetKeyState(0x90)
if status:
    systray = SysTrayIcon("yes.ico", "Num Lock is ON", None)
    systray.start()
else:
    systray = SysTrayIcon("no.ico", "Num Lock is OFF", None)
    systray.start()
while True:
    stchk = hllDll.GetKeyState(0x90)
    if stchk:
        systray.update(icon="yes.ico")
        systray.update(hover_text="Num Lock is ON")
    else:
        systray.update(icon="no.ico")
        systray.update(hover_text="Num Lock is OFF")
    sleep(1)
Exemplo n.º 11
0
        if next_csgo_check < time.time():
            print("Looking for csgo.exe...")
            found_csgo = False
            for pid in psutil.pids():
                try:  # same as for enum_window_callback
                    p = psutil.Process(pid)
                    if p.name() == "csgo.exe":
                        found_csgo = True
                        break
                except:
                    # print("Something could have gone wrong here while finding csgo.exe, ignore this")
                    pass
            if found_csgo:
                notify("Found csgo.exe, running server.")
                if systray:
                    systray.update(hover_text=our_name + ": running")

                httpd = CSGOGameStateServer(server_address,
                                            CSGOGameStateRequestHandler)
                print("Starting httpd at {}:{}".format(server_address[0],
                                                       port))
                httpd.serve_forever()
            next_csgo_check = time.time() + 30
except KeyboardInterrupt:
    if httpd:
        print('Stopping httpd...')
        httpd.server_close()
    exit()
except Exception as e:
    notify("Error: " + str(e))
    input("Press Enter to quit.")
Exemplo n.º 12
0
class SysTrayService:
    def __init__(self, mainService):
        logger.info('Run : ini')
        self.app = None
        self.aboutUI = None
        self.settingUI = None

        self.mainService = mainService

    def start(self):
        # TODO notification anpassen (kein ToolTip)
        logger.info('Run: iniSystray')
        menu_options = (
            ("Settings", None, self.openSettings),
            ("Restart", None, self.restart),
            ("About", None, self.about),
        )
        self.systray = SysTrayIcon(CHECK_ICO,
                                   STATUS_OK,
                                   menu_options,
                                   on_quit=self.on_quit_callback)
        logger.info('systray start')
        self.systray.start()

    def about(self, systray):

        # TODO About Anpassen
        self.iniAboutUI()
        aboutText = '<html><head/><body><p>Utility to get a notification to commit and/or push the repository</p><p><br/>Developed by Christian Beigelbeck \
        </p><p>\
        Licensed under the <a href="https://www.gnu.org/licenses/gpl-3.0-standalone.html"><span style=" text-decoration:\
         underline; color:#2980b9;">GPL v3 license</span></a></p><p>Project home: \
         <a href="https://overmindstudios.github.io/BlenderUpdater/"><span style=" text-decoration:\
         underline; color:#2980b9;">https://www.github.io/VCSReminder/</a></p> \
         Application version: ' + '0.0.1' + '</body></html> '

        QtWidgets.QMessageBox.about(self.aboutUI, 'About', aboutText)

    def on_quit_callback(self, systray):
        logger.info('Run: on_quit_callback')
        self.mainService.stop()

    def updateSystrayInfo(self, ico, status):
        self.systray.update(ico, status)

    def restart(self, systray):
        logger.info('Run: restart')
        self.mainService.restart()

    def openSettings(self, systray):

        logger.info('Run: openSettings')
        self.iniSettingUI()
        logger.info('exec settingUI')
        self.settingUI.exec()
        self.app.exec_()

    def iniAboutUI(self):
        if self.app == None:
            logger.info('INI Application')
            self.app = QtWidgets.QApplication(sys.argv)
            logger.info('set Style')
            self.app.setStyle("Fusion")
            logger.info('set Palette')
            self.app.setPalette(setPalette())
        if self.aboutUI == None:
            self.aboutUI = AboutUIService()

    def iniSettingUI(self):
        if self.app == None:
            logger.info('INI Application')
            self.app = QtWidgets.QApplication(sys.argv)
            logger.info('set Style')
            self.app.setStyle("Fusion")
            logger.info('set Palette')
            self.app.setPalette(setPalette())
        if self.settingUI == None:
            self.settingUI = SettingsUIService(self.mainService)
Exemplo n.º 13
0
def status():
    menu_options = (("Open router host", None, open_router), )
    systray = SysTrayIcon("C://Program Files//Router Tray//zero.ico",
                          "Huawei signal",
                          menu_options,
                          on_quit=on_quit_callback)
    systray.start()
    while True:
        rs = scrape()
        print(rs)
        if rs <= 72:
            systray.update(icon="C://Program Files//Router Tray//five.ico")
            systray.update(hover_text="-" + str(rs) + "dB")
            time.sleep(3)
        if 73 <= rs <= 79:
            systray.update(icon="C://Program Files//Router Tray//four.ico")
            systray.update(hover_text="-" + str(rs) + "dB")
            time.sleep(3)
        if 80 <= rs <= 84:
            systray.update(icon="C://Program Files//Router Tray//three.ico")
            systray.update(hover_text="-" + str(rs) + "dB")
            time.sleep(3)
        if 85 <= rs <= 95:
            systray.update(icon="C://Program Files//Router Tray//two.ico")
            systray.update(hover_text="-" + str(rs) + "dB")
            time.sleep(3)
        if rs >= 95:
            systray.update(icon="C://Program Files//Router Tray//one.ico")
            systray.update(hover_text="-" + str(rs) + "dB")
            time.sleep(3)
Exemplo n.º 14
0
def on_quit_callback(systray):
    systray.shutdown()
    sys.exit(0)


if __name__ == "__main__":

    menu_options = (("Say Hello", None, date_progress), )
    systray = SysTrayIcon("loris.ico",
                          "Example tray icon",
                          menu_options,
                          on_quit=on_quit_callback)
    systray.start()

    while True:
        time_now = datetime.datetime.now()
        percentage_passed_year = "Year's progress: " + str(
            year_progress(time_now))
        percentage_passed_month = "Month's progress: " + str(
            month_progress(time_now))
        percentage_passed_day = "Today's progress: " + str(
            date_progress(time_now))
        percentage_passed_hour = "Hour's progress: " + str(
            hour_progress(time_now))
        percentage_passed_minute = "Minute's progress: " + str(
            minute_progress(time_now))
        hover_text = percentage_passed_year + "\n" + percentage_passed_month + "\n" + percentage_passed_day + "\n" + percentage_passed_hour + "\n" + percentage_passed_minute
        systray.update(hover_text=hover_text)
        time.sleep(1)