def init_cursor(self): font_name = self.text.clutter_text.get_font_name() for i in font_name.split(): try: self.cursor_height = unit.pt_to_px(int(i)) except ValueError: if 'px' in i: self.cursor_height = int(i.strip('px')) else: pass self.cursor_height = round(self.cursor_height) self.cursor = Cursor((5, self.cursor_height)) self.cursor.set_depth(10) self.add_child(self.cursor) self.cursor.set_x(0) self.cursor.set_y(0)
def _fix_scroll(self, *args): label_props = pisak.css.get_properties( 'MxLabel.{}'.format(self.text.get_style_class())) font_size = label_props['font-size'] if 'pt' in font_size: cursor_height = unit.pt_to_px(int(font_size.strip('pt'))) elif 'px' in font_size: cursor_height = int(font_size.strip('px')) else: _LOG.warning('Cannot parse font-size sensibly,' 'falling to default cursor size: 100.') cursor_height = 100 lines = self.clutter_text.get_layout().get_line_count() text_len = len(self.text.get_text()) factor = 1.5*text_len**0.55/lines self.clutter_text.set_cursor_size(cursor_height*factor)
def _fix_scroll(self, *args): label_props = pisak.css.get_properties('MxLabel.{}'.format( self.text.get_style_class())) font_size = label_props['font-size'] if 'pt' in font_size: cursor_height = unit.pt_to_px(int(font_size.strip('pt'))) elif 'px' in font_size: cursor_height = int(font_size.strip('px')) else: _LOG.warning('Cannot parse font-size sensibly,' 'falling to default cursor size: 100.') cursor_height = 100 lines = self.clutter_text.get_layout().get_line_count() text_len = len(self.text.get_text()) factor = 1.5 * text_len**0.55 / lines self.clutter_text.set_cursor_size(cursor_height * factor)