0

When trying to use the .config() method to change the font size of the 'button1' attribute of the 'studentmainmenuscreen' object I got this error: Error

I can't figure out why this error is occurring! Please help me?!

class standardclass: #creates the class called 'standardclass'
    def __init__(self, labeltext, b1t, b1c, b2t, b2c, tlxc, b1x, b1y, b2x, b2y): #creates the initalization subroutine and passes the parameters in the bracket
        self.canvas = Canvas(root, width=600, height=600, highlightthickness=0,  bg='#A9E2f3') #creates the canvas attribute
        self.canvas.pack()  #packs the canvas inside of the root window
        self.titlelabel = Label(self.canvas, text=labeltext, font=('Arial', 30), bg='#A9E2f3').place(x=tlxc,y=20) #creates the title label attribute
        self.button1 = Button(self.canvas, text=b1t, command=b1c, font=('Arial', 30), relief='flat').place(x=b1x,y=b1y) #creates the bottom left button attribute
        self.button2 = Button(self.canvas, text=b2t, command=b2c, font=('Arial', 30), relief='flat').place(x=b2x,y=b2y) #creates the bottom right button attribute

studentmainmenuscreen = standardclass('Main Menu', 'Maths Tests', temporarysubroutine, 'Logout', temporarysubroutine, 225, 200, 300, 200, 400)
studentmainmenuscreen.button1.config(font=('Arial', 20))
studentmainmenuscreen.button1.update()
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574

1 Answers1

1

You're changing the type of object in line:

self.button1 = Button(self.canvas, text=b1t, command=b1c, font=('Arial', 30), relief='flat').place(x=b1x,y=b1y)

For both buttons.

You can create the button first, then call the place() methods:

self.button1 = Button(params)
self.button2 = Button(params)
self.button1.place(params)
self.button2.place(params)

Here is a good article to refer to.

GKE
  • 960
  • 8
  • 21