Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

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

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. 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()
    
  5. foundin changed to: "TkVersion 8.6"
  6. is_private changed to: "0"
  7. login: "GOLosinas"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "18ce5dcbd56fb12aaee69b84ea192d8d353caf30"
  10. resolution changed to: "None"
  11. severity changed to: "Important"
  12. status changed to: "Open"
  13. submitter changed to: "GOLosinas"
  14. subsystem changed to: "02. Event Loops"
  15. title changed to:
    <<Increment>> event is endlessly triggered once messagebox closes
    
  16. type changed to: "Bug"