Shuffling List with Tkinter GUI Display

  • Share this:

Code introduction


This function takes a list as input and uses the Tkinter library to create a simple GUI window displaying all elements of the list, and returns a shuffled list.


Technology Stack : Tkinter, ttk

Code Type : Python function

Code Difficulty : Intermediate


                
                    
def shuffle_list(input_list):
    import tkinter as tk
    from tkinter import ttk

    root = tk.Tk()
    root.withdraw()  # Hide the main window
    tree = ttk.Treeview(root, columns=('Item',), show='headings')
    tree.heading('Item', text='Item')
    for item in input_list:
        tree.insert('', 'end', values=(item,))
    tree.pack(expand=True, fill='both')
    root.mainloop()
    return [item for item in tree.get_children()]                
              
Tags: