TypeError: 'unicode' object is not callable

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
figment
Regular
Posts: 33
Joined: Sat Apr 01, 2017 11:02 pm
Contact:

TypeError: 'unicode' object is not callable

#1 Post by figment »

Trying to make a popup screen to change the name from the preferences menu.

The textbutton:

Code: Select all

textbutton ("Change Name") action Show("namechange")
Calls the screen:

Code: Select all

screen namechange():
    
    modal True
    
    zorder 200

    style_prefix "confirm"

    add "gui/overlay/confirm.png"

    frame:

        vbox:
            xalign .5
            yalign .5
            spacing 30

            input default "FirstName" length 10 allow "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" changed persistent.mc
            input default "LastName" length 10 allow "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" changed persistent.lname

            textbutton "Done" action Return()
The screen shows up, but once I try to delete the default, it throws the following:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
TypeError: 'unicode' object is not callable

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "renpy/common/_layout/screen_main_menu.rpym", line 28, in script
    python hide:
  File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\ast.py", line 814, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\python.py", line 1719, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/_layout/screen_main_menu.rpym", line 30, in <module>
    ui.interact()
  File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\ui.py", line 285, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2526, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 3204, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 960, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 960, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 960, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\screen.py", line 651, in event
    rv = self.child.event(ev, x, y, st)
  File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 960, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 232, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 960, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 1225, in event
    self.update_text(content, self.editable)
  File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 1182, in update_text
    self.changed(new_content)
TypeError: 'unicode' object is not callable

Windows-8-6.2.9200
Ren'Py 6.99.12.4.2187
Steampunk 1.0
I'm baffled.

figment
Regular
Posts: 33
Joined: Sat Apr 01, 2017 11:02 pm
Contact:

Re: TypeError: 'unicode' object is not callable

#2 Post by figment »

Anyone? Even a "No, your code is entirely wrong, start again" would be helpful.

I have no idea what's wrong, and even less idea how to make it right.

jw2pfd
Regular
Posts: 87
Joined: Tue Sep 18, 2012 9:55 pm
Location: DFW, TX, USA
Contact:

Re: TypeError: 'unicode' object is not callable

#3 Post by jw2pfd »

I think your problem is in these two lines:

Code: Select all

            input default "FirstName" length 10 allow "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" changed persistent.mc
            input default "LastName" length 10 allow "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" changed persistent.lname
I am pretty sure it has to do with the changed parts in each statement.

https://renpy.org/doc/html/screens.html ... nput#input
changed - A python function that is called with what the user has typed, when the string changes.

persistent.mc and persistent.lname are not python functions I assume. I think this means that it's trying to call a string or other object like it's a function once you make a change to the input field and that causes the error. You can temporarily try removing or commenting the 'changed' part of the statements out to see if the rest of it works.

figment
Regular
Posts: 33
Joined: Sat Apr 01, 2017 11:02 pm
Contact:

Re: TypeError: 'unicode' object is not callable

#4 Post by figment »

Okay. Yes, that seems to be the problem. Thank you so much. I somehow missed that changed calls a function.

persistent.mc and persistent.lname are the variables I want to change.

So I guess now I need to write a function that accepts the input and assigns it to those variable.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2402
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: TypeError: 'unicode' object is not callable

#5 Post by Ocelot »

No, you need to utilise value property. It expects InputValue. More about it here: https://renpy.org/doc/html/screen_actio ... put-values
< < insert Rick Cook quote here > >

figment
Regular
Posts: 33
Joined: Sat Apr 01, 2017 11:02 pm
Contact:

Re: TypeError: 'unicode' object is not callable

#6 Post by figment »

Nope, I have no idea what's going on. :(

Where should I be using InputValue? Is that what I should be calling with changed, or is that what I should be using in place of input?

User avatar
Saltome
Veteran
Posts: 244
Joined: Sun Oct 26, 2014 1:07 pm
Deviantart: saltome
Contact:

Re: TypeError: 'unicode' object is not callable

#7 Post by Saltome »

He means like this:

Code: Select all

input value FieldInputValue(persistent, "mc") length 10 allow "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
input value FieldInputValue(persistent, "lname") length 10 allow "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
Now you still have a bit of a problem, since you can only edit one of the fields. But there are different solutions, depending on how you want it to work in the end.

The easy way is to just have separate buttons for each field.
Or you could do something a little more ellaborate, which allows you to have both fields on the screen at the same time.
Deviant Art: Image
Discord: saltome
Itch: Phoenix Start

figment
Regular
Posts: 33
Joined: Sat Apr 01, 2017 11:02 pm
Contact:

Re: TypeError: 'unicode' object is not callable

#8 Post by figment »

Beautiful. Thank you so much. I'll play with this when I get home.

You guys are excellent, and I appreciate your help.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]