Search code examples
pythonpygtk

Checking if a Button was clicked


How can I check if a button was clicked? Could this code work or do I have to use a different command/syntax?

def div_clicked(self, button14):
    self.entry.set_text(self.entry.get_text() + str("/"))
    if button14 == "clicked":
        self.equal_clicked()
        self.arithmetic = "division"

Especially this line:

if button14 == "clicked":

I would like to know how can I change the code so the self.equal_clicked() function gets called.


Solution

  • Extend your code you can do this form too

    self.button14.connect("clicked", self.button14_click, "division")
    
    def button14_click(self, button, data):
         self.entry.set_text(self.entry.get_text() + str("/"))
         self.equal_clicked()
         self.arithmetic = data