Python Forum
tkinter get method is not accepting value
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter get method is not accepting value
#1
I am trying a mini project just for my practice purpose, here when i enter the value '1' when i run this program, the option.get() is not accepting the value from 'entry' , because it is not printing "Your existing balance is 10000".
Please note that i have call user_choice function to process to next steps, this is just one part of rest of the project.
If it is accepting it should be printing "Your existing balance is 10000" Please help, thanks in advance.

import tkinter as tk

global balance 

balance= 10000

def user_choice():

    a = (option.get()) #not able to accept input from the entry
    if(a==1):
        print("You existing Balance is ",balance)
    #if(a==2):


    

root1 = tk.Tk()

option = tk.StringVar()  
canvas = tk.Canvas(root1,height=500,width=500)
canvas.pack()
frame = tk.Frame(root1,bg='#80c1ff')
frame.place(relx=0.1,rely=0.1,relwidth=0.8,relheight=0.8)
label = tk.Label(frame,
                 text="|| Enter number 1-4 || \n Please Choose your options",bg="yellow")
label.place(relx=0.15,rely=0.1,relwidth=0.7)
label = tk.Label(frame,
                 text="\n 1- Check saving Balance \n 2- Deposit Funds \n 3- Withdraw Funds \n 4- Transfer Funds ",bg="yellow")
label.place(relx=0.15,rely=0.2,relwidth=0.7)
entry = tk.Entry(root1,bg="gray",textvariable=option) #HERE is the INPUT VALUE Entering
entry.place(relx=0.45,rely=0.43,relwidth=0.09)
button = tk.Button(master=root1, text='OK',bg='purple',activebackground='pink',fg='white',command=user_choice) #Here I am calling the function 
button.place(relx=0.41,rely=0.489,relwidth=0.16) 

root1.mainloop()
Reply
#2
Please explain what you mean by "it is not accepting the value". Are there errors? Does something not work as expected? More info please!
Reply
#3
(Sep-15-2020, 05:28 PM)ndc85430 Wrote: Please explain what you mean by "it is not accepting the value". Are there errors? Does something not work as expected? More info please!

I have updated my issue, here i mean option.get() method is not accepting the value from 'entry'
Reply
#4
What type of value does option.get() return? Is it a string?
Reply
#5
(Sep-15-2020, 05:39 PM)ndc85430 Wrote: What type of value does option.get() return? Is it a string?
Thanks a lot , i spent lot of time, i understand it now.

It can be string or int , just i have to convert it either way to work it around, i dint know it would matter so much. Now its working.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  TKinter Widget Attribute and Method Quick Reference zunebuggy 3 789 Oct-15-2023, 05:49 PM
Last Post: zunebuggy
  tkinter -- after() method and return from function -- (python 3) Nick_tkinter 12 7,238 Feb-20-2021, 10:26 PM
Last Post: Nick_tkinter
  Tkinter menu font size -method to change tonycat 2 7,707 Oct-11-2020, 02:43 AM
Last Post: tonycat
  tkinter get method is not accepting value when called by function jagasrik 1 2,495 Sep-16-2020, 05:28 AM
Last Post: Yoriz
  Tkinter - Issues with "iconbitmap" method aquerci 3 5,814 May-21-2020, 09:46 AM
Last Post: aquerci

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020