2

I have read this question but its answer does not work for me, so this is not its duplicate.

This problem is happening on a project I have, where I essentially have separated the GUI module and the main module. From the main module I initialize the GUI which should in turn make the status icon (i.e. set the icon and title of it) but despite my efforts its label always reads the name of the python script.

The project's faulty code is analog to the following:

import gtk

class Main:

    def __init__(self):
        self.statusicon = gtk.StatusIcon()
        self.statusicon.set_from_icon_name('call-end-symbolic')
        self.statusicon.set_title('Title reads')

        self.cb = gtk.combo_box_new_text() # Faulty line

        gtk.main()

if __name__ == '__main__':
    instance = Main()

As ridiculous as might seem, by removing the "faulty line" the code works perfectly, i.e. the title is set. However, if one does not remove that line, the title is not set, and the script name remains as title.

I read the PyGTK documentation, and it says that the gtk method called in the faulty line is deprecated - that I should use gtk.ComboBoxText() instead; however, I cannot find the gtk.ComboBoxText within my gtk module:

>>> dir(gtk.ComboBoxText)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'ComboBoxText'

I guess this question is more in need for a bug report than an answer, but if I am wrong please correct me.

Community
  • 1
  • 1
Severo Raz
  • 174
  • 12
  • Please don't ask us to browse your code. Make a minimal program that demonstrates your problem and paste it here. In two years, when someone else comes looking for the same answer, your code will probably have changed so much as to be unrecognizable. – ptomato May 24 '12 at 09:57
  • That said, it's important to say _what_ doesn't work about the other answer. I see you have a debugging print statement in your `GUI.__init__`, what does it print? – ptomato May 24 '12 at 09:58
  • Fair enough - I recognize it is not appropriate to use dynamic source code for an example intended for long use. I will provide a test case in some hours if I can. However, the debug print statement does print the title. – Severo Raz May 26 '12 at 08:09
  • I think as a solution I will port my little project to GTK 3 anyway – Severo Raz May 26 '12 at 09:13
  • 1
    Excellent job of improving your question! Unfortunately, I don't know the answer. I do know that the `ComboBoxText` was added relatively recently and so may be newer than your version of PyGTK. – ptomato May 27 '12 at 13:29
  • I have the same problem. pyGTK reference manual says ComboBoxText() is available since pygtk 2.24, but a dir(pygtk) doesn't show it, and gtk.pygtk_version says: (2, 24, 0) – jcoppens Nov 25 '13 at 18:03

0 Answers0