Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1579

Python • Re: compile python from source with tkinter support

$
0
0
I am not sure what you are aiming for, here is an example using tkinter to spawn a window.

Code:

#!/usr/bin/env python3"""Simple Tkinter window for Raspberry Pi 3 (Python 3)."""import tkinter as tkdef main() -> None:    root = tk.Tk()    root.title("Pi 3 - Tkinter Test")    root.resizable(False, False)    # Basic layout    frame = tk.Frame(root, padx=20, pady=20)    frame.pack()    label = tk.Label(frame, text="Hello from Tkinter on a Raspberry Pi 3!", font=("Arial", 14))    label.pack(pady=(0, 12))    btn = tk.Button(frame, text="Close", command=root.destroy)    btn.pack()    root.mainloop()if __name__ == "__main__":    main()
You will need to install this:

Code:

sudo apt install -y python3-tk

Statistics: Posted by foxsquirrel — Mon Dec 29, 2025 3:37 am



Viewing all articles
Browse latest Browse all 1579

Trending Articles