Python Forum
Entry in textdocument
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Entry in textdocument
#1
Hello.
I've made two little script with tkinter.
In the first one, you have to enter an animal e.g. "dog" and the word dog, get's written into a textile called "new animals.txt".
Now in the second one, you have to enter an animal too. At this point, I have to problems: (Because I never did that before, and I don't know how to do it):

1. After you've entered the animal in the second script, you're clicking on a button. Now the animal get's written into a text file called "animals.txt". But I want the program to check, if the animal, also stands in "new animals.txt". If it is the case, it get's written into "animals.txt". If the animal, you've entered is not already in "newanimals.txt" not.

2. I've noticed, that if you enter an animal, e.g. dog and after that e.g. cat, the dog gets deleted and the cat is in the first line. How do I do it, that the cat, get's written into the second line, and the dog says in the first line?

Here's the part of my code, you need:

Animalcheck = StringVar()

Entry(window, textvariable=Animalcheck).grid(row=4, column=4)
ConfirmButton = Button(window, text="Confirm", command=animalcheck).grid(row=6, column=4)

def animalcheck():
        animalcheck = Animalcheck.get()
        saveanimal = open("animals.txt", "w")
        saveanimal.write(animalcheck)
That was an example of the second script. The first script looks like it, with a few changes in the document names.

Thanks for your help.

Piethon
Reply


Messages In This Thread
Entry in textdocument - by Piethon - Sep-10-2019, 02:36 PM
RE: Entry in textdocument - by Denni - Sep-10-2019, 03:53 PM
RE: Entry in textdocument - by Piethon - Sep-10-2019, 04:23 PM
RE: Entry in textdocument - by Denni - Sep-10-2019, 08:56 PM
RE: Entry in textdocument - by Axel_Erfurt - Sep-10-2019, 10:42 PM
RE: Entry in textdocument - by Piethon - Sep-11-2019, 05:46 PM
RE: Entry in textdocument - by jefsummers - Sep-11-2019, 06:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Transfer Toplevel window entry to root window entry with TKinter HBH 0 4,463 Jan-23-2020, 09:00 PM
Last Post: HBH
  [Tkinter] how to get the entry information using Entry.get() ? SamyPyth 2 3,493 Mar-18-2019, 05:36 PM
Last Post: woooee

Forum Jump:

User Panel Messages

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