I would like to create for my linux task bar a little applet in python, which simply display an icon that could change of color, and when we click on it, which show a simple information menu.
But I have no idea about the resources I could use to perform it.
I started with gtk and in particular I found the gtk.status_icon_new_from_file to display an svg icon. But I can't dynamically change the icon's color through the svg. I have to modify the colors in my file, and then to reload it. Is there a way to give directly the data of the icon rather than the name of it ?
Besides, I don't know where to continue then to code my menu. Any idea ?
Finally, is it possible to some text above an icon ?
Edit : I would like to have solution about a generic taskbar, since I'm using tint2 (with openbox) under archlinux. So I need solutions compatible with the freedesktop recommendations and not specific to Gnome or Ubuntu. Maybe solutions with a xfce4 desktop.
Status icon is most generic solution, but legacy.
Appindicator was designed for ubuntu to easy keep icon and menu in taskbar.
There is examples in several languages
http://developer.ubuntu.com/resources/technologies/application-indicators/
What is your Desktop Shell? Each shell has a better way to keep applet on taskbar. Some of these solutions has compatibility with other shells (appindicator has support in KDE, Gnome2, Gnome Shell and maybe others).
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 beginner in wxPython, and I have two questions:
How can I put the Linux terminal in wxPython?
How do I connect the event, for example, of a combobox (or other) in Tabs (class1,class2,etc) to write text in TextControl (in class2)?
"The linux terminal" is a text console that needs to talk to a framebuffer or other display driver, so you're not going to be able to put that in a window without a whole lot of work.
But hopefully what you actually want is to just put any decent terminal in there—something you can run a shell in, ideally something that will match some TERMCAP entry so it can do things like curses, etc. You could build something like that yourself, but it's a lot of work. An easier solution is to use one of the pre-existing libraries for this, like wxTerm.
I am planning to do the folliwing:
Create a PyGtk GUI (hardcoded, no Glade) with some widgets, and at the bottom of the screen put some sort of VTE (Virtual Terminal Emulator) from where I could manipulate the widgets, for example changing their attributes and calling their methods from the commandline.
The result would be similar to using AutoCAD's commands, only that I would be acting upon the GUI objects.
I have already found very few things about gtk.VteTerminal widget, but not only could not find a working example or make one myself, it also seem to be a system terminal, not a "current session" python terminal where I could run python commands and access GUI objects.
Any suggestion?
Thanks for reading
What you want exists already: GtkParasite. It's meant for debugging, but I'm sure if you wanted it to actually be a part of your application, you could adapt it.
I'm late to the party, but I had a similar problem.
Look here
Virtual Terminal Question
It's an option if you decide to do something different than what you might have already done.
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. :)
I've got a Python/GTK project I've been working on for a while, and some of the functionality I want already exists in Gnome panel applets. Based on my reading, panel applets are already in a subclass of the standard GTK Bin, so I would think there'd be a way that I can use the C-based GTK objects in my Python-based application.
For instance, I've got the fish applet in /usr/lib/gnome-panel/fish-applet-2 as a binary
Can I do some GTK magic to get that object so it can be embedded into my Python/GTK gui?
I'm not expecting a step-by-step walkthrough, but if anyone can point me in the right direction, I'd appreciate it.
The code for applets in gnome panel is quite complex. It's based on the gnome Bonobo framework (which in turn is based on CORBA). But now the whole thing is in a bit of a flux because gnome is moving away from Bonobo to a new dbus-based design. So if it's loading existing gnome panel applets you want you should absolutely use the code from gnome panel to do it. There is (or at least was) an example program included that does nothing but load an applet into a window.
If you want to display a widget from one of your own programs (a custom applet) inside another of your programs it's much easier. There are a set of widgets called GtkSocket and GtkPlug for this purpose. Of course the to programs doesn't need to run on the same machine. But there is always the delicate problem of getting them together in the first place.