Question

In: Computer Science

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

options = tk.StringVar(window)
options.set("Choose one value")  # default value
soldData = tk.OptionMenu(window, options, "Peter", "John", "Mary", "Jonatan", "Steve")
soldData.grid(row=3, column=1)
cal = DateEntry(window, width=12, background='darkblue', foreground='white', borderwidth=2)
cal.grid(row=4, column=1)


def readValue():
    excel_barcode = barcode.get()
    excel_product = product.get()
    excel_money = money.get()
    excel_sold = options.get()
    date = cal._date
    print(date)
    data = [excel_barcode, excel_product, excel_money, excel_sold, date]
    workbook = load_workbook("dailylog.xlsx")
    worksheet = workbook.worksheets[0]
    worksheet.append(data)
    workbook.save("dailylog.xlsx")
    cleardate()


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=5, pady=20, padx=20)
button = tk.Button(text="CLEAR", command=cleardate).grid(row=5, column=1, pady=20, padx=20)
window.geometry("500x400")
window.mainloop()

Solutions

Expert Solution

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=80)
tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=80)
tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=80)
tk.Label(window, text="sold by").grid(row=3, sticky="W", pady=20, padx=80)
tk.Label(window, text="Failed date").grid(row=4, sticky="W", pady=20, padx=80)

# entries
barcode = tk.Entry(window)
product = tk.Entry(window)
money = tk.Entry(window)

# arraging
barcode.grid(row=0, column=1, padx=(0, 30), sticky='ew')
product.grid(row=1, column=1, padx=(0, 30), sticky='ew')
money.grid(row=2, column=1, padx=(0, 30), sticky='ew')

options = tk.StringVar(window)
options.set("Choose one value")  # default value
soldData = tk.OptionMenu(window, options, "Peter", "John", "Mary", "Jonatan", "Steve")
soldData.grid(row=3, column=1)
cal = DateEntry(window, width=12, background='darkblue', foreground='white', borderwidth=2)
cal.grid(row=4, column=1)

def readValue():
    excel_barcode = barcode.get()
    excel_product = product.get()
    excel_money = money.get()
    excel_sold = options.get()
    date = cal._date
    print(date)
    data = [excel_barcode, excel_product, excel_money, excel_sold, date]
    workbook = load_workbook("dailylog.xlsx")
    worksheet = workbook.worksheets[0]
    worksheet.append(data)
    workbook.save("dailylog.xlsx")
    cleardate()


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=5, pady=20, padx=20)
button = tk.Button(text="CLEAR", command=cleardate).grid(row=5, column=1, pady=20, padx=20)

window.geometry("500x400")
window.mainloop()
**************************************************

Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.

Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.


Related Solutions

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) #...
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 Code: 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)...
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) #...
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 code everytime i hit submit all the fields in the fomr should be...
Python 3 Fix code everytime i hit submit all the fields in the fomr should be cleaned # 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,...
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 =...
In Python: how can I fix the IsADirectoryError: [Errno 21] Is a directory: ??? this is...
In Python: how can I fix the IsADirectoryError: [Errno 21] Is a directory: ??? this is my code: #importing sqlite and pandas import sqlite3 import pandas as pd #goal print("Welcome! The goal of this assigment is to create a database to find meanings and synonyms for given phrases.") #Connecting database conn = sqlite3.connect("keilavaldez.db") #Creating cursor to remove existing specified tables cur = conn.cursor() #creating tables cur.execute("CREATE TABLE Synsets([SynsetID] INTEGER,[Definition] text)") cur.execute("CREATE TABLE Phrases([SynsetID] INTEGER,[phrase] text)") conn.commit() #opening and reading table...
JAVA: How do I fix the last "if" statement in my code so that outputs the...
JAVA: How do I fix the last "if" statement in my code so that outputs the SECOND HIGHEST/MAXIMUM GPA out of the given classes? public class app { private static Object minStudent; private static Object maxStudent; public static void main(String args[ ]) { student st1 = new student("Rebecca", "Collins", 22, 3.3); student st2 = new student("Alex", "White", 19, 2.8); student st3 = new student("Jordan", "Anderson", 22, 3.1); student[] studentArray; studentArray = new student[3]; studentArray[0] = st1; studentArray[1] = st2; studentArray[2]...
Can someone fix this code so that it can count comparison and exchange? import java.util.Arrays; class...
Can someone fix this code so that it can count comparison and exchange? import java.util.Arrays; class Main { static int comparisons; static int exchanges; // Recursive function to perform insertion sort on sub-array arr[i..n] public static void insertionSort(int[] arr, int i, int n) { int value = arr[i]; int j = i; // Find index j within the sorted subset arr[0..i-1] // where element arr[i] belongs while (j > 0 && arr[j - 1] > value) { arr[j] = arr[j...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT