0

I have a huge list l1 of almost 1074 app names in it

['10 Best Foods for You' '104 找工作 - 找工作 找打工 找兼職 履歷健檢 履歷診療室' '11st' ...
 'Hotwire Hotel & Car Rental App' 'Housing-Real Estate & Property'
 'Houzz Interior Design Ideas'] 

I want to display all the apps in the same window as below, but all of them aren't visible. enter image description here

Im getting the following error in the console:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\tkinter\__init__.py", line 1705, in __call__
    return self.func(*args)
  File "C:/Users/Samit Patil/Desktop/PlaystoreStudy Project/test_gui.py", line 496, in <lambda>
    tk.Button(frame, text='Select query', width='15', font=("Open Sans", 13, 'bold'), bg='brown', fg='white',command=lambda c=i:query(c+1)).grid(row=i,column=1,sticky=W)
  File "C:/Users/Samit Patil/Desktop/PlaystoreStudy Project/test_gui.py", line 439, in query
    populate(frame)
  File "C:/Users/Samit Patil/Desktop/PlaystoreStudy Project/test_gui.py", line 418, in populate
    tk.Label(frame, text=l1[5], width='80',anchor=W,relief=GROOVE, height="4", font=("Calibri", 10, 'bold'), fg='black', bg='Green',wraplength=500).grid(row=i,column=0,sticky=W)
  File "C:\ProgramData\Anaconda3\lib\tkinter\__init__.py", line 2766, in __init__
    Widget.__init__(self, master, 'label', cnf, kw)
  File "C:\ProgramData\Anaconda3\lib\tkinter\__init__.py", line 2299, in __init__
    (widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: character U+1f602 is above the range (U+0000-U+FFFF) allowed by Tcl

My code:

        qy14apps = Toplevel(screen2)
        qy14apps.title("Select one app")
        adjustWindow(qy14apps) # configuring the window
        l1=list_apps()
        print (len(l1))
        def onFrameConfigure(canvas):

            canvas.configure(scrollregion=canvas.bbox("all"))

        def populate(frame):

            for i in range(len(l1)):
                tk.Label(frame, text=l1[i], width='80',anchor=W,relief=GROOVE, height="4", font=("Calibri", 10, 'bold'), fg='black', bg='Green',wraplength=500).grid(row=i,column=0,sticky=W)
                #l2=Label(text="\n", bg='white')
                #l2.grid(row=i+1,column=0)
                tk.Button(frame, text='Select app', width='15', font=("Open Sans", 13, 'bold'), bg='brown', fg='white',command="").grid(row=i,column=1,sticky=W)

        canvas = tk.Canvas(qy14apps, borderwidth=0, background="#ffffff")
        frame = tk.Frame(canvas, background="#ffffff")
        vsb = tk.Scrollbar(qy14apps, orient="vertical", command=canvas.yview)
        canvas.configure(yscrollcommand=vsb.set)

        vsb.pack(side="right", fill="y")
        canvas.pack(side="left", fill="both", expand=True)
        canvas.create_window((4,4), window=frame, anchor="nw")

        frame.bind("<Configure>", lambda event, canvas=canvas: onFrameConfigure(canvas))
        populate(frame)

I dont understand where im going wrong, is it because the list is too huge? I have applied the same concept for a list of 20 elements and it worked then. Any help would be highly appreciable. Thanks.

Aditya Patil
  • 123
  • 1
  • 1
  • 9
  • It's likely you hit a [maximum-canvas-size-for-extremely-large-images](https://stackoverflow.com/questions/50244202/how-can-i-increase-tkinter-maximum-canvas-size-for-extremely-large-images) – stovfl Jan 06 '20 at 20:07
  • 1
    You are likely to run into problems with a list that tall, but the specific error you're getting is something entirely different: basically, Tkinter's (or maybe Tk's) Unicode handling is profoundly broken. Possible solutions here: https://stackoverflow.com/questions/40222971/python-find-equivalent-surrogate-pair-from-non-bmp-unicode-char – jasonharper Jan 06 '20 at 20:33

1 Answers1

-2

I would rather insert that amount of data into a listbox and link the button to a function that retrieves the selected list item via your listbox variable

listboxvariablename.curselection()

To remove the curly braces you might get around each listbox entry, loop over the list before inserting it into the listbox and refer to the entry by it's index. That will strip out the curly braces while inserting the entries into the listbox.

M Laing
  • 52
  • 5
  • 2
    This doesn't address the actual error, which will occur even if you use a listbox. (`character U+1f602 is above the range (U+0000-U+FFFF) allowed by Tcl`) – Bryan Oakley Jan 06 '20 at 21:26