I am trying to make my own gui with Python. I am using Tkinter and eventhough I made the buttons show text, the text won´t show up.
import classes
root = Tk()
root.geometry('395x400')
e = Entry(root, width=60, borderwidth=5)
e.grid(row=0, column=0, columnspan=3, padx=10, pady=10)
#buttons
button_add_student=Button(root, name="add student", padx=90, pady=20, command=)
button_show_student=Button(root, name="enter", padx=90, pady=20, )
button_add_student.grid(row=1, column=0)
button_show_student.grid(row=1, column=1)
root.mainloop() ```
They don't show text but you haven't given them any text to show. If you want a button to have a textual label then you need to provide a value to the text
attribute:
button_add_student=Button(root, text="add student", ...)
button_show_student=Button(root, text="enter", ...)
You were using the name
attribute, which specifies the internal name for the widget. The name is only visible if you print out the string representation of the widget (eg: print(str(button_add_student))
).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.