Questions tagged [mainloop]
69 questions
3
votes
2 answers
Can you call mainloop() more than once in tkinter?
What I mean by this is can you make the program open the window more than once by putting the mainloop() function in a for loop or a while loop? It would probably look something like this:
for i in range(n):
window.mainloop()
Or this if we are…

MathGeek
- 141
- 9
3
votes
1 answer
Python + Tkinter: "AttributeError"
I also have not a lot of practice with Python and have a fundamental problem of understanding the error: AttributeError: 'NoneType' object has no attribute '_root', which only appears, when I define the dec variable BEFORE defining the main window…

Lars Lindner
- 33
- 4
2
votes
2 answers
Tkinter, update widgets real time if list is modified
Let say I've a list of widgets that are generated by tkinter uisng a loop (it's customtkinter in this case but since tkinter is more well known so I think it'd be better to make an example with it), each widgets lie in the same frame with different…

V21
- 57
- 6
2
votes
0 answers
How to queue a task AFTER all widget resizing operations?
I want to query a widget's size after changing its contents. Here's a demonstration:
import tkinter as tk
win = tk.Tk()
label = tk.Label(win)
label.pack()
def callback1():
label['text'] = 'hello world'
win.after_idle(callback2)
def…

Aran-Fey
- 39,665
- 11
- 104
- 149
2
votes
1 answer
Asynchronous Soup calls
I'm working on simple extension for Gnome DE and have some trouble wrapping my head around asynchronous Soup calls and the event loop.
Here's what I have:
_httpSession = new Soup.Session();
let token = 'sometoken'
let url = 'someurl';
let _allData…

Juozas Miškinis
- 109
- 1
- 5
2
votes
2 answers
tk.mainloop() vs root.mainloop()?
I have tried to find some Q/A or article about the use of tk.mainloop() vs root.mainloop() with no success.
My question is this: Is there any difference between the 2 uses. It seams to me the correct method would be to use…

Mike - SMT
- 14,784
- 4
- 35
- 79
1
vote
1 answer
Tkinter: error main thread not in mainloop
this question has been asked many times but to be honest I don't quite understand why do I get this error "RuntimeError: main thread is not in main loop". I have the following code to read data from Serial and draw some graph with it. My problem is…

cbroggi
- 23
- 3
1
vote
1 answer
simple Tkinter program - window vanishes after clicking button - maintop problem?
Coders,
I guess I have a newbie question: my windows disappears when I click on a button. If I put in root.mainloop() as last line in the buttonClicked-function, then the program is fine - but it looks not right...what is wrong here?
import tkinter…

texpiet
- 13
- 3
1
vote
1 answer
how to pass a function with parameters to after method of tk?
I want to run a function alongside the main loop of a window. I have this code:
from tkinter import *
window = Tk()
def task():
print("hello")
window.after(1000, task)
window.after(1000, task)
window.mainloop()
This code prints "hello"…

LukasFun
- 171
- 1
- 4
- 17
1
vote
1 answer
Understanding mainloop() better
My understanding of tk.mainloop() was that it would run and handle the events of window related to the first created Tcl interpreter and .mainloop() would handle the events of the window related to the interpreter linked with the widget.…

Delrius Euphoria
- 14,910
- 3
- 15
- 46
1
vote
1 answer
Tkinter mainloop broken, messagebox keeps popping up
class StartUp():
def __init__(self):
pass
def verify(self):
username = ("s")
password = ("s")
usernameEntry = usernameVar.get()
passwordEntry = passVar.get()
start = StartUp()
…

sebtheoo
- 125
- 10
1
vote
1 answer
what is the function of window = Tk() in this program as leaving it out gives the same output
from tkinter import *
window = Tk()
sample = Label(text="some text")
sample.pack()
sample2 = Label(text="some other text")
sample2.pack()
sample.mainloop()
Whats the difference between sample.mainloop() and…

Kun.tito
- 165
- 1
- 7
1
vote
1 answer
confirm and mainloop in pyautogui, and tkinter
I am looking for the way I can use x value within Tkinter widget.
I couldn't find an appropriate answer from the web.
Any advice is appreciated.
Thanks
regarding, confirm, it returns x and print(x) works.
from pyautogui import *
def test():
…

BBiYak
- 29
- 5
1
vote
1 answer
Running every GStreamer pipeline into a separate (GLib) thread
All of the GStreamer samples are initializing GLib main thread through some form of:
loop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(loop);
As far as I understood this main loop is used for all the signals processing.
Also Bus messages are…

pvv
- 147
- 10
1
vote
1 answer
Jargon for whether a platform's UI framework provides the main loop for you?
While I was in university, I remember one of my textbooks having specific jargon to distinguish these two different API paradigms but, for the life of me, I can't remember which book it was in and Google has been no help.
APIs like Win32, Xlib, and…

ssokolow
- 14,938
- 7
- 52
- 57