No code after login.go()
will be executed until the GUI is closed – calling login.go()
starts the GUI’s event loop, this is where tktiner is checking for events.
I would define the function at the top of your code, and then put the line that calls GetNews(usr)
on the line before login.go()
If the GetNews(usr)
function call takes a long time to complete (which it could, if the DB has a lot of table, lack of indexes, etc) then there might be quite a delay before the GUI shows up.
If the GetNews(usr)
function call never returns, then the GUI will never show.
You could, put the call to GetNews(usr)
into a thread, so that the GUI can start, and the function runs in the background.
Have a look here for more info: http://appjar.info/pythonThreads/
It would look something like: login.thread(GetNews, usr)
NB. updating the GUI from a thread is risky. You would be safer putting all of the GUI updates into thread safe calls, e.g. login.queueFunction(home.updateLabel, "l1", "new label text")
1
solved SQL and calling a function