Aug-03-2021, 06:26 AM
Hi all I am experiencing a strange issue.
I have two scripts in tkinter one is for date picker from a calender when i run the script it runs perfectly.
I have two scripts in tkinter one is for date picker from a calender when i run the script it runs perfectly.
# Import Required Library from tkinter import * from tkcalendar import Calendar # Create Object root = Tk() # Set geometry root.geometry("400x400") # Add Calendar cal = Calendar(root, selectmode = 'day', year = 2020, month = 5, day = 22) cal.pack(pady = 20) def grad_date(): date.config(text = "Selected Date is: " + cal.get_date()) # Add Button and Label Button(root, text = "Get Date", command = grad_date).pack(pady = 20) date = Label(root, text = "") date.pack(pady = 20) # Excecute Tkinter root.mainloop()The second script is something i am working on. I want to insert the date picker in the GUI . I have a current date , which is required . the date picker is to select the delivery date. when I add the above mentioned date picker script to my script I get an error
Error:Traceback (most recent call last):
File "C:\Users\INDIAN\Desktop\python exercises\order form\order form - Copy 4.py", line 5, in <module>
from tkcalender import Calender
ModuleNotFoundError: No module named 'tkcalender'
here is the code.from tkinter import * import tkinter as tk import datetime as dt from tkinter import ttk from tkcalender import Calender #win=tk.Tk() #win.title('Lab Order Form') root = Tk() root.title("Lab Order Form") d = f'{dt.datetime.now():%a, %b %d %Y}' cal = Calendar(root, selectmode = 'day', year = 2020, month = 5, day = 22) cal.pack(pady = 20) def grad_date(): date.config(text = "Selected Date is: " + cal.get_date()) # Add Button and Label Button(root, text = "Get Date", command = grad_date).pack(pady = 20) date = Label(root, text = "") date.pack(pady = 20) def getvals(): print("Submitting form") print(f"{labnamevalue.get(),patientnamevalue.get(), workvalue.get(), toothnumbervalue.get(), materialvalue.get(), shadevalue.get(), labservicevalue.get()} ",d,de) with open("records.txt", "a") as f: f.write(f"{labnamevalue.get(),patientnamevalue.get(), workvalue.get(), toothnumbervalue.get(), materialvalue.get(), shadevalue.get(), labservicevalue.get()}\n ") root.geometry("644x344") #Heading Label(root, text="Arora Dental Care\n Lab Work Order ", font="comicsansms 13 bold", pady=15).grid(row=0, column=5) #Text for our form labname = Label(root, text=" Lab. Name") patientname=Label(root, text=" Patient.Name") orderdate=Label(root, text="Order Date") date=Label(root,text=d,fg="black", bg="white",font=("Helvetica", 11)) work = Label(root, text="Work Required") toothnumber = Label(root, text="Tooth Number") material = Label(root, text="Material") shade = Label(root, text="Shade") #Pack text for our form labname.grid(row=1, column=2,padx=5,pady=5) patientname.grid(row=1, column=5,padx=5,pady=5) orderdate.grid(row=2, column=5,padx=5,pady=5) date.grid(row=2,column=7,padx=5,pady=5) work.grid(row=2, column=2,padx=5,pady=5) toothnumber.grid(row=3, column=2,padx=5,pady=5) material.grid(row=4, column=2,padx=5,pady=5) shade.grid(row=5, column=2,padx=5,pady=5) # Tkinter variable for storing entries labnamevalue = StringVar() patientnamevalue = StringVar() orderdatevalue= StringVar() workvalue = StringVar() toothnumbervalue = StringVar() materialvalue = StringVar() shadevalue = StringVar() labservicevalue = IntVar() #Entries for our form labnameentry = Entry(root, width=23,textvariable=labnamevalue) patientnameentry = Entry(root,width=23, textvariable=patientnamevalue) #orderdateentry=Entry(root,textvariable=orderdatevalue) workentry =ttk.Combobox(root,width=20,textvariable=workvalue) workentry['values']=("Crown","Bridge","Onlay","Inlay","Veneer") workentry.current() #workentry = Entry(root, textvariable=workvalue) toothnumberentry =ttk.Combobox(root,width=20,textvariable=toothnumbervalue) toothnumberentry['values']=("18","17","16","15","14","13","12","11","21","22","23","24","25","26","27","28","38","37","36","35","34","33","32","31","41","42","43","44","45","46","47","48") toothnumberentry.current() materialentry =ttk.Combobox(root,width=20,textvariable=materialvalue) materialentry['values']=("PFM","Zirconia","NiCr","NiCr+Ceramic facing","EMax") materialentry.current() #materialentry = Entry(root, textvariable=materialvalue) shadeentry =ttk.Combobox(root,width=20,textvariable=shadevalue) shadeentry['values']=("A1","A2","A3","A3.5","A4","B1","B2","B3","B4","C1","C2","C3","C4","D2","D3","D4") shadeentry.current() #shadeentry = Entry(root, textvariable=shadevalue) # Packing the Entries labnameentry.grid(row=1, column=3,padx=5,pady=5) patientnameentry.grid(row=1, column=7,padx=5,pady=5) #orderdateentry.grid(row=2, column=7) workentry.grid(row=2, column=3,padx=5,pady=5) toothnumberentry.grid(row=3, column=3,padx=5,pady=5) materialentry.grid(row=4, column=3,padx=5,pady=5) shadeentry.grid(row=5, column=3,padx=5,pady=5) #Checkbox & Packing it labservice = Checkbutton(text="Want metal coping trial", variable = labservicevalue) labservice.grid(row=7, column=3) #Button & packing it and assigning it a command Button(text=" submit ", command=getvals).grid(row=13, column=3) root.mainloop()I know there is something wrong , but am unable to figure it out. Can somebody help.