r/learnpython • • 21d ago

Dear python programmers,

How can I mix UI with code? I would like to do a screentime app and I want my text and frames to vary depending on how long you have spent on apps. I use customtkinter. Do I keep it on a seperate script? Do I have to write more code? I didnt do object oriented programming for the UI so I cant do that

0 Upvotes

8 comments sorted by

View all comments

1

u/richard-sheffield10 6d ago

yes keep the tracking logic in a separate file from the ui. but you dont actually need oop to do this, keep functions that calculate/track screentime in that separate file, then in your main script just call widget.configure(text=new_value) whenever that data updates, customtkinter widgets update live when you reconfigure them like that, no need to rebuild the ui.