嗨,我想通过 python QT 代码打开一个新窗口。目前我正在尝试 QFileialog getOpenFileName 和 getExistingDirectory 但是它们都没有按预期工作。只需使用给定的路径打开一个新窗口。
from PyQt4 import QtGui,QtCore
import sys
class OpenDir(QtGui.QMainWindow):
def __init__(self):
super(OpenDir, self).__init__()
self.openDirectory()
def openDirectory(self):
print "Hi i am openDirectory Function . I will open Directory selected "
openDirectoryDialog=QtGui.QFileDialog()
#oD=openDirectoryDialog.getOpenFileName(self,"open","C:/") # open file name
oD=openDirectoryDialog.getExistingDirectory(self,"open","C:/") #Selectes folder
if len(oD) > 0:
print "accepted"
else:
print "nothing selected"
def main():
app = QtGui.QApplication(sys.argv)
ui=OpenDir()
sys.exit(app.exec_())
#Function Main END
if __name__ == '__main__':
main()