python - SOS - Print values from one class to another -


import sys  pyqt5.qtwidgets import qwidget, qlabel, qapplication,qlcdnumber, qvboxlayout pyqt5.qtcore import (qcoreapplication, qobject, qrunnable, qthread, qthreadpool, pyqtsignal) pyqt5 import qtgui import time  class scoreboard(qwidget):     def __init__(self):         super().__init__()         self.initui()      def initui(self):         scorelcd = qlcdnumber(self)         scorelcd.display(x) #how grab values in x below display here          self.setgeometry(10, 50, 100, 100)         self.setwindowtitle('timer')         self.show()  class countup(qthread):     def run(self):           x = 0          while 1:             x = x + 1             time.sleep(1)             print (x) #i want value in x printed in gui above   def counter():     app = qapplication(sys.argv)     ex = scoreboard()      thread = countup()     thread.finished.connect(app.exit)     thread.start()      sys.exit(app.exec_())   if __name__ == '__main__':     counter() 

i have 2 different classes countup runs while loop , scoreboard displays numbers. i'm trying print values in x countup class scoreboard class such:

scorelcd.display(x) 

which give me error x not defined. cause i'm trying values class altogether.

so question how access values of x class scoreboard

enter image description here

just picture,you can make native variable in parent class

1.define function can return value,just set_value in x

2.define class includes class x,such y

3.cause x parent of y,so can directly use x's function


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -