PyGtk3, How to Create "title-changed" signal for Gtk.Window Widget? - pygtk

i want create signal that runs when title of window changed.
example
def printTitleChanged(windowName):
print("title of",windowName, "changed")
myWindow = gtk.Window("example")
myWindow.connect("title-changed", printTitleChanged, "myWindow")

I might be mistaken, but the window title is out of reach from Python - it is managed by the window manager, except for setting and reading the title.
Also, normally only your program can change the title, so, if you want a callback when set_title is called, define a new method set_title which overrides the original set_title, and generate the callback yourself.
So: define a new class (eg. My_window) which inherits from Gtk's GtkWindow, and redefine set_title.

Related

How should a test be written for a delegate for editing?

I have a tree view for which some fields need to use a custom delegate for editing. The delegate presents a QListView for value selection. It seems like the QAbstractItemView.edit() method should be used to initiate the edit from the test but I can't figure out how to get access to the created editor (a QListView) so I can select the proper element for the test.
This is part of a test I had working with a QComboBox delegate before switching to the QListVew, but it seems too manual.
for index, enumerator in enumerate(group.children):
editor = delegate.createEditor(
parent=viewport,
option=None,
index=target_index,
)
editor.setCurrentIndex(index)
delegate.setModelData(editor, model, target_index)
assert enumerator.uuid == item.enumeration_uuid
https://github.com/altendky/st/commit/643c5c30f87fc3bfd8b422687e81f740ec36ef44#diff-06bc81dbbd9f7a12878169d5238e1572R846
Here is what I came up with.
https://github.com/altendky/st/blob/089432162b9e8ca67eafdfcc2a4ecc34e8f0e96e/epyqlib/tests/test_attrsmodel.py#L848
for row, enumerator in enumerate(group.children):
assert view.edit(
target_index,
PyQt5.QtWidgets.QAbstractItemView.AllEditTriggers,
None,
)
editor, = view.findChildren(PyQt5.QtWidgets.QListView)
index = editor.model().index(row, 0, editor.rootIndex())
editor.setCurrentIndex(index)
editor.clicked.emit(index)
# this is fun. if you get weird issues try doing this more times
for _ in range(3):
application.processEvents()
assert enumerator.uuid == item.enumeration_uuid
Do note that I connect the editor's clicked signal to post an enter-key event since the view's are hardcoded to catch an enter event and finish editing.

Call Pop-Up for WebDynpro from a Business AddIn?

We got a Web Dynpro Application which was created with the Floorplan Manager.
By clicking a specific button I start a Business AddIn which check some conditions and then it should show a popup on the screen with a message for the user.
Is there a way I can accomplish that?
One way to get a PopUp (eg confirmation) window in Floorplan applications is to overwrite the NEEDS_CONFIRMATION method of the Interface IF_FPM_GUIBB_*_EXT inside your feeder-class.
Create a reference to cl_fpm_confirmation_request and put this one in the export-parameter EO_CONFIRMATION_REQUEST of the Method.
By Example:
METHOD if_fpm_guibb_list_ext~needs_confirmation.
DATA li_req TYPE REF TO cl_fpm_confirmation_request.
CASE io_event->mv_event_id.
WHEN 'YOUR_EVENT_ID'.
CREATE OBJECT li_req
EXPORTING
it_confirmation_text = 'Plaintext in Content of Popup'
iv_window_title = 'Title of the Popup'
iv_button_text_approve = 'Text Approve-Button'
iv_button_text_reject = 'Text Reject-Button'
.
eo_confirmation_request = li_confrequ.
ENDCASE.
ENDMETHOD.
The method will be called before the PROCESS_EVENT-Method an will override it when you cancel the popup.
Please be aware that every GUIBB-Implementation has it´s own extension interface, e.g. List, Tree, ...
For a deeper look inside popups in FPM or custom-popups have a look into https://blogs.sap.com/2013/11/26/popups-in-floorplan-manager/

Can't find Dojo IconMenuItem callback example. (Defined by dojox/mobile/_ItemBase)

I can't find Dojo IconMenuItem callback example. (Defined by dojox/mobile/_ItemBase)
callback
Defined by dojox/mobile/_ItemBase
A callback function that is called when the transition has been finished. A function reference, or name of a function in context.
I try to call a function after the transition is called.
I tried to find an example how to set the callback function.
I also need to find an example of giving the function a context (parameters).
Like this:
on(iconJs, "click", lang .hitch({"context":{"currentSchool":schools[i].id}}, function(){getKlassen("fillKlastoevoegenView", this.context);}));
This is what I tried (for html part)
<li data-dojo-type="dojox.mobile.IconMenuItem" data-dojo-props="label: 'Scholen', transition:'slide', url:'views/klappr/overviewSchool.html', urlTarget:'overviewSchool' callback : 'overviewSchoolController.show()';" ></li>
I also need to do it programmatically like this
iconJs =new dojox.mobile.IconItem({label:'', deletable: false, icon:'images/Tile_Toevoegen.png', transition:'slide', class:'klasIcon', url:'views/klappr/addKlas.html', urlTarget:'addKlas', callback : 'overviewSchoolController.show();'});
ItemBase is the base class for several Dojo widgets, including dojox.mobile.ListItem (which I believe is the most common of all of them).
So, for what you are looking for, here you'll find how to do the simplest example: Dojo mobile and callback in dojox.mobile.ListItem
Also, for the programatic sample, this should help: http://comments.gmane.org/gmane.comp.web.dojo.user/54040 specially this one: http://permalink.gmane.org/gmane.comp.web.dojo.user/54117

NSTokenField click completion list item

I have an NSTokenField in my application and I implemented the tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem: method in which I specify the receiver’s tokenizing character set with the setTokenizingCharacterSet: method:
def tokenField(tokenField, completionsForSubstring:substring, indexOfToken:tokenIndex, indexOfSelectedItem:selectedIndex)
tokenField.setTokenizingCharacterSet(NSCharacterSet.whitespaceAndNewlineCharacterSet)
end
It works as expected when I click on the space bar or the enter button. I would also like to have the same behavior when I click on one of the item of the completion list with my mouse.
How is that possible?
Thanks for your help.
I don't know if it's possible to have this behaviour with a NSTokenField.
But you should take a look at MTTokenField which do what you want out of the box.
To do so, you will have to:
1.Create an Xcode Project as a Static Library(Do not enable ARC).
2.Save your project to vendor/MTTokenField
3.Drag and drop all the files of MTTokenField located in the subdirectory 'MTTokenField' to your new XCode project. Choose to copy the files.
4.Add this to your rakefile in order to compile and link the library with your Rubymotion project.
app.vendor_project("vendor/MTTokenField/", :xcode, :xcodeproj => "MTTokenField.xcodeproj", :target => "MTTokenField", :products => ["libMTTokenField.a"], :headers_dir => "MTTokenField")
5.In Interface Builder change the class of your NSTokenField to NSTextField and then set its custom class to MTTokenField, and also change the custom class of the cell: MTTokenFieldCell instead of NSTextFieldCell.
6.Then you have to set the delegate of your MTTokenField to a class which has to respond to :
def tokenField(tokenField, completionsForSubstring: substring )
# your have to return an array containing your results matching substring.
end
And that's it. It should work.
Hope it helps !
I found another solution using NSTokenField instead of MTTokenField.
In the delegate of my NSTokenField, I used the controlTextDidChange method of NSControl which is called anytime I write a character in my token field. In this method I check if there is a NSLeftMouseUp event which is triggered, and if it's the case, I simulate a click on Return. And that's it.
def controlTextDidChange(aNotification)
application = NSApplication.sharedApplication
event = application.currentEvent
if event.type == NSLeftMouseUp
e1 = CGEventCreateKeyboardEvent(nil, 0x24, true)
CGEventPost(KCGSessionEventTap, e1)
end
end
There is one more thing to do to make it properly work: the issue here is that if I have a completion list with 3 items for instance, one of them will be selected by default, let's say the first one. In this case, the solution will work as expected if I click the second or the third item but I will have to double click the first item to make it work.
To fix this, turn off the autocompletion and only display the suggestion box, i.e add this line to the tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem: method:
selectedIndex[0] = -1

update table in gtk

I have window that contains a table on screen, now I want to attach a widget to that table I use
gtk_table_attach(GTK_TABLE(table), label, ...)
the function is correct and it runs without any error
but table does not respond to that line I mean there is no change on my table, I think I need something to tell that table update it self but how?
note= that line is inside a callback of a signal and I am sure that signal runs
note2= I do not want to destroy window for that
note3= I use gtk+ and pygtk
note4= I am sure I attach that widget to a correct position ( it is free)
Did you call gtk_widget_show() on label first?