I am in the process of writing an app that I want to make a GUI for. I've got a little bit of experience with making GUI's in wxpython already, but one thing I have not had to try yet; is minimizing an application to tray. I have been doing my research and figured out how to make the icon, but what I have gotten stuck in the mud with is minimizing the Frame to the tray. I have found no functions that I can use to hide the frame with (wx.Frame.Hide() is not the answer). Do any of you know of any way that I could accomplish this? Thanks!
You need to look at the wxPython demo's source code. Look for the part which mentions the DemoTaskBarIcon. Then you'll want to bind to wx.EVT_ICONIZE. You do end up using the frame's Hide() method within the "iconize" event handler. How else would you hide it? Then to show it again, you'll want to use the menu from your task bar icon (which is technically a system tray icon on Windows). See also:
http://bytes.com/topic/python/answers/699757-wxpython-how-minimize-taskbar
http://wxpython-users.1045709.n5.nabble.com/minimize-to-try-question-td2359957.html
Related
How can I can a function and create a function for the icon context menu? I want to make the iconic Open New Window function pop-up when you right click on the icon menu in the taskbar/dock. See this question for more info on this kind of question.
Places I have looked but found nothing:
https://www.tcl.tk/man/tcl8.5/TkCmd/tk_mac.html#M15
https://pyinstaller.org/en/stable/feature-notes.html#open-event-handling-in-a-tkinter-based-gui-application
While there are a tiny subset of apple events that you can benefit from the DockMenu is not accessible directly via tkinter. Turns out mac is not really open for modifications and even smaller tasks can be hard. You could consider to use a system tray icon instead.
I am currently making an embedded multi-touch software using Kivy.
However, our hardware spec is little tight, so I am trying to optimize GUI for better performance.
Then I've found that Kivy Popup is slow when first pops up then gets faster after that. So now I am guessing that Kivy is doing some caching.
So, I want widgets, especially popups and screens since they are very slow, to act like they were opened once before.
I've tried to open and dismiss every popup widgets and go through all the screens when initializing the program. It seems quite effective except that I could not figure out how to hide the screen changing yet, but I am looking for some better approach.
I've looked for kivy document about kivy.cache here
But it is not clear whether this is what I am looking for or not. In addition, it is hard to understand what do I have to do and what to expect as a result. (Seems it does not work in a way that I want anyway)
It would probably be best to find what takes most time during the first startup, to make sure to cache that, instead of preloading every possible widget. One possibility is that it's just loading the default style texture, which you can load by setting the source of any image widget to images/defaulttheme-0.png, the first widget that needs it (that includes popup) will not to load it itself if you do. If you find that even after displaying a Button, the first Popup is still slow to load, then that's certainly something else, maybe running kivy at trace log_level will help seeing what happens last before the slowdown.
python -c kivy:log_level:trace main.py
I want to make a heads-up display that pops up it's frame, taking focus from the previous application and then gives focus back to that application when it's done.
wxPython frames have Hide and Show methods that work but don't focus the application. Also, there's SetFocus which you'd think would do it but doesn't.
Update
I found a nasty hack that works. Rather than hide and show the frame, you save the app state and close the app instead of hiding. Then when you want to show again you spark a new one in a new multiprocessing.Process. Hardly ideal though. I hope someone has something better.
Clarification
To clarify, I'm trying to get the keyboard focus, not just to get the frame on top of the stack.
This issue might be specific to OS X.
You might be able to steal focus by calling Raise on the frame. There is the wx.STAY_ON_TOP style flag that could also be applied. Then you might be able to just use the frame's Show and Hide methods to make it work.
Depending on what exactly you want to do, you might take a look at the ToasterBox widget. I can't recall if it actually steals focus, but it just pop up and go away on its own, which is handy in some cases.
I created an complete logger-type program, that logs the certain data from the internet sources. It's GUI I coded in wx.python, now I want to daemonize it (if it is the right term). The program needs to run in background and user has to have option to call/open GUI when he pleases. How can I achieve this with wx.python?
I wouldn't really "daemonize" it per se. Instead, I would just put it in the system tray...at least, that's what I would do on Windows. I assume you can do something similar on the other OSes. Basically you want to bind the frame to wx.EVT_ICONIZE and in that method, you hide it. Then when the user double-clicks the taskbar icon, you want to show it and probably Raise it too.
There's some badly formatted code here: http://bytes.com/topic/python/answers/699757-wxpython-how-minimize-taskbar (I've used a variation of it myself, so I know it works).
And here's some information on Task bar icons: http://www.blog.pythonlibrary.org/2011/12/13/wxpython-101-creating-taskbar-icons/
In order to indicate activity, some applications (e.g. Pidgin) highlight their entry in GNOME's Window List panel widget (e.g. via bold font or flashing color). This indication is reset automatically when the window is activated.
I have a terminal application for which I would like to achieve the same thing (preferably via Perl, but Python would work too) - but I have no idea where to start. I imagine I'd first have to find the terminal window (based on window title) and then trigger some kind of GTK action.
Any help would be greatly appreciated!
In a GTK application, use gtk_window_set_urgency_hint(). If you have a terminal application, you can't really do that - with libwnck you can get information about other application's windows, but as far as I know you can't get a GtkWindow pointer to another application's window.
May I suggest using the terminal beep? Of course this isn't a sure way to attract the user's attention, but some terminals are able to flash the title bar instead of beeping, or such things.
I'm not really into GTK programming, but as far as i know you want to set an "URGENT"-Flag for the Window which should be highlighted. Maybe this will get you any further. :)