how to pass arguements to a function in tkinter

Viewed 23

I have small snippet:

import tkinter as tk
win = tk.Tk()
win.geometry('200x100')
def getchoice(param):
   print(param) # this is always none how to get the value i entered in text field field

lab2 = tk.Label(win,text="enter sub/pub").pack()
choice = tk.Entry(win).pack()
button = tk.Button(win,text="ok",command=lambda: getchoice(str(choice))).pack()
win.mainloop() 

my getchoice function is called but callby parameter is always none. any suggestions?

0 Answers
Related