D
D
Dmitry Kovalev2019-12-29 13:12:01
Python
Dmitry Kovalev, 2019-12-29 13:12:01

Why is the button not visible?

There is a code that launches the "Menu" class, it also contains an array with buttons, their location, color, etc.

one

buttons = [
    (120, 140, u'Play', (250,250,30), (250,30,250), 0),
    (130, 210, u'Quit', (250,250,30), (250,30,250), 1)]
game = Menu(buttons )
game.menu()


The menu class itself (did not add click processing here, I think this does not affect my problem in any way):
Class Menu

class Menu:
    def __init__(self, buttons = [res_x, rex_y, u'Button', (0,128,128), (1,333,123)]):
        self.buttons = buttons
    def render(self, powerhnost, font, numButton):
        for i in self.buttons:
            if numButton == i[5]: 
                powerhnost.blit(font.render(i[2], 1, i[4]), (i[0], i[1]))
            else:
                powerhnost.blit(font.render(i[2], 1, i[3]), (i[0], i[1]))
    def menu(self):
        done = True
        font_menu = font.Font('fonts/asinastra.otf', 33)
        button = 0


(I apologize in advance for being Hindu, I resorted to watching videos, I myself can’t yet - I don’t have enough knowledge)
The problem is that everything works at startup (no errors are displayed in VScode), but the buttons themselves are not displayed, although wrote everything right. What is the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2019-12-29
@RivalCode

The render method, which apparently should display the buttons, is not called anywhere.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question