Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Simple Button click on image file to create action?
I am looking for a simple example of a python program that would display an image file and then be able to tell if the user clicked on the image with the left mouse button so that an action could be performed. I found one that seems pretty simple but it needs the "clutter" module which I can't find. Running python 2.7. Now I'm not a python programmer. I'm an old unix guy who is a volunteer at a museum writing an application on a Raspberry Pi. The main program I found that I hacked to do what I wanted works great. Now I need some more user interface on a touchscreen so all the user has is the equivalent of a left mouse button to make selections for the program. Here is the example I found of a graphical display with the ability to return info. I believe I can simplify this to just detect a button click then use Popen to call a program but if someone has some code ... or even knows where I can find a compatible clutter, I can probably plod my way through. I've tried to use graphical programs like feh but they do not do what I need.

import clutter

#create a clutter stage and set the display size
stage = clutter.Stage()
stage.set_size(400, 400)

#load the image for the buttons
img=clutter.cogl.texture_new_from_file('button.png',clutter.cogl.TEXTURE_NO_SLICING, clutter.cogl.PIXEL_FORMAT_ANY)

#example create button from class  start

class button(clutter.Texture):
    def __init__(self,id,row=1,padding=10):
        self.set_size (100,100)
        self.set_position (id*100,self.row*100)
        #call click method on button clicked
    def clicked(self,stage, event):
        print "class click="+str(" row "+str(self.row)

#example class with collection of button class
class buttons:
    def __init__(self):
        for i in range(0,10):
    #iter method so we can step through all buttons in a for loop
    def __iter__(self):
        for i in self.buttonlist:
            yield i
    #append a new button
    def append(self,btton):

#crate instance of buttons class
#append buttons class to stage
for b in buttonlist2:

#example of creating button with function calls end

#show everything in the stage
#main clutter loop

Top Page

Messages In This Thread
Simple Button click on image file to create action? - by jpezz - Mar-26-2019, 10:54 PM

Possibly Related Threads...
Thread Author Replies Views Last Post
  Tkinter Buttons action d3fi 1 108 Nov-20-2019, 09:16 PM
Last Post: Larz60+
  [Tkinter] Checking button click in Tkinter GalaxyCoyote 3 239 Oct-20-2019, 03:28 AM
Last Post: GalaxyCoyote
  [PyQt] Problem how to click a button inside a group box? mart79 2 251 Aug-05-2019, 01:21 PM
Last Post: mart79
  Refresh image in label after every 1s using simple function jenkins43 1 368 Jul-28-2019, 02:49 PM
Last Post: Larz60+
  Button with Image Icon Friend 2 316 Jul-25-2019, 09:39 AM
Last Post: Friend
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 415 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp
  [Tkinter] Tkinter window pop up again when i click button Orimura_Sandy 1 646 May-12-2019, 08:17 PM
Last Post: joe_momma
  [Tkinter] Not getting entry values on button click & treeview not updating ? swanysto 4 1,241 May-10-2019, 04:16 PM
Last Post: swanysto
  right mouse button click with PyQt5 brecht83 4 4,326 Nov-09-2018, 02:55 PM
Last Post: brecht83
  [Tkinter] Completing Action when CheckBox is Checked Anysja 2 975 Aug-02-2018, 04:38 PM
Last Post: Anysja

Forum Jump:

Users browsing this thread: 1 Guest(s)