I only use windows, I am currently using windows 10 and python 3.9.4
I can create a .py file on my desktop, open it in vs code and using the following code:
I can also double click on that .py file and it works.
I can create a .py file on my desktop, open it in vs code and using the following code:
import tkinter as tk from tkinter import ttk class TkApp(tk.Tk): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.entry = ttk.Entry(self) self.entry.pack(padx=5, pady=5) self.button = ttk.Button(self, text='Print', command=self.on_button) self.button.pack(pady=5) def on_button(self): print(f'Entry contains: {self.entry.get()}') if __name__ == '__main__': app = TkApp() app.mainloop()click on the little green triangle in the top right corner to run python file in terminal and it just works.
I can also double click on that .py file and it works.