I want to create a button in tkinter and when pressed, have that button call a different program into this program. (this is just an example) Say I have the one program that shows the button that says "Square root" and I have another program that takes a number such as: 4, using the input() function, and finds the square root of 4. I want that button when pressed to call the "square root program" and input it into the "button" program. (Again. just an example. if I really wanted to do the square root stuff I would just make a different function called: def square_root())
#Button.py
from tkinter import *
root = Tk()
def call_the_other_program():
#This is the part I don't know how to do...
#Do I import the different program somehow?
#Is this even possible xD
b = Button(root, text = "Square root", command = call_the_other_program())
Square root program:
import math
x = input("input a number")
print("the square root of", x, "is:", math.sqrt(x))
#I want this to be the program that is called
Thanks for explaining to me! 😊