refreshText widget in tkinter
I try to create an update of my text widget in tkinter .
def affichage_update ():
with open('archives/monitor1_loc35L.txt') as monitor1, open('archives/monitor2_loc35L.txt') as monitor2:
s= Scrollbar(generalites)
T= Text(generalites,bg='powder blue',width=450,height=350,font=('arial',14,'bold'))
s.pack(side=RIGHT, fill=Y)
T.pack(side=LEFT, fill=Y)
s.config(command=T.yview)
T.config(yscrollcommand=s.set)
while True:
line1 = monitor1.readline()
if len(line1) == 0:
break
line1 = line1.strip().split()
line2 = monitor2.readline()
line2 = line2.strip().split()
T.insert(END, f'{line1[0]:15}t {line1[1]:10}tt {line2[1]:10}n')
T.after(1000, affichage_update)
affichage_update()
I would like help to find a solution to the automatic update of the content of my Text widget for example every 1 second
thanks
python tkinter
|
show 7 more comments
I try to create an update of my text widget in tkinter .
def affichage_update ():
with open('archives/monitor1_loc35L.txt') as monitor1, open('archives/monitor2_loc35L.txt') as monitor2:
s= Scrollbar(generalites)
T= Text(generalites,bg='powder blue',width=450,height=350,font=('arial',14,'bold'))
s.pack(side=RIGHT, fill=Y)
T.pack(side=LEFT, fill=Y)
s.config(command=T.yview)
T.config(yscrollcommand=s.set)
while True:
line1 = monitor1.readline()
if len(line1) == 0:
break
line1 = line1.strip().split()
line2 = monitor2.readline()
line2 = line2.strip().split()
T.insert(END, f'{line1[0]:15}t {line1[1]:10}tt {line2[1]:10}n')
T.after(1000, affichage_update)
affichage_update()
I would like help to find a solution to the automatic update of the content of my Text widget for example every 1 second
thanks
python tkinter
1
For automatically updating text box or any filed for that matter you should look intoafter()
. It is the built in method from tkinter that is used for timed events.
– Mike - SMT
Nov 20 '18 at 13:04
it's wrote in the code , but the content of the text is refreshed one first ime and not every second
– atlass218
Nov 21 '18 at 8:56
You will need to add anafter
statement inside of your function so the function calls itself at a regular interval.
– Mike - SMT
Nov 21 '18 at 15:39
this line do what you tell I think :T_generalites_loc35L_axe_bottom_loc35L.after(1000, affichage_ddm_axe_loc35L_update)
– atlass218
Nov 21 '18 at 21:47
Try this instead:generalites_bottom_loc35L.after(1000, affichage_ddm_axe_loc35L_update ()
. You will also need to do the text creation and placement outside of the function and then do updates on the text only inside the function.
– Mike - SMT
Nov 21 '18 at 21:53
|
show 7 more comments
I try to create an update of my text widget in tkinter .
def affichage_update ():
with open('archives/monitor1_loc35L.txt') as monitor1, open('archives/monitor2_loc35L.txt') as monitor2:
s= Scrollbar(generalites)
T= Text(generalites,bg='powder blue',width=450,height=350,font=('arial',14,'bold'))
s.pack(side=RIGHT, fill=Y)
T.pack(side=LEFT, fill=Y)
s.config(command=T.yview)
T.config(yscrollcommand=s.set)
while True:
line1 = monitor1.readline()
if len(line1) == 0:
break
line1 = line1.strip().split()
line2 = monitor2.readline()
line2 = line2.strip().split()
T.insert(END, f'{line1[0]:15}t {line1[1]:10}tt {line2[1]:10}n')
T.after(1000, affichage_update)
affichage_update()
I would like help to find a solution to the automatic update of the content of my Text widget for example every 1 second
thanks
python tkinter
I try to create an update of my text widget in tkinter .
def affichage_update ():
with open('archives/monitor1_loc35L.txt') as monitor1, open('archives/monitor2_loc35L.txt') as monitor2:
s= Scrollbar(generalites)
T= Text(generalites,bg='powder blue',width=450,height=350,font=('arial',14,'bold'))
s.pack(side=RIGHT, fill=Y)
T.pack(side=LEFT, fill=Y)
s.config(command=T.yview)
T.config(yscrollcommand=s.set)
while True:
line1 = monitor1.readline()
if len(line1) == 0:
break
line1 = line1.strip().split()
line2 = monitor2.readline()
line2 = line2.strip().split()
T.insert(END, f'{line1[0]:15}t {line1[1]:10}tt {line2[1]:10}n')
T.after(1000, affichage_update)
affichage_update()
I would like help to find a solution to the automatic update of the content of my Text widget for example every 1 second
thanks
python tkinter
python tkinter
edited Nov 22 '18 at 5:57
atlass218
asked Nov 20 '18 at 11:16
atlass218atlass218
43
43
1
For automatically updating text box or any filed for that matter you should look intoafter()
. It is the built in method from tkinter that is used for timed events.
– Mike - SMT
Nov 20 '18 at 13:04
it's wrote in the code , but the content of the text is refreshed one first ime and not every second
– atlass218
Nov 21 '18 at 8:56
You will need to add anafter
statement inside of your function so the function calls itself at a regular interval.
– Mike - SMT
Nov 21 '18 at 15:39
this line do what you tell I think :T_generalites_loc35L_axe_bottom_loc35L.after(1000, affichage_ddm_axe_loc35L_update)
– atlass218
Nov 21 '18 at 21:47
Try this instead:generalites_bottom_loc35L.after(1000, affichage_ddm_axe_loc35L_update ()
. You will also need to do the text creation and placement outside of the function and then do updates on the text only inside the function.
– Mike - SMT
Nov 21 '18 at 21:53
|
show 7 more comments
1
For automatically updating text box or any filed for that matter you should look intoafter()
. It is the built in method from tkinter that is used for timed events.
– Mike - SMT
Nov 20 '18 at 13:04
it's wrote in the code , but the content of the text is refreshed one first ime and not every second
– atlass218
Nov 21 '18 at 8:56
You will need to add anafter
statement inside of your function so the function calls itself at a regular interval.
– Mike - SMT
Nov 21 '18 at 15:39
this line do what you tell I think :T_generalites_loc35L_axe_bottom_loc35L.after(1000, affichage_ddm_axe_loc35L_update)
– atlass218
Nov 21 '18 at 21:47
Try this instead:generalites_bottom_loc35L.after(1000, affichage_ddm_axe_loc35L_update ()
. You will also need to do the text creation and placement outside of the function and then do updates on the text only inside the function.
– Mike - SMT
Nov 21 '18 at 21:53
1
1
For automatically updating text box or any filed for that matter you should look into
after()
. It is the built in method from tkinter that is used for timed events.– Mike - SMT
Nov 20 '18 at 13:04
For automatically updating text box or any filed for that matter you should look into
after()
. It is the built in method from tkinter that is used for timed events.– Mike - SMT
Nov 20 '18 at 13:04
it's wrote in the code , but the content of the text is refreshed one first ime and not every second
– atlass218
Nov 21 '18 at 8:56
it's wrote in the code , but the content of the text is refreshed one first ime and not every second
– atlass218
Nov 21 '18 at 8:56
You will need to add an
after
statement inside of your function so the function calls itself at a regular interval.– Mike - SMT
Nov 21 '18 at 15:39
You will need to add an
after
statement inside of your function so the function calls itself at a regular interval.– Mike - SMT
Nov 21 '18 at 15:39
this line do what you tell I think :T_generalites_loc35L_axe_bottom_loc35L.after(1000, affichage_ddm_axe_loc35L_update)
– atlass218
Nov 21 '18 at 21:47
this line do what you tell I think :T_generalites_loc35L_axe_bottom_loc35L.after(1000, affichage_ddm_axe_loc35L_update)
– atlass218
Nov 21 '18 at 21:47
Try this instead:
generalites_bottom_loc35L.after(1000, affichage_ddm_axe_loc35L_update ()
. You will also need to do the text creation and placement outside of the function and then do updates on the text only inside the function.– Mike - SMT
Nov 21 '18 at 21:53
Try this instead:
generalites_bottom_loc35L.after(1000, affichage_ddm_axe_loc35L_update ()
. You will also need to do the text creation and placement outside of the function and then do updates on the text only inside the function.– Mike - SMT
Nov 21 '18 at 21:53
|
show 7 more comments
2 Answers
2
active
oldest
votes
My answer should help you 2 ways here.
To show you what a minimum example looks like.
To provide some detail on how to use
after()
.
Please in the future use a MCVE for questions. You will need your imports a root window and the minimum amount of code needed to reproduce the problem.
This example should help:
import tkinter as tk
generalites = tk.Tk()
s = tk.Scrollbar(generalites)
T = tk.Text(generalites)
s.pack(side="right", fill="y")
T.pack(side="left", fill="y")
s.config(command=T.yview)
T.config(yscrollcommand=s.set)
def affichage_update():
with open('archives/monitor1_loc35L.txt') as monitor1, open('archives/monitor2_loc35L.txt') as monitor2:
while True:
line1 = monitor1.readline()
if len(line1) == 0:
break
line1 = line1.strip().split()
line2 = monitor2.readline()
line2 = line2.strip().split()
T.insert("end", f'{line1[0]:15}t {line1[1]:10}tt {line2[1]:10}n')
T.after(1000, affichage_update)
affichage_update()
generalites.mainloop()
add a comment |
my code is so long and I have minimized it :
generalites is a tab of the notebook
so I think I can't write the last line : generalites.mainloop()
because there is'nt yet the end of my code
at the first picture, I must to write data into labelframe
add data into labelframe
and I will to recieve the informations and write it into text by textfiles
like this picture
data in Text widget
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391824%2frefreshtext-widget-in-tkinter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
My answer should help you 2 ways here.
To show you what a minimum example looks like.
To provide some detail on how to use
after()
.
Please in the future use a MCVE for questions. You will need your imports a root window and the minimum amount of code needed to reproduce the problem.
This example should help:
import tkinter as tk
generalites = tk.Tk()
s = tk.Scrollbar(generalites)
T = tk.Text(generalites)
s.pack(side="right", fill="y")
T.pack(side="left", fill="y")
s.config(command=T.yview)
T.config(yscrollcommand=s.set)
def affichage_update():
with open('archives/monitor1_loc35L.txt') as monitor1, open('archives/monitor2_loc35L.txt') as monitor2:
while True:
line1 = monitor1.readline()
if len(line1) == 0:
break
line1 = line1.strip().split()
line2 = monitor2.readline()
line2 = line2.strip().split()
T.insert("end", f'{line1[0]:15}t {line1[1]:10}tt {line2[1]:10}n')
T.after(1000, affichage_update)
affichage_update()
generalites.mainloop()
add a comment |
My answer should help you 2 ways here.
To show you what a minimum example looks like.
To provide some detail on how to use
after()
.
Please in the future use a MCVE for questions. You will need your imports a root window and the minimum amount of code needed to reproduce the problem.
This example should help:
import tkinter as tk
generalites = tk.Tk()
s = tk.Scrollbar(generalites)
T = tk.Text(generalites)
s.pack(side="right", fill="y")
T.pack(side="left", fill="y")
s.config(command=T.yview)
T.config(yscrollcommand=s.set)
def affichage_update():
with open('archives/monitor1_loc35L.txt') as monitor1, open('archives/monitor2_loc35L.txt') as monitor2:
while True:
line1 = monitor1.readline()
if len(line1) == 0:
break
line1 = line1.strip().split()
line2 = monitor2.readline()
line2 = line2.strip().split()
T.insert("end", f'{line1[0]:15}t {line1[1]:10}tt {line2[1]:10}n')
T.after(1000, affichage_update)
affichage_update()
generalites.mainloop()
add a comment |
My answer should help you 2 ways here.
To show you what a minimum example looks like.
To provide some detail on how to use
after()
.
Please in the future use a MCVE for questions. You will need your imports a root window and the minimum amount of code needed to reproduce the problem.
This example should help:
import tkinter as tk
generalites = tk.Tk()
s = tk.Scrollbar(generalites)
T = tk.Text(generalites)
s.pack(side="right", fill="y")
T.pack(side="left", fill="y")
s.config(command=T.yview)
T.config(yscrollcommand=s.set)
def affichage_update():
with open('archives/monitor1_loc35L.txt') as monitor1, open('archives/monitor2_loc35L.txt') as monitor2:
while True:
line1 = monitor1.readline()
if len(line1) == 0:
break
line1 = line1.strip().split()
line2 = monitor2.readline()
line2 = line2.strip().split()
T.insert("end", f'{line1[0]:15}t {line1[1]:10}tt {line2[1]:10}n')
T.after(1000, affichage_update)
affichage_update()
generalites.mainloop()
My answer should help you 2 ways here.
To show you what a minimum example looks like.
To provide some detail on how to use
after()
.
Please in the future use a MCVE for questions. You will need your imports a root window and the minimum amount of code needed to reproduce the problem.
This example should help:
import tkinter as tk
generalites = tk.Tk()
s = tk.Scrollbar(generalites)
T = tk.Text(generalites)
s.pack(side="right", fill="y")
T.pack(side="left", fill="y")
s.config(command=T.yview)
T.config(yscrollcommand=s.set)
def affichage_update():
with open('archives/monitor1_loc35L.txt') as monitor1, open('archives/monitor2_loc35L.txt') as monitor2:
while True:
line1 = monitor1.readline()
if len(line1) == 0:
break
line1 = line1.strip().split()
line2 = monitor2.readline()
line2 = line2.strip().split()
T.insert("end", f'{line1[0]:15}t {line1[1]:10}tt {line2[1]:10}n')
T.after(1000, affichage_update)
affichage_update()
generalites.mainloop()
answered Nov 22 '18 at 13:33


Mike - SMTMike - SMT
9,39921234
9,39921234
add a comment |
add a comment |
my code is so long and I have minimized it :
generalites is a tab of the notebook
so I think I can't write the last line : generalites.mainloop()
because there is'nt yet the end of my code
at the first picture, I must to write data into labelframe
add data into labelframe
and I will to recieve the informations and write it into text by textfiles
like this picture
data in Text widget
add a comment |
my code is so long and I have minimized it :
generalites is a tab of the notebook
so I think I can't write the last line : generalites.mainloop()
because there is'nt yet the end of my code
at the first picture, I must to write data into labelframe
add data into labelframe
and I will to recieve the informations and write it into text by textfiles
like this picture
data in Text widget
add a comment |
my code is so long and I have minimized it :
generalites is a tab of the notebook
so I think I can't write the last line : generalites.mainloop()
because there is'nt yet the end of my code
at the first picture, I must to write data into labelframe
add data into labelframe
and I will to recieve the informations and write it into text by textfiles
like this picture
data in Text widget
my code is so long and I have minimized it :
generalites is a tab of the notebook
so I think I can't write the last line : generalites.mainloop()
because there is'nt yet the end of my code
at the first picture, I must to write data into labelframe
add data into labelframe
and I will to recieve the informations and write it into text by textfiles
like this picture
data in Text widget
edited Nov 22 '18 at 20:57
answered Nov 22 '18 at 20:39
atlass218atlass218
43
43
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391824%2frefreshtext-widget-in-tkinter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
For automatically updating text box or any filed for that matter you should look into
after()
. It is the built in method from tkinter that is used for timed events.– Mike - SMT
Nov 20 '18 at 13:04
it's wrote in the code , but the content of the text is refreshed one first ime and not every second
– atlass218
Nov 21 '18 at 8:56
You will need to add an
after
statement inside of your function so the function calls itself at a regular interval.– Mike - SMT
Nov 21 '18 at 15:39
this line do what you tell I think :T_generalites_loc35L_axe_bottom_loc35L.after(1000, affichage_ddm_axe_loc35L_update)
– atlass218
Nov 21 '18 at 21:47
Try this instead:
generalites_bottom_loc35L.after(1000, affichage_ddm_axe_loc35L_update ()
. You will also need to do the text creation and placement outside of the function and then do updates on the text only inside the function.– Mike - SMT
Nov 21 '18 at 21:53