-
Notifications
You must be signed in to change notification settings - Fork 0
/
radioButton.py
33 lines (24 loc) · 1.02 KB
/
radioButton.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from tkinter import *
class Tela:
def __init__(self):
self.janela = Tk()
self.valor = StringVar()
self.rb1 = Radiobutton(self.janela, text='Python', variable=self.valor, value='Python', command=self.mostrar)
self.rb1.pack()
self.rb1.select()
self.rb2 = Radiobutton(self.janela, text='Java', variable=self.valor, value='Java', command=self.mostrar)
self.rb2.pack()
self.rb3 = Radiobutton(self.janela, text='C++', variable=self.valor, value='C++', command=self.mostrar)
self.rb3.pack()
self.saida = Label(self.janela)
self.saida.pack()
mainloop()
def mostrar(self):
escolha = self.valor.get()
if escolha == 'Python':
self.saida['text'] = "print('Olá, mundo')"
elif escolha == 'Java':
self.saida['text'] = "System.out.println('Olá, mundo')"
else:
self.saida['text'] = "std::cout << 'Olá, mundo' << std::end|"
minhaTela = Tela()