Thursday, May 2, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 940  / 1 Year ago, thu, december 29, 2022, 6:04:29

I am fairly new to both quickly and Python. I am facing several problems while learning to use quickly from the following tutorial on the Ubuntu developers site:
http://developer.ubuntu.com/resources/app-developer-cookbook/multimedia/creating-a-simple-media-player/



The following error I'm unable to understand:



Traceback (most recent call last):
File "/home/sumit/Sumit/simple-player/simple_player/SimplePlayerWindow.py", line 36, in on_openbutton_clicked
if response==gtk.RESPONSE_OK:
NameError: global name 'gtk' is not defined


I realize that I am supposed to import something, so I tried to add import gtk which it didn't work and it gave the following error:



  from gtk import _gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata: assertion `node != NULL' failed
from gtk import _gtk


I have followed every step of the tutorials so far. But there is no mention of any other imports other that "prompts" and "os". Please help.






Contribution of Agmenor, facing the same problem:



I also tried to replace the text if response == gtk.RESPONSE_OK: by if response == Gtk.RESPONSE_OK: (notice the capital G). This gives another error:



AttributeError: 'gi.repository.Gtk' object has no attribute 'RESPONSE_OK'

More From » application-development

 Answers
7

I replaced "gtk.RESPONSE_OK" with "Gtk.ResponseType.OK"



Now everything is working correctly.



Found it here:
http://python-gtk-3-tutorial.readthedocs.org/en/latest/dialogs.html


[#37563] Friday, December 30, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fieldcheon

Total Points: 24
Total Questions: 105
Total Answers: 109

Location: Western Sahara
Member since Tue, Feb 16, 2021
3 Years ago
;