Python tkinter bg wird nicht erkannt?

Hallo ich in tkinter ein kleines gui geschrieben, das ein Download anzeigen soll. Das funktioniert auch alles allerdings ist der Hintergrund vom Text nicht genau weis sondern so leicht grau. Deshalb wollte ich den bg von der Schrift umändern, was anscheinend nicht funktioniert D:

Code:

```from tkinter import *
 from tkinter.ttk import *
import time




ws=Tk()
ws.title("Open download-Test")
ws.geometry("600x300")
ws.iconbitmap("F:\Explorer\Bilder\dcqf9q5-dcb565f7-7fc6-4973-a6c1-af6a4e867717.ico")
ws.configure(bg="white")

Progress_Bar=Progressbar(master=ws,orient=HORIZONTAL,length=300)
Progress_Bar.place(x=10, y=150)

Line1 = Label(master=ws, text='You have to wait until the program is fully downloaded:',bg="white", font=('Corbel', 12, 'italic'))
Line1.place(x=10, y=10)

HMH = PhotoImage(file = r"F:\Explorer\Bilder\Screenshot_8.png")
Img1 = Label(ws, image = HMH)
Img1.place(x = 10,y = 40)

Line2 = Label(master=ws, text='download-Test', font=('Corbel', 12,"bold", 'italic'))
Line2.place(x=46, y=43)

Line3 = Label(master=ws, text='which is: Binary File(54 GB) ', font=('Corbel', 12, 'italic'))
Line3.place(x=46, y=68)

Line3 = Label(master=ws, text='from://www.Test.com ', font=('Corbel', 12, 'italic'))
Line3.place(x=46, y=88)

Line3 = Label(master=ws, text='Remaining download time:', font=('Corbel', 12))
Line3.place(x=10, y=118)

cmd1 = Label(master=ws, text='0%', font=('Corbel', 12, 'italic'))
cmd1.place(x=320, y=150)



i = 0
def Slide():
    global i
    while(i<100):
        i = i +1
        Progress_Bar['value'] = i
        ws.update_idletasks()
        time.sleep(1)
        conect = str(i) + "%"
        cmd1.config(text=conect)
    if i == 100:
        print("Finish")

Slide()

mainloop()

Und das ist die fehlermeldung:

Wenn jemand die Antwort weis würde ich mich sehr über eine Antwort freuen.

MFG. Theo

Bild zum Beitrag
programmieren, Python, Tkinter
Tkinter hängt sich auf wenn ich den Button drücke?

Hi, ich soll für die Schule in Informatik ein Verschlüsselungsprogramm schreiben. Ich habe hier die Caeser verschlüsselung genommen. Der Code hat ohne Tkinter Super Funktioniert:

def Code():
code = input("Code: ")
Verschiebung = int(input("Verschiebungsfaktor: "))
coded = "".join(chr((ord(char) + Verschiebung) % 256) for char in code)
print("Verschlüsselter Code:", coded)
def Encode():
code = input("Verschlüsselung: ")
x = int(input("Verschiebungsfaktor: "))
Verschiebung = -x
encoded = "".join(chr((ord(char) + Verschiebung) % 256) for char in code) print("Entschlüsselter Code:", encoded)

Hier ist der Code mit Tkinter:

from tkinter import *
def Code():
  code = input(b.get())
  Verschiebung = int(input(d.get()))
  coded = "".join(chr((ord(char) + Verschiebung) % 256) for char in code)
  h.config(text=coded)
def Encode():
  code = input(b.get())
  x = int(input(d.get()))
  Verschiebung = -x
  encoded = "".join(chr((ord(char) + Verschiebung) % 256) for char in code)
  h.config(text=encoded)
F = Tk()
F.title('Coding')
F.geometry('500x500')
F.config(bg='gray')
a = Label(master=F, text='Eingabe:', fg='white', bg='black', font=('Arial',16))
a.place(x=50, y=50, width=200, height=50)
b = Entry(master=F, text='', font=('Arial',16))
b.place(x=275, y=50, width=200, height=50)
c = Label(master=F, text='Schlüssel:', fg='white', bg='black', font=('Arial',16))
c.place(x=50, y=125, width=200, height=50)
d = Entry(master=F, text='', font=('Arial',16))
d.place(x=275, y=125, width=200, height=50)
e = Button(master=F, text='Verschlüsseln', fg='white', bg='black', font=('Arial',16), command=Code)
e.place(x=50, y=200, width=200, height=50)
g = Button(master=F, text='Entschlüsseln', fg='white', bg='black', font=('Arial',16), command=Encode)
g.place(x=275, y=200, width=200, height=50)
h = Label(master=F, text='', font=('Arial',16))
h.place(x=50, y=275, width=425, height=50)
F.mainloop()

Das Problem ist, das sich Tkinter aufhängt und abstürtzt wenn ich einen Button drücke

Computer, Technik, programmieren, Python, Tkinter
AttributeError: 'PhotoImage' object has no attribute 'shape'?

Ich bin derzeit dabei mit tkinter, opencv und mit Media Pipe Framework zu arbeiten. Dabei möchte ich Bilder Hochladen können und die hochgeladenen Bilder soll mithilfe von Mediapipe die Hand Landmarks erfassen. Mit Hand Landmarks meine ich alle 21 Positionen eines Hand zu erkennen (Hier findet ihr mehr Infos dazu: https://google.github.io/mediapipe/solutions/hands.html ). Leider bekomme ich mit meiner erstellten Implementierung folgende Fehlermeldung:

INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python\Python37\lib\tkinter\__init__.py", line 1705, in __call__
    return self.func(*args)
  File "C:/Users/bj/projects/pro1/pictureMp.py", line 31, in imageLandmarks
    height, width, _ = image.shape
AttributeError: 'PhotoImage' object has no attribute 'shape'

Was kann ich dagegen machen? Hier ist mein aktueller Code:

def imageLandmarks():
    global panelA
    with mpHands.Hands(static_image_mode=True, max_num_hands=2, min_detection_confidence=0.5) as hands:
        select_image.path = filedialog.askopenfilename()
        filename = os.path.basename(select_image.path)

        if len(select_image.path) > 0:
            image = cv2.imread(select_image.path)
            image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
            image = Image.fromarray(image)
            image = ImageTk.PhotoImage(image)

            height, width, _ = image.shape
            results = hands.process(image)

            num_cords = 21
            landmarks = ['class']
            for val in range(1, num_cords + 1):
                landmarks += ['x{}'.format(val), 'y{}'.format(val), 'z{}'.format(val)]

                if results.multi_hand_landmarks:
                    for num, hand in enumerate(results.multi_hand_landmarks):
                        mpDraw.draw_landmarks(image, hand, mpHands.HAND_CONNECTIONS)
programmieren, Python, opencv, Tkinter

Meistgelesene Beiträge zum Thema Tkinter