Hi all, I have been poking wx document and also google but i havent prevailed. All I need is to get all drives C, D, E etc just like my computer is. What is the trick? Thanks

Recommended Answers

All 2 Replies

Dirdialog may be what you are looking for.

import wx

class MyFrame(wx.Frame):
    '''Info abot class | Doc string'''
    def __init__(self, parent, mytitle, mysize):
        wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize)         
        
        self.SetBackgroundColour('light blue')       
        self.panel = wx.Panel(self)        
        b = wx.Button(self.panel,-1,"Create and Show a DirDialog", (50,50))
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)

    def OnButton(self, evt):        
        dlg = wx.DirDialog(self, "Choose a directory:",
                          style=wx.DD_DEFAULT_STYLE
                           #| wx.DD_DIR_MUST_EXIST
                           #| wx.DD_CHANGE_DIR
                           )        
        if dlg.ShowModal() == wx.ID_OK:
            self.log.WriteText('You selected: %s\n' % dlg.GetPath())        
        dlg.Destroy()

if __name__ == "__main__":
    app = wx.App()   
    mytitle = 'My window'  
    width = 300
    height = 200
    MyFrame(None, mytitle, (width, height)).Show()
    app.MainLoop()

Thanks Snippsat for good code but what I'm looking for is the way to get Drives without dialog just as you get files within a folder without a dialog. I want to get all available Drives and know if the drive is USB or CD or HDD
something like this:
C: HDD
D: HDD
E: CD/DVD
F: USB

Thanks for reply

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.