Re: debugging some old glade.XML code, not getting a return of text?



Hello everybody,

Could somebody help me out please?

A code snippet of a piece of replacement code to popup a window to fill in a question and have the answer stored as variable would be great.

I got the below piece of code, but it is not returning any text anymore "entry.get_text()".

If I need to provide more information please let me know.

def ask(question, parent=None):
dia = glade.XML(terp_path('terp.glade'), 'win_quest', gettext.textdomain())
        win = dia.get_widget('win_quest')
        label = dia.get_widget('label')
        label.set_text(question)
        entry = dia.get_widget('entry')

        if not parent:
                parent=service.LocalService('gui.main').window
        win.set_transient_for(parent)
        win.set_icon(TINYERP_ICON)

        response = win.run()
        print response
        parent.present()
        win.destroy()

        if response == gtk.RESPONSE_CANCEL:
                return None
        else:
                return entry.get_text()

Thank you,

Kind regards,

Jelle

On 2020-01-14 00:10, Jelle de Jong wrote:
Hello everybody,

I am debugging a piece of old python gtk code and found that the bellow ask function using glade.XML to ask a question does not seem to return the insert string entered into the generated dialog.

How can I change the bellow code to return the insert text string?

Kind regards,

Jelle de Jong


def ask(question, parent=None):
        dia = glade.XML(terp_path('terp.glade'), 'win_quest', gettext.textdomain())
         win = dia.get_widget('win_quest')
         label = dia.get_widget('label')
         label.set_text(question)
         entry = dia.get_widget('entry')

         if not parent:
                 parent=service.LocalService('gui.main').window
         win.set_transient_for(parent)
         win.set_icon(TINYERP_ICON)

         response = win.run()
         print response
         parent.present()
         win.destroy()

         #jelledj
         name = entry.get_text()
         print name
         print "testing"

         if response == gtk.RESPONSE_CANCEL:
                 return None
         else:
                 return entry.get_text()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]