Question

In: Computer Science

Python 3 Fix this: show the current date where the calendar field is # required library...

Python 3

Fix this: show the current date where the calendar field is

# required library
import tkinter as tk
from tkcalendar import DateEntry
import xlsxwriter

# frame
window = tk.Tk()
window.title("daily logs")
#window.resizable(0,0)
# labels
tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20)
tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20)
tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20)
tk.Label(window, text="Failed date").grid(row=3, sticky="W", pady=20, padx=20)
# entries
barcode = tk.Entry(window)
product = tk.Entry(window)
money = tk.Entry(window)
# arraging
barcode.grid(row=0, column=1)
product.grid(row=1, column=1)
money.grid(row=2, column=1)
cal = DateEntry(window, width=12, year=2019, month=6, day=22, background='darkblue', foreground='white', borderwidth=2)
cal.grid(row=3, column=1)
# callback function
def cleardate():
    barcode.delete(0, 'end')
    product.delete(0, 'end')
    money.delete(0, 'end')


# callback function
def readValue():
    excel_barcode = barcode.get()
    excel_product = product.get()
    excel_money = money.get()
    date = cal._date
    print(date)
    workbook = xlsxwriter.Workbook("dailylog.xlsx")
    worksheet = workbook.add_worksheet()
    worksheet.write("A1", "BARCODE")
    worksheet.write("B1", "MONEY")
    worksheet.write("C1", "PRODUCT")
    worksheet.write("D1", "date")
    worksheet.write("A2", excel_barcode)
    worksheet.write("B2", excel_money)
    worksheet.write("C2", excel_product)
    worksheet.write("D2", str(date))
    workbook.close()
    cleardate() #calls cleardate() function

# button to trigger actions
button = tk.Button(text="SUBMIT", command=readValue).grid(row=4, pady=20, padx=20)
button = tk.Button(text="CLEAR", command=cleardate).grid(row=4, column=1, pady=20, padx=20)
window.geometry("500x400")
window.mainloop()

Solutions

Expert Solution

I hope this is what you needed. I have written a code for this. just import date from datetime. I have also attached screenshot

code------------------------------------------------------

import tkinter as tk
from tkcalendar import Calendar, DateEntry
import xlsxwriter
from datetime import date
# frame
window = tk.Tk()
window.title("daily logs")
#window.resizable(0,0)
# labels
tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20)
tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20)
tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20)
tk.Label(window, text="Failed date").grid(row=3, sticky="W", pady=20, padx=20)
# entries
barcode = tk.Entry(window)
product = tk.Entry(window)
money = tk.Entry(window)
# arraging
barcode.grid(row=0, column=1)
product.grid(row=1, column=1)
money.grid(row=2, column=1)
today = date.today() #will give the current date
cal = DateEntry(window, width=12, year=today.year, month=today.month, day=today.day, background='darkblue', foreground='white', borderwidth=2)
cal.grid(row=3, column=1)
# callback function
def cleardate():
    barcode.delete(0, 'end')
    product.delete(0, 'end')
    money.delete(0, 'end')


# callback function
def readValue():
    excel_barcode = barcode.get()
    excel_product = product.get()
    excel_money = money.get()
    date = cal._date
    print(date)
    workbook = xlsxwriter.Workbook("dailylog.xlsx")
    worksheet = workbook.add_worksheet()
    worksheet.write("A1", "BARCODE")
    worksheet.write("B1", "MONEY")
    worksheet.write("C1", "PRODUCT")
    worksheet.write("D1", "date")
    worksheet.write("A2", excel_barcode)
    worksheet.write("B2", excel_money)
    worksheet.write("C2", excel_product)
    worksheet.write("D2", str(date))
    workbook.close()
    cleardate() #calls cleardate() function

# button to trigger actions
button = tk.Button(text="SUBMIT", command=readValue).grid(row=4, pady=20, padx=20)
button = tk.Button(text="CLEAR", command=cleardate).grid(row=4, column=1, pady=20, padx=20)
window.geometry("500x400")
window.mainloop()

Screenshots------------------------------------------------


Related Solutions

Python 3 Calendar does not showing up Fix code: # required library import tkinter as tk...
Python 3 Calendar does not showing up Fix code: # required library import tkinter as tk from tkcalendar import DateEntry import xlsxwriter # frame window = tk.Tk() window.title("daily logs") #window.resizable(0,0) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=3, sticky="W", pady=20, padx=20) # entries barcode = tk.Entry(window) product = tk.Entry(window) money = tk.Entry(window) # arraging barcode.grid(row=0, column=1) product.grid(row=1, column=1) money.grid(row=2, column=1) cal = DateEntry(window, width=12, year=2019,...
Python 3 In the field where it says failure day indicate current date if i run...
Python 3 In the field where it says failure day indicate current date if i run the program today it show todays date and if i run the program tomorrow it show me tomorrows date and so on . The program is rewriting the product everytime it gets executed i want to add new products as a list in excel # required library import tkinter as tk from tkcalendar import DateEntry import xlsxwriter # frame window = tk.Tk() window.title("daily logs")...
Python 3 In the field where it says failure day indicate current date if i run...
Python 3 In the field where it says failure day indicate current date if i run the program today it show todays date and if i run the program tomorrow it show me tomorrows date and so on . The program is rewriting the product everytime it gets executed i want to add new products as a list in excel # required library import tkinter as tk from tkcalendar import DateEntry import xlsxwriter # frame window = tk.Tk() window.title("daily logs")...
fix this code in python and show me the output. do not change the code import...
fix this code in python and show me the output. do not change the code import random #variables and constants MAX_ROLLS = 5 MAX_DICE_VAL = 6 #declare a list of roll types ROLLS_TYPES = [ "Junk" , "Pair" , "3 of a kind" , "5 of a kind" ] #set this to the value MAX_ROLLS pdice = [0,0,0,0,0] cdice = [0,0,0,0,0] #set this to the value MAX_DICE_VAL pdice = [0,0,0,0,0,0] cdice = [0,0,0,0,0,0] #INPUT - get the dice rolls i...
Python 3 Fix the code so if the user does not select a value in the...
Python 3 Fix the code so if the user does not select a value in the sold by field, it shows a warning message indicating "Choose one value" import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook window = tk.Tk() window.title("daily logs") window.grid_columnconfigure(1,weight=1) window.grid_rowconfigure(1,weight=1) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="sold by").grid(row=3, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=4, sticky="W", pady=20, padx=20) #...
In python can you fix the error in the line where it says message = input("Input...
In python can you fix the error in the line where it says message = input("Input a lowercase sentence: ") this is the error message I get after running the program and inputing a lowercase sentence Input a lowercase sentence:hello hi MM§MTraceback (most recent call last): MM§M File "client.py", line 14, in <module> MM§M message = input("Input a lowercase sentence:") MM§M File "<string>", line 1 MM§M hello hi MM§M ^ MM§MSyntaxError: unexpected EOF while parsing from socket import * #...
Python 3 Fix this: The program is rewriting the product in excel everytime it gets executed...
Python 3 Fix this: The program is rewriting the product in excel everytime it gets executed i want to make a list and add new products everytime submit button its executed # required library import tkinter as tk from tkcalendar import DateEntry import xlsxwriter # frame window = tk.Tk() window.title("daily logs") #window.resizable(0,0) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=3, sticky="W", pady=20, padx=20) # entries...
Python 3 What to fix: When i click the clear button it clears everything but not...
Python 3 What to fix: When i click the clear button it clears everything but not the sold by field import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook window = tk.Tk() window.title("daily logs") # window.resizable(0,0) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="sold by").grid(row=3, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=4, sticky="W", pady=20, padx=20) # entries barcode = tk.Entry(window) product = tk.Entry(window) money...
Python 3 Fix the code so i can make the window larger or smaller and the...
Python 3 Fix the code so i can make the window larger or smaller and the fields adjusts everytime according to the window size import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook window = tk.Tk() window.title("daily logs") # window.resizable(0,0) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="sold by").grid(row=3, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=4, sticky="W", pady=20, padx=20) # entries barcode = tk.Entry(window)...
Python 3 Fix the code so i can make the window larger and the fields increase...
Python 3 Fix the code so i can make the window larger and the fields increase size import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook window = tk.Tk() window.title("daily logs") # window.resizable(0,0) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="sold by").grid(row=3, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=4, sticky="W", pady=20, padx=20) # entries barcode = tk.Entry(window) product = tk.Entry(window) money = tk.Entry(window) #...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT