I don't know why my python GUI code name program doesn't work
up vote
0
down vote
favorite
I'm a college student who's trying to learn python as we speak. I'm very new and cannot successfully run this program that allows the user to create a code name using a GUI that collects information such as the user's gender, their name, and last name. I'm struggling to make the codename function work and integrate it into my "Show" button.
If anyone has a few minutes to spare and wants to look at my code, I'd appreciate it immensely. Again, I'm sorry if I'm really new/bad at this, but I'm trying to learn.
Cheers!
from tkinter import *
class CodeNameProgram:
def __init__(self):
window = Tk()
window.title("Code Name Generator")
genderOption = StringVar()
Label(window, text="First Name").grid(row=0)
Label(window, text="Last Name").grid(row=1)
R1 = Radiobutton(window, text="Male", value="male", var=genderOption).grid(row=2,column=0, sticky=E)
R2 = Radiobutton(window, text="Female", value="female", var=genderOption).grid(row=2,column=1)
e1 = Entry(window).grid(row=0, column=1)
e2 = Entry(window).grid(row=1, column=1)
Button(window, text='Quit', command=window.quit).grid(row=3, column=0, sticky=E, pady=4)
Button(window, text='Show',command=codename).grid(row=3, column=1, pady=4)
def codename(self):
e1 = s1[:1]
if e == "a":
firstcodename = "Spring"
elif e == "b":
firstcodename = "Spring"
elif e == "c":
firstcodename = "Spring"
elif e == "d":
firstcodename = "Spring"
elif e == "e":
firstcodename = "Spring"
elif e == "f":
firstcodename = "Spring"
elif e == "g":
firstcodename = "Summer"
elif e == "h":
firstcodename = "Summer"
elif e == "i":
firstcodename = "Summer"
elif e == "j":
firstcodename = "Summer"
elif e == "k":
firstcodename = "Summer"
elif e == "l":
firstcodename = "Summer"
elif e == "m":
firstcodename = "Summer"
elif e == "n":
firstcodename = "Autumn"
elif e == "o":
firstcodename = "Autumn"
elif e == "p":
firstcodename = "Autumn"
elif e == "q":
firstcodename = "Autumn"
elif e == "r":
firstcodename = "Autumn"
else:
firstcodename = "Winter"
e2= s2[:1]
if e == "a":
lastcodename = "Thunder"
elif e == "b":
lastcodename = "Thunder"
elif e == "c":
lastcodename = "Thunder"
elif e == "d":
lastcodename = "Thunder"
elif e == "e":
lastcodename = "Thunder"
elif e == "f":
lastcodename = "Thunder"
elif e == "g":
lastcodename = "Shadow"
elif e == "h":
lastcodename = "Shadow"
elif e == "i":
lastcodename = "Shadow"
elif e == "j":
lastcodename = "Shadow"
elif e == "k":
lastcodename = "Shadow"
elif e == "l":
lastcodename = "Shadow"
elif e == "m":
lastcodename = "Shadow"
elif e == "n":
lastcodename = "Flash"
elif e == "o":
lastcodename = "Flash"
elif e == "p":
lastcodename = "Flash"
elif e == "q":
lastcodename = "Flash"
elif e == "r":
lastcodename = "Flash"
else:
lastcodename = "Terminator"
genderOption = gender
if genderOption == "male":
gender = "Mr. "
else:
gender = "Mrs. "
print(get.gender)
print(get.firstcodename)
print(get.lastcodename)
CodeNameProgram()
python user-interface tkinter radio-button
add a comment |
up vote
0
down vote
favorite
I'm a college student who's trying to learn python as we speak. I'm very new and cannot successfully run this program that allows the user to create a code name using a GUI that collects information such as the user's gender, their name, and last name. I'm struggling to make the codename function work and integrate it into my "Show" button.
If anyone has a few minutes to spare and wants to look at my code, I'd appreciate it immensely. Again, I'm sorry if I'm really new/bad at this, but I'm trying to learn.
Cheers!
from tkinter import *
class CodeNameProgram:
def __init__(self):
window = Tk()
window.title("Code Name Generator")
genderOption = StringVar()
Label(window, text="First Name").grid(row=0)
Label(window, text="Last Name").grid(row=1)
R1 = Radiobutton(window, text="Male", value="male", var=genderOption).grid(row=2,column=0, sticky=E)
R2 = Radiobutton(window, text="Female", value="female", var=genderOption).grid(row=2,column=1)
e1 = Entry(window).grid(row=0, column=1)
e2 = Entry(window).grid(row=1, column=1)
Button(window, text='Quit', command=window.quit).grid(row=3, column=0, sticky=E, pady=4)
Button(window, text='Show',command=codename).grid(row=3, column=1, pady=4)
def codename(self):
e1 = s1[:1]
if e == "a":
firstcodename = "Spring"
elif e == "b":
firstcodename = "Spring"
elif e == "c":
firstcodename = "Spring"
elif e == "d":
firstcodename = "Spring"
elif e == "e":
firstcodename = "Spring"
elif e == "f":
firstcodename = "Spring"
elif e == "g":
firstcodename = "Summer"
elif e == "h":
firstcodename = "Summer"
elif e == "i":
firstcodename = "Summer"
elif e == "j":
firstcodename = "Summer"
elif e == "k":
firstcodename = "Summer"
elif e == "l":
firstcodename = "Summer"
elif e == "m":
firstcodename = "Summer"
elif e == "n":
firstcodename = "Autumn"
elif e == "o":
firstcodename = "Autumn"
elif e == "p":
firstcodename = "Autumn"
elif e == "q":
firstcodename = "Autumn"
elif e == "r":
firstcodename = "Autumn"
else:
firstcodename = "Winter"
e2= s2[:1]
if e == "a":
lastcodename = "Thunder"
elif e == "b":
lastcodename = "Thunder"
elif e == "c":
lastcodename = "Thunder"
elif e == "d":
lastcodename = "Thunder"
elif e == "e":
lastcodename = "Thunder"
elif e == "f":
lastcodename = "Thunder"
elif e == "g":
lastcodename = "Shadow"
elif e == "h":
lastcodename = "Shadow"
elif e == "i":
lastcodename = "Shadow"
elif e == "j":
lastcodename = "Shadow"
elif e == "k":
lastcodename = "Shadow"
elif e == "l":
lastcodename = "Shadow"
elif e == "m":
lastcodename = "Shadow"
elif e == "n":
lastcodename = "Flash"
elif e == "o":
lastcodename = "Flash"
elif e == "p":
lastcodename = "Flash"
elif e == "q":
lastcodename = "Flash"
elif e == "r":
lastcodename = "Flash"
else:
lastcodename = "Terminator"
genderOption = gender
if genderOption == "male":
gender = "Mr. "
else:
gender = "Mrs. "
print(get.gender)
print(get.firstcodename)
print(get.lastcodename)
CodeNameProgram()
python user-interface tkinter radio-button
Welcome to SO, please note that '. I'm struggling to make the codename function work' is not a specific enough question for this site. Try to describe your problem more accurately. If you get an error, include the complete traceback in your message. If you don't get the expected output, include the output you get vs the expected one. As a side note: you could rewrite your conditionsif 'a' <= e <= 'f':
...
– Thierry Lathuille
Nov 11 at 17:46
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm a college student who's trying to learn python as we speak. I'm very new and cannot successfully run this program that allows the user to create a code name using a GUI that collects information such as the user's gender, their name, and last name. I'm struggling to make the codename function work and integrate it into my "Show" button.
If anyone has a few minutes to spare and wants to look at my code, I'd appreciate it immensely. Again, I'm sorry if I'm really new/bad at this, but I'm trying to learn.
Cheers!
from tkinter import *
class CodeNameProgram:
def __init__(self):
window = Tk()
window.title("Code Name Generator")
genderOption = StringVar()
Label(window, text="First Name").grid(row=0)
Label(window, text="Last Name").grid(row=1)
R1 = Radiobutton(window, text="Male", value="male", var=genderOption).grid(row=2,column=0, sticky=E)
R2 = Radiobutton(window, text="Female", value="female", var=genderOption).grid(row=2,column=1)
e1 = Entry(window).grid(row=0, column=1)
e2 = Entry(window).grid(row=1, column=1)
Button(window, text='Quit', command=window.quit).grid(row=3, column=0, sticky=E, pady=4)
Button(window, text='Show',command=codename).grid(row=3, column=1, pady=4)
def codename(self):
e1 = s1[:1]
if e == "a":
firstcodename = "Spring"
elif e == "b":
firstcodename = "Spring"
elif e == "c":
firstcodename = "Spring"
elif e == "d":
firstcodename = "Spring"
elif e == "e":
firstcodename = "Spring"
elif e == "f":
firstcodename = "Spring"
elif e == "g":
firstcodename = "Summer"
elif e == "h":
firstcodename = "Summer"
elif e == "i":
firstcodename = "Summer"
elif e == "j":
firstcodename = "Summer"
elif e == "k":
firstcodename = "Summer"
elif e == "l":
firstcodename = "Summer"
elif e == "m":
firstcodename = "Summer"
elif e == "n":
firstcodename = "Autumn"
elif e == "o":
firstcodename = "Autumn"
elif e == "p":
firstcodename = "Autumn"
elif e == "q":
firstcodename = "Autumn"
elif e == "r":
firstcodename = "Autumn"
else:
firstcodename = "Winter"
e2= s2[:1]
if e == "a":
lastcodename = "Thunder"
elif e == "b":
lastcodename = "Thunder"
elif e == "c":
lastcodename = "Thunder"
elif e == "d":
lastcodename = "Thunder"
elif e == "e":
lastcodename = "Thunder"
elif e == "f":
lastcodename = "Thunder"
elif e == "g":
lastcodename = "Shadow"
elif e == "h":
lastcodename = "Shadow"
elif e == "i":
lastcodename = "Shadow"
elif e == "j":
lastcodename = "Shadow"
elif e == "k":
lastcodename = "Shadow"
elif e == "l":
lastcodename = "Shadow"
elif e == "m":
lastcodename = "Shadow"
elif e == "n":
lastcodename = "Flash"
elif e == "o":
lastcodename = "Flash"
elif e == "p":
lastcodename = "Flash"
elif e == "q":
lastcodename = "Flash"
elif e == "r":
lastcodename = "Flash"
else:
lastcodename = "Terminator"
genderOption = gender
if genderOption == "male":
gender = "Mr. "
else:
gender = "Mrs. "
print(get.gender)
print(get.firstcodename)
print(get.lastcodename)
CodeNameProgram()
python user-interface tkinter radio-button
I'm a college student who's trying to learn python as we speak. I'm very new and cannot successfully run this program that allows the user to create a code name using a GUI that collects information such as the user's gender, their name, and last name. I'm struggling to make the codename function work and integrate it into my "Show" button.
If anyone has a few minutes to spare and wants to look at my code, I'd appreciate it immensely. Again, I'm sorry if I'm really new/bad at this, but I'm trying to learn.
Cheers!
from tkinter import *
class CodeNameProgram:
def __init__(self):
window = Tk()
window.title("Code Name Generator")
genderOption = StringVar()
Label(window, text="First Name").grid(row=0)
Label(window, text="Last Name").grid(row=1)
R1 = Radiobutton(window, text="Male", value="male", var=genderOption).grid(row=2,column=0, sticky=E)
R2 = Radiobutton(window, text="Female", value="female", var=genderOption).grid(row=2,column=1)
e1 = Entry(window).grid(row=0, column=1)
e2 = Entry(window).grid(row=1, column=1)
Button(window, text='Quit', command=window.quit).grid(row=3, column=0, sticky=E, pady=4)
Button(window, text='Show',command=codename).grid(row=3, column=1, pady=4)
def codename(self):
e1 = s1[:1]
if e == "a":
firstcodename = "Spring"
elif e == "b":
firstcodename = "Spring"
elif e == "c":
firstcodename = "Spring"
elif e == "d":
firstcodename = "Spring"
elif e == "e":
firstcodename = "Spring"
elif e == "f":
firstcodename = "Spring"
elif e == "g":
firstcodename = "Summer"
elif e == "h":
firstcodename = "Summer"
elif e == "i":
firstcodename = "Summer"
elif e == "j":
firstcodename = "Summer"
elif e == "k":
firstcodename = "Summer"
elif e == "l":
firstcodename = "Summer"
elif e == "m":
firstcodename = "Summer"
elif e == "n":
firstcodename = "Autumn"
elif e == "o":
firstcodename = "Autumn"
elif e == "p":
firstcodename = "Autumn"
elif e == "q":
firstcodename = "Autumn"
elif e == "r":
firstcodename = "Autumn"
else:
firstcodename = "Winter"
e2= s2[:1]
if e == "a":
lastcodename = "Thunder"
elif e == "b":
lastcodename = "Thunder"
elif e == "c":
lastcodename = "Thunder"
elif e == "d":
lastcodename = "Thunder"
elif e == "e":
lastcodename = "Thunder"
elif e == "f":
lastcodename = "Thunder"
elif e == "g":
lastcodename = "Shadow"
elif e == "h":
lastcodename = "Shadow"
elif e == "i":
lastcodename = "Shadow"
elif e == "j":
lastcodename = "Shadow"
elif e == "k":
lastcodename = "Shadow"
elif e == "l":
lastcodename = "Shadow"
elif e == "m":
lastcodename = "Shadow"
elif e == "n":
lastcodename = "Flash"
elif e == "o":
lastcodename = "Flash"
elif e == "p":
lastcodename = "Flash"
elif e == "q":
lastcodename = "Flash"
elif e == "r":
lastcodename = "Flash"
else:
lastcodename = "Terminator"
genderOption = gender
if genderOption == "male":
gender = "Mr. "
else:
gender = "Mrs. "
print(get.gender)
print(get.firstcodename)
print(get.lastcodename)
CodeNameProgram()
python user-interface tkinter radio-button
python user-interface tkinter radio-button
asked Nov 11 at 17:29
lizziefawley
1
1
Welcome to SO, please note that '. I'm struggling to make the codename function work' is not a specific enough question for this site. Try to describe your problem more accurately. If you get an error, include the complete traceback in your message. If you don't get the expected output, include the output you get vs the expected one. As a side note: you could rewrite your conditionsif 'a' <= e <= 'f':
...
– Thierry Lathuille
Nov 11 at 17:46
add a comment |
Welcome to SO, please note that '. I'm struggling to make the codename function work' is not a specific enough question for this site. Try to describe your problem more accurately. If you get an error, include the complete traceback in your message. If you don't get the expected output, include the output you get vs the expected one. As a side note: you could rewrite your conditionsif 'a' <= e <= 'f':
...
– Thierry Lathuille
Nov 11 at 17:46
Welcome to SO, please note that '. I'm struggling to make the codename function work' is not a specific enough question for this site. Try to describe your problem more accurately. If you get an error, include the complete traceback in your message. If you don't get the expected output, include the output you get vs the expected one. As a side note: you could rewrite your conditions
if 'a' <= e <= 'f':
...– Thierry Lathuille
Nov 11 at 17:46
Welcome to SO, please note that '. I'm struggling to make the codename function work' is not a specific enough question for this site. Try to describe your problem more accurately. If you get an error, include the complete traceback in your message. If you don't get the expected output, include the output you get vs the expected one. As a side note: you could rewrite your conditions
if 'a' <= e <= 'f':
...– Thierry Lathuille
Nov 11 at 17:46
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251335%2fi-dont-know-why-my-python-gui-code-name-program-doesnt-work%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Welcome to SO, please note that '. I'm struggling to make the codename function work' is not a specific enough question for this site. Try to describe your problem more accurately. If you get an error, include the complete traceback in your message. If you don't get the expected output, include the output you get vs the expected one. As a side note: you could rewrite your conditions
if 'a' <= e <= 'f':
...– Thierry Lathuille
Nov 11 at 17:46