[SOLVED]Error: 'str' object is not callable, textbuttons

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
User avatar
piinkpuddiin
Newbie
Posts: 5
Joined: Sat Dec 16, 2023 3:20 pm
Completed: Rotten Wife, Priscyllia's last night, The Succubus Won't Fuck Me
Projects: "You're so nice!", TBD, TTGH
Tumblr: piinkpuddiin
itch: piinkpuddiin
Contact:

[SOLVED]Error: 'str' object is not callable, textbuttons

#1 Post by piinkpuddiin »

Hello, I'm having a "'str' object is not callable" error whenever I hover over a textbutton.

The BBCode:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00start.rpy", line 275, in script
    python:
  File "renpy/common/00start.rpy", line 279, in <module>
    renpy.call_in_new_context("_main_menu")
TypeError: 'str' object is not callable

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

Full traceback:
  File "renpy/common/00start.rpy", line 275, in script
    python:
  File "C:\Users\mnsan\Downloads\renpy-8.0.3-sdk\renpy\ast.py", line 1138, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\mnsan\Downloads\renpy-8.0.3-sdk\renpy\python.py", line 1122, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "renpy/common/00start.rpy", line 279, in <module>
    renpy.call_in_new_context("_main_menu")
  File "C:\Users\mnsan\Downloads\renpy-8.0.3-sdk\renpy\game.py", line 349, in call_in_new_context
    return renpy.execution.run_context(False)
  File "C:\Users\mnsan\Downloads\renpy-8.0.3-sdk\renpy\execution.py", line 955, in run_context
    context.run()
  File "renpy/common/_layout/screen_main_menu.rpym", line 28, in script
    python hide:
  File "/home/tom/ab/renpy-build-fix/tmp/install.linux-x86_64/lib/python3.9/site-packages/future/utils/__init__.py", line 444, in raise_
  File "renpy/common/_layout/screen_main_menu.rpym", line 28, in script
    python hide:
  File "C:\Users\mnsan\Downloads\renpy-8.0.3-sdk\renpy\ast.py", line 1138, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\mnsan\Downloads\renpy-8.0.3-sdk\renpy\python.py", line 1122, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "renpy/common/_layout/screen_main_menu.rpym", line 28, in <module>
    python hide:
  File "renpy/common/_layout/screen_main_menu.rpym", line 35, in _execute_python_hide
    ui.interact()
  File "C:\Users\mnsan\Downloads\renpy-8.0.3-sdk\renpy\ui.py", line 299, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\mnsan\Downloads\renpy-8.0.3-sdk\renpy\display\core.py", line 3582, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, pause_modal=pause_modal, **kwargs) # type: ignore
  File "C:\Users\mnsan\Downloads\renpy-8.0.3-sdk\renpy\display\core.py", line 4538, in interact_core
    rv = renpy.display.focus.mouse_handler(ev, x, y)
  File "C:\Users\mnsan\Downloads\renpy-8.0.3-sdk\renpy\display\focus.py", line 604, in mouse_handler
    return change_focus(new_focus, default=default)
  File "C:\Users\mnsan\Downloads\renpy-8.0.3-sdk\renpy\display\focus.py", line 537, in change_focus
    rv = widget.focus(default=default)
  File "C:\Users\mnsan\Downloads\renpy-8.0.3-sdk\renpy\display\behavior.py", line 993, in focus
    rv = run(self.hovered)
  File "C:\Users\mnsan\Downloads\renpy-8.0.3-sdk\renpy\display\behavior.py", line 379, in run
    return action(*args, **kwargs)
TypeError: 'str' object is not callable
My code:

Code: Select all

screen navigation():

    if renpy.get_screen("main_menu"):

        hbox:
            textbutton _("Start") action Start():
                pos (90, 990)
                text_size 50
            
            textbutton _("Options") action ShowMenu("preferences"):
                pos (720, 990)
                text_size 50

            textbutton _("Extras") action ShowMenu("extras"):
                pos (1440, 990)
                text_size 50

            text "piinkpuddiin":
                font "fonts/Bayon-Regular.ttf"
                pos (-324, 2)
                size 50

            text "The Succubus Won't Fuck Me":
                font "fonts/Bayon-Regular.ttf"
                pos (14, 2)
                size 50

            text "ACE JAM":
                font "fonts/Bayon-Regular.ttf"
                pos (517, 2)
                size 50

    else:

        vbox:
            textbutton _("Start"):  
                action Start()
                text_size 56
                pos (95, -9)

            textbutton _("Load"): 
                action ShowMenu("load")
                pos (-65, 72)
                text_style "verticaltxt"
                hovered "#000"
                unhovered "#458"

            textbutton _("Help"):
                action ShowMenu("help")
                pos (-65, 72)
                text_style "verticaltxt"
                hovered "#000"
                unhovered "#458"
        
        vbox:
            textbutton _("Extras"):
                pos (1700, 172)
                action ShowMenu("extras")
                text_style "verticaltxt"
                hovered "#000"
                unhovered "#458"

            textbutton _("About"):
                pos (1700, 172)
                action ShowMenu("about")
                text_style "verticaltxt"
                hovered "#000"
                unhovered "#458"

        vbox:
            textbutton _("quit") action Quit()
Any help is much appreciated!
Last edited by piinkpuddiin on Thu Jan 25, 2024 2:16 pm, edited 1 time in total.

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

Re: Error: 'str' object is not callable, textbuttons

#2 Post by Ocelot »

hovered "#000" That says "when the button is hovered, execute #000". Which makes no sense.

you probably wanted to set hover_color property on text within button. Which is better done by using styles, but if you insist on setting it on buttons directly, it is either hover_text_color or text_hover_color, I do not remember order of prefix application here.
< < insert Rick Cook quote here > >

User avatar
piinkpuddiin
Newbie
Posts: 5
Joined: Sat Dec 16, 2023 3:20 pm
Completed: Rotten Wife, Priscyllia's last night, The Succubus Won't Fuck Me
Projects: "You're so nice!", TBD, TTGH
Tumblr: piinkpuddiin
itch: piinkpuddiin
Contact:

Re: Error: 'str' object is not callable, textbuttons

#3 Post by piinkpuddiin »

I see, thank you for your help!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]