Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add linebreaks in menu? #20

Open
oraant opened this issue May 29, 2019 · 4 comments
Open

How to add linebreaks in menu? #20

oraant opened this issue May 29, 2019 · 4 comments

Comments

@oraant
Copy link

oraant commented May 29, 2019

Want to something like this:
20190530021134

But I can only get this:
image

What should I do?

@ghost
Copy link

ghost commented Apr 15, 2020

I would love to know this too, does anyone know yet?

@wiggin15
Copy link
Contributor

This is currently not supported by "infi.systray", but can be achieved by using MENUITEM.fType = MFT_SEPARATOR. I currently don't have time to add this feature properly, but here's a quick-and-dirty patch that adds this capability, by setting an item text to 5 hyphens (-----):

diff --git a/src/infi/systray/win32_adapter.py b/src/infi/systray/win32_adapter.py
index 1b9a9ef..ba4c37e 100755
--- a/src/infi/systray/win32_adapter.py
+++ b/src/infi/systray/win32_adapter.py
@@ -70,6 +70,7 @@ SM_CXSMICON = 49
 SM_CYSMICON = 50
 COLOR_MENU = 4
 DI_NORMAL = 3
+MFT_SEPARATOR = 0x00000800
 
 WPARAM = ctypes.wintypes.WPARAM
 LPARAM = ctypes.wintypes.LPARAM
@@ -148,6 +149,9 @@ class NOTIFYICONDATA(ctypes.Structure):
 def PackMENUITEMINFO(text=None, hbmpItem=None, wID=None, hSubMenu=None):
     res = MENUITEMINFO()
     res.cbSize = ctypes.sizeof(res)
+    if text == "-----":
+        res.fType = MFT_SEPARATOR
+        return res
     res.fMask = 0
     if hbmpItem is not None:
         res.fMask |= MIIM_BITMAP

@ghost
Copy link

ghost commented Apr 15, 2020

Many thanks wiggin,
but as a comparative noob I can't make head nor tail of that.
I know you are busy so maybe somebody else
can work out how to implement this from the above.

If someone could work this into a def I would be forever in their debt, metaphorically :-)

@ghost
Copy link

ghost commented Apr 19, 2020

Oky after getting some help from the python forum https://python-forum.io/Thread-Can-anyone-make-sense-of-this?pid=111107#pid111107

I have made the changes and this works beautifully.
Thanks.

screenshot of separator bars:
https://i.postimg.cc/sf5GFdHM/seperators.png

Pastebin of the changed w32_adaptor.py file which can be found
in your python \Lib\site-packages\infi\systray:

https://pastebin.com/i9L6iUwd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants