unreal_glitch
unreal_glitch

Reputation: 13

Python guizero: textBox = [textBox]

OK, I been using guizero for a couple of days but I found a problem that has been perplexing me. Here a simplified version of the code.

from guizero import App, Text, PushButton, Picture, Drawing, TextBox

app = App("Testing")
          
def test():
    global testing
    print(testing)

button = PushButton(app,test, text = "press to test")
button.bg = "red"
button.text_size= 35

tittle = Text(app, "Testing input here")
testing = TextBox(app, text= "" )
app.display()

No matter what the users input into the Textbox, it is always print:

[TextBox] object with text ""

I tried putting testing into an argument in the function test, it comes up with the same thing.

[TextBox] object with text ""

If I don't make an argument in the function or global testing, it makes the same thing, and if I make the textbox before the button, I have the same problem.

Can anyone find a way to work around the problem or to fix this, I'm new to guizero so I have little to an idea what I'm doing

Upvotes: 1

Views: 1602

Answers (1)

scotty3785
scotty3785

Reputation: 7006

If you want to print the contents of the Text widget then you need to do

def test():
    global testing
    print(testing.value)

This will get the value of the testing widget rather than the "repr" of the widget.

Seems like a bit of "bug" in guizero that the description text that is output doesn't update when the value of the widget is updated.

Issue has been accepted by the developer and a fix has been pushed to a development branch. https://github.com/lawsie/guizero/issues/392

Upvotes: 1

Related Questions