Python Forum
I think this is a problem with returning? maby?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I think this is a problem with returning? maby?
#1
import Button
import Menues
import pygame
import sys
from pygame.locals import *
x = 0
y = 30
import os
os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (x,y)

pygame.font.init()

pygame.init()
infoObject = pygame.display.Info()
correctedscreenheight= (infoObject.current_h - 30)
screen = pygame.display.set_mode((infoObject.current_w, correctedscreenheight))
screenxsize = infoObject.current_w
screenysize = infoObject.current_h
pygame.display.set_caption('Dnd reimagined')
mainscreen = pygame.image.load("dnd.png").convert()
WHITE = (25 , 25, 25)
fuckoff = Button.button()
buttoncolorinner = (200, 200, 200)
buttoncolorouter = (50, 50, 50)
bxp = (infoObject.current_w / 2)
byp = (correctedscreenheight / 2)
startbuttonstuff = Menues


def keyhandler():
    mpos = pygame.mouse.get_pos()
    clicky = pygame.mouse.get_pos()
    pressed = pygame.mouse.get_pressed()
    startthings = startbuttonstuff.Menues.startmenue
    bxp = startthings[0]
    byp = startthings[1]
    bxw = startthings[2]
    byw = startthings{3}

    otherxcornerofbutton = bxp + bxw
    otherycornerofbutton = byp + byw

    if pressed[0] == 1 and bxp < clicky[0] < otherxcornerofbutton and byp < clicky[1] < otherycornerofbutton:
        buttoncolorinner = (50, 50, 50)
        buttoncolorouter = (200, 200, 200)
        startbuttonstuff.Menues.startmenue()
    else:
        buttoncolorinner = (200, 200, 200)
        buttoncolorouter = (50, 50, 50)
        startbuttonstuff.Menues.startmenue()

    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.display.quit()
            pygame.quit()
        if event.type == pygame.MOUSEBUTTONDOWN:
            if event.button == 1:

                if bxp < mpos[0] < otherxcornerofbutton and byp < mpos[1] < (otherycornerofbutton):
                    fuckoff.click()






while True:

    mainscreen = pygame.transform.scale(mainscreen, (infoObject.current_w, infoObject.current_h))



    screen.blit(mainscreen, (0, 0))

    keyhandler()



    pygame.display.update()
class Menues:

    def __call__(self):
        a=1

    def __init__(self):
        a=1

    def charactormenue(self):

        a=1

    def startmenue(screenxsize, screenysize, bxp, byp)
:

        bxw = 200
        byw = 150
        bxp = bxp - (bxw // 2)
        byp = byp - byw // 2)
        textforbutton = ("Start")
        return bxp, byp, bxw, byw, textforbutton
import pygame


class button:
    def __init__(self):
        a=1



    def __call__(self):
        a=1


    def draw(self, screen, buttoncolorinner, buttoncolorouter, bxp, byp, bxw, byw, textforbutton):
        innerbuttonxpos = bxp + ((bxw * .1)//2)
        innerbuttonoutlinewidth = bxw * .9
        innerbuttonypos = byp + ((byw * .1)//2)
        innerbuttonoutlineheight =  byw * .9
        textsize = bxw * .3
        textsize = int(textsize)

        maintext = pygame.font.SysFont('Comic Sans MS', textsize)
        buttontext = maintext.render(textforbutton, False, (0, 0, 0))

        pygame.draw.rect(screen, buttoncolorouter, (bxp, byp, bxw, byw))

        pygame.draw.rect(screen, buttoncolorinner, (innerbuttonxpos, innerbuttonypos, innerbuttonoutlinewidth, innerbuttonoutlineheight))
        screen.blit(buttontext, ((innerbuttonxpos + 10), (innerbuttonypos + 10)))
        return

    def click(self):
        a=1
errors:
pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "C:/Users/Blue/Desktop/CompDnd/Main.py", line 75, in <module>
keyhandler()
File "C:/Users/Blue/Desktop/CompDnd/Main.py", line 35, in keyhandler
bxp = startthings[0]
TypeError: 'function' object is not subscriptable

Process finished with exit code 1




I think maby there is something wrong with getting the values from the class startmenue, but i am lost. help would be greatly appreciated. Thanks!
Reply


Messages In This Thread
I think this is a problem with returning? maby? - by TheNumericDolfin - Aug-16-2018, 10:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem returning values Naito 7 3,981 Jan-19-2019, 08:21 PM
Last Post: Naito

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020