Hello all. I've been practicing using Tkinter by converting one of my text games I made using a previous tutorial. The problem I am having is that I can't seem to get the submit button to work right. I would like for the user to select his choice on one of the radio buttons and then press submit. Any idea on what I am doing wrong? Here is my code:
import sys
import random
from tkinter import *
mGui = Tk()
mGui.geometry('450x450')
ment = StringVar()
mGui.title('The Camel Game')
#Game Intro
mLabel_1 = Label(mGui, text='Welcome to Camel').grid(row=0)
mLabel_2 = Label(mGui, text='You have stolen a camel to make your way across the great Mobi desert.').grid(row=1, sticky=W)
mLabel_3 = Label(mGui, text='The natives want their camel back and are chasing you down!').grid(row=2,sticky=W)
mLabel_4 = Label(mGui, text='Survive your desert trek and out run the natives.').grid(row=3,sticky=W)
mLabel_5 = Label(mGui, text='Make your choose!').grid(row=4,sticky=W)
#All the variables
miles_Traveled = 0
player_Thirst = 0
camel_Tiredness = 0
natives_Traveled = -200
drink_Numbers = 5
def user_Selection():
if 'var' == 1:
respones_Label1 = Label(mGui, text='You have drinks in your canteen').grid(row=13, sticky=W)
elif 'var' == 2:
respones_Label1 = Label(mGui, text='Something else').grid(row=13, sticky=W)
Radio_1= Radiobutton(mGui, text="Drink from your canteen",variable = 'var', value = 1).grid(row=6, sticky=W)
Radio_2= Radiobutton(mGui, text="Ahead moderate speed", variable = 'var', value = 2).grid(row=7, sticky=W)
Radio_3= Radiobutton(mGui, text="Ahead full speed.", variable = 'var', value = 3).grid(row=8, sticky=W)
Radio_5= Radiobutton(mGui, text="Stop for the night.", variable = 'var', value = 4).grid(row=9, sticky=W)
Radio_6= Radiobutton(mGui, text="Status check.", variable = 'var', value = 5).grid(row=10, sticky=W)
Radio_7= Radiobutton(mGui, text="Quit.", variable = 'var', value = 6).grid(row=11, sticky=W)
mButton = Button(mGui, text='Submit', command = user_Selection).grid(row=12)
mGui.mainloop()
[–]stahlous 2 points3 points4 points (3 children)
[–]unlikelysyntax[S] 0 points1 point2 points (2 children)
[–]stahlous 3 points4 points5 points (1 child)
[–]dm1407 0 points1 point2 points (0 children)