Ask coding questions

← Back to all posts
Python Button - PLEASE HELP
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
taopeng
Iwantto
JoMounir
Harjeet72000
mkhoi
yt_jayoneil5
TheDrone7
KiKUP
CodeCenter
Comments
hotnewtop
a5rocks
CodeCenter

@a5rocks I'm looking for a text button

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)

mishai

gffff

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

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"

SJC_Muhammad

I don't think that helps

theangryepicbanana

You can't use tkinter on repl.it yet

TheDrone7

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

CodeCenter

@TheDrone7 I'm looking for a text button

TheDrone7

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

AllAwesome497

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

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

TheDrone7

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

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.

TheDrone7

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

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

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