-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f0c4d1
commit 00fa4df
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from tkinter import * | ||
|
||
def showresult(): | ||
print("Value of v is ",v.get()) | ||
|
||
root = Tk() | ||
v = IntVar() | ||
Label(root, text="Choose a programming language:",justify = LEFT, padx = 20).grid(row=1) | ||
Radiobutton(root, text="Python", padx = 20, variable=v, value=0).grid(row=2) | ||
Radiobutton(root, text="Perl", padx = 20, variable=v, value=1).grid(row=3) | ||
|
||
Button(root,text="Show Result",command=showresult).grid(row=4) | ||
root.mainloop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import tkinter as tk | ||
|
||
root = tk.Tk() | ||
|
||
v = tk.IntVar() | ||
v.set(1) # initializing the choice, i.e. Python | ||
|
||
languages = [ | ||
("Python",1), | ||
("Perl",2), | ||
("Java",3), | ||
("C++",4), | ||
("C",5) | ||
] | ||
|
||
def ShowChoice(): | ||
print(v.get()) | ||
|
||
tk.Label(root, | ||
text="""Choose your favourite | ||
programming language:""", | ||
justify = tk.LEFT, | ||
padx = 20).pack() | ||
|
||
for val, language in enumerate(languages): | ||
tk.Radiobutton(root, | ||
text=language, | ||
padx = 20, | ||
variable=v, | ||
command=ShowChoice, | ||
value=val).pack(anchor=tk.W) | ||
|
||
|
||
root.mainloop() |