def __init__(self, options): """Create the Key Mon window. Options dict: scale: float 1.0 is default which means normal size. meta: boolean show the meta (windows key) kbd_file: string Use the kbd file given. emulate_middle: Emulate the middle mouse button. theme: Name of the theme to use to draw keys """ settings.SettingsDialog.register() self.btns = [ 'MOUSE', 'BTN_RIGHT', 'BTN_MIDDLE', 'BTN_MIDDLERIGHT', 'BTN_LEFT', 'BTN_LEFTRIGHT', 'BTN_LEFTMIDDLE', 'BTN_LEFTMIDDLERIGHT' ] self.options = options self.pathname = os.path.dirname(__file__) if self.options.scale < 1.0: self.svg_size = '-small' else: self.svg_size = '' # Make lint happy by defining these. self.mouse_image = None self.alt_image = None self.hbox = None self.window = None self.event_box = None self.mouse_indicator_win = None self.key_image = None self.shift_image = None self.ctrl_image = None self.meta_image = None self.buttons = None self.enabled = { 'MOUSE': self.options.mouse, 'SHIFT': self.options.shift, 'CTRL': self.options.ctrl, 'META': self.options.meta, 'ALT': self.options.alt, 'KEYS': self.options.keys, 'BUTTONS': self.options.buttons, } #Disables all Buttons when nobuttons has been triggered if not self.enabled['BUTTONS']: self.enabled['SHIFT'] = False self.enabled['META'] = False self.enabled['ALT'] = False self.enabled['CTRL'] = False self.enabled['KEYS'] = False self.modmap = mod_mapper.safely_read_mod_map(self.options.kbd_file) self.name_fnames = self.create_names_to_fnames() self.devices = xlib.XEvents() self.devices.start() self.pixbufs = lazy_pixbuf_creator.LazyPixbufCreator( self.name_fnames, self.options.scale) self.create_window()
def __init__(self, options): """Create the Key Mon window. Options dict: scale: float 1.0 is default which means normal size. meta: boolean show the meta (windows key) kbd_file: string Use the kbd file given. emulate_middle: Emulate the middle mouse button. theme: Name of the theme to use to draw keys """ settings.SettingsDialog.register() self.btns = [ 'MOUSE', 'BTN_RIGHT', 'BTN_MIDDLE', 'BTN_MIDDLERIGHT', 'BTN_LEFT', 'BTN_LEFTRIGHT', 'BTN_LEFTMIDDLE', 'BTN_LEFTMIDDLERIGHT' ] self.options = options self.pathname = os.path.dirname(os.path.abspath(__file__)) if self.options.scale < 1.0: self.svg_size = '-small' else: self.svg_size = '' # Make lint happy by defining these. self.hbox = None self.window = None self.event_box = None self.mouse_indicator_win = None self.key_image = None self.buttons = None self.no_press_timer = None self.move_dragged = False self.shape_mask_current = None self.shape_mask_cache = {} self.MODS = ['SHIFT', 'CTRL', 'META', 'ALT'] self.IMAGES = ['MOUSE'] + self.MODS self.images = dict([(img, None) for img in self.IMAGES]) self.enabled = dict([(img, self.get_option(cstrf(img.lower))) for img in self.IMAGES]) self.options.kbd_files = settings.get_kbd_files() self.modmap = mod_mapper.safely_read_mod_map(self.options.kbd_file, self.options.kbd_files) self.name_fnames = self.create_names_to_fnames() self.devices = xlib.XEvents() self.devices.start() self.pixbufs = lazy_pixbuf_creator.LazyPixbufCreator( self.name_fnames, self.options.scale) self.create_window() self.reset_no_press_timer()