Search code examples
pythontkinterwxpython

GUI for web search history


I'm absolute beginner to python. I am building a web-history tracker, which tracks user's web history and accessed time. And I want to create a GUI with a button and display the user's history once they click the button.I have watched so many videos and yet didn't get the idea to link the code with the button to get the output. If some life savior could help me with this it would be highly appreciated. Thank you so much in advance


Solution

  • Here is my most basic GUI skeleton that I use to start my GUI applications. Just so I don't have to remember the initial setup every time.

    import tkinter as tk
    
    class OOP:
        def __init__(self):
            self.win = tk.Tk()
            self.win.title("My Title")
            self.create_widgets()
    
        def click_me(self): # this is how you set up functions to run on button clicks
            print("button was clicked")
    
        def create_widgets(self):
            tk.Label(self.win, text="My GUI").pack(expand=1, fill='both')
            tk.Button(self.win, text="Click ME", command=self.click_me).pack(expand=1, fill='both')
    
    app = OOP()
    app.win.mainloop()
    

    You can look up information about how to fill it out all over the web. I use http://effbot.org/tkinterbook/ as a main reference point though. If you want more help you will have to post an actual question that needs solving