for example if you have a an image, button, and a label. If you don't click the button or anywhere on the screen/window in 10 seconds, then hide the button and the label. If you click the screen/window then it shows the button and label and resets thanks to Gonzalo Odiard's suggest the issue now is only: How to handle a click on the screen with python gtk if buttons are also there? (how to call custom method "eventListener()" if screen is clicked)
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, GLib
def button_pressed():
global clicked
clicked = 0
def eventListener():
global clicked
clicked = 0
btn.set_visible(True)
lbl.set_visible(True)#set visible
def hide():
global clicked
if(clicked >=10):
btn.set_visible(False) #set invisible
lbl.set_visible(False)
else:
clicked += 1
GLib.timeout_add_seconds(1, hide)
def callback(window, event):
global countToHide
countToHide = 0
btn.set_visible(True)
lbl.set_visible(True)
width, height= pyautogui.size()
builder = Gtk.Builder()
builder.add_from_file("main.glade")#this gets glade class for GUI
win = builder.get_object("Main_Page")#this sets screen/window to var for display later
global clicked
clicked = 0
btn= builder.get_object("button")#get object button from glade
btn.connect("clicked",button_pressed)#handle events of glade button
lbl= builder.get_object("label")#get Label from glade
#initialize event listener for if screen/window is clicked
#?how to do this
#call method if 10 second go by with out anything being clicked
#this method below
#hide()
GLib.timeout_add_seconds(10, hide)
win.connect('button-press-event', callback)
win.show() #show GUI
Gtk.main()