Why "\" and "/" are mixed?
os.getcwd()
emits backslash string.
On the other hand, QFileDialog
emits forward slash string.
Why?
Example
Please execute this sample code.
from PySide import QtGui
from PySide import QtCore
import sys
import os
class DirectoryPrinter(QtGui.QWidget):
def __init__(self,parent=None):
super(DirectoryPrinter,self).__init__(parent=None)
self.filedialog_pushbutton = QtGui.QPushButton("filedialog",self)
self.connect(self.filedialog_pushbutton,QtCore.SIGNAL("clicked()"),self.filename_getter)
def filename_getter(self):
print("from os.getcwd()",os.getcwd())
filename = QtGui.QFileDialog.getOpenFileName(self,"Select your file",os.path.expanduser("~"))[0]
print("from QFileDialog",filename)
def main():
try:
QtGui.QApplication([])
except Exception as e:
print(22,e)
directoryprinter = DirectoryPrinter()
directoryprinter.show()
sys.exit(QtGui.QApplication.exec_())
if __name__ == "__main__":
main()
Result (on my occasion)
from os.getcwd()
: J:\
from QFileDialog
: C:/Users/******/setup.py