Python Forum
Tkinter Listbox tab char issues - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: Tkinter Listbox tab char issues (/thread-9146.html)



Tkinter Listbox tab char issues - ashtona - Mar-23-2018

Hello, I'm writing a GUI app in tkinter. Right now I am trying to insert filenames that I have stored in an SQL database into a Listbox with a tab in front of it. However the tab seems to always show up on the end. I have tried adding a char(9) to the front of the filenames in the SQL database and also a '\t' char when I am doing the actual inserting. I am using windows 10. Has anyone else had issues with this?

Thanks in advance.


RE: Tkinter Listbox tab char issues - Barrowman - Mar-23-2018

I think you will need to post your code for anyone to help. Please make sure to use code tags to display your code correctly.


RE: Tkinter Listbox tab char issues - ashtona - Mar-26-2018

I am trying to insert a tab char in the SectionList.insert line, the problem is it seems to always end up in front of the string I am inserting.
values = self.Query("SELECT Filename FROM ShubertDocs WHERE Frame = '" + key + "' AND FrameSection = '" + element + "';")
i=0
for value in values:
    self.SectionList.insert(i, str(value[0]))
    i += 1



RE: Tkinter Listbox tab char issues - Barrowman - Mar-26-2018

In your first post you say the Tab is always at the end but in your second it's at the beginning. Which do you want it to be?
Has the data in the database got the Tabs in it or not?
If not where in the code you have shown do you think you are inserting it?
What about the rest of your code?


RE: Tkinter Listbox tab char issues - ashtona - Mar-27-2018

The tab ends up on the END when I run the GUI tool, if I do this
 #Scroll bars for listbox
self.yScroll = Scrollbar(self.window, orient=VERTICAL)
self.xScroll = Scrollbar(self.window, orient=HORIZONTAL)    
small_font = font.Font(size=15)
self.SectionList = Listbox(self.window, height=23, width=30,selectmode=MULTIPLE,yscrollcommand=self.yScroll.set,xscrollcommand=self.xScroll.set, font=small_font)

values = self.Query("SELECT Filename FROM ShubertDocs WHERE Frame = '" + key + "' AND FrameSection = '" + element + "';")
i=0
for value in values:
    self.SectionList.insert(i, '\t' + str(value[0]))
    i += 1
If I add a CHAR(9) in the database to a file it also ends up on the END of the string that I am inserting. Either way when I run the tool in my listbox, I have a tab on the end of my string not the front. Do you want to see my whole program? not sure what other parts are relevant.

Thanks, sorry for not being more clear.