gtk.StatusIcon with double click - python

I'm using python GTK under Gnome (Gnome 3 in Fedora 15).
I'd like to catch events when the user double clic on the icon in the tray area.
I found that "activate" signals is called when the user do a single clic, but can't find the signal or a proper way to call a method when the user double clic on it.
How can I do ?
Thanks for your help!

You can't. Gtk+ itself doesn't even know if it was single or double clicked.
From the Gtk+ documentation about the ::activate signal:
Gets emitted when the user activates the status icon. If and how status icons can activated is platform-dependent.
Interestingly Qt knows about this (it has Trigger and DoubleClick). Maybe you can work around this by using ::button-press-event instead and counting it, but I'm not sure this can be called the recommended way.
Also, a personal note as a user: I prefer status icons that are activated by a single click.

Related

PyQt - QFileDialog selects with single click

I have this very strange problem. I use QFileDialog to select files, but the selection is done with a single click, instead of double click as in everywhere else. Maybe something specific for the look-and-feel, or something in the configuration.
My form (single click):
Eclipse form (double click):
Any idea how to set it to double-click? Thanks.
This is controlled by the QT5 configuration on your system.
Run qt5ct (on a Unix-like system, or the equivalent elsewhere) and uncheck 'Activate on single click'.

easygui CLOSE button (on top right of window) not functioning

i have created a chat system in python, using easygui for graphical user interface.
there are minimize,maximize and close button on top right of window,but the close button is not functioning at all.i just can use the exit button which i created to close the application. i had some search and found there is a problem with easygui, so is it totally impossible to fix this problem? or how can i remove that close button from top right as there is no use for it. its final year project and i'm afraid my advisor and supervisor want try that button and i lose mark because of no function
is there anyway to fix it or at least remove that close button?
This is likely past the due date for your assignment...sorry. But, that was a known limitation of easygui. An up-to-date version with a fix for that will be released soon. If you can't wait, you can take a look at it in development form: https://github.com/robertlugg/easygui

PySide Button Auto Repeat doesn't start until mouse is moved

I have a PySide application with a single button that implements auto-repeat. But the auto-repeat functionality doesn't seem to be working correctly.
If I simply click and hold the button, its function is only called once no matter how long I wait or what the auto-repeat settings are. But as soon as I move the mouse, the button's functionality is called repeatedly, just as it should be.
This is with Python 2.6, PySide 1.1.2, running on Windows 7 64 bit.
self.btn.setAutoRepeat(True)
self.btn.setAutoRepeatDelay(200)
self.btn.setAutoRepeatInterval(100)
I was having a similar problem using normal QT4.x on linux. The issue was that something was connected to the clicked signal. I think it was stealing/changing the focus of the mouse. I just changed that item to connect to the the released signal. That doesn't mean you can't connect to clicked, but just be sure that there are no focus stealing side-effects.

highlighting a window in GNOME's window list

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. :)

Asynchronously updating PyGTK tray icon

As explained here, I have a simple tray icon using PyGTK.
Being very new to GTK, it appears to me that gtk.main() is synchronous, blocking any further processing until the respective UI is closed.
So how can I periodically (e.g. every 5 seconds) update/refresh StatusIcon's icon - do I have to resort to Twisted et al. for this?
You can use gobject.timeout_add() to add periodical tasks. The first parameter is the interval in seconds, the second parameter is the callback you want to be called. The callback is called as long as it returns something that evaluates to True when used as a bool.
See also section 20 of the PyGTK FAQ, in particular question 20.7.
You can't refresh easily the tray icon , take it from some one that did already try this and failed (Actually i just drop it for the reason that "If the implementation is hard to explain, it's a bad idea.") ,
but here is what i have so far, to refresh the Status Icon you will have to set your status icon using gtk.status_icon_new_from_gicon() method, from the doc :
Creates a status icon displaying a
gio.Icon(). If the icon is a themed
icon, it will be updated when the
theme changes.
So if you want to refresh the Status Icon you will have to create your icon using gio themed icon , and now you can update directly your themed icon and this change will be shown directly in the tray status.
Now about your question :
Yes gtk.main() block waiting for signal, so you just have to bind a signal to an action and when this signal is triggered the action can be executed , for your case in your action callback you can put the code that will refresh your Status Image.
Hope i did help you here.

Categories

Resources