Datagrid: How do you guys display data to the grid?

There is nothing wrong with your code, it works as expected.

The missing part is in the DataGrid column settings: you need to tell each column what data to show:


I noticed that the Main server module defines the global variables OPENAI_API_KEY and client.

If you don’t have the persistent server enabled, you are always recreating those global variables, even when you don’t need it. For example when you click on “Journal Entry”, you make a server call to get the result of a database search. That search doesn’t need those globals and yet you are wasting time creating them.

If you do have the persistent server enabled on the other hand, you need to be careful because those globals may be shared across all requests from all user sessions, and may stay there and maybe over time grow to fill up the server memory.

I just mentioned this kind of problem with globals in another post earlier today: Question on data binding with Data Grid - #9 by stefano.menci


EDIT
I also noticed inconsistent names: My_Journal, saveDreams, search_dreams, date_picker_dateOfBirth, HomeTemplate, …

Inconsistently sprinkling capital letters or underscores makes the code less readable. This may not bother you today, but as you get more familiar with Python you will realize that inconsistently named objects make the code less readable.

A little advice: please look into naming conventions with Python, or just make up your own convention and try to be more consistent. Pick one convention per object type, for example ClassNames, class_instances, TableNames, table_columns, javaScriptStuff, etc.

2 Likes