PDA

View Full Version : Problems with directory display



salik89
28th January 2014, 12:57
Hi all, I am encountering a problem with directories-reading. It is able to read it but it is not displaying correctly.
Like it is reading from Source A but it displays the item from Source B instead of A

When user types executes the program, it will display 2 ListWidgets respectively - refItemList and jobItemList, depending on what the user types in the LineEdit
For example, if the user types testItemA, and hits the ShowItems button, it will displays all the folders only (test01 etc)
I have placed an example output in the code below, hopefully it makes sense


''' Directory for users to compare refList folders to '''
jobList = os.listdir("/u/ykt/Desktop/test/testItemA")
# ['test01', 'test02', 'test03', 'test04', 'test05']

''' Directory that users access and compare it to jobList folders '''
refList = os.listdir("/user_data/testItemEx")
#['test01', 'test02', 'test03', 'format01', 'format02.py', 'test.py']

refItems = []
for item in jobList:
if item in refList:
refItems.append(item)

# Output in refList: ['test01', 'test02', 'test03']
# Output in jobList: ['test01', 'test02', 'test03', 'test04', 'test05']

''' Adding the items into the listWidgets '''
self.jobItemList.addItems(jobList)
self.refItemList.addItems(refItems)

''' So that there can only be one selection between the 2 Lists '''
self.itemsDict = {}
self.itemsDict[self.refItemList] = self.jobItemList
self.itemsDict[self.jobItemList] = self.refItemList

self.refItemList.clicked.connect(self.listSelect)
self.jobItemList.clicked.connect(self.listSelect)

def listSelect(self):
self.shotsDict[self.sender()].clearSelection()

But as there are some parts that I am using my school in-house modules to write on, I am encountering the problem where as I am printing out the item selected, it retains from the previous selection.

For example, in test01, it contains itemD, itemE, itemF; test02 contains itemG, itemH, itemI
It happens when I retype in the LineEdit to test02 (therefore reading test02 items in the jobList), and as I print it out, it is actually printing as 'test01, itemD' instead of 'test01, itemG'

Are there anyways for me to force item read according to the jobList?
I hope I am making sense here

ChrisW67
28th January 2014, 22:17
For example, in test01, it contains itemD, itemE, itemF; test02 contains itemG, itemH, itemI
It happens when I retype in the LineEdit to test02 (therefore reading test02 items in the jobList), and as I print it out, it is actually printing as 'test01, itemD' instead of 'test01, itemG'

Are there anyways for me to force item read according to the jobList?
I hope I am making sense here
No. What is "it" in "It happens"?
Nothing in your code has anything to do with reading or outputting the content of a file. Nothing shows uses of a QLineEdit.