Search code examples
python-2.7sortingtkintertkinter-canvastkinter-entry

which widget is used to sort column-wise data in tkinter GUI Python 2.7


I have written a GUI application in Python 2.7 in which many data are there to show in a column-wise. I just wanna to know that which widget should i use for shorting data column-wise so that the sorting widget will look good :-D or Which widget is used to sort column-wise data in tkinter GUI Python 2.7 ?


Solution

  • The below script demonstrates that you can get a callback from a Label widget if you wanted to use that instead.

    from tkinter import *
    
    root = Tk()
    
    label = Label(root, text="Click me")
    
    label.pack()
    
    def callback(event):
        print("You did it!")
    
    label.bind("<Button-1>", callback)
    
    root.mainloop()
    

    The same logic can be applied to any widget, if you wanted to use a Listbox as a "button" (for some ungodly reason) for example, that's also possible with the same logic.