I wrote this code and if i uncomment the first two comments i get the first error and if i uncomment the second two comments i get the second error but if i only open the window2 with everything uncommenented it works just fine. Though the first and the second window have nothing really to do with each other.
Code:
import tkinter as tk
import ttkbootstrap as ttk
import tkinterDnD
import sys
import pygame
import multiprocessing as mp
file = None
pygame.mixer.init()
def on_closing():
sys.exit()
def drop(event):
global file
file = event.data
window1.destroy()
def openFile():
global file
file = tk.filedialog.askopenfile(mode='r',title="Pick a file you want to open", filetypes=[("Audio Files",".mp3 .wav")])
pygame.mixer.music.load(file)
pygame.mixer.music.play(loops=0)
window1.destroy()
window1 = tkinterDnD.Tk()
window1.config(bg="#333333")
window1.title("Tmp Audio Player")
window1.geometry(str(round(window1.winfo_screenwidth() / 2)) + "x" + str(round(window1.winfo_screenheight() / 2)) + "+" + str(round(window1.winfo_screenwidth() / 4)) + "+" + str(round(window1.winfo_screenheight() / 4)))
window1.bind('\<Escape\>', lambda e: sys.exit())
tmp = ttk.Window(themename="custom")
tmp.destroy()
window1.protocol("WM_DELETE_WINDOW", on_closing)
frame = ttk.Frame(master=window1, ondrop=drop, relief="solid")
label = ttk.Label(master=frame, text="Drag and drop a file here or open one")
label.pack(fill="both", expand=True, padx=300, pady=200)
frame.place(relx=0.5, rely=0.5,anchor="center")
openFileButton = ttk.Button(master=window1,command=openFile,text="Open file", bootstyle="outline")
openFileButton.place(relx=0.5, rely=0.73, anchor="center")
window1.mainloop()
window2 = ttk.Window(themename="custom")
window2.title("Tmp Audio Player")
window2.state('zoomed')
window2.bind('\<Escape\>', lambda e: sys.exit())
#my_meter = ttk.Meter(master=window2)
#my_meter.pack()
#volume = ttk.Scale(master=window2)
#volume.pack()
label2 = ttk.Label(master=window2, text="Drag and drop a file here or open one")
label2.pack()
window2.mainloop()
First Error:
Traceback (most recent call last):
File "c:\Users\Sirius\Desktop\Tmp Audio Player.py", line 54, in <module>
my_meter = ttk.Meter(master=window2)
File "C:\Users\Sirius\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ttkbootstrap\widgets.py", line 718, in __init__
self._setup_widget()
File "C:\Users\Sirius\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ttkbootstrap\widgets.py", line 758, in _setup_widget
self._draw_base_image()
File "C:\Users\Sirius\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ttkbootstrap\widgets.py", line 862, in _draw_base_image
self._set_widget_colors()
File "C:\Users\Sirius\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ttkbootstrap\widgets.py", line 773, in _set_widget_colors
self._meterbackground = Colors.update_hsv(background, vd=-0.1)
File "C:\Users\Sirius\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ttkbootstrap\style.py", line 367, in update_hsv
r, g, b = Colors.hex_to_rgb(color)
File "C:\Users\Sirius\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ttkbootstrap\style.py", line 315, in hex_to_rgb
r, g, b = colorutils.color_to_rgb(color)
TypeError: cannot unpack non-iterable NoneType object
Second Error:
Traceback (most recent call last):
File "c:\Users\Sirius\Desktop\Tmp Audio Player.py", line 57, in <module>
volume = ttk.Scale(master=window2)
File "C:\Users\Sirius\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ttkbootstrap\style.py", line 4960, in __init__
ttkstyle = Bootstyle.update_ttk_widget_style(
File "C:\Users\Sirius\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ttkbootstrap\style.py", line 5050, in update_ttk_widget_style
builder_method(builder, widget_color)
File "C:\Users\Sirius\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ttkbootstrap\style.py", line 1710, in create_scale_style
images = self.create_scale_assets(colorname)
File "C:\Users\Sirius\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ttkbootstrap\style.py", line 1610, in create_scale_assets
size = self.scale_size(size)
File "C:\Users\Sirius\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ttkbootstrap\style.py", line 1116, in scale_size
winsys = self.style.master.tk.call("tk", "windowingsystem")
_tkinter.TclError: can't invoke "tk" command: application has been destroyed