Python Forum
[Tkinter] bind lambda keypress counter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] bind lambda keypress counter
#1
I am trying to recreate a flash piece in python:
This is a link to a thread that contains the flash based sentry gun program: http://forum.alienslegacy.com/viewtopic.php?f=3&t=3019


I have been playing around with things and so far this is my attempt do program logic for a fire countdown button press counter:
import pygame
from tkinter import *
import tkinter
import keyboard
import pynput


pygame.init()


def final_count(event):
    if count == 0:
      count == 500
    count -= 1
    print(count)
    

# Create object
root = tkinter.Tk()

# Adjust size
root.geometry("640x400")
root.configure(bg='black')
var = StringVar()
var = 500

count = IntVar()
Grid.rowconfigure(root,0,weight=1, uniform='a')
Grid.columnconfigure(root,0,weight=1, uniform='a')
Grid.rowconfigure(root,1,weight=1, uniform='b')
Grid.columnconfigure(root,1,weight=1, uniform='b')

rounds = Button(root,justify=CENTER,textvariable=(var),bg='black', fg='yellow', highlightbackground='yellow', highlightcolor='black',activebackground='yellow')
rounds.grid(row=0,column=0, sticky="EW")
label1 = Label(root, textvariable=count)
label1.grid(row=1, column=0, sticky="EW")
label1.bind('<KeyPress>', lambda f : final_count)



root.mainloop()
I am documenting the progress here:
http://forum.alienslegacy.com/viewtopic.php?f=3&t=19394
And trying to recreate the font used here:
http://forum.alienslegacy.com/viewtopic.php?f=3&t=19399
Reply


Messages In This Thread
bind lambda keypress counter - by knoxvilles_joker - Apr-11-2021, 01:02 AM
RE: tkinter bind lambda keypress counter - by Yoriz - Apr-11-2021, 10:16 AM
RE: tkinter bind lambda keypress counter - by Yoriz - Apr-11-2021, 10:57 PM
RE: bind lambda keypress counter - by Yoriz - Apr-12-2021, 06:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] bind menator01 1 1,249 Apr-15-2022, 08:47 PM
Last Post: menator01
  update text variable on label with keypress knoxvilles_joker 3 4,901 Apr-17-2021, 11:21 PM
Last Post: knoxvilles_joker
  [Tkinter] Mouse click without use bind ATARI_LIVE 8 7,410 Oct-23-2020, 10:41 PM
Last Post: ATARI_LIVE
  [Kivy] AttributeError: 'NoneType' object has no attribute 'bind' faszination_92 2 6,263 Apr-12-2020, 07:01 PM
Last Post: Larz60+
  [WxPython] Bind error PeterLinux 1 2,238 Apr-06-2020, 03:07 AM
Last Post: joe_momma
  Tkinter:Unable to bind and unbind function with a button shallanq 2 5,027 Mar-28-2020, 02:05 AM
Last Post: joe_momma
  [Tkinter] How to bind an event when enter is pressed on a Entry control? Michael4 4 3,949 Aug-29-2019, 10:11 PM
Last Post: Michael4
  Update plot by <Return> bind with entry widget Zorro 1 4,125 Mar-09-2019, 12:27 PM
Last Post: Zorro
  Bind only fires off once? WuchaDoin 3 4,490 Dec-18-2018, 07:46 PM
Last Post: buran
  [WxPython] bind label and entry text with return key metulburr 1 3,264 Aug-14-2018, 10:02 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

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