Giter VIP home page Giter VIP logo

Comments (12)

dynobo avatar dynobo commented on May 19, 2024 2

Tray Icon Support arrived in the latest beta release 0.2.0-b1!

Please help by testing and providing feedback.

from normcap.

ashishpatel1992 avatar ashishpatel1992 commented on May 19, 2024 1

Well, we don't need to run as a service during startup. But a good suggestion is if it's executed once, it can stay at tray icon. The reason is that if a user has selected text recently. There is a high chance that he will again use the tool within a few minutes.

We can consider it a design enhancement. Although as I said it will only go to tray icon when EXE file is executed manually.
(This could be my personal opinion, for now, I have found an alternative way by dragging the executable file to my taskbar and pinned it, so I don't need to go and run the program again and again)

image

from normcap.

dynobo avatar dynobo commented on May 19, 2024

I personally prefer software to not run in the background constantly, especially if I don't need it very often.

But considering the startup time, which is especially slow for the exe-release on windows, I can understand if some people prefer to run it as a service.

Therefore I'll take a look on this, but can't promise anything here, because I have no idea how difficult it is to implement this platform independently (which is one of the major goals for this project).

Thanks for your suggestion!

from normcap.

dynobo avatar dynobo commented on May 19, 2024

I like your suggestion! As a first step, we could:

  1. add a command line switch like --keep-in-tray to activate the tray icon
  2. If the tray icon is active and you click on it, a simple menu will show up:
    97741698-24bdb480-1b09-11eb-8319-390251f2cf13
    (the scribble doesn't show a system tray, I know... ;-)

What do you think?

from normcap.

ashishpatel1992 avatar ashishpatel1992 commented on May 19, 2024

Yeah looks good to me. We can use PyQt5 for that. A demonstrated example is available here
This is a cross-platform library for Windows and macOS

from normcap.

dynobo avatar dynobo commented on May 19, 2024

Hey @ashishpatel1992, while PyQt5 definitely could do that, I'll try to stay away from it. It's a too powerful (and bloated) framework, for such a tiny feature. For the same reason I'm currently using Tkinter as UI-Framework, which is less bloated and a default lib in Python.

However, Tkinter (as far as I can tell) doesn't support tray icons. I'm currently experimenting if pystray can do the job :-)

from normcap.

dynobo avatar dynobo commented on May 19, 2024

pystray conflicts with pyperclip (module for clipboard handling). I filed a simple PR which could help: asweigart/pyperclip#182

Waiting till it arrives upstream...

from normcap.

ashishpatel1992 avatar ashishpatel1992 commented on May 19, 2024

Hi @dynobo ,
I have been trying to test pystray but looks like I am stuck at this point. I have followed the documentation Creating a system tray icon.
My Sample code

from pystray import Icon as icon, Menu as menu, MenuItem as item
from PIL import Image

state = False
im = Image.new(mode = "RGB", size = (200, 200), color = (153, 153, 255))

def on_clicked(icon, item):
    global state
    state = not item.checked

icon('test', im, menu=menu(item('Checkable',on_clicked,checked=lambda item: state))).run()

and getting the following error

(base) ashish@pixels:~/Desktop/sa/test$ python test.py 
Failed to dock icon
Traceback (most recent call last):
  File "/home/ashish/anaconda3/lib/python3.7/site-packages/pystray/_xorg.py", line 162, in _update_icon
    self._assert_docked()
  File "/home/ashish/anaconda3/lib/python3.7/site-packages/pystray/_xorg.py", line 389, in _assert_docked
    assert self._systray_manager
AssertionError
Failed to dock icon
Traceback (most recent call last):
  File "/home/ashish/anaconda3/lib/python3.7/site-packages/pystray/_xorg.py", line 143, in _show
    self._assert_docked()
  File "/home/ashish/anaconda3/lib/python3.7/site-packages/pystray/_xorg.py", line 389, in _assert_docked
    assert self._systray_manager
AssertionError

Do you have any idea about this error? I am testing it on Ubuntu 20.04.1 LTS

from normcap.

dynobo avatar dynobo commented on May 19, 2024

@ashishpatel1992 : Your code-example works on my machine, I see the "icon" and don't get an error. My best guess is that you are missing a dependency. You could try to install the following stuff:

sudo apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0
pip install PyGObject

from normcap.

ashishpatel1992 avatar ashishpatel1992 commented on May 19, 2024

Hi @dynobo ,
Well, the packages didn't help, but I noticed one thing it wasn't working on Python 3.7.6 but was working fine on python 3.8.
Also tested on windows and working fine under python 3.8

from normcap.

ashishpatel1992 avatar ashishpatel1992 commented on May 19, 2024

Hi @dynobo ,
Sure I will test this and let you know the feedback.

from normcap.

dynobo avatar dynobo commented on May 19, 2024

Considered as solved with #116

from normcap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.