← Back to Community
Python Button - PLEASE HELP
Profile icon
CodeCenter

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 [earned 5 cycles]
View Answer
Voters
Profile icon
JATHINVINAY
Profile icon
taopeng
Profile icon
Iwantto
Profile icon
JoMounir
Profile icon
Harjeet72000
Profile icon
mkhoi
Profile icon
yt_jayoneil5
Profile icon
TheDrone7
Profile icon
KiKUP
Profile icon
CodeCenter
Comments
hotnewtop
Profile icon
a5rocks
Profile icon
CodeCenter

@a5rocks I'm looking for a text button

Profile icon
a5rocks

@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 : https://pypi.org/project/xterm/ (has no docs, just read the source on the homepage)

Profile icon
mishai

gffff

Profile icon
JacksonDucharme

ur doggy

Profile icon
PySimpleGUI

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

https://repl.it/@PySimpleGUI/Click-Text-Instead-of-Button

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:
https://repl.it/@PySimpleGUI/Click-Text-Instead-of-Button-Web-Version

Profile icon
SJC_Muhammad

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"

Profile icon
SJC_Muhammad

I don't think that helps

Profile icon
theangryepicbanana

You can't use tkinter on repl.it yet

Profile icon
TheDrone7

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

Profile icon
CodeCenter

@TheDrone7 I'm looking for a text button

Profile icon
TheDrone7

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

Profile icon
AllAwesome497

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

Profile icon
CodeCenter

@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

Profile icon
TheDrone7

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

Profile icon
CodeCenter

@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.

Profile icon
TheDrone7

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

Profile icon
CodeCenter
Profile icon
ChristianThone

@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?

Profile icon
PySimpleGUI

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