Menu bar icons on Mac?

Some Mac applications put a small icon in the right-hand area of the menu bar (see attached screenshot). These seem like a natural parallel to system tray icons on Windows.

I have a system tray icon (wx.TaskBarIcon, I mean) up and running under wxPython on Windows, but the menu I have appearing out of that is bound to the Mac Dock icon instead. Is there any way to create these menu bar icons on Mac using wxPython?

If not, I would advocate for having wx.TaskBarIcon represented on Mac with a menu bar icon. They seem like the right rendering for Mac.

Thanks for any suggestions....

-M

menubaricons.gif

Marc Hedlund wrote:

Some Mac applications put a small icon in the right-hand area of the menu bar (see attached screenshot). These seem like a natural parallel to system tray icons on Windows.

I have a system tray icon (wx.TaskBarIcon, I mean) up and running under wxPython on Windows, but the menu I have appearing out of that is bound to the Mac Dock icon instead. Is there any way to create these menu bar icons on Mac using wxPython?

If not, I would advocate for having wx.TaskBarIcon represented on Mac with a menu bar icon. They seem like the right rendering for Mac.

Thanks for any suggestions....

There was a lot of heated discussion on wx-dev about this back when the wx.TaskBarIcon functionality was first enabled for wxMac. One side wanted the icons on the menubar because that made the most sense in light of how they work on the other platforms. The other side were the purists that made arguments about how the Apple HIG forbids things like that (which obviously doesn't stop other projects from doing it anyway <wink!>) and that an application's notification area and related menu are supposed to be done on the dock icon.

There was some discussion of a compromise where the first wx.TaskBarIcon would go on the dock, and that any additional wx.TaskBarIcon's would be status items located on the menubar. I don't think this has been implemented yet however, although I'm not sure why. If Ryan is still reading this group he can probably chime in on this, otherwise asking the question on the wx-dev list will probably get some response and maybe even stimulate some changes.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Some Mac applications put a small icon in the right-hand area of the menu bar (see attached screenshot). These seem like a natural parallel to system tray icons on Windows.

[...]

There was a lot of heated discussion on wx-dev about this back when the wx.TaskBarIcon functionality was first enabled for wxMac. One side wanted the icons on the menubar because that made the most sense in light of how they work on the other platforms. The other side were the purists that made arguments about how the Apple HIG forbids things like that (which obviously doesn't stop other projects from doing it anyway <wink!>) and that an application's notification area and related menu are supposed to be done on the dock icon.

There was some discussion of a compromise where the first wx.TaskBarIcon would go on the dock, and that any additional wx.TaskBarIcon's would be status items located on the menubar. I don't think this has been implemented yet however, although I'm not sure why. If Ryan is still reading this group he can probably chime in on this, otherwise asking the question on the wx-dev list will probably get some response and maybe even stimulate some changes.

Got it, thanks, I will ask on that list.

In the meantime, I'm getting complaints about my app (which is basically a background operation that rarely needs interaction, but shouldn't be invisible) "polluting" the Dock. So I'm interested in pursuing this however I can. You description above makes me think this should be done as a wxPython extension, for now at least.

What's the best way to go about doing that from Python? Is there a sample extension that provides source, which I could use as a template?

Thanks much, again.

-M

···

On Wed, 19 Apr 2006, Robin Dunn wrote:

Hi Robin,

Marc Hedlund wrote:

Some Mac applications put a small icon in the right-hand area of the menu bar (see attached screenshot). These seem like a natural parallel to system tray icons on Windows.
I have a system tray icon (wx.TaskBarIcon, I mean) up and running under wxPython on Windows, but the menu I have appearing out of that is bound to the Mac Dock icon instead. Is there any way to create these menu bar icons on Mac using wxPython?
If not, I would advocate for having wx.TaskBarIcon represented on Mac with a menu bar icon. They seem like the right rendering for Mac.
Thanks for any suggestions....

There was a lot of heated discussion on wx-dev about this back when the wx.TaskBarIcon functionality was first enabled for wxMac. One side wanted the icons on the menubar because that made the most sense in light of how they work on the other platforms. The other side were the purists that made arguments about how the Apple HIG forbids things like that (which obviously doesn't stop other projects from doing it anyway <wink!>) and that an application's notification area and related menu are supposed to be done on the dock icon.

As an aside, I think it isn't necessarily the issues themselves that cause the debate to become heated. :wink: Of course, that said, I'll admit I fell into that trap a few times in the past... ;-/

There was some discussion of a compromise where the first wx.TaskBarIcon would go on the dock, and that any additional wx.TaskBarIcon's would be status items located on the menubar. I don't think this has been implemented yet however, although I'm not sure why. If Ryan is still reading this group he can probably chime in on this, otherwise asking the question on the wx-dev list will probably get some response and maybe even stimulate some changes.

IMHO the best solution is to make it an option, but to make the default behavior match that of the HIG. (I believe I stated this way back when too, though that was so long ago...) The menu bar icons have limitations, such as that they are automatically hidden by menu bars when space gets tight (and the only way to get them to reappear is to switch apps), and they also don't have nice features the dock icons have, like the ability to resize the icon to get more on the screen, or the ability to show progress (on some action) using the dock icon. I think that's part of why the HIG doesn't recommend them. (Last I checked, it doesn't forbid them, BTW, it just says they're only for use for very specific cases, namely when the program doesn't have a dock icon for whatever reason, but provides a persistent service.)

The issue with the icons being hidden is particularly prevalent on laptops, where some people are working with 13'' screens. I've had experiences with this, and having to switch back and forth between two applications just to access a menu bar icon is really annoying.

In any case, if the developer really feels that's what they want, then I'm all for letting them override the default behavior; but the dock icon is where the functionality exposed by tray bar icons on Windows is normally found in Mac programs. (e.g. iTunes, Camino, Terminal, Mail.app, etc.) Since wx is about native look and feel, I think the default should be what native and/or system apps do, particularly when the OS vendor recommends that behavior.

Thanks,

Kevin

···

On Apr 19, 2006, at 3:43 PM, Robin Dunn wrote:

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Hi Marc,

Some Mac applications put a small icon in the right-hand area of the menu bar (see attached screenshot). These seem like a natural parallel to system tray icons on Windows.

[...]

There was a lot of heated discussion on wx-dev about this back when the wx.TaskBarIcon functionality was first enabled for wxMac. One side wanted the icons on the menubar because that made the most sense in light of how they work on the other platforms. The other side were the purists that made arguments about how the Apple HIG forbids things like that (which obviously doesn't stop other projects from doing it anyway <wink!>) and that an application's notification area and related menu are supposed to be done on the dock icon.

There was some discussion of a compromise where the first wx.TaskBarIcon would go on the dock, and that any additional wx.TaskBarIcon's would be status items located on the menubar. I don't think this has been implemented yet however, although I'm not sure why. If Ryan is still reading this group he can probably chime in on this, otherwise asking the question on the wx-dev list will probably get some response and maybe even stimulate some changes.

Got it, thanks, I will ask on that list.

In the meantime, I'm getting complaints about my app (which is basically a background operation that rarely needs interaction, but shouldn't be invisible) "polluting" the Dock. So I'm interested in pursuing this however I can. You description above makes me think this should be done as a wxPython extension, for now at least.

What's the best way to go about doing that from Python? Is there a sample extension that provides source, which I could use as a template?

If you wanted to do it from Python, you'd have to use PyObjC, which lets you access Cocoa APIs from Python. The API you're looking for is NSStatusItem. Here's a message from the Pythonmac-SIG that talks about the API and links to an example of using it from PyObjC:

http://mail.python.org/pipermail/pythonmac-sig/2005-September/015041.html

Regards,

Kevin

···

On Apr 19, 2006, at 5:37 PM, Marc Hedlund wrote:

On Wed, 19 Apr 2006, Robin Dunn wrote:

Thanks much, again.

-M

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Great, thanks very much, I appreciate both of your replies.

I agree with you about the laptop/small screen crowding issue. I'll probably use this as an optional tool and give people another path to get there if they would prefer.

Thanks again.

-M

···

On Wed, 19 Apr 2006, Kevin Ollivier wrote:

Hi Marc,

What's the best way to go about doing that from Python? Is there a sample extension that provides source, which I could use as a template?

If you wanted to do it from Python, you'd have to use PyObjC, which lets you access Cocoa APIs from Python. The API you're looking for is NSStatusItem. Here's a message from the Pythonmac-SIG that talks about the API and links to an example of using it from PyObjC:

[Pythonmac-SIG] Dock menu

Kevin Ollivier wrote:

There was some discussion of a compromise where the first wx.TaskBarIcon would go on the dock, and that any additional wx.TaskBarIcon's would be status items located on the menubar. I don't think this has been implemented yet however, although I'm not sure why. If Ryan is still reading this group he can probably chime in on this, otherwise asking the question on the wx-dev list will probably get some response and maybe even stimulate some changes.

IMHO the best solution is to make it an option, but to make the default behavior match that of the HIG. (I believe I stated this way back when too, though that was so long ago...)

I finally took a peek at the code and it looks like it was implemented this way, (passing an option to the constructor,) but currently there is only one option. :-/

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

That is a compromise all right!

I haven't posted about is on wx-dev yet, but plan to.

Thanks again.

-M

···

On Thu, 20 Apr 2006, Robin Dunn wrote:

IMHO the best solution is to make it an option, but to make the default behavior match that of the HIG. (I believe I stated this way back when too, though that was so long ago...)

I finally took a peek at the code and it looks like it was implemented this way, (passing an option to the constructor,) but currently there is only one option. :-/