Is there a way to carry out 2 or more functions when a button is pressed?

  button, function, python

This code is meant to print 2 values when a button is pressed

from tkinter import *

def func_1():
    print(100)

def func_2():
    print(200)

root = Tk()
canvas = Canvas(root, width=500, height=300)
btn = Button(root, text='click me', command=func_1 and func_2)
btn.pack()

Unfortunately, whenever the button is pressed, only the latter of the two functions is printed. What’s wrong with the code and how do I get it to work?

Source: Python Questions

LEAVE A COMMENT