0

I am creating a Python program to generate a returns report. I have created a simple GUI for my program that allows the user to select the categories they would like to run the report for. The only issue is that in the GUI, each selection has (' ',) format. I was wondering how I could remove these from the options so it displays only the words? I have attached a screenshot of the GUI and the code for the GUI is below.

cat_SQL = "SELECT DISTINCT Inventory.Category FROM Inventory"
cursor.execute(cat_SQL)
result = cursor.fetchall()
final_result = [list(i) for i in result]
string_result = [tuple(map(str, eachTuple)) for eachTuple in final_result]
text = "Select Category(ies): "
title = 'Returns Summary'
choices = string_result
cat_output = multchoicebox(text, title, choices)

GUI Screenshot

cn_code
  • 3
  • 3
  • 2
    Do you know what ``tuple(map(str, eachTuple))`` does in your code? – Mike Scotty Mar 16 '22 at 13:51
  • 1
    It would be better to stop converting tuples to strings than to try to remove tuple formatting from an existing string. – chepner Mar 16 '22 at 13:52
  • I have tried just passing choices = final_result but that formats the options as [u' '] – cn_code Mar 16 '22 at 13:55
  • Please, avoid [posting images of text](https://unix.meta.stackexchange.com/questions/4086/psa-please-dont-post-images-of-text). It is a better practice to transcribe them instead. – accdias Mar 16 '22 at 13:55
  • Line 5 (which MikeScotty mentioned) converts your map objects to tuples. By using `''.join()` you can return strings instead. – white Mar 16 '22 at 13:57

0 Answers0