[issue28498] tk busy command

Miguel report at bugs.python.org
Sun Oct 23 05:23:19 EDT 2016


Miguel added the comment:

Hi klappnase,
you are right with the function tk_busy_configure(). Maybe there is a little bit of code duplicated. I think that it's better to directly change the Tkinter function _configure() to make it more general:
    def _configure(self, cmd, cnf, kw):
        """Internal function."""
        if kw:
            cnf = _cnfmerge((cnf, kw))
        elif cnf:
            cnf = _cnfmerge(cnf)
        if cnf is None:
            return self._getconfigure(cmd)
        if isinstance(cnf, str):
            return self._getconfigure1(cmd + ('-'+cnf,))
        self.tk.call(cmd + self._options(cnf))

I think that it's interesting to do this change because the function is more general and maybe can be used again in the future for new features in Tcl Tk. This way, we avoid code duplication (Dont Repeat Yourself is one of the philosophes of Python). This is the new version of tk_busy_configure using the mentioned change:
    def tk_busy_configure(self, cnf=None, **kw):
        return self._configure(('tk', 'busy', 'configure', self._w), cnf, kw)

It's more concise.
I disagree with tk_busy_status(). It's better to be more predictable an return the same than the other methods that uses getboolean(). If there is a bug, it's better to solve that bug.  Could you please guive me an code example that replicates the bug?

The _getboolean function is implemented in _tkinter.c. This is the implementation:
    static PyObject *
    Tkapp_GetBoolean (self, args)
         PyObject *self;
         PyObject *args;
    {
      char *s;
      int v;

      if (!PyArg_Parse (args, "s", &s))
        return NULL;
      if (Tcl_GetBoolean (Tkapp_Interp (self), s, &v) == TCL_ERROR)
        return Tkinter_Error (self);
      return Py_BuildValue ("i", v);
    }

A priori , I can't appreciate any bug in this function. If there is some bug, it's in another place of the C code.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28498>
_______________________________________


More information about the Python-bugs-list mailing list