Search code examples
pythonpyqtpyqt4qfiledialog

PyQT QFileDialog - get full directory including IP of disk


I'd like to get full path of my directory, something like:

//192.168.1.23/D/test/test/aaaa/

or

//192.168.1.23/D:/test/test/aaaa/

How can I get QFileDialog to give me the IP address of the HDD that I have selected?

Currently using

self.project= str(QtGui.QFileDialog.getExistingDirectory(self,  "Select Directory", lastDir))

tried going via os.path.dirname(self.project) but that only ever goes down to D:\

Thanks!


Solution

  • Not sure where I found it but here is the option I followed at the end. I let user decide then which device to use for location

    from netifaces import interfaces, ifaddresses, AF_INET
    p =[]
    for ifaceName in interfaces():
        addresses = [i['addr'] for i in ifaddresses(ifaceName).setdefault(AF_INET, [{'addr':'No IP addr'}] )]
        p.append(ifaceName.join(addresses))   
    
    print p[0],p[1]
    print p