'Need help creating a GUI with Tkinter in python
I am trying to make a Pokedex using pokeapi, and to make that I need a GUI, i am trying to make it look something like this:

I don't really know how to add the "???" marks under the values of "name and "HP" so far my code looks like this:
from tkinter import *
from pokeapi import *
#create a new GUI window
window = Tk()
window.title("Pokedex")
#a label containing the instructions
lblInstructions = Label(window,text="Enter a number between 1 and 718:")
lblInstructions.pack()
#an 'entry' textbox for typing in the pokemon number
txtPokemonNo = Entry(window)
txtPokemonNo.pack()
#a button that will get the info for a pokemon
btnGetInfo = Button(window,text="Get Data!")
btnGetInfo.pack()
#labels for the pokemon name
lblNameText = Label(window,text="Name:")
lblNameText.pack()
lblNameValue = Label(window,text="???")
lblNameValue = Label(window,text="HP")
lblNameValue.pack()
window.mainloop()
I need to add the other values with the varibles (the question marks) can anyone help with that?
Solution 1:[1]
2 errors actually:
- You forgot to pack the label with
"???" - The
"???"label and HP name label have the same variable name. Code:
from tkinter import *
from pokeapi import *
#create a new GUI window
window = Tk()
window.title("Pokedex")
#a label containing the instructions
lblInstructions = Label(window,text="Enter a number between 1 and 718:")
lblInstructions.pack()
#an 'entry' textbox for typing in the pokemon number
txtPokemonNo = Entry(window)
txtPokemonNo.pack()
#a button that will get the info for a pokemon
btnGetInfo = Button(window,text="Get Data!")
btnGetInfo.pack()
#labels for the pokemon name
lblNameText = Label(window,text="Name:")
lblNameText.pack()
lblNameValue = Label(window,text="???")
lblNameValue.pack()
lblHPName = Label(window,text="HP")
lblHPName.pack()
lblHPValue = Label(window,text="0")
lblHPValue.pack()
# Continue like this
window.mainloop()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Anshumaan Mishra |
