PyQt QTreeWidget - SIGNAL 'clicked' from header - pyqt4

Is it possible to make the header item of a QTreeWidget clickable ? ( what would be the syntax if it is ? )

Yes. setClickable method of the QHeaderView would be the way. You can get the QHeaderView by calling header() method of your QTreeWidget.

Related

Render outcome of "action" attribute?

i want to completely rewrite a <h:commandButton> renderer. Now i'm stuck at rendering the "action" attribute of the button. Is there a possibility to render this attribute the same way it gets rendered by the standard renderer ? Is there a possibility to retrieve the generated script from somewhere ? Furthermore i don't want to use third party libs, if possible.
Thanks in advance !
As always, BalusC was right. There is no generated Javascript.
But there was another thing i forgot about. One needs to add the following code: button.queueEvent(new ActionEvent(button)); in the decode method of the according component renderer, where "button" is the UIComponent parameter of the "decode" method.
Thanks a lot BalusC !

PyQt check if value of qlabel changed

I Need to check if the value (str) of a qlabel changed.
I think about using the following code (nearly the same as used by a spinbox widget in PyQt):
self.connect(self.ui.labelEntry, QtCore.SIGNAL("valueChanged(str)"), self.autovalidate)
What's the correct Methode to check if value changed?
All the best;
QLabels don't have a valueChanged/textChanged signal. You either have to use another widget type (a QLineEdit for instance) or to subclass QLabel and create your own change-aware class with a textChanged signal.
If you use QtDesigner, it might be simpler to go with the first solution and customize your QLineEdit from the Designer. In the property editor, unckeck frame, check readOnly, and write background-color:"transparent" in styleSheet and you've got a QLabel looking QLineEdit.
You also should use the new-style syntax, it's far more elegant.
self.ui.labelEntry.textChanged.connect(self.autovalidate)

How to do event handling for dynamically introduced elements in page in yui3

I am having trouble to do event handling for elements which are dynamically introduced in the page.I currently use:
Y.on("click",function,'.dynamicObj');
Here suppose 'dynamicObj' is the class which I add when I make these element.But Y.on has the polling issue so sometimes my code worked properly sometime it didn't.
So can somebody please guide on how to eventhandling for dynamically add elements of the page at the same time no polling issue is faced.
You usually listen to the event on an element that contains the dynamic element and let the event bubble up to reach it.
instead of using 'on' use 'delegate' to bind event.
ex Y.one('<already present element selector>').delegate('<event>', <binder function name>, '<element on which event is to be binded>')

How to change grid row color in wicket?

I want to change grid row color when I click a row in Wicket.
Do you have any suggestion?
Without actually seeing your code it's difficult to tell what is the more suitable way of doing this for you.
If you want to change to a specific color known at page generation time, do it client-side (javascript).
Make sure the grid row has a wicket:id so that Wicket can have control over it. Add it as a WebMarkupContainer if you haven't got it. Add a SimpleAttributeModifier for the onclick attribute that will change the css class of the element. For instance:
rowMarkupContainer = new WebMarkupContainer("row");
String javascript = "this.setAttribute('class', 'myClass');";
rowMarkupContainer.add(new SimpleAttributeModifier("onclick", javascript);
Where myClass is a CSS class that uses a new color.
Alternatively, you can always hardcode the onclick event handler in the HTML without specifying a wicket:id.

What's the purpose of the GtkWidget.events property for (like) GtkTreeView widgets?

I have a Glade GUI description file with a GtkTreeView in a GtkHBox in a window; and there's a handler for the row_activated signal. Now, Glade has automatically set the "events" property (inherited from GtkWidget) of that treeview to some value (GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK). And there are two strange things with this:
removing the pre-set value (so that the property is empty) doesn't seem to break the application (at least not with the old GTK 2.10 I have atm).
in fact, an annoying bug I has seen before (where the treeview items would not correctly react to expand or collapse clicks) is now gone!
I have yet to test this with a newer GTK version, but the question is already there: exactly what is the purpose for this events property? And why does Glade automatically and unnecessarily set it to some value? Does this have some side effects I'm not aware of?
It's a bug in glade, it always sets the event property of widgets it create. It has no notion of the default value of a property so it always sets it.
Doesn't this mask indicate the events you're willing to receive? In this case, you'll probably want to receive notification that the user has clicked or double-clicked an item in the GtkTreeView, and you'll want to register callbacks to handle these events.
me.yahoo.com/a/kUQ7zeQ: but even if I set the property to an empty string as mentioned, the row_activated handler is still called when I double-click on a row (or press Enter or Space). So the treeview still gets events...

Resources