Setting Up
Import the required library and set up the required objects:
from tkinter import *
import tkinter as tk
from tkinter import *
import tkinter as tk
Creating the Form
win = Tk()
win.geometry("700*280")
To make the form look pretty:
canvas = Canvas( win, width=1000, height=750,bg="red")
canvas.create_text(500m50,text="Calculator",fill="black", font=('Helvetica 15 bold'))
canvas.pack()
win.geometry("700*280")
To make the form look pretty:
canvas = Canvas( win, width=1000, height=750,bg="red")
canvas.create_text(500m50,text="Calculator",fill="black", font=('Helvetica 15 bold'))
canvas.pack()
Create a Button
tk.Button(win, text="Button", width=5, height=1,bg="White",highlightbackground="#37d3ff").place(x=100, y=100)
Make the button work!
1. Create a function that will be called when the button is pressed.
2.Create the button and attach the function to the button:
Button1= tk.Button(win, text="1", width=5, height=1, bg="White", highlightbackground="#37d3ff", command=Button1Command).place(x=200, y=300)
2.Create the button and attach the function to the button:
Button1= tk.Button(win, text="1", width=5, height=1, bg="White", highlightbackground="#37d3ff", command=Button1Command).place(x=200, y=300)
Create a TextboxAnsText = tk.Entry(win, bg="White", highlightbackground="#37d3ff")
AnsText.place(x=100, y=50, width=370,height=40) AnsText.insert(0, "") |
Update the TextboxAnsText.delete(0,"end")
AnsText.insert(0, "new text") Tk.update() |
Run your Program
canvas.pack()
win.mainloop()
win.mainloop()