Exemplo n.º 1
0
Arquivo: misc.py Projeto: rdbende/teek
 def _command_runner(self, *args):
     if args[0] == 'moveto':
         moveto, fraction = args
         fraction = from_tcl(float, fraction)
         self.config['command'].run('moveto', fraction)
     elif args[0] == 'scroll' and args[-1] in ('units', 'pages'):
         scroll, number, units_or_pages = args
         number = from_tcl(int, number)
         self.config['command'].run('scroll', number, units_or_pages)
     else:  # pragma: no cover
         raise ValueError("ttk::scrollbar's command ran with unexpected "
                          "arguments: " + repr(args))
Exemplo n.º 2
0
Arquivo: base.py Projeto: rdbende/teek
    def _callback_runner(self, callback, *args):
        assert len(args) == len(_BIND_SUBS)

        event = Event()
        for (character, type_, attrib), string_value in zip(_BIND_SUBS, args):
            assert isinstance(string_value, str)
            try:
                value = from_tcl(type_, string_value)
            except (ValueError, teek.TclError) as e:
                if string_value == '??':
                    value = None
                elif attrib == 'sendevent':
                    # this seems to be a bug in Tk, here's a minimal example:
                    #
                    #    label .lab -text "click this to do the bug"
                    #    pack .lab
                    #    bind .lab <Leave> { puts "leave: %E" }
                    #    bind .lab <Button-1> { tk_messageBox }
                    #
                    # for me this prints "leave: 343089580", even though
                    # bind(3tk) says that %E is 1 or 0
                    value = None
                else:  # pragma: no cover
                    raise e  # if this runs, there's a bug in teek

            setattr(event, attrib, value)

        return callback.run(event)
Exemplo n.º 3
0
Arquivo: base.py Projeto: rdbende/teek
 def data(self, type_spec):
     return from_tcl(type_spec, self._data)