GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Table of Contents
  • wx.FileSystemHandler
  • Show Source
  • index
  • modules
  • next
  • previous
  • Home
  • Gallery
  • wx

This view

  • Original page
  • New address

GeezerVison is showing docs.wxpython.org — wx.FileSystemHandler — wxPython 4.3.2 Docs

phoenix_title wx.FileSystemHandler¶

Classes derived from wx.FileSystemHandler are used to access virtual file systems.

Its public interface consists of two methods: wx.FileSystemHandler.CanOpen and wx.FileSystemHandler.OpenFile .

It provides additional protected methods to simplify the process of opening the file: GetProtocol, GetLeftLocation, GetRightLocation, GetAnchor, GetMimeTypeFromExt.

Please have a look at overview (see wx.FileSystem) if you don’t know how locations are constructed.

Also consult the list of available handlers.

Note that the handlers are shared by all instances of wx.FileSystem.


class_hierarchy Class Hierarchy¶

Inheritance diagram for class FileSystemHandler:

Inheritance diagram of FileSystemHandler


sub_classes Known Subclasses¶

wx.ArchiveFSHandler, DataSchemeFSHandler , wx.FilterFSHandler, wx.InternetFSHandler, wx.MemoryFSHandler


method_summary Methods Summary¶

__init__

Constructor.

CanOpen

Returns True if the handler is able to open this file.

FindFirst

Works like FindFirstFile .

FindNext

Returns next filename that matches parameters passed to wx.FileSystem.FindFirst .

GetAnchor

Returns the anchor if present in the location.

GetLeftLocation

Returns the left location string extracted from location.

GetMimeTypeFromExt

Returns the MIME type based on extension of location.

GetProtocol

Returns the protocol string extracted from location.

GetRightLocation

Returns the right location string extracted from location.

OpenFile

Opens the file and returns wx.FSFile pointer or nullptr if failed.


api Class API¶

class wx.FileSystemHandler(Object)¶

Possible constructors:

FileSystemHandler() -> None

Classes derived from FileSystemHandler are used to access virtual file systems.


Methods¶

__init__(self)¶

Constructor.

Return type:

None



CanOpen(self, location)¶

Returns True if the handler is able to open this file.

This function doesn’t check whether the file exists or not, it only checks if it knows the protocol. Example:

def CanOpen(self, location):

    return self.GetProtocol(location) == "http"

Must be overridden in derived handlers.

Parameters:

location (string)

Return type:

bool



FindFirst(self, wildcard, flags=0)¶

Works like FindFirstFile .

Returns the name of the first filename (within filesystem’s current path) that matches wildcard. flags may be one of FILE (only files), DIR (only directories) or 0 (both).

This method is only called if CanOpen returns True.

Parameters:
  • wildcard (string)

  • flags (int)

Return type:

str



FindNext(self)¶

Returns next filename that matches parameters passed to wx.FileSystem.FindFirst .

This method is only called if CanOpen returns True and FindFirst returned a non-empty string.

Return type:

str



static GetAnchor(location)¶

Returns the anchor if present in the location.

See wx.FSFile.GetAnchor for details.

Example:

if self.GetAnchor("index.htm#chapter2") == "chapter2":
    DoSomething()
Parameters:

location (string)

Return type:

str

Note

the anchor is NOT part of the left location.



static GetLeftLocation(location)¶

Returns the left location string extracted from location.

Example:

if self.GetLeftLocation("file:myzipfile.zip#zip:index.htm") == "file:myzipfile.zip":
    DoSomething()
Parameters:

location (string)

Return type:

str



static GetMimeTypeFromExt(location)¶

Returns the MIME type based on extension of location.

(While wx.FSFile.GetMimeType returns real MIME type - either extension-based or queried from HTTP.)

Example:

if GetMimeTypeFromExt("index.htm") == "text/html":
    wx.MessageBox("Is HTML!")
Parameters:

location (string)

Return type:

str



static GetProtocol(location)¶

Returns the protocol string extracted from location.

Example:

if self.GetProtocol("file:myzipfile.zip#zip:index.htm") == "zip":
    UnzipFile(filename)
Parameters:

location (string)

Return type:

str



static GetRightLocation(location)¶

Returns the right location string extracted from location.

Example:

if self.GetRightLocation("file:myzipfile.zip#zip:index.htm") == "index.htm":
    ReadHTML(filename)
Parameters:

location (string)

Return type:

str



OpenFile(self, fs, location)¶

Opens the file and returns wx.FSFile pointer or nullptr if failed.

Must be overridden in derived handlers.

Parameters:
  • fs (wx.FileSystem) – Parent FS (the FS from that OpenFile was called). See the ZIP handler for details of how to use it.

  • location (string) – The absolute location of file.

Return type:

wx.FSFile

© Copyright 2012-2026, The wxPython Team. Created using Sphinx 9.1.0 and the python-docs-theme.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.