Python Forum
Tkinter:Unable to bind and unbind function with a button
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tkinter:Unable to bind and unbind function with a button
declare your functions before you create the buttons unless you create a class
python reads your script from top to bottom:
def add_medication1():
def confirm1():
    global morn_med_label,confirm_button1
    morn_med=morn_med_Text.get("1.0",END), rely =0.82, anchor = CENTER)
    confirm_button1.place_forget(), rely = 0.76, anchor = CENTER)
morn_med_label=Label(root,bg="light blue", font=("Arial",15 ))
morn_med_button = Button(root, text="Add Medication", command=add_medication1, font=("Arial", 12)), rely = 0.76, anchor = CENTER)
confirm_button1=Button(root, text="Confirm", command=confirm1, font=("Arial", 12)),y=400)
if you bind a mouse event to a function it requires an argument
def keyboard(event):
    def select(value):
        ....# more       
I used event but it could be anything you want- then you can get information from the event like x= event.x to give you the x,y position of the mouse click

Messages In This Thread
RE: Tkinter:Unable to bind and unbind function with a button - by joe_momma - Mar-28-2020, 02:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  TKinter restarting the mainloop when button pressed zazas321 1 67 Jan-22-2021, 12:31 PM
Last Post: deanhystad
  tkinter touchscreen scrolling - button press makes unwanted scrolling nanok66 1 131 Dec-28-2020, 10:00 PM
Last Post: nanok66
  Using Tkinter inside function not working Ensaimadeta 3 210 Dec-23-2020, 02:57 PM
Last Post: deanhystad
  function in new window (tkinter) Dale22 7 360 Nov-24-2020, 11:28 PM
Last Post: Dale22
  [Tkinter] Mouse click without use bind ATARI_LIVE 8 1,465 Oct-23-2020, 10:41 PM
Star [Tkinter] How to perform math function in different page of Tkinter GUI ravaru 2 273 Oct-23-2020, 05:46 PM
Last Post: deanhystad
  Tkinter - How can I remove the background borders from ttk.Button? TurboC 4 773 Oct-18-2020, 10:58 AM
Last Post: TurboC
  Call local variable of previous function from another function with Python3 & tkinter Hannibal 5 405 Oct-12-2020, 09:16 PM
Last Post: deanhystad
  tkinter | Button color text on Click Maryan 2 353 Oct-09-2020, 08:56 PM
Last Post: Maryan
  tkinter get method is not accepting value when called by function jagasrik 1 293 Sep-16-2020, 05:28 AM
Last Post: Yoriz

Forum Jump:

User Panel Messages

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