]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/wxMimeTypesManager.py
Reworked how stock objects are initialized. They now have an
[wxWidgets.git] / wxPython / demo / wxMimeTypesManager.py
index 9400a5c2d570e4f8666874920e514ac56e239633..5b0227ebf042881bdd89426461a94316ae556e47 100644 (file)
@@ -1,7 +1,8 @@
 
-import pprint, string
+import pprint, string, os
 from wxPython.wx import *
 from mimetypes_wdr import *
+from Main import opj
 
 #----------------------------------------------------------------------------
 
@@ -9,17 +10,17 @@ from mimetypes_wdr import *
 
 class MimeTypesTestPanel(wxPanel):
     def __init__(self, parent, id,
-        pos = wxPyDefaultPosition, size = wxPyDefaultSize,
+        pos = wxDefaultPosition, size = wxDefaultSize,
         style = wxTAB_TRAVERSAL ):
         wxPanel.__init__(self, parent, id, pos, size, style)
 
-        MakeMimeTypesTestPanel( self, true )
+        MakeMimeTypesTestPanel( self, True )
 
         # WDR: handler declarations for MimeTypesTestPanel
         EVT_LISTBOX(self, ID_LISTBOX, self.OnListbox)
         EVT_BUTTON(self, ID_LOOKUP_BTN, self.OnLookup)
 
-        self.GetInputText().SetValue("html")
+        self.GetInputText().SetValue("wav")
         self.OnLookup()
 
         mimetypes = wxTheMimeTypesManager.EnumAllFileTypes()
@@ -33,8 +34,8 @@ class MimeTypesTestPanel(wxPanel):
     def OnListbox(self, event):
         mimetype = event.GetString()
         self.GetInputText().SetValue(mimetype)
-        self.GetMimeBtn().SetValue(TRUE)
-        self.GetExtensionBtn().SetValue(FALSE)
+        self.GetMimeBtn().SetValue(True)
+        self.GetExtensionBtn().SetValue(False)
         self.OnLookup()
 
 
@@ -75,15 +76,21 @@ class MimeTypesTestPanel(wxPanel):
         self.GetExtensionsTxt().SetValue(str(ft.GetExtensions()))
         self.GetDescriptionTxt().SetValue(str(ft.GetDescription()))
 
-        ext = ft.GetExtensions()[0]
+        extList = ft.GetExtensions()
+        if extList:
+            ext = extList[0]
+            if ext[0] == ".": ext = ext[1:]
+        else:
+            ext = ""
+        filename = "SPAM" + "." + ext
         mime = ft.GetMimeType() or ""
-        cmd = ft.GetOpenCommand("SPAM" + ext, mime)
+        cmd = ft.GetOpenCommand(filename, mime)
         self.GetOpenCmdTxt().SetValue(str(cmd))
 
-        cmd = ft.GetPrintCommand("SPAM" + ext, mime)
+        cmd = ft.GetPrintCommand(filename, mime)
         self.GetPrintCmdTxt().SetValue(str(cmd))
 
-        all = ft.GetAllCommands("SPAM" + ext, mime)
+        all = ft.GetAllCommands(filename, mime)
         if all is None:
             self.GetAllCmdsTxt().SetValue("")
         else:
@@ -95,7 +102,7 @@ class MimeTypesTestPanel(wxPanel):
     # WDR: methods for MimeTypesTestPanel
 
     def GetListbox(self):
-        return wxPyTypeCast( self.FindWindowById(ID_LISTBOX), "wxListBox" )
+        return self.FindWindowById(ID_LISTBOX)
 
     def GetIconIndexTxt(self):
         return self.FindWindowById(ID_ICON_INDEX_TXT)
@@ -158,10 +165,19 @@ overview = """\
 
 
 import mimetypes_wdr
+import images
 
 def MyBitmapsFunc( index ):
-    return wxImage( "bitmaps/noicon.png", wxBITMAP_TYPE_PNG ).ConvertToBitmap()
+    return images.getNoIconBitmap()
 
 mimetypes_wdr.MyBitmapsFunc = MyBitmapsFunc
 
 
+
+
+
+
+if __name__ == '__main__':
+    import sys,os
+    import run
+    run.main(['', os.path.basename(sys.argv[0])])