简体   繁体   中英

Problem with tkinter lines of text disappearing on raspberry pi

I wrote a small program that displays the train arrival times by my house. It updates every seven seconds. The program runs great on my computer (macOS), but on pi (raspbian) the lines displaying the trains flash and then disappear in a weird pattern. For example, for the first two rotations, all the trains display perfectly. Then on the second rotation, the station name will flash and then disappear. Then on the third rotation, the title and the first five trains will disappear. Then on the fourth rotation the cycle will start again. The program is written in Python with tkinter. I know it's not a monitor issue like the monitor itself blacking out because the monitor has no problems when the program isn't running. I will link videos of the program running on my laptop and on the pi below.

The logic of how the lines disappear (paraphrased):

while True:
    line = requests.get(api)
    line.pack()
    window.update()
    line.after(7, line.destroy())
    time.sleep(7)

Then the API is called again and new lines populate.

Please help, I have been stuck on this for months.

Program running on raspbian:

https://vimeo.com/731101731

Program running normally on laptop:

https://vimeo.com/731102051

I changed

line.after(7, line.destroy())

to

line.after(7, line.destroy)

so the destroy() function is not called immediately as described by @bryan-oakley in the comments

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM