def __init__(self, handle): ShareableActivity.__init__(self, handle) self.old_eqs = [] self.ml = MathLib() self.parser = AstParser(self.ml) # These will result in 'Ans <operator character>' being inserted self._chars_ans_diadic = [ op[0] for op in self.parser.get_diadic_operators() ] try: self._chars_ans_diadic.remove('-') except: pass self.KEYMAP['multiply'] = self.ml.mul_sym self.KEYMAP['divide'] = self.ml.div_sym self.KEYMAP['equal'] = self.ml.equ_sym self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) self.select_reason = self.SELECT_SELECT self.buffer = u"" self.showing_version = 0 self.showing_error = False self.ans_inserted = False self.show_vars = False self.connect("key_press_event", self.keypress_cb) self.connect("destroy", self.cleanup_cb) self.color = sugar3.profile.get_color() self.layout = CalcLayout(self) self.label_entry = self.layout.label_entry self.text_entry = self.layout.text_entry self.last_eq_sig = None self.last_eqn_textview = None self.reset() self.layout.show_it() self.connect('joined', self._joined_cb) self.parser.log_debug_info()
def __init__(self, ml=None, pl=None): self._namespace = {} self._immutable_vars = [] self._used_var_ofs = {} if ml is None: self.ml = MathLib() else: self.ml = ml if pl is None: self.pl = Plot(self) else: self.pl = pl for key, val in self.BUILTIN_VARS.iteritems(): self.set_var(key, val, immutable=True) # Help manager self._helper = Helper(self) self.set_var('help', self._helper.get_help, immutable=True) self._special_func_args = { (self._helper.get_help, 0): self._ARG_STRING, (self.pl.plot, 0): self._ARG_NODE, } # Plug-in plot function self.set_var('plot', self.pl.plot, immutable=True) self._helper.add_help('plot', PLOTHELP) self._load_plugins() # Redirect operations to registered functions for key, val in self.UNARYOP_MAP.iteritems(): if type(val) is types.StringType: self.UNARYOP_MAP[key] = self.get_var(val) for key, val in self.BINOP_MAP.iteritems(): if type(val) is types.StringType: self.BINOP_MAP[key] = self.get_var(val)
def setUp(self): self.matlib = MathLib()
def setUp(self): self.math = MathLib()