I'm creating with PyQt5 a program that creates wordclouds.
The program has: 1. a main window that gets the text and generate a wordcloud 2. a settings window that has 3 color options
I need to pass the user chosen color from the settings window to the main window. For that, i've created 3 classes:
class A:
def __init__(self, colormap):
self.colormap = colormap
def set_colormap(self, x):
self.colormap = x
def get_colormap(self):
return self.colormap
#in the real program this class represents the second window with the color pick options:#
class B(A):
def __init__(self):
A.__init__(self, "blue")
self.c = A("blue")
def userColorChoice(self):
userinput = input("Choose ColorMap: \n")
#in the real program there are 3 button for options instead of this input#
c.set_colormap(userinput)
And:
from test2 import B
#in the real program this represnts the class of the main window which includes the create wordcloud function:#
class C(B):
def __init__(self):
Func = B()
self.ChosenColorMap = Func.c.get_colormap()
def create_wordcloud(self):
#here i'm using the self.ChosenColorMap#
My problem is that when i use the self.ChosenColorMap in my class C it gets the default value of self.c (in this case: "blue") and not the user choice.
I think that the problem is in Func = B() in class C because whenever i call it, it initialize self.c to "blue".
How can i fix it?
Thanks
self.userColorChoice()and then look atself.get_colormap()?self.userColorChoice()is connected to a button. Whenever the user clicks on the button, the color choice changes