This is A personal project that i get an error on


#1



when i run the program it reads the label and the first button but not button 2{button2 = Button(app)
button2.grid()
button2.configure(" This is Button 2")}
Or past
It runs perfect no errors when i take it out

I expect it to read all the buttons and behave properly


from tkinter import *

root = Tk()

root.title('Simple Gui')
root.geometry('450x450')

app = Frame(root)
app.grid()

label = Label(app, text = " Label, mainly used for a title")
label.grid()

button1 = Button(app, text="Simple play Button")
button1.grid()


button2 = Button(app)
button2.grid()
button2.configure(" This is Button 2")

button3 = Button(app)
button3.grid()

button3["text"] = "This is a set text"

button4 = Button(app, text="CLOSE GAME; Button 4")
button4.grid()

root.mainloop()


#2

Still can't figure it out


#3

i can't run the code, it gives an error for this line:

button2.configure(" This is Button 2")

looking in the documentation (url), i can't find configure. Are you sure configure is right?


#4

No im somewhat new to python its using tkinter library just trying all the ways of making a button with it


#5

i know, the documentation i linked to is tkinter, i recognized the library, but i couldn't find anything about .configure related to tkinter.


#6

What would it be then im still new to python and tkinter btw


#7

config maybe?

http://effbot.org/tkinterbook/button.htm#Tkinter.Button.config-method


#8

At this point i just want text to appear i replaced the button 2 section with

button2 = Button(app)
button2.text =("This is Button 2")
button2.grid()

i get no errors but no text shows up


#9

why not combine it?

button2 = Button(app,text="This is button 2")

i think otherwise you need:

button2.text ("This is Button 2")

without equal sign. I am currently not on my own computer, so i can't test it


#10

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.