sid_snake
Posts: 11
Joined: Thu Sep 05, 2019 8:04 pm

guizero - question, in more ways than one

Thu Sep 05, 2019 8:20 pm

I'm not sure where to ask this. I'm exploring guizero using the Thonny app as supplied in the latest R-Pi B+/noobs package (python 3.7.3).

I'm trying out the popup dialogue boxes from the example code. I can get the info, warning and yesno popups working fine but the "question" dialogue popup has a problem.

The Shell shows this:

Code: Select all

ImportError: cannot import name 'question' from 'guizero'
This is where I need advice, I notice from the guizero Github website the "question" popup was a recent addition to the lastest version, that being 1.0

I suspect therefore my install of guizero might not be version 1.0, so is there a command I can run that will show what version of guizero I have?

I could install guizero again, but I'd rather be sure I know what the problem is before doing a hope-this-fresh-install-works type fix.

thanks

User avatar
ben_nuttall
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 231
Joined: Sun Aug 19, 2012 11:19 am
Location: Cambridge, UK
Contact: Website

Re: guizero - question, in more ways than one

Thu Sep 05, 2019 10:34 pm

Find what version you have:
pip3 freeze | grep guizero
(it takes a while)

Alternatively, use this method: https://gpiozero.readthedocs.io/en/stab ... -installed

To upgrade:
pip3 install guizero --upgrade
Community Manager - Raspberry Pi Foundation
Author of GPIO Zero and creator of piwheels

scotty101
Posts: 3735
Joined: Fri Jun 08, 2012 6:03 pm

Re: guizero - question, in more ways than one

Fri Sep 06, 2019 8:26 am

Guizero also stores a version number inside the source code. To see it type the following commands in a python interpreter

Code: Select all

import guizero
guizero.__version__
For me this reports

Code: Select all

'1.0.0'
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

scotty101
Posts: 3735
Joined: Fri Jun 08, 2012 6:03 pm

Re: guizero - question, in more ways than one

Fri Sep 06, 2019 8:30 am

Also, check if this code works for you.

Code: Select all

from guizero import App, PushButton, Text

def button_pressed():
    name = app.question("Hello", "What's your name?")
    # if Cancel is pressed None is return
    # so check a name was entered
    if name is not None:
        hello.value = "Hello " + name

app = App()
button = PushButton(app, command=button_pressed, text="Hello")
hello = Text(app)
app.display()
There were some recent changes that moved questions from requiring an import to be a "mixin" with the base widget.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

sid_snake
Posts: 11
Joined: Thu Sep 05, 2019 8:04 pm

Re: guizero - question, in more ways than one

Fri Sep 06, 2019 7:31 pm

Thanks for the info, I first ran what looked easy and got this:-

Code: Select all

>>> import guizero
guizero.__version__
Traceback (most recent call last):
  File "<pyshell>", line 2, in <module>
AttributeError: module 'guizero' has no attribute '__version__'
I used the Shell window of Thonny, maybe that's the wrong place, anyway...

So I assume there's something amiss, so I then ran:

Code: Select all

pip3 freeze | grep guizero
Then after about 4 seconds I got the goody bag:
guizero==0.6.0

Thanks for the the code to update guizero, ran it, it took a few seconds and now I'm at 1.0.0 Thanks too for the "question" test code, I ran it and that works.
Many thanks

Return to “Python”