Python Forum
[Tkinter] Tkinter Textbox only showing one character
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Tkinter Textbox only showing one character
#1
Hello,
I am writing an ID3 parser from scratch and ever since I made the change to search byte signatures matching an ID3 frame tag so it knew when to stop parsing a tag. However now it only displays the first character in the title name or artist name. The code is shown below here:
Tkinter displayed the entire song title or artist title before I had it search an entire array of ID3 signatures and search for any tag listed in the array such as TIT2 or TSSE instead of just TPE1. All tags in frame tag array shown here in section 4 https://id3.org/id3v2.3.0

I attached a picture so you can get a better idea of what it's doing (right click on it and select open in new tab):

[Image: 10d1udxCt9YuaiJQjgBMfrmcw0gINx70Q]

and here is the code to extract artist information:

def getartist(parsedFile):
    global artistName
    global ArtistInfo
    global artistArray
    global artistStartingIndex
    global nextTagCheck
    global nextTagText
    global artistsName
    artistArray = []
    for s in range(len(parsedFile)):
        if parsedFile[s] == b'T':
            if parsedFile[s + 1] == b'P':
                if parsedFile[s + 2] == b'E':
                    if parsedFile[s + 3] == b'1':
                        artistArray = []
                        artistName = ""
                        artistsName = ""
                        nextTagCheck = []
                        nextTagText = ""
                        ArtistFrameTag = s + 4
                        for i in range(ArtistFrameTag, len(parsedFile)):
                            if str(parsedFile[i].hex()) == "ff":
                                if str(parsedFile[i + 1].hex()) == "fe":
                                    artistStartingIndex = i + 2
                                    for n in range(artistStartingIndex, len(parsedFile)):
                                        if parsedFile[n] != 'b\x00':
                                            nextTagCheck.append(parsedFile[n].decode(encoding="UTF-8"))
                                            nextTagCheck.append(parsedFile[n + 1].decode(encoding="UTF-8"))
                                            nextTagCheck.append(parsedFile[n + 2].decode(encoding="UTF-8"))
                                            nextTagCheck.append(parsedFile[n + 3].decode(encoding="UTF-8"))
                                            nextTag = nextTagText.join(nextTagCheck)
                                            if nextTag in id3Tags:
                                                break
                                            nextTagCheck.clear()

                                            artistArray.append(parsedFile[n].decode(encoding="UTF-8"))
                                break
    print("Artist parsing complete, displaying artist information...")
    if artistArray:
        artistsName = artistName.join(artistArray)
        print("Artist Name:" + artistsName)
        if metadata_text_artist != 0:
            metadata_text_artist.delete(1.0, tk.END)
        metadata_text_artist.insert(tk.END, "Artist Name: " + artistsName)
    else:
        print("Format not recognized or cannot find Artist tag information")
and tkinter root mainloop and update functions are present at the end of the code:

root.deiconify()
root.after_idle(root.attributes, '-topmost', 0)
root.lift()

root.update()

metadata_text_title = tk.Text(root, height=1, width=64)
metadata_text_title.pack()

metadata_text_artist = tk.Text(root, height=1, width=64)
metadata_text_artist.pack()

openFile1 = tk.Button(root, text="Open MP3 File...", command=file1)
openFile1.pack()

compare = tk.Button(root, text="Extract", command=extract)
compare.pack()

root.mainloop()
Reply
#2
Foung the Error:

if parsedFile[n] != 'b\x00':
should be:

if parsedFile[n] != b'\x00':
The b (standing for byte) was inside the quotation marks instead of in front

Tkinter was only printing the first character in the artistArray because the second index on the array will not display because it cannot be decoded into UTF-8 string when it is (byte) b'\x00'
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  recording textbox data into a variable paul18fr 4 365 Feb-19-2024, 09:30 PM
Last Post: Axel_Erfurt
  [Tkinter] tkinter menubar not showing on mac ventura taras 1 2,043 Dec-17-2022, 02:44 PM
Last Post: Yoriz
  tkinter showing image in button rwahdan 3 5,528 Jun-16-2021, 06:08 AM
Last Post: Yoriz
  [Tkinter] Redirecting stdout to TextBox in realtime Gilush 2 9,773 Jun-06-2020, 11:05 AM
Last Post: deanhystad
  [Tkinter] Entry box not showing 2 decimal places Chuck_Norwich 3 5,627 Apr-24-2020, 05:28 PM
Last Post: deanhystad
  tkinter how to unselect text in textbox Battant 0 2,226 Feb-17-2020, 02:00 PM
Last Post: Battant
  [Tkinter] showing results in TKInter as Vertical List diegoctn 4 3,193 Jan-18-2019, 02:33 PM
Last Post: diegoctn
  [Tkinter] cannot type in textbox msteffes 2 2,956 Jul-28-2018, 04:20 AM
Last Post: msteffes
  GUI insert textbox value into a Class dimvord 0 2,225 Jul-04-2018, 06:49 PM
Last Post: dimvord
  [Tkinter] Tkinter optionmenu child menu position showing 0,0 thatguy14 2 4,592 Jun-15-2018, 10:42 AM
Last Post: thatguy14

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020