Python Forum
[Tkinter] Two text files in Text widget (python 3)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Two text files in Text widget (python 3)
#1
Hi;
I'm trying to display the contents of 02 text files in a Tkinter (Text) widget, but I didn'tt arrived.
File contents (loc1.txt):

Quote:21/06/18 -0.7
22/06/18 -0.5
06/07/18 -0.7
13/07/18 -0.6
20/07/18 -0.3
27/07/18 -0.5
10/08/18 -1.2
17/08/18 -0.5
24/08/18 -0.3
21/09/18 -0.2
28/09/18 -0.4
17/10/18 -0.1

Content of the second text file (loc2.txt):

Quote:21/06/18 -0.7
22/06/18 -0.5
06/07/18 -0.8
13/07/18 -0.7
20/07/18 -0.3
27/07/18 -0.7
10/08/18 -1.0
17/08/18 -0.5
24/08/18 -0.3
21/09/18 -0.2
28/09/18 -0.5
17/10/18 -0.3

Here is the code I made to display the contents of a text file:

sous_generalites=Frame(generalites,bg='powder blue')
sous_generalites.pack(side=BOTTOM)
 
s_generalites= Scrollbar(sous_generalites)
T_generalites= Text(sous_generalites,bg='powder blue',width=750,height=550,font=('arial',14,'bold'),padx=20)
 
s_generalites.pack(side=RIGHT, fill=Y)
T_generalites.pack(side=LEFT, fill=Y)
s_generalites.config(command=T_generalites.yview)
T_generalites.config(yscrollcommand=s_generalites.set)
 
filename =('archives/loc1.txt')
fichier = open(filename, "r")
content_generalites= fichier.read()
fichier.close()
 
T_generalites.insert(END, content_generalites)
Each of the two files has two columns (the first column is the same for both files, it represents the date)
here is the image of the desired concept:
[Image: p5pt.jpg]

thanks or help
Reply


Messages In This Thread
Two text files in Text widget (python 3) - by atlass218 - Nov-04-2018, 07:35 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] Populate QComboBox with "text" and "userData" from database. carecavoador 0 133 Jun-19-2024, 02:01 PM
Last Post: carecavoador
  update text variable on label with keypress knoxvilles_joker 5 5,652 May-31-2024, 02:09 PM
Last Post: menator01
  Button to +1 in text box everytime it's clicked martyloo 1 638 May-01-2024, 02:32 PM
Last Post: Axel_Erfurt
  Transparent window background, but not text on it muzicman0 7 3,411 Feb-02-2024, 01:28 AM
Last Post: Joically
  [Kivy] Create a function to store text fields and drop downs selection in KivyMD floxia 0 1,842 Dec-18-2022, 04:34 AM
Last Post: floxia
  [Tkinter] Updating tkinter text BliepMonster 5 6,885 Nov-28-2022, 01:42 AM
Last Post: deanhystad
  Can't change the colour of Tk button text Pilover 6 15,554 Nov-15-2022, 10:11 PM
Last Post: woooee
  [PyQt] QLineEdit Caret (Text Cursor) Transparency malonn 5 3,118 Nov-04-2022, 09:04 PM
Last Post: malonn
  [PyQt] Hover over highlighted text and open popup window DrakeSoft 2 1,748 Oct-29-2022, 04:30 PM
Last Post: DrakeSoft
  [PyQt] Determine whether text in QTableView cell is fully visible or not random_nick 0 1,099 Oct-27-2022, 09:29 PM
Last Post: random_nick

Forum Jump:

User Panel Messages

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