Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Tkinter, button doesnt working ;//

import tkinter as tk
okno = tk.Tk()

def callback():

refresh = tk.Button(okno, text="Click", command=callback())
What is wrong with this hello world program in tkinter? The "click!" appears immediately after run script. Clicking button do nothing but when i comment these lines
#refresh = tk.Button(okno, text="Click", command=callback())
there is no "click!" in my console.
refresh = tk.Button(okno, text="Click", command=callback)
Yeah, or use lambda like
refresh = tk.Button(okno, text="Click", command= lambda: callback())
(Jul-18-2018, 10:41 AM)Dzonzi Wrote: Yeah, or use lambda like
refresh = tk.Button(okno, text="Click", command= lambda: callback())
I don't think this will work
callback() part will execute the callback function, it will print 'click' and return None.
So your line is same as
refresh = tk.Button(okno, text="Click", command=lambda:None)
and the use of lambda in this case in not needed anyway

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [Tkinter] Checking button click in Tkinter GalaxyCoyote 3 182 Oct-20-2019, 03:28 AM
Last Post: GalaxyCoyote
  [Tkinter] Tkinter button help and general commands Iceman 1 192 Sep-01-2019, 05:09 PM
Last Post: Yoriz
  python file(.py) not working with my tkinter project DeanAseraf1 8 361 Jul-30-2019, 12:55 PM
Last Post: DeanAseraf1
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 352 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp
  [Tkinter] sleep(n) not working inside tkinter mainloop roger31415 2 486 Jul-14-2019, 06:57 PM
Last Post: wuf
  [Tkinter] Tkinter window pop up again when i click button Orimura_Sandy 1 515 May-12-2019, 08:17 PM
Last Post: joe_momma
  tkinter- adding a new window after clicking a button built on the gui ShashankDS 2 675 Apr-18-2019, 12:48 PM
Last Post: ShashankDS
  [Tkinter] Help with tkinter; images and button commands SheeppOSU 2 508 Mar-28-2019, 02:01 AM
Last Post: woooee
  tkinter - global variable not working albry 2 1,232 Jan-26-2019, 04:22 AM
Last Post: Larz60+
  Tkinter Button Settings kaanertugrul 3 988 Jan-25-2019, 03:41 PM
Last Post: Larz60+

Forum Jump:

Users browsing this thread: 1 Guest(s)