Closed ghost closed 9 years ago
That's a GTK+ issue. The function is only available from a rather recent GTK+ version. What is your version?
Can you cook up a patch that checks for the that function being available and only executes it if it is there? Check whether there is a branch doing exactly that already ;-) It should be as easy as if hasattr(backButton, 'set_alway_show_image'): ...
I have Gtk-3.0 version installed on my system. See the output of dpkg -l | grep libgtk here : http://paste.ubuntu.com/8517333/. Check if something is different. The latest available Gtk version is 3.12 Do I need to upgrade to Gtk-3.12
FTR: Your paste shows "libgtk-3-0 3.4.2-0ubuntu0.7"
The problematic function here is set_alway_show_image
. It has been introduced with Gtk 3.6:
https://developer.gnome.org/gtk3/stable/GtkButton.html#gtk-button-set-always-show-image
Sure, updating to 3.6 would be an option. But I'd rather prefer the application to be able to run on Gtk 3.4.
One approach to achieve this, as I've tried to outline in my previous comment, is to dynamically detect the presence of the problematic function and only execute it if it is available. This is my preferred solution to this problem.
As the solution suggested by you, I have send the patch to fix this issue. Now I'm able to run even on Gtk-3.0, so can be easily run on Gtk-3.4.
I see your patch in 8489a31e035d6e792e5e9c6eef73a10aaefcaa5e. Good work! I am wondering whether it'd be easier for us to do it once only, not everytime we're attempting to call that function.
An idea I have is to check the existence on the Gtk.Button
class directly. I.e. if not hasattr(Gtk.Button, 'set_alway_show_image'): setattr(Gtk.Button, 'set_alway_show_image', lambda foo:)
.
Can you check whether this approach works?
Do you also think it'd be a nicer approach?
On a general note, the pull request contains commits that are not directly relevant to this issue. Let's try to keep the patches clean and not mix several issues at once.
So the approach is to define the global function say check,
def check(Button): if not hasattr(Button, 'set_always_show_image'): setattr(Button, 'set_always_show_image', 'False')
and then call this function when the button.set_always_show_image(True) is defined as check(self.loadButton)
I have tested this approach and seems to work. We have to define the function in both the files Sections.py and SignPages.py
Yes, Please remove that PR having multiple commit messages.
Have I clearly understood your approach. Please inform me, after that I can send the PR to fix this issue.
The approach I am envisioning involves modifying the Gtk.Button class.
You are modifying each instance of a Gtk.Button.
The difference is, that we can modify the class once and be done with it.
With your approach, we need to modify each and every instance.
So I think the approach I have in mind involves adding a line to the top of the module, maybe smth like if not hasattr(Gtk.Button, 'set_always_show_image'): setattr(Gtk.Button, 'set_always_show_image', lambda x: x)
or so.
With that, we only need to add one line as opposed to modify many locations in the code.
Do you see the difference between modifying the class and modifying every single instance?
I have completely understood your approach, I'm looking for the Gtk.Button class. Where is it implemented, in which file?
Yes, my apporach involves modifying each and every instance of the call for 'set_always_show_image'. Your approach of modifying the modifying the Gtk.button class is good, Please inform me where shall I look for the Gtk.button class.
very good :-)
You find the Button class int he Gtk module which comes from gi.repository
. See the from gi.repository import Gtk
line?
It might be sufficient to just add smth like if not hasattr(Gtk.Button, 'set_always_show_image'): setattr(Gtk.Button, 'set_always_show_image', lambda x: x)
right below that import.
I'm getting the TypeError: str object is not callable by just adding the above lines below the import Gtk. Please see: http://paste.ubuntu.com/8717729/
Please help me to fix this
hm. hard to tell without the actual code you're trying to run.
Can you create a branch, commit your current code, push, and mention the commit id here so that I can have a look at the code?
smth like this: git checkout -b tmp_nitika_gtkcompat; git commit -- . ; git push tmp_nitika_gtkcompat
hm. Don't know. Looks good to me. You could try to print out the type and the value of the button's set_always_show_image
attribute in order to find out what's going on.
Now the error seems to be different one. Please see the below stdout
root (INFO): Startup
root (DEBUG): Building cmd: 'gpg' '--command-fd' '0' '--with-fingerprint' '--list-options' 'show-sig-subpackets,show-uid-validity,show-unusable-uids,show-unusable-subkeys,show-keyring,show-sig-expire' '--status-fd' '2' '--quiet' '--batch' '--fixed-list-mode' '--no-tty' '--with-colons' '--use-agent' '--list-secret-keys'
Traceback (most recent call last):
File "/home/nitika/geysigning/keysign/MainWindow.py", line 59, in on_startup
notebook.append_page(KeySignSection(self), Gtk.Label('Keys'))
File "/home/nitika/geysigning/keysign/Sections.py", line 213, in init
self.backButton.set_always_show_image(True)
TypeError:
Any idea on how to fix this.
The error is this TypeError:
I'm not able to resolve the error. Could you Please help me with this. thanks.
TypeError: lambda () takes exactly I argument.
Have you googled this error message? In my result list are items such as http://stackoverflow.com/a/19842410/2015768 or http://stackoverflow.com/q/4909585/2015768 The answer is very likely that the function you have defined expects one argument, but is called with two arguments. As we don't care about actually executing anything, it should be sufficient to define the function with two parameters.
should be fixed by 6bdb55aa8fe203fe1538165655e8fac0fa306e56
/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed import gobject._gobject root (INFO): Startup root (DEBUG): Building cmd: 'gpg' '--command-fd' '0' '--with-fingerprint' '--list-options' 'show-sig-subpackets,show-uid-validity,show-unusable-uids,show-unusable-subkeys,show-keyring,show-sig-expire' '--status-fd' '2' '--quiet' '--batch' '--fixed-list-mode' '--no-tty' '--with-colons' '--use-agent' '--list-secret-keys' Traceback (most recent call last): File "/home/nitika/geysigning/MainWindow.py", line 57, in on_startup notebook.append_page(KeySignSection(self), Gtk.Label('Keys')) File "/home/nitika/geysigning/Sections.py", line 212, in init self.backButton.set_always_show_image(True) AttributeError: 'Button' object has no attribute 'set_always_show_image' root (INFO): Activate!