[.PY - TKINTER] Mini guessing game using an interface
Thu Oct 05, 2017 3:05 pm
- Code:
from tkinter import *
class MyApp(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.pergunta = Label(self, text='Brazil was discovered in:', fg='red')
self.pergunta.pack()
self.botao1 = Button(self, text='A:\n1490', background='green',
command=self.escolhaA)
self.botao1.pack()
self.botao2 = Button(self, text='B:\n1628', background='yellow',
command=self.escolhaB)
self.botao2.pack()
self.botao3 = Button(self, text='C:\n1500', background='black',
fg='white', command=self.escolhaC)
self.botao3.pack()
self.pack()
def escolhaA(self):
print('Wrong dude !\n:(')
def escolhaB(self):
print('Wrong dude !\n:(')
def escolhaC(self):
print('Right !!!\n:D')
app = MyApp()
app.master.title('Guessing Game')
app.master.geometry('400x400+300+300')
mainloop()
*** Remember that you dont need to use "background", if you like simple and short things, just replace it for "bg".
And "fg" stands for the color of the font used.
- Joao:
- Posts : 12
Points : 2393
Reputation : 4
Join date : 2017-10-03
Re: [.PY - TKINTER] Mini guessing game using an interface
Thu Oct 05, 2017 3:36 pm
Renan Araújo wrote:
- Code:
from tkinter import *
class MyApp(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.pergunta = Label(self, text='Brazil was discovered in:', fg='red')
self.pergunta.pack()
self.botao1 = Button(self, text='A:\n1490', background='green',
command=self.escolhaA)
self.botao1.pack()
self.botao2 = Button(self, text='B:\n1628', background='yellow',
command=self.escolhaB)
self.botao2.pack()
self.botao3 = Button(self, text='C:\n1500', background='black',
fg='white', command=self.escolhaC)
self.botao3.pack()
self.pack()
def escolhaA(self):
print('Wrong dude !\n:(')
def escolhaB(self):
print('Wrong dude !\n:(')
def escolhaC(self):
print('Right !!!\n:D')
app = MyApp()
app.master.title('Guessing Game')
app.master.geometry('400x400+300+300')
mainloop()
*** Remember that you dont need to use "background", if you like simple and short things, just replace it for "bg".
And "fg" stands for the color of the font used.
and if i want to delete one button, for example, the right is C, but when user click on A or B, what i have to do ?
Re: [.PY - TKINTER] Mini guessing game using an interface
Thu Oct 05, 2017 3:38 pm
for example:
- Code:
self.botao2 = Button(self, text='B:\n1628', background='yellow',
command=self.escolhaB)
- Code:
self.botao2.destroy()
- Joao:
- Posts : 12
Points : 2393
Reputation : 4
Join date : 2017-10-03
Re: [.PY - TKINTER] Mini guessing game using an interface
Thu Oct 05, 2017 3:40 pm
what about using another interface module ? do you know any thats easier ?
Re: [.PY - TKINTER] Mini guessing game using an interface
Thu Oct 05, 2017 3:43 pm
Joao wrote:what about using another interface module ? do you know any thats easier ?
For me, TKinter is the coolest and the best to use, and it would be more welcomed as you are learning to code interfaces.
Take a look at python docs about TK, i'm sure you'll like it.
- Joao:
- Posts : 12
Points : 2393
Reputation : 4
Join date : 2017-10-03
Re: [.PY - TKINTER] Mini guessing game using an interface
Thu Oct 05, 2017 3:47 pm
Renan Araújo wrote:Joao wrote:what about using another interface module ? do you know any thats easier ?
For me, TKinter is the coolest and the best to use, and it would be more welcomed as you are learning to code interfaces.
Take a look at python docs about TK, i'm sure you'll like it.
So i'll take a look, and after i get in touch
Permissions in this forum:
You cannot reply to topics in this forum
|
|