Reputation: 113
update: i fixed the previous issue but now i have this, i have never seen this error before TypeError: insert() missing 1 required positional argument: 'chars' if someone could explain what this means that would be great, thank you...this is the last thing i need to complete my project i have done everything else :)
#Imports the moduels needed
import tkinter as tk
from tkinter import ttk
from PIL import Image, ImageTk #EDIT: This module worked for me after I installed Pillow in my computer from "http://pillow.readthedocs.io/en/4.1.x/installation.html"
import webbrowser #imports the module for URL links
import io, base64 #imports the module for letting images be seen without changing code
#adds the URL and window for the program tkinter
URL = "http://windowhut.com.au" #the URL used
window = tk.Tk() #this makes the tkinter window appear
window.title("window App") #title of the app
window.geometry("500x500") #size of the app
#define IntVar variables
cvar = tk.IntVar()
cvar2 = tk.IntVar()
cvar3 = tk.IntVar()
#defines the webbrowser function
def open_ph(event):
webbrowser.open_new_tab(URL)
#define the main button and the click button
button = tk.Button(window, text="Welcome to Awesome pizza")
button.grid(column=0, row=0)
button.bind("<Button-1>", open_ph)
#define check buttons
check1 = ttk.Checkbutton(window, text="Meat Lovers", variable=cvar, onvalue=1, offvalue=0)
check1.grid(column=0, row=1, padx=(5, 95))
check2 = ttk.Checkbutton(window, text="Supreme", variable=cvar2, onvalue=1, offvalue=0)
check2.grid(column=0, row=3, padx=(10, 120))
check3 = ttk.Checkbutton(window, text="Vegetarian", variable=cvar3, onvalue=1, offvalue=0)
check3.grid(column=0, row=5, padx=(10, 120))
#define the option menu
choice = tk.OptionMenu(window, tk.IntVar(), "Select your size!", "Small", "Medium", "Large")
choice.grid(column=1, row=0, padx=(5, 95))
#define labels
name_label = tk.Label(text="Name")
name_label.grid(column=1, row=1, padx=(10, 120))
number_label = tk.Label(text="Contact number")
number_label.grid(column=1, row=3, padx=(5, 95))
address_label = tk.Label(text="Delivery address")
address_label.grid(column=1, row=5, padx=(5, 95))
#define entries
name_entry = tk.Entry()
name_entry.grid(column=1, row=2, padx=(5, 95))
number_entry = tk.Entry()
number_entry.grid(column=1, row=4, padx=(5, 95))
address_entry = tk.Entry()
address_entry.grid(column=1, row=6, padx=(5, 95))
#defines the print function for the message board
def message_customer():
print(name_entry.get())
print(number_entry.get())
print(address_entry.get())
name = Person(name_entry.get(), number_entry.get(), address_entry.get())
text_answer = tk.Text(master=window, height=10, width=20)
text_answer.grid(column=1, row=7, padx=(10, 120))
text_answer.insert("Thank you {name} for ordering our window, it should be ready within 30 mintues!, have a great day!".format(name=name.name, number=name.number, address=name.address))
#define click button function
click_button = tk.Button(text="Complete Order", command=message_customer)
click_button.grid(column=1, row=7, padx=(5, 95))
#create class method
class Person:
def __init__(self, name, number=None, address=None):
self.name = name
self.number = number
self.address = address
Upvotes: 1
Views: 16048
Reputation: 13372
According to the docs, the insert
method takes 2 positional (ordering matters) arguments. e.g.
text.insert('1.0', 'here is my text to insert')
You have only provided the 2nd argument, add the 1st one ("where to insert") too.
Upvotes: 2