How to access first_file.py methods (eventfilter and func_textbox_textchanged methods) from second_file.
In my first_file.py, I have a methods eventfilter and func_textbox_textchanged. Now I want to access the methods from my second File. paste my code here. nothing Will happen as desired.
first_file.py
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
class Label():
def __init__(self,textbox):
print("inside constructor")
self.tbox1 = textbox
def eventFilter(self, source,event):
print("inside event filter")
if event.type() == QEvent.KeyPress and source is self.tbox1:
if event.key() == Qt.Key_A:
pritn("Key A is pressed")
return super(label, self).eventFilter(source, event)
def func_textbox_textchanged(self,txt):
print("inside text box text changed")
print(tbox1.text())
second_file.py
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from first_file import *
class Check(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("Check Window")
self.textbox = QLineEdit(self)
self.textbox.setGeometry(100,100,300,30)
self.textbox.installEventFilter(self)
process = label(self.textbox)
self.textbox.textChanged.connect(process.func_textbox_textchanged)
def main():
myapp = QApplication(sys.argv)
mywin = Check()
mywin.show()
sys.exit(myapp.exec_())
if __name__ == '__main__':
main()