I am creating an app which will be used to upload images to a specified server. I have created my GUI in Qt Designer, everything works fine I just am stuck on something that I know is simple. Cant seem to wrap my head around it.
The idea is for the script to go through and see how many text fields are filed in with paths of images - from there get each path and in order upload each one to server. I can make it work with just one box just fine but when i try to create a loop for this process it falls apart. I basically need to return 'fullname' with each different path. This is just a snippit but you get the idea..
The concept seems simple enough and I have rewritten this as many ways and I could find and think of. Any help would be awesome. Should I be using lists to do this instead or something?
# count how many images there are going to be
if not self.imgOnePathLabel.text().isEmpty():
totalImages = 1
# gets the path from IMAGE 1 box
image1 = self.imgOnePathLabel.text()
fullname = '%s' % image1
if not self.imgTwoPathLabel.text().isEmpty():
totalImages = 2
image2 = self.img2PathLabel.text()
fullname = '%s' % image2
if not self.imgThreePathLabel.text().isEmpty():
totalImages = 3
imageThreePath = self.imgThreePathLabel.text()
fullname = '%s' % imageThreePath
try:
for x in range(1,totalImages,1):
# split end file from the file path
name = os.path.split(fullname)[1]
f = open(fullname, "rb")
# store our selected file
ftp.storbinary('STOR ' + name, f)
msg = "Sent <font color=green>" + name + "</font>"
self.logBrowser.append(msg)
f.close()
finally:
msg = "<font color=green>" "Ok" "</font>"
self.logBrowser.append(msg)