Sunday, June 11, 2023

A Python Program I wrote

 I wrote a Python Program the other day, ignore the links, it has a button to go to a test website, a button to quit, and a button to go to a website my parents made, as well as some text. Here it is:

from tkinter import *
from tkinter import ttk
import webbrowser

root = Tk()

def opentestsite():
    url = ""

def opengoogleaja():

frm = ttk.Frame(root, padding=10)
ttk.Label(frm, text="Hello World!").grid(column=0, row=0)
ttk.Button(frm, text="Quit", command=root.destroy).grid(column=1, row=0)
ttk.Label(frm, text="test line 2").grid(column=0, row=1)
ttk.Button(frm, text="Open test website", command=opentestsite).grid(column=1, row=1)
ttk.Button(frm, text="Open", command=opengoogleaja).grid(column=0, row=2)


It should work on Python 3.10.8 and maybe above, I used the IDLE editor and installed it from the official Python website I also used the official Tkinter library as well as the new cleaner-looking ttk.
I suggest copy-pasting it straight out and it should work without you having to install anything unless your Python instalment doesn't have tkinter like in Jupyter Notebook where it is not in the initial package due to software limitations.

No comments:

Post a Comment