Python Forum
How many times it was pressed the button
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How many times it was pressed the button
#4
Hello,
This is a sample button,i am a beginner in python and tkinter,can you help me with this code,if is possible i want like push button 10 times it write in file and send to my email,every day,this is mashine for water and i want to know how much is pushing the buttons,i have two buttons for warm and cool water.if you can help me и will be very grateful.

import tkinter as tk
from tkinter import *
import smtplib
from tkinter import Tk, Toplevel, Button
import RPi.GPIO as GPIO
import time
import tkinter.ttk as ttk
from tkinter.ttk import Progressbar, Style, Button
 
 
 
 

 
master1 =Toplevel()
master3 =Toplevel()
 
 
##################################right
 
master1.minsize(150,150+170+170)
master1.geometry("185x1000+0+0")
master1.configure(background="black",)
master1.title("2")
master1.overrideredirect(True)
#################################left
  
 
master3.label = tk.Label(master3, text='this is OK')
master3.label.pack()
 
 
 
def text_1_2():
    b2()
    nadpisok()
   ##########################
 
     
def nadpisok():
    print('Button clicked')
    master3.label['text'] = 'please wait'
    master3.button['state'] = 'disabled'
    master3.after(3000, master.delayed_textok)
    
     
def delayed_textok():
    master3.label['text'] = 'this is OK'
    master3.button['state'] = 'normal'
    master3.after(3000, master.finhished)
 
      
 
 
###########################################
GPIO.setwarnings(False)
 
    
#########################################
def b2():
        GPIO.setmode(GPIO.BCM)
        RELAIS_2_GPIO = 10
        GPIO.setup(RELAIS_2_GPIO, GPIO.OUT)
        GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
        time.sleep(0.35)
        GPIO.output(RELAIS_2_GPIO, GPIO.LOW)
        time.sleep(0.35)
#########################################
 
 
image2 = tk.PhotoImage(file="")
b = button = tk.Button(master1,image=image2, height=80, width=160,background="red",font="0",bd=10,fg="black",command= text_1_2)
b.place(x = 0, y = 120)
label2=Label(master1,text="",height=0, width=0,bg="#100C19",font="Times 13 underline",fg="white",relief="solid",bd=0).place(x=0,y=200)
#########################
 
master.mainloop()
GPIO.cleanup()

probably it is
pretty complex code..
Reply


Messages In This Thread
How many times it was pressed the button - by chano - Aug-13-2019, 11:41 AM
RE: How many times it was pressed the button - by chano - Aug-15-2019, 07:42 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Find how many times a user played an artist and how many times disruptfwd8 1 2,610 May-04-2018, 08:32 AM
Last Post: killerrex

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020