Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In drop down, how do i display default text? #193

Open
ranjit-shanker-s opened this issue Jul 11, 2023 · 1 comment
Open

In drop down, how do i display default text? #193

ranjit-shanker-s opened this issue Jul 11, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@ranjit-shanker-s
Copy link

ranjit-shanker-s commented Jul 11, 2023

I have a tksheet with a drop down on 4th column. The data on this column is from a dataframe 'df' and can be empty or non-empty.
The column should display 1, 2, 3 as choices in a drop down. However the column should also display the value from the dataframe as it's default value .
How do I display the 'df' value for each row? The syntax I have in my mind is:
sheet.create_dropdown(r = "all", c = 4, text = df.loc[row]['column_name'], values = ['1', '2', '3'])
But, how do I fetch row index for each cell , in the example below? Is there any variable that holds this value?
sheet.create_dropdown(r = "all", c = 4, text = df.loc[?????]['column_name'], values = ['1', '2', '3'])

@ragardner
Copy link
Owner

Sorry for the delay in replying,

If you're NOT concerned about a user being able to insert rows using right click and inserted rows creating cells in column 4 which do not have a drop down you can do (let me know if it doesn't work)

for row in range(sheet.total_rows()):
    sheet.create_dropdown(r = row, c = 4, text = df.loc[row]['column_name'], values = ['1', '2', '3'])

If you are conerned about cells being added to column 4 which don't have a drop down when a user right click inserts rows (if they're able to) then this is a bit of a tricky problem at the moment and one that I'm not sure I have a solution for sorry but I will get back to you if I find or create one

@ragardner ragardner added the enhancement New feature or request label Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants