1

I use Python3.6 with gi.repository. Indeed I have created a Gtk.Entry that the user must fill in. This field is followed by a button. I would like to recover the value of the Gtk.Entry when the user clicks on the button. For my part I have created a signal, and when the user clicks on the button, I get the text from the Gtk.entry. however I would like to use this value in the rest of the code and not only in the function of the signal. please give me the right approach to do what I want. here is my signal

# definition du signal pour entrer
def on_button1_nombre_mise(self, widget):
    nombre = 0
    try:
        nombre = int(self.entry.get_text())
        self.label.set_text("Tapez maintenant le montant de votre mise : ")
    except ValueError:
        self.label.set_text("Vous n'avez pas saisi de nombre")
        print("Vous n'avez pas saisi de nombre")
    if nombre < 0 or nombre > 49:
        self.label.set_text("Votre n'est pas compris entre 0 et 49.")
    else:
        self.input = nombre
liberforce
  • 11,189
  • 37
  • 48
Lone.S
  • 11
  • 2

1 Answers1

0

You're already saving it in an object when doing self.input = nombre. To use it somewhere else, just use access that object's input attribute, like in thatobject.input or self.input, dependng where is the code you execute.

liberforce
  • 11,189
  • 37
  • 48