-
-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Moving widgets vertically #230
Comments
Can you provide a complete example to test this issue? Maybe it can be an error ahaahah, At first glance I thought positions would be easy... but not when making a library |
1 similar comment
Hi, I found that you're using center_content=True, then widget_offset vertical position is "overridden". The following code works as intended: import os
import pygame
import pygame_menu
pygame.init()
os.environ['SDL_VIDEO_CENTERED'] = '1'
surface = pygame.display.set_mode((1000, 600))
def set_difficulty(selected, value):
"""
Set the difficulty of the game.
"""
print('Set difficulty to {} ({})'.format(selected[0], value))
def start_the_game():
"""
Function that starts a game. This is raised by the menu button,
here menu can be disabled, etc.
"""
print('Do the job here !')
theme = pygame_menu.themes.THEME_DARK.copy()
theme.widget_offset = (0, 300)
menu = pygame_menu.Menu(height=600,
width=1000,
theme=theme,
title='Welcome',
center_content=False)
menu.add_text_input('Name: ', default='John Doe')
menu.add_selector('Difficulty: ', [('Hard', 1), ('Easy', 2)], onchange=set_difficulty)
menu.add_button('Play', start_the_game)
menu.add_button('Quit', pygame_menu.events.EXIT)
if __name__ == '__main__':
menu.mainloop(surface) For avoiding this issue, if vertical offset is different than zero, and center_content is not False it will raise a warning |
From now on, this message is displayed using your example:
|
Thanks, it works now! :) |
Firstly I want to say, I love this module. ppizarror has even helped me via mail, he is a great guy.
Problem:
The widgets appear in the center of the screen and I want to move them up slightly. That doesn't work.
Firstly, I choose a theme and make a copy of it:
theme = pygame_menu.themes.THEME_DARK.copy()
Then I try to change the position of the widgets, using
theme.widget_offset
. This only works for the x axes, and only to the right side, because you can't enter negative values for the offset. Altering the second value oftheme.widget_offset
does nothing. It's supposed to move the widgets vertically, but that doesn't happen. Am I doing something wrong or is this bugged?The text was updated successfully, but these errors were encountered: