Overview
| Artifact ID: | f9f56d4a7a3d527b9392e87a8c4016ad416f13b97c4507b0c4257f2869a47051 |
|---|---|
| Ticket: | ce6b428620dd89bc46786654e3aa1d62d74d3fc8
<<Increment>> event is endlessly triggered once messagebox closes |
| User & Date: | GOLosinas on 2022-02-10 02:40:25 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
I am using a ttk.Spinbox to capture some number and I want to display a messagebox once the value in the spinbox reaches the limit. I bound the spinbox to the <code> <<Increment>> </code> event to perform a check, and display the message but the event is endlessly triggered once you close the messagebox. I made a small application to illustrate the issue. class App(Tk): def __init__(self): super().__init__() self.title('Sample') self.geometry('300x100') Selector(self).pack() class Selector(ttk.Frame): def __init__(self, container): super().__init__(container) self.max_length = 10 self.input = IntVar(0) self.check_length_calls = 0 self.label = ttk.Label(self, text="Quantity: ").pack() self.spinbox = ttk.Spinbox(self, from_=0, to=10, textvariable=self.input) self.spinbox.pack() self.spinbox.bind('<<Increment>>', lambda e: self.check_length(e)) ttk.Button(self, text="print func calls", command= self.print_check_length_calls).pack() def check_length(self, e): self.check_length_calls += 1 if str(self.spinbox) != str(self.focus_get()): return if self.input.get() == self.max_length: messagebox.showwarning("Max length reached", "Too long!") self.focus_set() def print_check_length_calls(self): print(self.check_length_calls) if __name__ == "__main__": app = App() app.mainloop() - foundin changed to: "TkVersion 8.6"
- is_private changed to: "0"
- login: "GOLosinas"
- priority changed to: "5 Medium"
- private_contact changed to: "18ce5dcbd56fb12aaee69b84ea192d8d353caf30"
- resolution changed to: "None"
- severity changed to: "Important"
- status changed to: "Open"
- submitter changed to: "GOLosinas"
- subsystem changed to: "02. Event Loops"
- title changed to:
<<Increment>> event is endlessly triggered once messagebox closes
- type changed to: "Bug"