Python Forum
Need help with an error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with an error
#1
Sorry, this is probably a dumb question but im still studing python
im making a calculator with guizero and i have this error

Error:
>>> Exception in Tkinter callback Traceback (most recent call last): File "C:\Program Files\Mu IDE\pkgs\tkinter\__init__.py", line 1705, in __call__ return self.func(*args) File "C:\Program Files\Mu IDE\pkgs\guizero\PushButton.py", line 197, in _command_callback self._command() File "c:\users\dell\mu_code\phase 2.py", line 16, in one screen_numbers = screen_numbers + '1' UnboundLocalError: local variable 'screen_numbers' referenced before assignment
what do i do to fix it?
Im new in the comunity btw


from guizero import App, Box, PushButton, Text
app = App(title="Project Sigma", bg="white", height=299, width=320)

#GUI

# Screen
screen_topside = Box(app, height=60, width=309, border=1, align="top")
screen_numbers = Text(screen_topside, height='fill', width='fill')
screen_numbers.text_size = 21

# Space between screen and numpad
space = Box(app, height=10, width=330, align="top")

# Functions
def one():
    screen_numbers = screen_numbers + '1'


# Number Pad
numpad = Box(app, height=223, width=309, layout='grid', border=1)

buttonc = PushButton(numpad, text='C', height=1, width=7, grid=[0,0])
buttond = PushButton(numpad, text='÷', height=1, width=7, grid=[1,0])
buttonm = PushButton(numpad, text='×', height=1, width=7, grid=[2,0])
button_del = PushButton(numpad, text='Del', height=1, width=7, grid=[3,0])
button1 = PushButton(numpad, text="1", command=one, height=1, width=7, grid=[0,1])
button2 = PushButton(numpad, text="2", height=1, width=7, grid=[1,1])
button3  = PushButton(numpad, text="3", height=1, width=7, grid=[2,1])
button_minus = PushButton(numpad, text='-', height=1, width=7, grid=[3,1])
button4  = PushButton(numpad, text="4", height=1, width=7, grid=[0,2])
button5  = PushButton(numpad, text="5", height=1, width=7, grid=[1,2])
button6  = PushButton(numpad, text="6", height=1, width=7, grid=[2,2])
button_plus = PushButton(numpad, text='+', height=1, width=7, grid=[3,2])
button7  = PushButton(numpad, text="7", height=1, width=7, grid=[0,3])
button8  = PushButton(numpad, text="8", height=1, width=7, grid=[1,3])
button9  = PushButton(numpad, text="9", height=1, width=7, grid=[2,3])
button_same = PushButton(numpad, text='=', height=4, width=7, grid=[3,3,4,3])
button0  = PushButton(numpad, text="0", height=1, width=18, grid=[0,4,2,4])
button_dot = PushButton(numpad, text='.', height=1, width=7, grid=[2,4])
Reply


Messages In This Thread
Need help with an error - by Miguel_Lona605 - Mar-25-2020, 09:17 PM
RE: Need help with an error - by michael1789 - Mar-25-2020, 09:35 PM
RE: Need help with an error - by Miguel_Lona605 - Mar-25-2020, 11:36 PM
RE: Need help with an error - by joe_momma - Mar-26-2020, 12:03 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020