I'm trying to show a json in my gui but right now it looks like this:
I want it to be properly formated. I've tried using this :
json_text = StringVar()
json_formatted = json.dumps(data, indent=4, sort_keys=True)
json_text.set(json_formatted)
It worked when I printed it but not in my gui I've also tried using:
test_json_text = Label(o_canvas_l, anchor='w', textvariable=json_text)
test_json_text.grid(column=0, row=0, sticky=W)

Messagewidget is better thanLabel. Setanchor="w"to make the text left-aligned. Unfortunately, it wraps long lines. TheTextwidget also works, and its text wrapping can be turned off. I would use something liketext = tk.Text(frame, wrap=tk.NONE) text.insert(tk.END, "before\nhello, world lorem ipsum\nafter") text.configure(state="disabled") text.pack()