Ask coding questions

← Back to all posts
Python Button - PLEASE HELP
CodeCenter (9)

I'm trying to make a button in Python. I've messed around with tkinter, but I can't get it to work. Can someone send me the code for a button?

Answered by a5rocks (828) [earned 5 cycles]
View Answer
CodeCenter (9)

@a5rocks I'm looking for a text button

a5rocks (828)

@CodeCenter Check out curses. You might be able to figure out how to get the mouse thing working.

Something else is that I remember @mat1 has a library that allows for mouse clicks in terminal. EDIT: Here : (has no docs, just read the source on the homepage)

PySimpleGUI (17)

Here's code like you asked for.... click the text instead of a button. When clicked, you'll see the click detected printed on the console

You can also run this code in a web page instead of tkinter by changing the import statement at the top to:
import PySimpleGUIWeb as sg

Here's a repl of the code with this change made:

SJC_Muhammad (7)

I'm confused... but I might know the solution
You don't have to press the button with the mouse, you can press a specific key, such as "Enter"

SJC_Muhammad (7)

I don't think that helps

theangryepicbanana (1697)

You can't use tkinter on yet

TheDrone7 (1900)

You can try using pysimplegui tho. It's easier although it gives lesser options, it's good

CodeCenter (9)

@TheDrone7 I'm looking for a text button

TheDrone7 (1900)

@CodeCenter what do you mean by that, do you have any examples or clips that can help me understand what you need?

AllAwesome497 (399)

@CodeCenter Maybe make a blank input? Or like maybe if the input = a then it "pushes" a button?

CodeCenter (9)

@TheDrone7 I saw a project on replit a while back, but I can't find it. I want to have text that when clicked, will execute a command. It works like a button, but it is text, not a box

TheDrone7 (1900)

Ok, I'm sorry I don't know python enough to be able to help you with that, good luck though.

CodeCenter (9)

@TheDrone7 Hey, by the way, would you like to help me out with making a website. I'm the official user for the Code Center dicord community, and I want to create a website. I have little html experience, and no CSS experience. If you could help me set something very simple up, that would be very helpful. I can provide all graphics and information. Also, go to my profile and we can talk in discord.

TheDrone7 (1900)

@CodeCenter I'm sorry but I already have a lot of projects due at the moment.

ChristianThone (67)

@CodeCenter Hey I have good experience in HTML, I don't know too much CSS But that won't be a problem, I will be willing to build your website free of charge. I have a few questions I need answered first tho.

Do you currently have a domain?

How much Experience do you have with HTML?

What kind of website are you looking to build?

PySimpleGUI (17)

@TheDrone7 The version of PySimpleGUI that works with that is not tkinter based is called PySimpleGUIWeb. It utilizes Remi as the underlying framework