Question

In: Computer Science

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, month=6, day=22, background='darkblue', foreground='white', borderwidth=2)
cal.grid(row=3, column=1)


# 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()


# callback function
def cleardate():
    barcode.delete(0, 'end')
    product.delete(0, 'end')
    money.delete(0, 'end')


# 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

Follow the steps to install the missing modules xlsxwriter and tkcalendar:

These two modules are must be installed to fix the above python code

Create a python project using PyCharm IDE and save the above source code file, any_name.py

Go to File > Settings

Go to project interpreter

On the right of the window, there is a "+" mark. Click on the "+" mark as shown below.

Then, search for the xlswriter package as shown and install the package.

xls-writer package is installed as shown below

Now, install tkcalendar package using the above similar steps.

Now, xlswriter and tkcalendar packages are installed.

Run the python code:

# required library
import tkinter as tk
# xlsxwriter as alias name for xlsxwriter 
import xlsxwriter as xlsxwriter
from tkcalendar import DateEntry

# 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 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()


# callback function
def cleardate():
    barcode.delete(0, 'end')
    product.delete(0, 'end')
    money.delete(0, 'end')


# 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()

Sample Output:

Enter the below data , for date click on the date button then a month window will appear .

select any date .

Then close the window. The result is saved to excel file dailylog.xlsx


Related Solutions

Python 3 Fix the code and rovide the correct indentation Code: import tkinter as tk from...
Python 3 Fix the code and rovide the correct indentation Code: import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook from tkinter import messagebox from datetime import datetime 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) # entries barcode = tk.Entry(window) product = tk.Entry(window) money =...
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...
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) #...
Please fix all of the errors in this Python Code. import math """ A collection of...
Please fix all of the errors in this Python Code. import math """ A collection of methods for dealing with triangles specified by the length of three sides (a, b, c) If the sides cannot form a triangle,then return None for the value """ ## @TODO - add the errlog method and use wolf fencing to identify the errors in this code def validate_triangle(sides): """ This method should return True if and only if the sides form a valid triangle...
Convert from python 2 to 3 from Tkinter import * # the blueprint for a room...
Convert from python 2 to 3 from Tkinter import * # the blueprint for a room class Room(object): # the constructor def __init__(self,name,image): # rooms have a name, exits (e.g., south), exit locations (e.g., to the south is room n), # items (e.g., table), item descriptions (for each item), and grabbables (things that can # be taken and put into the inventory) self.name = name self.image = image self.exits = {} self.items = {} self.grabbables = [] # getters and...
import tkinter as tk import math window = tk.Tk() window.title("RSA Encryption/Decryption") window.geometry("500x500") #screen.configure(background="black") #functions def Modulus():...
import tkinter as tk import math window = tk.Tk() window.title("RSA Encryption/Decryption") window.geometry("500x500") #screen.configure(background="black") #functions def Modulus(): p = int(p_input1.get()) q = int(q_input1.get()) n = p*q    open_text = tk.Label(text="Keep your Messages Secure", fg = "white", bg = "blue") open_text.pack() Encryp_text = tk.Label(text="Encryption", fg="white", bg="red") Encryp_text.place(x=200, y=35) Decryp_text = tk.Label(text="Decryption", fg="white", bg="green") Decryp_text.place(x=200, y=270) p_input=tk.Label(text="Enter the value of P: ") p_input.place(x=10, y=58) p_input1=tk.Entry() p_input1.place(x = 130, y=58) q_input=tk.Label(text="Enter the value of q:") q_input.place(x=10, y=78) q_input1=tk.Entry() q_input1.place(x = 130, y=78) mod =...
Python 3 Fix the code so if the user enter the same bar code more than...
Python 3 Fix the code so if the user enter the same bar code more than three times, it shows a warning message indicating that the product was already tested 3 times and it reached the limits Code: import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook from tkinter import messagebox from datetime import datetime 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,...
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)...
Can you fix the errors in this code? package demo; /** * * */ import java.util.Scanner;...
Can you fix the errors in this code? package demo; /** * * */ import java.util.Scanner; public class Booolean0p {        public class BooleanOp {            public static void main(String[] args) {                int a = 0, b = 0 , c = 0;                Scanner kbd = new Scanner(System.in);                System.out.print("Input the first number: ");                a = kbd.nextInt();                System.out.print("Input...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT