Ask coding questions

← Back to all posts
How do I create buttons in Python?
Aqual

Is there a way for me to create multiple buttons in Python on this website?

Voters
RiddikNeetipall
jingsaning
Aqual
Comments
hotnewtop
sugarfi

You could have some sort of a selection menu with the arrow keys, but buttons with the mouse will not work.

Aqual

@sugarfi ok, how do I do that?

sugarfi

@Aqual you can use the curses library (https://docs.python.org/3/howto/curses.html)
and also this article seems like a pretty good tutorial on the subject
https://codeburst.io/building-beautiful-command-line-interfaces-with-python-26c7e1bb54df

CodeLongAndPros

@sugarfi Look at asciimatics; it's higher level than Python Curses (I know) and supports TUI.

sugarfi

@CodeLongAndPros yeah, but curses is easier for a beginner.

CodeLongAndPros

@sugarfi

curses is easier for a beginner

asciimatics is literally Tk for terminal. They have documentation, and support mouse clicks.

Aqual

Can you walk me through this?

Aqual

Ok.

RohilPatel

Don't you need a server on frontend to make this work?

emilyUsesPascal

You cannot create buttons in the terminal, however you can have a webserver and have buttons there