我正在创建一个应用程序,用于将图像上传到指定的服务器。我在Qt Designer中创建了我的图形用户界面,一切正常,我只是卡在了我所知道的很简单的东西上。似乎不能把我的头包裹起来。卡在循环中!
这个想法是让脚本通过并查看有多少文本字段与图像路径一起提交 - 从那里获取每个路径并将每个路径上传到服务器。我可以让它只用一个盒子工作,但是当我尝试为这个过程创建一个循环时,它就会崩溃。我基本上需要返回每个不同路径的“全名”。这只是一个snippit,但你明白了......
这个概念似乎很简单,我已经改写了很多方法,我可以找到和想到。任何帮助都是极好的。我应该使用列表来做到这一点,或者什么?
# 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)
只是有关环路评论... X的值将是1和2,但从来没有3如果totalImages为3 。 – 2009-11-17 20:09:21