Avoiding { in tkinter label coming from tuple

Question:

So I moved from printing my results to displaying them via a tkinter label.

ttk.Label(root, text = (‘Erlaubte Fehlergrenze zwischen’, hin1,’ und ‘, hin2,’ = ‘,fehlergrenze,’ Wir haben: ‘, fehler)).pack()

Now I have the problem that I get unwanted brackets {} seemingly coming from ”.

Example for a current output: {Erlaubte Fehlergrenze zwischen} 0100042 { und } 0100047 { = } 2.83 { Wir haben: } 2.78

I am thinking the problem here is that I am trying to display a tuple instead of a string, so I decided to convert it into a string and display it which doesnt seem too smart either.

Maybe there is an easier/better option to just avoid those brackets?

Thanks in advance.

Example for a wanted output: Erlaubte Fehlergrenze zwischen 0100042 und 0100047 = 2.83 Wir haben: 2.78

Asked By: swiss army knive

||

Answers:

Does this help? Using f-strings in Python 3.6 and later.

Code:

from tkinter import ttk
import tkinter as tk

root = tk.Tk()

hin1 = '0100042'
hin2 = '0100047'
fehlergrenze = 2.83  
fehler = 2.47
ttk.Label(root, text = f'Erlaubte Fehlergrenze zwischen {hin1 } und { hin2} = { fehlergrenze } Wir haben:{fehler}').pack()

root.mainloop()

Output image:

enter image description here

Answered By: toyota Supra
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.