Please help with the solution to the problem:
QCoreApplication::exec: The event loop is already running.
I need to create a window with a button. When you click on the button, a new window opens with the image and the clicker module, which allows you to place labels on the image and read the coordinates of these labels.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Button,RadioButtons, CheckButtons
from PIL import Image
from mpl_point_clicker import clicker
from PIL import Image
def link(val):
fig1 = plt.figure(2)
axes1 = fig1.subplots()
width = 400
height = 300
img = Image.new( mode = "RGB", size = (width, height) )
klicker = clicker(axes1, ["1", "2", "3", "4"], markers=["x", "o", "*", "+"],colors=['red','blue','yellow','yellow'])
plt.show()
if __name__ == "__main__":
fig = plt.figure(figsize=(8, 5))
ax = fig.subplots()
plt.subplots_adjust(left = 0.35, bottom=0.1)
#---BUTTON---
ax_start_button = plt.axes([0.5,0.01,0.3, 0.05])
#xposition, yposition, width, height
start_button = Button(ax_start_button, 'Начать работу', color ='white', hovercolor = 'grey')
start_button.on_clicked(link)
plt.show()
I tried to solve it using tread - he writes that it is impossible to place the graph not in the main thread. I tried to close the figure, but the error is the same