Sat Nov 25, 2023 8:55 pm
#!/usr/bin/env python
# timer.py
# Creator: TT
# This plug-in was intended to be used as a way to roughly measure a manual process.
# If you map it to a shortcut (ie. Ctrl+T) then just Ctrl+T before you do your manual editing/operations in GIMP
# Then when you're done, just Ctrl+T again and it'll gimp_message the time in seconds since the last time you hit Ctrl+T
# Open Source
# Rel: 1.0
from gimpfu import *
import time
global_var_id = 'timertt' #used to store our startt timer.
def set_global_variable(value):
gimp.set_data(global_var_id, str(value))
def get_global_variable():
return float(gimp.get_data(global_var_id))
def timer_tt():
try:
startt = get_global_variable()
except RuntimeError:
startt = time.time()
endt = time.time()
time_taken = endt-startt
pdb.gimp_message("Time since last call in secs:" + str(time_taken))
set_global_variable(time.time())
# Register the Python-Fu plugin
register(
"python_fu_timer_tt",
"Times since last this plug-in was call",
"Times since last this plug-in was call",
"TT",
"TT",
"2023.11.25",
"Timer",
"", # Alternately use RGB, RGB*, GRAY*, INDEXED etc.
[
#INPUT BEGINS
#(PF_IMAGE, "img", "Image", None),
#(PF_DRAWABLE, "layer", "Drawable", None),
#INPUT ENDS
],
[],
timer_tt,
menu="<Image>/Python-Fu")
main()
Sun Nov 26, 2023 6:07 pm
#!/usr/bin/env python
# timer.py
# Creator: TT
# =======================================================================================
# NOTICE: This version has tracking code which increments a single counter each use.
# You can get untracked version at http://gimpchat.com/viewtopic.php?f=9&t=20651#p285522
# =======================================================================================
# This plug-in was intended to be used as a way to roughly measure a manual process.
# If you map it to a shortcut (ie. Ctrl+T) then just Ctrl+T before you do your manual editing/operations in GIMP
# Then when you're done, just Ctrl+T again and it'll gimp_message the time in seconds since the last time you hit Ctrl+T
# Open Source
# Rel: 1.0
from gimpfu import *
import time
# TRACKING CODE STARTS ================================================================================
# ================================================================================================
import requests
def hit_it(): #this function is called whenever we want to increment counter of var timertt in data below
TRACKING_VARNAME = 'timertt' #Change this value to track different var for each plug-in
# Replace these values with your Firebase configuration
firebase_config = {"apiKey": "AIzaSyApnXYZuSzdpQNXYg0ZWHLF2t3VHjqmf9k","databaseURL": "https://single-counter-default-rtdb.firebaseio.com/"}
counter_path = TRACKING_VARNAME + ".json"
response = requests.get(firebase_config['databaseURL']+counter_path,params={"key": firebase_config["apiKey"]})
if response.status_code == 200:
current_value = response.json()
if current_value is None: #FIRST RUN EVER doesn't have a value we'll just make value 0 so it can be incremented
current_value = 0
new_value = current_value + 1
update_response = requests.put(firebase_config['databaseURL']+counter_path,json=new_value,params={"key": firebase_config["apiKey"]})
if update_response.status_code == 200:
pass
#pdb.gimp_message(new_value) #debug to see incremented value
# TRACKING CODE ENDS ==================================================================================
# =================================================================================================
global_var_id = 'timertt' #used to store our startt timer.
def set_global_variable(value):
gimp.set_data(global_var_id, str(value))
def get_global_variable():
return float(gimp.get_data(global_var_id))
def timer_tt():
try:
startt = get_global_variable()
except RuntimeError:
startt = time.time()
endt = time.time()
time_taken = endt-startt
pdb.gimp_message("Time since last call in secs:" + str(time_taken))
hit_it() #tracking usage here
set_global_variable(time.time())
# Register the Python-Fu plugin
register(
"python_fu_timer_tt",
"Times since last this plug-in was call",
"Times since last this plug-in was call",
"TT",
"TT",
"2023.11.25",
"Timer",
"", # Alternately use RGB, RGB*, GRAY*, INDEXED etc.
[
#INPUT BEGINS
#(PF_IMAGE, "img", "Image", None),
#(PF_DRAWABLE, "layer", "Drawable", None),
#INPUT ENDS
],
[],
timer_tt,
menu="<Image>/Python-Fu")
main()
# TRACKING CODE STARTS ================================================================================
# ================================================================================================
import requests
def hit_it(): #this function is called whenever we want to increment counter of var timertt in data below
TRACKING_VARNAME = 'timertt' #Change this value to track different var for each plug-in
# Replace these values with your Firebase configuration
firebase_config = {"apiKey": "AIzaSyApnXYZuSzdpQNXYg0ZWHLF2t3VHjqmf9k","databaseURL": "https://single-counter-default-rtdb.firebaseio.com/"}
counter_path = TRACKING_VARNAME + ".json"
response = requests.get(firebase_config['databaseURL']+counter_path,params={"key": firebase_config["apiKey"]})
if response.status_code == 200:
current_value = response.json()
if current_value is None: #FIRST RUN EVER doesn't have a value we'll just make value 0 so it can be incremented
current_value = 0
new_value = current_value + 1
update_response = requests.put(firebase_config['databaseURL']+counter_path,json=new_value,params={"key": firebase_config["apiKey"]})
if update_response.status_code == 200:
pass
#pdb.gimp_message(new_value) #debug to see incremented value
# TRACKING CODE ENDS ==================================================================================
# =================================================================================================