mcplatform module

Copyright (c) 2010-2012 David Rio Vierra

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

class mcplatform.BaseWindowHandler(*args, **kwargs)[source]

Abstract class for the platform specific window handlers. If initialized, this class casts a NotImplementedError.

desk_env = 'windows'
flush()[source]

Just does nothing...

get_position()[source]

...

get_root_rect()[source]

...

get_size()[source]

...

get_state()[source]

...

set_mode(size, mode)[source]

Wrapper for pygame.display.set_mode().

set_position(pos, update=True)[source]

...

set_size(size, update=True)[source]

...

set_state(state=1, size=(-1, -1), pos=(-1, -1), update=True)[source]

...

sync()[source]

Just does nothing...

mcplatform.OSXVersionChecker(name, compare)[source]

Rediculously complicated function to compare current System version to inputted version.

class mcplatform.WWindowHandler(pos=(0, 0), size=(0, 0), mode=None)[source]

Bases: mcplatform.BaseWindowHandler

Object to deal with Microsoft Window managers.

desk_env = 'windows'
get_position()[source]

Return the window actual position as a tuple.

get_root_rect()[source]

Return a four values tuple containing the position and size of the very first OS window object.

get_size()[source]

Return the window actual size as a tuple (width, height).

get_state()[source]

Return wheter the window is maximized or not, or minimized or full screen.

set_mode(size, mode)[source]

Wrapper for pygame.display.set_mode().

set_position(pos, update=True)[source]

Set the window position. :pos: list or tuple: the new position (x, y).

set_size(size, update=True)[source]

Set the window size. :size: list or tuple: the new size. :mode: bool: (re)set the pygame.display mode; self.mode must be a pygame display mode object. Raises a TypeError if something else than a list or a tuple is sent.

set_state(state=1, size=(-1, -1), pos=(-1, -1), update=True)[source]

Set wheter the window is maximized or not, or minimized or full screen. If no argument is given, assume the state will be windowed and not maximized. If arguments are given, only the first is relevant. The other ones are ignored.

** Only maximized and normal states are implemented for now. **

State:valid arguments:

‘minimized’, MINIMIZED, 0. ‘normal’, NORMAL, 1: windowed, not maximized. ‘maximized’, MAXIMIZED, 2. ‘fullscreen, FULLSCREEN, 3.

Size:list, tuple: the new size; if (-1, -1) self.get_size() is used. If one element is -1 it is replaced by the corresponding valur from self.get_size().
Pos:list, tuple: the new position; if (-1, -1), self.get_position is used. If one element is -1 it is replaced by the corresponding valur from self.get_position().
Update:bool: whether to call the internal flush method.
mcplatform.WindowHandler

alias of WWindowHandler

class mcplatform.XWindowHandler(pos=(0, 0), size=(0, 0), mode=None)[source]

Bases: mcplatform.BaseWindowHandler

Object to deal with XWindow managers (Linux).

desk_env = 'windows'
flush()[source]

Wrapper around Xlib.Display.flush()

get_position()[source]

Return the window actual position as a tuple.

get_root_rect()[source]

Return a four values tuple containing the position and size of the very first OS window object.

get_size()[source]

Return the window actual size as a tuple (width, height).

get_state()[source]

Return wheter the window is maximized or not, or minimized or full screen.

set_position(pos, update=True)[source]

Set the window position. :pos: list or tuple: the new position (x, y). :update: bool: wheteher to call the internal sync method.

set_size(size, update=True)[source]

Set the window size. :size: list or tuple: the new size. Raises a TypeError if something else than a list or a tuple is sent.

set_state(state=1, size=(-1, -1), pos=(-1, -1), update=True)[source]

Set wheter the window is maximized or not, or minimized or full screen. If no argument is given, assume the state will be windowed and not maximized. If arguments are given, only the first is relevant. The other ones are ignored.

** Only maximized and normal states are implemented for now. **

State:valid arguments:

‘minimized’, MINIMIZED, 0. ‘normal’, NORMAL, 1: windowed, not maximized. ‘maximized’, MAXIMIZED, 2. ‘fullscreen, FULLSCREEN, 3.

Size:list, tuple: the new size; if (-1, -1) self.get_size() is used. If one element is -1 it is replaced by the corresponding valur from self.get_size().
Pos:list, tuple: the new position; if (-1, -1), self.get_position is used. If one element is -1 it is replaced by the corresponding valur from self.get_position().
Update:bool: whether to call the internal flush method.
sync()[source]

Wrapper around Xlib.Display.sync()

mcplatform.askCreateWorld(initialDir)[source]
mcplatform.askOpenFile(title='Select a Minecraft level....', schematics=False, suffixes=None)[source]
mcplatform.askOpenFileGtk(title, suffixes, initialDir)[source]
mcplatform.askOpenFileWin32(title, schematics, initialDir, suffixes=None)[source]
mcplatform.askOpenFolderGtk(title, initialDir)[source]
mcplatform.askOpenFolderWin32(title, initialDir)[source]
mcplatform.askSaveFile(initialDir, title, defaultName, filetype, suffix)[source]
mcplatform.askSaveSchematic(initialDir, displayName, fileFormat)[source]
mcplatform.buildFileTypes(filetypes)[source]
mcplatform.dynamic_arguments(func_to_replace, askFile_func)[source]
mcplatform.getTexturePacks()[source]
mcplatform.get_desktop_environment()[source]
mcplatform.is_running(process)[source]
mcplatform.platform_open(path)[source]
mcplatform.setupWindowHandler()[source]

‘Link’ the corresponding window handler class to WindowHandler.