samuraix.util

class samuraix.util.ClientMessageHandlers

a little helper class for client message event handlers. You just connect an atom to a handler function and pass every ooxcb.xproto.ClientMessageEvent to handle(), and you will get the events handled.

handle(evt)
call the matching handler function for evt and return the result or print a warning to the log if there is no matching handler.
register_handler(atom, func)
Parameters:
  • func – function taking one argument, the client message event.
  • atom – is the (cached!) atom object.
class samuraix.util.DictProxy(other, prefix)

a dict proxy creates a proxy to a dict the prefix argument is prefixed to all key operations so that

>>> d = {'a.b':1}
>>> pd = DictProxy(d, 'a.')
>>> pd['b'] == d['a.b']
True

all other dict operations should also work

class samuraix.util.OrderedDict(data=None, **kwdata)
an ordered dictionary, from http://code.activestate.com/recipes/496761/
samuraix.util.parse_buttonstroke(s)

Return (modifiers, button id), extracted from the string s.

It has to contain several modifiers and a button index, joined together with a ‘+’:

CTRL+1
MOD4+2

1 is the left mouse button, 2 the middle, 3 the right button.

samuraix.util.wait_for_key(screen, callback)

grab the keyboard, wait until the user presses an arbitrary key and call callback. callback is required to have this function signature:

def callback(keycode)

samurai-x

Previous topic

samuraix.screen

This Page