How to passing Value from a function to another class with python
<p>Here I have 2 different classes called <code>c_elementOptFrame</code> (lets call it class <code>a</code>) and <code>c_elementFigFrame</code> (and this is class <code>b</code>). In class <code>a</code>, I have radio button object, these button will change an image in which I construct with label in class <code>b</code>, in other words, I wanted to change this image when I click those radio button. The radio button has been set up with method called <code>react</code> , in this method I wanted to pass a value (string) to class <code>b</code>, so that class <code>b</code> will use this value to change the image. But it doesn't work as I expected. The value has been passed to class <code>b</code> (I printed the value) but the image doesn't come up, I tried several ways but I still couldn't do it yet. so this is my code, please let me know if you have couple of suggestions or an alternative to do it. Thank you</p>

<p>code:</p>

<pre><code>class c_elementOptFrame(QFrame):
  def __init__(self, parent=None):
    super(c_elementOptFrame,self).__init__()

    self.setVisible(True)
    self.setMaximumWidth(150)
    self.setFrameShadow(QFrame.Plain)
    self.setFrameShape(QFrame.Box)
    self.setLineWidth(1)
    self.setFrameStyle(QFrame.StyledPanel)

    #layoutmanager
    layout = QVBoxLayout()

    #all objects inside this frame
    strel_lab = QLabel("Element Types")
    strel_lab.setContentsMargins(0,0,10,10)

    group_box = QGroupBox('Structural Element') 
    opts_group = QButtonGroup()
    opts_group.setExclusive(True)

    beam_but = QRadioButton("Beams")
    slab_but = QRadioButton("Slabs")
    beam_but.toggled.connect(self.react_1)
    slab_but.toggled.connect(self.react_2)

    opts_group.addButton(beam_but)
    opts_group.addButton(slab_but)

    group_box.setLayout(layout)

    concls_lab = QLabel("Concrete Class")
    concls_lab.setContentsMargins(0,15,10,10)

    concls_opt = QComboBox()
    concls_opt.addItem("C30")
    concls_opt.addItem("C40")
    concls_opt.addItem("C50")

    mod_but = QPushButton("Modify Parameter", self)
    mod_but.clicked.connect(self.modifyParam)

    create_but = QPushButton("Create Model", self)
    create_but.setDisabled(False)
    create_but.clicked.connect(self.nextFrame)

    #add objects to layout
    layout.addWidget(strel_lab)
    layout.addWidget(beam_but)
    layout.addWidget(slab_but)
    layout.addWidget(concls_lab)
    layout.addWidget(concls_opt)
    layout.addWidget(mod_but)
    layout.addStretch()
    layout.addWidget(create_but)

    self.setLayout(layout)


  def react_1(self, enabled):
    if enabled:
        pict_path = 1
        c_elementFigFrame(pict_path)

class c_elementFigFrame(QFrame):
  def __init__(self, pict_path):
    super(c_elementFigFrame,self).__init__()

    self.setFrameShadow(QFrame.Plain)
    self.setFrameShape(QFrame.Box)
    self.setLineWidth(1)
    self.setFrameStyle(QFrame.StyledPanel)

    layout = QVBoxLayout()
    pict = QLabel('Test')
    pict.sizeHint()

    pixmap = QPixmap()

    if pict_path == 1:
        print(True)
        pixmap.load('beam.png')
        pict.setPixmap(pixmap)
    #else:    
        #pixmap = QPixmap(pict_path)
        #pict.setPixmap(pixmap)


    layout.addWidget(pict)

    self.setLayout(layout)
</code></pre>