Changing quick menu textbuttons to imagebuttons

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
Vytswell
Newbie
Posts: 14
Joined: Tue Oct 27, 2020 2:23 pm
Contact:

Changing quick menu textbuttons to imagebuttons

#1 Post by Vytswell » Fri Nov 06, 2020 8:00 am

Hello there,
I've tried to change bottom quick menu textbuttons to image ones and change their position, but got some big error traceback at launch

Code: Select all

I'm sorry, but an uncaught exception occurred.
While running game code:
  File "game/story/prologue.rpy", line 9, in script
    """
  File "game/story/prologue.rpy", line 9, in script
    """
  File "renpy/common/000window.rpy", line 98, in _window_auto_callback
    _window_show()
  File "renpy/common/000window.rpy", line 60, in _window_show
    renpy.with_statement(trans)
  File "game/screens.rpy", line 243, in execute
    screen quick_menu():
  File "game/screens.rpy", line 243, in execute
    screen quick_menu():
  File "game/screens.rpy", line 248, in execute
    if quick_menu:
  File "game/screens.rpy", line 250, in execute
    hbox:
  File "game/screens.rpy", line 256, in execute
    imagebutton auto "gui/icons/Back.png" action Rollback()
  File "renpy/common/00defaults.rpy", line 139, in _imagemap_auto_function
    rv = auto_param % variant
TypeError: not all arguments converted during string formatting

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

Full traceback:
  File "C:\Apps\RenPy\renpy\bootstrap.py", line 316, in bootstrap
    renpy.main.main()
  File "C:\Apps\RenPy\renpy\main.py", line 578, in main
    run(restart)
  File "C:\Apps\RenPy\renpy\main.py", line 143, in run
    renpy.execution.run_context(True)
  File "C:\Apps\RenPy\renpy\execution.py", line 908, in run_context
    context.run()
  File "game/story/prologue.rpy", line 9, in script
    """
  File "game/story/prologue.rpy", line 9, in script
    """
  File "C:\Apps\RenPy\renpy\ast.py", line 671, in execute
    statement_name("say")
  File "C:\Apps\RenPy\renpy\ast.py", line 45, in statement_name
    i(name)
  File "renpy/common/000window.rpy", line 98, in _window_auto_callback
    _window_show()
  File "renpy/common/000window.rpy", line 60, in _window_show
    renpy.with_statement(trans)
  File "C:\Apps\RenPy\renpy\exports.py", line 1601, in with_statement
    return renpy.game.interface.do_with(trans, paired, clear=clear)
  File "C:\Apps\RenPy\renpy\display\core.py", line 2251, in do_with
    clear=clear)
  File "C:\Apps\RenPy\renpy\display\core.py", line 2702, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "C:\Apps\RenPy\renpy\display\core.py", line 3094, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Apps\RenPy\renpy\display\core.py", line 541, in visit_all
    d.visit_all(callback, seen)
  File "C:\Apps\RenPy\renpy\display\core.py", line 541, in visit_all
    d.visit_all(callback, seen)
  File "C:\Apps\RenPy\renpy\display\core.py", line 541, in visit_all
    d.visit_all(callback, seen)
  File "C:\Apps\RenPy\renpy\display\core.py", line 541, in visit_all
    d.visit_all(callback, seen)
  File "C:\Apps\RenPy\renpy\display\screen.py", line 430, in visit_all
    callback(self)
  File "C:\Apps\RenPy\renpy\display\core.py", line 3094, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Apps\RenPy\renpy\display\screen.py", line 440, in per_interact
    self.update()
  File "C:\Apps\RenPy\renpy\display\screen.py", line 625, in update
    self.screen.function(**self.scope)
  File "game/screens.rpy", line 243, in execute
    screen quick_menu():
  File "game/screens.rpy", line 243, in execute
    screen quick_menu():
  File "game/screens.rpy", line 248, in execute
    if quick_menu:
  File "game/screens.rpy", line 250, in execute
    hbox:
  File "game/screens.rpy", line 256, in execute
    imagebutton auto "gui/icons/Back.png" action Rollback()
  File "C:\Apps\RenPy\renpy\ui.py", line 946, in _imagebutton
    idle = choice(idle, idle_image, "idle", required=True)
  File "C:\Apps\RenPy\renpy\ui.py", line 934, in choice
    rv = renpy.config.imagemap_auto_function(auto, name)
  File "renpy/common/00defaults.rpy", line 139, in _imagemap_auto_function
    rv = auto_param % variant
TypeError: not all arguments converted during string formatting
Code fragment is:

Code: Select all

screen quick_menu():
    zorder 100

    if quick_menu:

        hbox:
            style_prefix "quick"

            xalign 0.7
            yalign 0.7

            imagebutton auto "gui/icons/Back.png" action Rollback()
            imagebutton auto "gui/icons/History.png"action ShowMenu('history')
            imagebutton auto "gui/icons/Skip.png" action Skip() alternate Skip(fast=True, confirm=True)
            imagebutton auto "gui/icons/Auto.png"action Preference("auto-forward", "toggle")
            imagebutton auto "gui/icons/Save.png" action QuickSave()
            imagebutton auto "gui/icons/Load.png" action QuickLoad()
            imagebutton auto "gui/icons/Options.png" action ShowMenu('preferences')
All icons exist and has corresponding names

What I did wrong? Please help.

User avatar
RicharDann
Veteran
Posts: 284
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: Changing quick menu textbuttons to imagebuttons

#2 Post by RicharDann » Fri Nov 06, 2020 9:08 am

You need to change the auto property to idle in every button.

Code: Select all

imagebutton idle "gui/icons/Back.png" action Rollback()
The error happened because Ren'Py expects that if you use auto, you must format the string and the images as explained here.
The most important step is always the next one.

Vytswell
Newbie
Posts: 14
Joined: Tue Oct 27, 2020 2:23 pm
Contact:

Re: Changing quick menu textbuttons to imagebuttons

#3 Post by Vytswell » Fri Nov 06, 2020 1:49 pm

Thanks, it worked

Post Reply

Who is online

Users browsing this forum: Bing [Bot]