Python Forum
Increase Numbers forever and need reset?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Increase Numbers forever and need reset?
#2
Why do you care about the value of some event handle? If I was writing something like "after" I would make sure to create a unique handle for each event. In the code below I create and delete a Frame each time the mouse button is pressed/released. Each time I get a different ID for the frame. Would you want to reset the frame ID?s
from tkinter import *
 
mouse_repeat = None
window = None
 
root = Tk() 
 
def mouse_event(event):
    global window
    if event.type == EventType.ButtonPress:
        window = Frame(root)
        print('start', window)
    elif window is not None:
        print('cancel', window)
        del window
        window = None

 
root.bind("<Button-1>", mouse_event)
root.bind("<ButtonRelease-1>", mouse_event)
root.mainloop()
Reply


Messages In This Thread
RE: Increase Numbers forever and need reset? - by deanhystad - Oct-23-2020, 12:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Increase the speed of a python loop over a pandas dataframe mcva 0 1,358 Jan-21-2022, 06:24 PM
Last Post: mcva
  How to increase the size of a png picture for the heatmap of the correlation? lulu43366 9 3,690 Oct-06-2021, 04:15 PM
Last Post: deanhystad
  generating random string unique forever Skaperen 5 2,400 Aug-20-2021, 07:15 AM
Last Post: Gribouillis
  Using SoX in Python to Increase mp3 Bitrate DRT 1 1,811 Jul-10-2021, 08:41 PM
Last Post: DRT
  Clicker count increase by 1 each time blakefindlay 1 5,819 Feb-03-2021, 03:50 PM
Last Post: deanhystad
  increase and decrease a slice value? KEYS 2 2,163 Nov-10-2020, 11:35 PM
Last Post: KEYS
  python multiprocessing import Pool, cpu_count: causes forever loop | help to remove Hassibayub 0 1,901 Jun-18-2020, 05:27 PM
Last Post: Hassibayub
  How do I add an element to a dic and increase an existing value Kanashi 2 1,880 Nov-21-2019, 02:56 PM
Last Post: ThomasL
  Print Numbers starting at 1 vertically with separator for output numbers Pleiades 3 3,822 May-09-2019, 12:19 PM
Last Post: Pleiades
  How to increase the data size SriRajesh 3 4,121 Nov-10-2018, 04:29 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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