Aug-28-2018, 09:26 AM
Actually previously i created a GUI in which all the classes are in same file. But now what i did for each class i created one one separate file. Now i'm importing each file where ever its required.
No its not using the same serial package.
In testing page, serial port is defined as
No its not using the same serial package.
In testing page, serial port is defined as
ser = serial.Serial(COM_Port, Baud_Rate) ser.isOpen()In AutomationTesting_ITOM, same serial port i'm using to send the data using the command as mentioned in function data
def data_tx(self): element = [0x4D, 0x08, 0xFF, 0x06, 0x1A, 0x52] data = bytearray(element) ser.write(data) receivedata = (ser.read(7)) data1 = binascii.b2a_hex(receivedata) data2 = ord(receivedata[6]) return data2But as ser is define in Testing.py file, when i'm trying to use same variable in AutomationTesting_ITOM its showing error
Error:Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1541, in __call__
return self.func(*args)
File "D:\PyCharm\Main_Project_75F\Separate_GUI_Class\AutomationTesting_ITOM.py", line 186, in clicked
self.txt1.insert(END, self.data_tx())
File "D:\PyCharm\Main_Project_75F\Separate_GUI_Class\AutomationTesting_ITOM.py", line 178, in data_tx
ser.write(data)
AttributeError: 'str' object has no attribute 'write'
I need any solution how to access the ser variable in AutomationTesting_ITOM page