0
class botucalistirclass(QtCore.QObject):


    redmessage = QtCore.pyqtSignal(str)
    greenmessage = QtCore.pyqtSignal(str)
    yellowmessage = QtCore.pyqtSignal(str)

    def bot(self):
        
        mode = "PC"
        if mode=="PC":
            while islenen_hesap_sayisi<hesapsayisi:
                islenen_hesap_sayisi += 1
                #Selenium codes

        elif mode=="VDS":
            #Selenium codes

            self.yellowmessage.emit("Program 24 saatlik bekleme süresine girdi.")

            time.sleep(86460)





class MainPage(QMainWindow):

        def __init__(self, *args, **kwargs):
            QtWidgets.QWidget.__init__(self, *args, **kwargs)
            loadUi("agb.ui", self)
            

            islenen_hesap_sayisi = 0

            hesap_sayisi = 10

hesap_sayisi is variable, just for example 10. When start other class, i getting error. Error is "UnboundLocalError: local variable 'islenen_hesap_sayisi' referenced before assignment". I want one variable use two class. How can do this?

ggforces
  • 35
  • 3
  • Just search for the error message, there are tons of similar questions. Also, please first extract a [mcve] next time, please. Also, the full backtrace is important, you don't want people to guess where that error happens. – Ulrich Eckhardt Mar 21 '22 at 16:46
  • Simple: botucalistirclass's islenen_hesap_sayisi is different from MainPage's as both are local variables that have different scopes, I recommend reviewing that basic python concept to avoid future problems. – eyllanesc Mar 21 '22 at 16:47
  • Already i know, its different two class. I want know how to use in other class... – ggforces Mar 21 '22 at 16:49
  • @ggforces Avoid many problems and simplify your logic, is it necessary to have the same variable in different classes, and worse in different threads? Well no, why not just create it in bot?: `islenen_hesap_sayisi = 0` `mode = "PC"`. And if you want to do something with the value of the variable in the other class then use a signal to send the information. – eyllanesc Mar 21 '22 at 16:56

0 Answers0