2004-01-02 14:36:26 -05:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Name: wxMimeTypesManager
|
|
|
|
# Purpose: Demonstrate use of wx.MimeTypesManager, wx.FileType
|
|
|
|
#
|
|
|
|
# Author: Jeff Grimmett (grimmtoo@softhome.net), adapted from original
|
|
|
|
# .wdr-derived demo
|
|
|
|
#
|
|
|
|
# Created: 12/31/03
|
|
|
|
# RCS-ID: $Id$
|
|
|
|
# Copyright:
|
|
|
|
# Licence: wxWindows license
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
#
|
2001-10-30 01:43:54 -05:00
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
|
|
|
|
import pprint
|
|
|
|
import wx
|
|
|
|
import images
|
2001-10-30 01:43:54 -05:00
|
|
|
|
2006-01-09 16:09:57 -05:00
|
|
|
|
|
|
|
# helper function to make sure we don't convert unicode objects to strings
|
|
|
|
# or vice versa when converting lists and None values to text.
|
|
|
|
convert = str
|
|
|
|
if 'unicode' in wx.PlatformInfo:
|
|
|
|
convert = unicode
|
|
|
|
|
2001-10-30 01:43:54 -05:00
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
class MimeTypesDemoPanel(wx.Panel):
|
|
|
|
def __init__(self, parent, log):
|
|
|
|
|
|
|
|
self.log = log
|
|
|
|
|
|
|
|
wx.Panel.__init__(self, parent, -1)
|
|
|
|
|
2004-01-08 17:20:47 -05:00
|
|
|
# This will be used for all of the labels that follow (bold label)
|
|
|
|
bfont = wx.Font(
|
|
|
|
self.GetFont().GetPointSize(),
|
|
|
|
self.GetFont().GetFamily(),
|
|
|
|
self.GetFont().GetStyle(),
|
|
|
|
wx.BOLD
|
|
|
|
)
|
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
# Contains everything
|
|
|
|
tsizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
|
|
|
|
# Contains upper controls
|
|
|
|
usizer = wx.BoxSizer(wx.HORIZONTAL)
|
|
|
|
|
2004-01-08 17:20:47 -05:00
|
|
|
# Text control for ext / type entry plus label.
|
|
|
|
t = wx.StaticText(self, -1, 'Extension / MIME type: ', style = wx.ALIGN_RIGHT )
|
|
|
|
t.SetFont(bfont)
|
2004-04-07 17:25:11 -04:00
|
|
|
usizer.Add(t, 0, wx.ALL | wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL, 2)
|
2004-01-08 17:20:47 -05:00
|
|
|
|
|
|
|
self.ext = wx.TextCtrl(self, -1, value="wav", style = wx.TE_PROCESS_ENTER )
|
2004-04-22 18:57:01 -04:00
|
|
|
usizer.Add(self.ext, 0, wx.ALL | wx.ALIGN_TOP, 4)
|
2004-01-08 17:20:47 -05:00
|
|
|
self.Bind(wx.EVT_TEXT_ENTER, self.OnLookup, self.ext)
|
2004-01-02 14:36:26 -05:00
|
|
|
|
|
|
|
# Select how to look it up
|
2004-01-08 17:20:47 -05:00
|
|
|
self.useExt = wx.RadioButton(self, -1, "By extension", style = wx.RB_GROUP)
|
|
|
|
self.useMime = wx.RadioButton(self, -1, "By MIME type")
|
|
|
|
|
|
|
|
usizer.Add(self.useExt, 0, wx.ALL | wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL, 4)
|
|
|
|
usizer.Add(self.useMime, 0, wx.ALL | wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL, 4)
|
|
|
|
self.useExt.SetValue(1)
|
2004-01-02 14:36:26 -05:00
|
|
|
|
|
|
|
# Trigger a lookup (hitting ENTER in the text ctrl will do the same thing)
|
|
|
|
self.go = wx.Button(self, -1, "Go get it!")
|
2004-01-08 17:20:47 -05:00
|
|
|
usizer.Add(self.go, 0, wx.ALL | wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL, 4)
|
2004-01-02 14:36:26 -05:00
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnLookup, self.go)
|
|
|
|
|
|
|
|
# StaticBox with larger label than usual
|
|
|
|
lbox = wx.StaticBox(self, -1, 'wx.FileType')
|
|
|
|
lbox.SetFont(
|
|
|
|
wx.Font(
|
|
|
|
self.GetFont().GetPointSize() * 2,
|
|
|
|
self.GetFont().GetFamily(),
|
|
|
|
self.GetFont().GetStyle(),
|
|
|
|
wx.BOLD
|
|
|
|
))
|
|
|
|
|
|
|
|
lsizer = wx.StaticBoxSizer(lbox, wx.HORIZONTAL)
|
|
|
|
|
|
|
|
# Contains the wx.FileType info
|
|
|
|
llsizer = wx.GridBagSizer(2, 2)
|
|
|
|
llsizer.AddGrowableCol(2)
|
|
|
|
|
|
|
|
#------- Icon info
|
|
|
|
|
|
|
|
t = wx.StaticText(self, -1, 'GetIconInfo: ', style = wx.ALIGN_RIGHT )
|
|
|
|
t.SetFont(bfont)
|
|
|
|
llsizer.Add(t, (0, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2)
|
|
|
|
|
|
|
|
self.icon = wx.StaticBitmap(self, -1, images.getNoIconBitmap())
|
2004-04-22 18:57:01 -04:00
|
|
|
llsizer.Add(self.icon, (0, 1), (1, 1), wx.ALL | wx.ALIGN_CENTER, 2)
|
2004-01-02 14:36:26 -05:00
|
|
|
|
2004-04-07 17:25:11 -04:00
|
|
|
self.iconsource = wx.TextCtrl(self, -1, value="", size=(125, -1), style = wx.TE_READONLY )
|
|
|
|
llsizer.Add(self.iconsource, (0, 2), (1, 1), wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 2)
|
2004-01-02 14:36:26 -05:00
|
|
|
|
2004-04-07 17:25:11 -04:00
|
|
|
self.iconoffset = wx.TextCtrl(self, -1, value="", size=(25,-1), style = wx.TE_READONLY )
|
2004-04-22 18:57:01 -04:00
|
|
|
llsizer.Add(self.iconoffset, (0, 3), (1, 1), wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2)
|
2004-01-02 14:36:26 -05:00
|
|
|
|
|
|
|
#------- MIME Type
|
|
|
|
|
|
|
|
t = wx.StaticText(self, -1, 'GetMimeType: ', style = wx.ALIGN_RIGHT )
|
|
|
|
t.SetFont(bfont)
|
|
|
|
llsizer.Add(t, (1, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2)
|
|
|
|
|
|
|
|
self.mimetype = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY )
|
|
|
|
llsizer.Add(self.mimetype, (1, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2)
|
|
|
|
|
|
|
|
#------- MIME Types
|
|
|
|
|
|
|
|
t = wx.StaticText(self, -1, 'GetMimeTypes: ', style = wx.ALIGN_RIGHT )
|
|
|
|
t.SetFont(bfont)
|
|
|
|
llsizer.Add(t, (2, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2)
|
|
|
|
|
|
|
|
self.mimetypes = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY )
|
|
|
|
llsizer.Add(self.mimetypes, (2, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2)
|
|
|
|
|
|
|
|
#------- Extensions
|
|
|
|
|
|
|
|
t = wx.StaticText(self, -1, 'GetExtensions: ', style = wx.ALIGN_RIGHT )
|
|
|
|
t.SetFont(bfont)
|
|
|
|
llsizer.Add(t, (3, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2)
|
|
|
|
|
|
|
|
self.extensions = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY )
|
|
|
|
llsizer.Add(self.extensions, (3, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2)
|
|
|
|
|
|
|
|
#------- Description
|
2001-10-30 01:43:54 -05:00
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
t = wx.StaticText(self, -1, 'GetDescription: ', style = wx.ALIGN_RIGHT )
|
|
|
|
t.SetFont(bfont)
|
|
|
|
llsizer.Add(t, (4, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2)
|
2001-10-30 01:43:54 -05:00
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
self.description = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY)
|
|
|
|
llsizer.Add(self.description, (4, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2)
|
2001-10-30 01:43:54 -05:00
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
#------- Open command
|
2001-10-30 01:43:54 -05:00
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
t = wx.StaticText(self, -1, 'GetOpenCommand: ', style = wx.ALIGN_RIGHT )
|
|
|
|
t.SetFont(bfont)
|
|
|
|
llsizer.Add(t, (5, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2)
|
|
|
|
|
|
|
|
self.opencommand = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY )
|
|
|
|
llsizer.Add(self.opencommand, (5, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2)
|
|
|
|
|
|
|
|
#------- Print command
|
|
|
|
|
|
|
|
t = wx.StaticText(self, -1, 'GetPrintCommand: ', style = wx.ALIGN_RIGHT )
|
|
|
|
t.SetFont(bfont)
|
|
|
|
llsizer.Add(t, (6, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2)
|
|
|
|
|
|
|
|
self.printcommand = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY )
|
|
|
|
llsizer.Add(self.printcommand, (6, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2)
|
|
|
|
|
|
|
|
#------- All commands
|
|
|
|
|
|
|
|
t = wx.StaticText(self, -1, 'GetAllCommands: ', style = wx.ALIGN_RIGHT )
|
|
|
|
t.SetFont(bfont)
|
|
|
|
llsizer.Add(t, (7, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2)
|
|
|
|
|
|
|
|
self.allcommands = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY | wx.TE_DONTWRAP | wx.TE_MULTILINE )
|
|
|
|
|
|
|
|
# Set the default height to be smaller than normal (for
|
|
|
|
# multi-line) so the sizer can then expand it to whatever
|
|
|
|
# space is available
|
|
|
|
self.allcommands.SetSize((-1, 20))
|
|
|
|
|
|
|
|
llsizer.Add(self.allcommands, (7, 1), (1, 3), wx.ALL | wx.GROW | wx.ALIGN_CENTER, 2)
|
|
|
|
|
|
|
|
# Tell the sizer to expand this row as needed
|
|
|
|
llsizer.AddGrowableRow(7)
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
|
2004-01-08 17:20:47 -05:00
|
|
|
lrsizer = wx.BoxSizer(wx.VERTICAL)
|
2004-01-02 14:36:26 -05:00
|
|
|
|
|
|
|
#------- List box with known MIME types
|
2004-01-08 17:20:47 -05:00
|
|
|
|
|
|
|
t = wx.StaticText(self, -1, 'Known MIME types')
|
|
|
|
t.SetFont(bfont)
|
|
|
|
lrsizer.Add(t, 0, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 4)
|
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
self.mimelist = wx.ListBox(self, -1, choices=[], style = wx.LB_SINGLE | wx.LB_SORT)
|
2004-04-22 18:57:01 -04:00
|
|
|
lrsizer.Add(self.mimelist, 1, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER | wx.FIXED_MINSIZE, 4)
|
2004-01-02 14:36:26 -05:00
|
|
|
self.Bind(wx.EVT_LISTBOX, self.OnListbox, self.mimelist)
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
lsizer.Add(llsizer, 1, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 4)
|
|
|
|
lsizer.Add(lrsizer, 0, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 4)
|
2001-10-30 01:43:54 -05:00
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
#----------------------------------------------------------------------------
|
2001-10-30 01:43:54 -05:00
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
tsizer.Add(usizer, 0, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 4)
|
|
|
|
tsizer.Add(lsizer, 1, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 4)
|
2001-10-30 01:43:54 -05:00
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
#----------------------------------------------------------------------------
|
2001-10-30 01:43:54 -05:00
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
self.SetSizer(tsizer)
|
|
|
|
tsizer.Fit(self)
|
|
|
|
|
|
|
|
# Populate the Known MIME types list with what is in the database
|
2004-04-01 12:44:05 -05:00
|
|
|
try:
|
|
|
|
mtypes = wx.TheMimeTypesManager.EnumAllFileTypes()
|
|
|
|
except wx.PyAssertionError:
|
|
|
|
mtypes = []
|
2006-01-09 16:09:57 -05:00
|
|
|
|
|
|
|
# TODO: On wxMac, EnumAllFileTypes produces tons of dupes, which
|
|
|
|
# causes quirky behavior because the list control doesn't expect
|
|
|
|
# dupes, and simply wastes space. So remove the dupes for now,
|
|
|
|
# then remove this hack when we fix EnumAllFileTypes on Mac.
|
|
|
|
mimes = []
|
2004-01-02 14:36:26 -05:00
|
|
|
for mt in mtypes:
|
2006-01-09 16:09:57 -05:00
|
|
|
if mt not in mimes:
|
|
|
|
self.mimelist.Append(mt)
|
|
|
|
mimes.append(mt)
|
2001-10-30 01:43:54 -05:00
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
# Do a lookup of *.wav for a starting position
|
|
|
|
self.OnLookup()
|
|
|
|
|
|
|
|
# Grab the selection from the listbox, push that into
|
|
|
|
# the text box at top, select 'MIME', and then look it up.
|
2001-10-30 01:43:54 -05:00
|
|
|
def OnListbox(self, event):
|
|
|
|
mimetype = event.GetString()
|
2004-01-02 14:36:26 -05:00
|
|
|
self.ext.SetValue(mimetype)
|
2004-01-08 17:20:47 -05:00
|
|
|
self.useMime.SetValue(1)
|
2001-10-30 01:43:54 -05:00
|
|
|
self.OnLookup()
|
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
# Look up a given file extension or MIME type.
|
2001-10-30 01:43:54 -05:00
|
|
|
def OnLookup(self, event=None):
|
2004-01-02 14:36:26 -05:00
|
|
|
txt = self.ext.GetValue()
|
|
|
|
|
|
|
|
# For MIME lookups
|
2004-01-08 17:20:47 -05:00
|
|
|
if self.useMime.GetValue() == 1:
|
2004-01-02 14:36:26 -05:00
|
|
|
fileType = wx.TheMimeTypesManager.GetFileTypeFromMimeType(txt)
|
2001-10-30 01:43:54 -05:00
|
|
|
msg = "Mime type"
|
2004-01-02 14:36:26 -05:00
|
|
|
|
|
|
|
# Select the entered value in the list
|
|
|
|
if fileType:
|
|
|
|
if self.mimelist.FindString(txt) != -1:
|
|
|
|
self.mimelist.SetSelection(self.mimelist.FindString(txt))
|
|
|
|
|
|
|
|
# Must be an extension lookup
|
2001-10-30 01:43:54 -05:00
|
|
|
else:
|
2004-01-02 14:36:26 -05:00
|
|
|
fileType = wx.TheMimeTypesManager.GetFileTypeFromExtension(txt)
|
2001-10-30 01:43:54 -05:00
|
|
|
msg = "File extension"
|
2004-01-02 14:36:26 -05:00
|
|
|
|
|
|
|
# Select the entered value in the list
|
|
|
|
if fileType:
|
2006-01-09 16:09:57 -05:00
|
|
|
if self.mimelist.FindString(convert(fileType.GetMimeType())) != -1:
|
2004-01-02 14:36:26 -05:00
|
|
|
# Using CallAfter to ensure that GUI is ready before trying to
|
|
|
|
# select it (otherwise, it's selected but not visible)
|
2006-01-09 16:09:57 -05:00
|
|
|
wx.CallAfter(self.mimelist.SetSelection, self.mimelist.FindString(convert(fileType.GetMimeType())))
|
2004-01-02 14:36:26 -05:00
|
|
|
|
|
|
|
|
2001-10-30 01:43:54 -05:00
|
|
|
if fileType is None:
|
2004-01-02 14:36:26 -05:00
|
|
|
wx.MessageBox(msg + " not found.", "Oops!")
|
2001-10-30 01:43:54 -05:00
|
|
|
else:
|
|
|
|
self.Update(fileType)
|
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
# Populate the wx.FileType fields with actual values.
|
2001-10-30 01:43:54 -05:00
|
|
|
def Update(self, ft):
|
2004-01-02 14:36:26 -05:00
|
|
|
|
|
|
|
#------- Icon info
|
2001-10-30 01:43:54 -05:00
|
|
|
info = ft.GetIconInfo()
|
2004-01-02 14:36:26 -05:00
|
|
|
|
2001-10-30 01:43:54 -05:00
|
|
|
if info is None:
|
2004-01-02 14:36:26 -05:00
|
|
|
bmp = images.getNoIconBitmap()
|
|
|
|
self.icon.SetBitmap(bmp)
|
|
|
|
self.iconsource.SetValue("")
|
|
|
|
self.iconoffset.SetValue("")
|
2001-10-30 01:43:54 -05:00
|
|
|
else:
|
|
|
|
icon, file, idx = info
|
2004-01-02 14:36:26 -05:00
|
|
|
if icon.Ok():
|
|
|
|
self.icon.SetIcon(icon)
|
|
|
|
else:
|
|
|
|
bmp = images.getNoIconBitmap()
|
|
|
|
self.icon.SetBitmap(bmp)
|
|
|
|
self.iconsource.SetValue(file)
|
2006-01-09 16:09:57 -05:00
|
|
|
self.iconoffset.SetValue(convert(idx))
|
2004-01-02 14:36:26 -05:00
|
|
|
|
|
|
|
#------- MIME type
|
2006-01-09 16:09:57 -05:00
|
|
|
self.mimetype.SetValue(convert(ft.GetMimeType()))
|
2004-01-02 14:36:26 -05:00
|
|
|
#------- MIME types
|
2006-01-09 16:09:57 -05:00
|
|
|
self.mimetypes.SetValue(convert(ft.GetMimeTypes()))
|
2004-01-02 14:36:26 -05:00
|
|
|
#------- Associated extensions
|
2006-01-09 16:09:57 -05:00
|
|
|
self.extensions.SetValue(convert(ft.GetExtensions()))
|
2004-01-02 14:36:26 -05:00
|
|
|
#------- Description of file type
|
2006-01-09 16:09:57 -05:00
|
|
|
self.description.SetValue(convert(ft.GetDescription()))
|
2004-01-02 14:36:26 -05:00
|
|
|
|
|
|
|
#------- Prep a fake command line command
|
2001-11-12 19:32:39 -05:00
|
|
|
extList = ft.GetExtensions()
|
2004-01-02 14:36:26 -05:00
|
|
|
|
2001-11-12 19:32:39 -05:00
|
|
|
if extList:
|
|
|
|
ext = extList[0]
|
2006-01-09 16:09:57 -05:00
|
|
|
if len(ext) > 0 and ext[0] == ".": ext = ext[1:]
|
2001-11-12 19:32:39 -05:00
|
|
|
else:
|
|
|
|
ext = ""
|
2004-01-02 14:36:26 -05:00
|
|
|
|
2001-10-30 02:03:33 -05:00
|
|
|
filename = "SPAM" + "." + ext
|
2001-10-30 01:43:54 -05:00
|
|
|
mime = ft.GetMimeType() or ""
|
2004-01-02 14:36:26 -05:00
|
|
|
|
|
|
|
#------- OPEN command
|
2001-10-30 01:58:52 -05:00
|
|
|
cmd = ft.GetOpenCommand(filename, mime)
|
2006-01-09 16:09:57 -05:00
|
|
|
self.opencommand.SetValue(convert(cmd))
|
2001-10-30 01:43:54 -05:00
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
#------- PRINT command
|
2001-10-30 01:58:52 -05:00
|
|
|
cmd = ft.GetPrintCommand(filename, mime)
|
2006-01-09 16:09:57 -05:00
|
|
|
self.printcommand.SetValue(convert(cmd))
|
2001-10-30 01:43:54 -05:00
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
#------- All commands
|
2001-10-30 01:58:52 -05:00
|
|
|
all = ft.GetAllCommands(filename, mime)
|
2004-01-02 14:36:26 -05:00
|
|
|
|
2001-10-30 01:43:54 -05:00
|
|
|
if all is None:
|
2004-01-02 14:36:26 -05:00
|
|
|
self.allcommands.SetValue("")
|
2001-10-30 01:43:54 -05:00
|
|
|
else:
|
|
|
|
verbs, commands = all
|
|
|
|
text = pprint.pformat(map(None, verbs, commands))
|
2004-01-02 14:36:26 -05:00
|
|
|
self.allcommands.SetValue(text)
|
|
|
|
|
2001-10-30 01:43:54 -05:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
2004-01-02 14:36:26 -05:00
|
|
|
win = MimeTypesDemoPanel(nb, log)
|
2001-10-30 01:43:54 -05:00
|
|
|
return win
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
overview = """\
|
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
The <b>wx.MimeTypesManager</b> class allows the application to retrieve the
|
|
|
|
information about all known MIME types from a system-specific location and the
|
|
|
|
filename extensions to the MIME types and vice versa. After initialization the
|
|
|
|
methods <b>GetFileTypeFromMimeType()</b> and <b>GetFileTypeFromExtension()</b>
|
|
|
|
may be called: they will return a <b>wx.FileType</b> object which may be further
|
|
|
|
queried for file description, icon and other attributes.
|
2001-10-30 01:43:54 -05:00
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
A global instance of <b>wx.MimeTypesManager</b> is always available as
|
|
|
|
<b>wx.TheMimeTypesManager</b>. It is recommended to use this instance instead
|
|
|
|
of creating your own because gathering MIME information may take quite a long
|
|
|
|
on Unix systems.
|
2001-10-30 01:43:54 -05:00
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
This demo shows how to use wx.TheMimeTypesManager to list all known MIME types
|
|
|
|
and retrieve that information as a wx.FileType from either an extension or
|
|
|
|
MIME type.
|
2003-07-02 19:13:10 -04:00
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
For further information please consult the wxWindows documentation for
|
|
|
|
<b>wx.MimeTypesManager</b> and <b>wx.FileType</b>.
|
2003-07-02 19:13:10 -04:00
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
"""
|
2003-07-02 19:13:10 -04:00
|
|
|
|
2004-01-02 14:36:26 -05:00
|
|
|
#----------------------------------------------------------------------
|
2003-07-02 19:13:10 -04:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
2004-03-04 19:06:33 -05:00
|
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|