Python Forum
Creating a calculation based on user entry
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a calculation based on user entry
#1
I am only days new to python so please bear with me.

The issue I think I am running into is that when I launch the script, python immediately gets the entry which is nothing at launch. I want to input an entry for the # of days for the rental and than get that and create a calculation so I can output the cost on the screen.

Any help would be much appreciated.

from tkinter import *

root = Tk()

#Welcome message
welcome_label = Label(root, text="Overlander Sports Rental Form")
welcome_label.grid(row=1, column=2)

#Entry line for employee name
ename = Entry(root)
ename.grid(row=2, column=2)

#Label for employee entry line
ename_label = Label(root, text="Employee Name: ")
ename_label.grid(row=2, column=1)

flname = Entry(root)
flname.grid(row=3, column=2)

flname_label = Label(root, text="Renter's Name: ")
flname_label.grid(row=3, column=1)

rental_period = Entry(root)
rental_period.grid(row=4, column=2)

rental_period_label = Label(root, text="Renting for # of days: ")
rental_period_label.grid(row=4, column=1)


def myclick():
    mylabel = Label(root, text="Saved!")
    mylabel.grid(row=5, column=3)
    test_renter = open("test_file", "w")
    test_renter.write("Employee Name: " + ename.get())
    test_renter.write("\n")
    test_renter.write("Renter's Name: " + flname.get())
    test_renter.write("\n")
    test_renter.write("Renting for: " + str(rental_period.get()) + " days")
    test_renter.write("\n")

    rental_period.get()
    print(rental_period)

    test_renter.close()


save_button = Button(root, text="Save", command=myclick, fg="blue")
save_button.grid(row=5, column=2)

root.mainloop()
Reply


Messages In This Thread
Creating a calculation based on user entry - by blakefindlay - Jan-26-2021, 06:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Randomizer script to provide options based on user and priority cubangt 10 2,498 Mar-11-2022, 07:22 PM
Last Post: cubangt
  Exit function from nested function based on user input Turtle 5 2,944 Oct-10-2021, 12:55 AM
Last Post: Turtle
  Automatic user/password entry on prompt by bash script PBOX_XS4_2001 3 2,825 May-18-2021, 06:42 PM
Last Post: Skaperen
Photo Creating column in python based on the other colums value count Bartek635 2 2,960 Apr-15-2021, 03:47 PM
Last Post: Bartek635
  Correct Language for creating a calculation tool bradkernohan 2 1,585 Nov-29-2020, 09:01 AM
Last Post: DeaD_EyE
  Loop back through loop based on user input, keeping previous changes loop made? hbkpancakes 2 2,962 Nov-21-2020, 02:35 AM
Last Post: hbkpancakes
  Creating new list based on exact regex match in original list interjectdirector 1 2,308 Mar-08-2020, 09:30 PM
Last Post: deanhystad
  Do Calculation between Rows based on Column values - Pandas Dataframe ahmedwaqas92 0 2,162 Jan-28-2020, 07:06 AM
Last Post: ahmedwaqas92
  Creating csv header from user-input list dvanommen 2 2,168 Aug-26-2019, 08:51 PM
Last Post: dvanommen
  Creating user accounts in Google Directory amankahlon 1 2,496 May-08-2018, 07:48 AM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020