Ren'Py Not seeing my menu buttons

Mescalino

Active Member
Aug 20, 2017
943
6,693
I am not seeing my menu buttons. Can anyone see what is wrong? Im not getting any errors but i have no idea whats wrong.

I tried playing with teh xpos and ypos but to avail.

Thanks.
 

Studio Errilhl

Member
Game Developer
Oct 16, 2017
315
237
would've been easier if you had just given the content of the image and such, so one could test, but first, I think you need the
Code:
focus_mask = True
on the imagebuttons? Don't quote me on that, though.
Also, you're adding an image in the main_menu() - have you tried removing that, to see if they show up then? It shouldn't matter, but might be worth a try.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,959
16,193
It's weird :/
If I take your main_menu screen and put in on a testing project (A), the buttons are seen.
If I take your whole screen.rpy file and put in on another testing project (B), the buttons are not seen.
If I take the first screen.rpy file (from A) and put in on the testing project B, the button are not seen.
If I take your whole screen.rpy file and put in on the testing project A, the buttons are seen.
Conclusion, it's not your screen, it's Ren'py default configuration. More precisely something in the gui.rpy file. But I past through a diff between the working one and the not working one, and didn't find what can lead to this problem.

I attached the gui.rpy file which work.
You'll have to change few things since it's not the one you worked with, starting with the screen size. But if you do it one line after the other, testing after every change, you'll find the problem and in the same time should have a working screen.
 

Mescalino

Active Member
Aug 20, 2017
943
6,693
Ok I got it working and i see what i did wrong.

I really messed up...
Now im using all dimensions (dont know why i messed with that) for 1920x1080 However All my renders are 1280x720. Now my screens are complete out of whack.

Is there a quick way to fix that?
 

Studio Errilhl

Member
Game Developer
Oct 16, 2017
315
237
There should only be one place to define the resolution in gui.rpy?
Code:
init python:
    gui.init(1920, 1080)
Have you tried changing only that to 1280,720?
 

Mescalino

Active Member
Aug 20, 2017
943
6,693
I did and then all my buttons are gone again.
I fear it may have to do with all the heights and sizes i also changed.

Example:
Code:
## Choice Buttons ##############################################################
##
## Choice buttons are used in the in-game menus.

define gui.choice_button_width = 1185
define gui.choice_button_height = None
define gui.choice_button_tile = False
define gui.choice_button_borders = Borders(150, 8, 150, 8)
define gui.choice_button_text_font = gui.default_font
define gui.choice_button_text_size = gui.text_size
define gui.choice_button_text_xalign = 0.5
define gui.choice_button_text_idle_color = "#cccccc"
define gui.choice_button_text_hover_color = "#ffffff"
And to make matters work i have no backup. So i have to fix this or start completely over.
 

Studio Errilhl

Member
Game Developer
Oct 16, 2017
315
237
Uhm... your borders, and the width of the buttons exceed the width of your viewport... At least I think they do... I don't remember the sequence right now. Let me test something. Yep - they go Left, Up, Right, Down. So what you have there is 1185+150+150 for the choice menu - that will quickly exceed the width you have available...
 

Mescalino

Active Member
Aug 20, 2017
943
6,693
I was fearing that, now that i know where the issue lies.

That was just one of the many examples...
Sigh.... Guess i wil have no other choice then to "hack" some other VN and redo all these settings.
(Probably on both the gui.rpy and screens.rpy)
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,959
16,193
Uhm... your borders, and the width of the buttons exceed the width of your viewport...
Stop, what did you just said ? I really need to find some times to sleep, I miss the obvious :(
And I was wrong, it's really the screen which are in cause :
Code:
    imagebutton auto "gui/new_%s.png" xpos 117 ypos 880 action Start()
"ypos 880" !!!

It's outside of the viewport 1280x780 default viewport. The buttons are rendered, but on a part of the screen which is never displayed.
That's why I couldn't saw them on my own project (all sized by default), but was able to with the project I work on for someone else (sized for 1920x1080).

Want to know the worse ? When it worked I had it right in front of my eyes. The background on the top left of the screen, and the buttons on the transparent zone outside of the background. But no, it just past unnoticed through my mind :(
 
  • Like
Reactions: Studio Errilhl

Mescalino

Active Member
Aug 20, 2017
943
6,693
ok then.... I missed that as well.

I guess then :
Code:
screen navigation():
    imagebutton auto "gui/back_%s.png" xpos 925 ypos 925 action Return()
    imagebutton auto "gui/load_%s.png" xpos 150 ypos 150 action ShowMenu("load")
    imagebutton auto "gui/pref_%s.png" xpos 350 ypos 150 action ShowMenu("preferences")
    imagebutton auto "gui/help_%s.png" xpos 550 ypos 550 action Help()
    imagebutton auto "gui/patr_%s.png" xpos 750 ypos 150 action OpenURL("https://www.patreon.com/")
is not the first menu i should see as 3 out 5 should be within range. So this one:
Code:
screen main_menu():

    ## This ensures that any other menu screen is replaced.
    tag menu

    style_prefix "main_menu"

    add "gui/main_menu.png"

    imagebutton auto "gui/new_%s.png" xpos 117 ypos 880 action Start()
    imagebutton auto "gui/load_%s.png" xpos 317 ypos 880 action ShowMenu("load")
    imagebutton auto "gui/pref_%s.png" xpos 507 ypos 880 action ShowMenu("preferences")
    imagebutton auto "gui/help_%s.png" xpos 1500 ypos 880 action Help()
    imagebutton auto "gui/quit_%s.png" xpos 1700 ypos 880 action Quit(confirm=True)
    imagebutton auto "gui/cred_%s.png" xpos 1300 ypos 900 action ShowMenu("about")
    imagebutton auto "gui/patr_%s.png" xpos 1700 ypos 50 action OpenURL("https://www.patreon.com/")
That one should be the Main menu... Just like it says.....

Guess i need some sleep as well...

Anyways at least i now know where to look. Just need to look at all the other settings in screens.rpy as well and probably redo gui settings as well.

I wonder if i made a new temp project i can copy those dimensions....

To be continued.....
(oh and thanks for all the help)
 
  • Like
Reactions: Studio Errilhl

Mescalino

Active Member
Aug 20, 2017
943
6,693
Ok i did some tinkering but now im getting an error:
Code:
I'm sorry, but an uncaught exception occurred.

After initialization, but before game start.
  File "renpy/common/00start.rpy", line 76, in _init_language
    renpy.change_language(language)
  File "game/screens.rpy", line 154, in <module>
    xpos gui.dialogue_xpos
AttributeError: 'StoreModule' object has no attribute 'dialogue_xpos'

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

Full traceback:
  File "H:\renpy-6.99.12.4-sdk\renpy\bootstrap.py", line 295, in bootstrap
    renpy.main.main()
  File "H:\renpy-6.99.12.4-sdk\renpy\main.py", line 487, in main
    run(restart)
  File "H:\renpy-6.99.12.4-sdk\renpy\main.py", line 69, in run
    renpy.translation.init_translation()
  File "H:\renpy-6.99.12.4-sdk\renpy\translation\__init__.py", line 506, in init_translation
    renpy.store._init_language()  # @UndefinedVariable
  File "renpy/common/00start.rpy", line 76, in _init_language
    renpy.change_language(language)
  File "H:\renpy-6.99.12.4-sdk\renpy\translation\__init__.py", line 583, in change_language
    new_change_language(tl, language)
  File "H:\renpy-6.99.12.4-sdk\renpy\translation\__init__.py", line 553, in new_change_language
    i.apply()
  File "H:\renpy-6.99.12.4-sdk\renpy\ast.py", line 2224, in apply
    value = renpy.python.py_eval(expr)
  File "H:\renpy-6.99.12.4-sdk\renpy\python.py", line 1749, in py_eval
    return py_eval_bytecode(code, globals, locals)
  File "H:\renpy-6.99.12.4-sdk\renpy\python.py", line 1743, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "game/screens.rpy", line 154, in <module>
    xpos gui.dialogue_xpos
AttributeError: 'StoreModule' object has no attribute 'dialogue_xpos'

Windows-7-6.1.7601-SP1
Ren'Py 6.99.12.4.2187
The Unconventional Love Triangle 0.1
Any assistance, i can not find where and how i should place this attribute.
 

Abi

Newbie
Aug 6, 2017
59
103
Ok i did some tinkering but now im getting an error:
Code:
I'm sorry, but an uncaught exception occurred.

After initialization, but before game start.
  File "renpy/common/00start.rpy", line 76, in _init_language
    renpy.change_language(language)
  File "game/screens.rpy", line 154, in <module>
    xpos gui.dialogue_xpos
AttributeError: 'StoreModule' object has no attribute 'dialogue_xpos'

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

Full traceback:
  File "H:\renpy-6.99.12.4-sdk\renpy\bootstrap.py", line 295, in bootstrap
    renpy.main.main()
  File "H:\renpy-6.99.12.4-sdk\renpy\main.py", line 487, in main
    run(restart)
  File "H:\renpy-6.99.12.4-sdk\renpy\main.py", line 69, in run
    renpy.translation.init_translation()
  File "H:\renpy-6.99.12.4-sdk\renpy\translation\__init__.py", line 506, in init_translation
    renpy.store._init_language()  # @UndefinedVariable
  File "renpy/common/00start.rpy", line 76, in _init_language
    renpy.change_language(language)
  File "H:\renpy-6.99.12.4-sdk\renpy\translation\__init__.py", line 583, in change_language
    new_change_language(tl, language)
  File "H:\renpy-6.99.12.4-sdk\renpy\translation\__init__.py", line 553, in new_change_language
    i.apply()
  File "H:\renpy-6.99.12.4-sdk\renpy\ast.py", line 2224, in apply
    value = renpy.python.py_eval(expr)
  File "H:\renpy-6.99.12.4-sdk\renpy\python.py", line 1749, in py_eval
    return py_eval_bytecode(code, globals, locals)
  File "H:\renpy-6.99.12.4-sdk\renpy\python.py", line 1743, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "game/screens.rpy", line 154, in <module>
    xpos gui.dialogue_xpos
AttributeError: 'StoreModule' object has no attribute 'dialogue_xpos'

Windows-7-6.1.7601-SP1
Ren'Py 6.99.12.4.2187
The Unconventional Love Triangle 0.1
Any assistance, i can not find where and how i should place this attribute.
The variables gui.dialogue_xpos and gui.dialogue_ypos are usually defined in gui.rpy. Look fot a larger section called "Dialogue".
If this doesn't help please attach file "errors.txt" - the "traceback.txt" file is sometimes misleading.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,959
16,193
Ok i did some tinkering but now im getting an error:
Yeah, there's few changes and now you are missing four variables added to the gui. I give them to you, with there default value :
Code:
define gui.dialogue_xpos = 560
define gui.dialogue_ypos = 905

## The maximum width of dialogue text, in pixels.
define gui.dialogue_width = 650

## The horizontal alignment of the dialogue text. This can be 0.0 for left-
## aligned, 0.5 for centered, and 1.0 for right-aligned.
define gui.dialogue_text_xalign = 0.0

If this doesn't help please attach file "errors.txt" - the "traceback.txt" file is sometimes misleading.
You either have one or the other, but neither both for the same error. "errors.txt" is filed with the errors at parsing time, while "traceback.txt" is filled with the traceback generated by an unexpected exception at run time.
But I agree, the traceback can be misleading.
 

Abi

Newbie
Aug 6, 2017
59
103
Yeah, there's few changes and now you are missing four variables added to the gui. I give them to you, with there default value :
Code:
define gui.dialogue_xpos = 560
define gui.dialogue_ypos = 905

## The maximum width of dialogue text, in pixels.
define gui.dialogue_width = 650

## The horizontal alignment of the dialogue text. This can be 0.0 for left-
## aligned, 0.5 for centered, and 1.0 for right-aligned.
define gui.dialogue_text_xalign = 0.0



You either have one or the other, but neither both for the same error. "errors.txt" is filed with the errors at parsing time, while "traceback.txt" is filled with the traceback generated by an unexpected exception at run time.
But I agree, the traceback can be misleading.

In theory this is totally correct. But actually it is pretty simple to create errors (especially in the pre-game-start phase) which lead to "traceback.txt" AND to "errors.txt". If you don't believe this just send me a private message and i give you an example.

The original problem should be solved anyway.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,959
16,193
In theory this is totally correct. But actually it is pretty simple to create errors (especially in the pre-game-start phase) which lead to "traceback.txt" AND to "errors.txt". If you don't believe this just send me a private message and i give you an example.
You piqued my curiosity.
There only three places where report_parse_errors is coupled with an exception and so where it can happen ; and it's the only place where "errors.txt" should be used. One is will cleaning back after loading the "persistent" file, and the two other are at parsing time if Ren'py encounter a duplicated label (will not log on "errors.txt" with all version) and when Ren'py fail to load one of it's own module (rpym/rpymc).
If there's another way to trigger the double logging, it's more a bug than anything else. So yes, I'm curious now.
 

Mescalino

Active Member
Aug 20, 2017
943
6,693
Thanks Anne, i Will try this later at home. Yes this is the first setups for the gui. With the exception of about 10-20 renders the story of chapter 1 is done and also wording on chapter 2. However i thought it would be best to start it right from the beginnen. It May take more time but should pay out in the long run. When the base gui is ok i can teak it. So far thanks.

EDIT: It worked. My define was named differently. Been copying stuff so need ot be more carefull next time.
 
Last edited:

Cyan

Member
Jul 25, 2017
126
551
Is there not a way to setup anchor points in ren'py? All those hardcoded pixel widths/heights aren't appealing to me.

And if there is a way to make them, why aren't they used more frequently?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,959
16,193
Is there not a way to setup anchor points in ren'py? All those hardcoded pixel widths/heights aren't appealing to me.

And if there is a way to make them, why aren't they used more frequently?
Because it work like CSS with way less possibilities (and probably a weaker box model). You can align at x% of the vertical or horizontal available space, and that's all. Everything else ask for a fixed number of pixels. Like in the same time the notion of "available" space depend of what's inside the widget/box (like CSS), you reach a dead end most of the time.
You want to put three buttons on a frame, one on the left, one on the middle and the last one on the right. If you do it with just :
Code:
 frame:
   button1 xalign 0.0
   button2 xalign 0.5
   button3 xalign 1.0
The frame will have a size of : width button1 + width button2 + width button3. So, using "xalign" or not will change nothing.
If you add a "xfill True" to the frame, it will take all the available horizontal space, and most of the time you'll have hard time if you want to put something on the right of this frame.
Therefore, in the end you'll have to use "xsize", "xmaximum" or "xminimum" which need a value in pixel. And because you already needed to switch to fixed value for the size of the widget/box, why start bothering with percent to position something inside it ?

This said, if fixed values are a problem with CSS (because of the different size of screen), they aren't at all with Ren'py. For Ren'py, the notion of "pixel" is in fact fluctuating. Basically it work like this :
1) create a virtual screen of the size asked by the author with gui.init()
2) Put everything at the exact position asked.
3) Reduce (or increase) this virtual screen to the size of the effective screen inside which the game is actually rendered.
4) Display this reduced (or increased) screen.

So whatever you use percent or fixed values, the result will be the same visually and it will not overflow out of the screen.
 
  • Like
Reactions: Cyan

Mescalino

Active Member
Aug 20, 2017
943
6,693
Renpy is a nice engine that is very configurable but not very user friendly.

The only other method i know to position things is with vbox but even there you workshop with pixels