# How do I add a command to a button in Tk?

**URL:** <https://discourse.julialang.org/t/how-do-i-add-a-command-to-a-button-in-tk/107237>\
**Category:** New to Julia\
**Tags:** question, gui\
**Created:** [December 6, 2023, 10:48pm UTC](https://discourse.julialang.org/t/how-do-i-add-a-command-to-a-button-in-tk/107237 "2023-12-06T22:48:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cyberbully](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cyberbully/32/205254_2.png) [@Cyberbully](https://discourse.julialang.org/u/Cyberbully)\
**Post date:** [December 6, 2023, 10:48pm UTC](https://discourse.julialang.org/t/how-do-i-add-a-command-to-a-button-in-tk/107237/1 "2023-12-06T22:48:07Z")

</div>

I’m familiar with python Tkinter and I’m also learning Julia Tk. Today I was experimenting with creating buttons but I couldn’t figure out how to execute a function when the button is pressed.

Example of my code:  
function t\_f()  
(Tab) println(“It works!”)  
end

function menuscreen(window)  
(Tab) newfile = Button(window,  
text=“New File”,  
command=t\_f)  
end

window = Toplevel()  
menuscreen(window)

When I try to run this it says that the ‘t\_f’ function doesn’t exist, but the ‘t\_f()’ does. And adding two parentheses to the end ‘()’ returns a different error.

In summary: how do I call a function using a button?

I’ve gotta add that I absolutely love the language, so far it has to be my favorite out of all the languages I know (Python, C++, and some bits of a few more)
