Folgendes Problem.
Ich habe ein GtkEntry und dahinter einen Button, der beim klicken den Inhalt des Entries auslesen soll.
Leider bekomme ich immer den Fehler, dass das Programm den GtkEntry nicht kennt.
Code: Alles auswählen
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GdkPixbuf, Gdk
from google_images_download import google_images_download as gid
responste = gid.googleimagesdownload()
import os, sys
#Comment the first line and uncomment the second before installing
#or making the tarball (alternatively, use project variables)
UI_FILE = "src/pygtk_foobar.ui"
#UI_FILE = "/usr/local/share/pygtk_foobar/ui/pygtk_foobar.ui"
class GUI:
def __init__(self):
# window initialization
self.builder = Gtk.Builder()
self.builder.add_from_file(UI_FILE)
self.builder.connect_signals(self)
window = self.builder.get_object('window')
window.show_all()
# data initialization
def on_window_destroy(self, window):
Gtk.main_quit()
def app_overview(self, window):
print("Overview")
def app_back(self, window):
print("Back")
def app_save(self, window):
print("Save")
def app_forward(self, window):
print("Forward")
def app_search(self, window):
print("Search")
species = str(Tbo_Species.get_text()) <-- Hier muss der Fehler laut Fehlermeldung sein! (mit self.Tbo_Species geht es nicht).
#arguments = {"keywords":
print("Species:", species)
def app_quit(self, window):
Gtk.main_quit()
def main():
app = GUI()
Gtk.main()
if __name__ == "__main__":
sys.exit(main())
Code: Alles auswählen
Traceback (most recent call last):
File "/home/rtfm/pygtk-foobar/src/pygtk_foobar.py", line 63, in app_search
species = str(Gtk.Tbo_Species.get_text())
File "/usr/lib/python2.7/dist-packages/gi/overrides/__init__.py", line 39, in __getattr__
return getattr(self._introspection_module, name)
File "/usr/lib/python2.7/dist-packages/gi/module.py", line 137, in __getattr__
self.__name__, name))
AttributeError: 'gi.repository.Gtk' object has no attribute 'Tbo_Species'
----------------------------------------------
Program exited with errcode (0)
LG,
TimeMen