Esempio n. 1
0
def _get_doc_and_function(obj):
    rtn = []
    for var in dir(obj):
        if not var.startswith("_"):
            rtn.append(var)
    return _getdoc(obj), rtn
Esempio n. 2
0
    def poll():
        """Poll the GUI.

        This will update the documentation according to the selected item.

        """

        global last_sel
        text.after(100, poll)
        sel = listbox.curselection()
        if sel != ():
            item = listbox.get(int(sel[0]))
            if last_sel != item:
                last_sel = item
                if item == "..":
                    text.config(state=_tk.NORMAL)
                    text.delete(1.0, _tk.END)
                    text.config(state=_tk.DISABLED)
                if item != "..":
                    item = item[2:]
                    text.config(state=_tk.NORMAL)
                    text.delete(1.0, _tk.END)
                    text.tag_config("heading", font=("Courier", 12, "bold"))
                    text.insert(_tk.END, item, "heading")
                    text.insert(_tk.END, "\n\n")
                    if type(eval(item)) == types.TypeType:
                        text.insert(_tk.END, doc_dict[item])
                        definition = "".join(
                            _inspect.getsourcelines(eval(item))[0])
                        start = definition.find("def __init__(self") + 17
                        end = definition.find(")", start)
                        if definition[start] == ",":
                            call = "(" + \
                                    definition[start + 1:end].lstrip() + ")"
                        else:
                            call = "()"
                        call = call.replace(" " * 16,
                                            " " * len(item.split(".")[-1]))
                        text.insert(_tk.END, "\n\n\n\n")
                        text.tag_config("item", font=("Courier", 10, "bold"))
                        text.tag_config("call", font=("Courier", 10, "italic"))
                        text.insert(_tk.END, item.split(".")[-1], "item")
                        text.insert(_tk.END, call, "call")
                        text.insert(_tk.END, "\n\n")
                        text.insert(_tk.END,
                                    _getdoc(eval(item + "." + "__init__")))
                    elif type(eval(item)) == types.FunctionType:
                        definition = "".join(
                            _inspect.getsourcelines(eval(item))[0])
                        text.tag_config("item", font=("Courier", 10, "bold"))
                        start = definition.find("(") + 1
                        end = definition.find(")", start)
                        call = "(" + definition[start:end].lstrip() + ")"
                        call = call.replace(
                            "    " + " " * len(item.split(".")[-1]) + " ",
                            " " * len(item.split(".")[-1] + " "))
                        text.tag_config("call", font=("Courier", 10, "italic"))
                        text.insert(_tk.END, item.split(".")[-1], "item")
                        text.insert(_tk.END, call, "call")
                        text.insert(_tk.END, "\n\n")
                        text.insert(_tk.END, doc_dict[item])
                    elif type(eval(item)) == types.MethodType:
                        definition = "".join(
                            _inspect.getsourcelines(eval(item))[0])
                        text.tag_config("item", font=("Courier", 10, "bold"))
                        start = definition.find("(self") + 1
                        end = definition.find(")", start)
                        if definition[start + 4] == ",":
                            call = "(" + \
                                    definition[start + 5:end].lstrip() + ")"
                        else:
                            call = "()"
                        call = call.replace(
                            "        " + " " * len(item.split(".")[-1]) + " ",
                            " " * len(item.split(".")[-1]) + " ")
                        text.tag_config("call", font=("Courier", 10, "italic"))
                        text.insert(_tk.END, item.split(".")[-1], "item")
                        text.insert(_tk.END, call, "call")
                        text.insert(_tk.END, "\n\n")
                        text.insert(_tk.END, doc_dict[item])
                    elif type(eval(item)) in (types.IntType, types.StringType,
                                              types.BooleanType,
                                              types.ListType, types.TupleType,
                                              types.DictionaryType):
                        pass
                    else:
                        if type(eval(item)) == property:
                            if eval(item).fset is None:
                                text.insert(_tk.END, "Read-only!")
                        else:
                            text.insert(_tk.END, doc_dict[item])

                    text.config(state=_tk.DISABLED)
Esempio n. 3
0
    def poll():
        """Poll the GUI.

        This will update the documentation according to the selected item.

        """

        global last_sel
        text.after(100, poll)
        sel = listbox.curselection()
        if sel != ():
            item = listbox.get(int(sel[0]))
            if last_sel != item:
                last_sel = item
                if item == "..":
                    text.config(state=_tk.NORMAL)
                    text.delete(1.0, _tk.END)
                    text.config(state=_tk.DISABLED)
                if item != "..":
                    item = item[2:]
                    text.config(state=_tk.NORMAL)
                    text.delete(1.0, _tk.END)
                    text.tag_config("heading", font=("Courier", 12, "bold"))
                    text.insert(_tk.END, item, "heading")
                    text.insert(_tk.END, "\n\n")
                    if type(eval(item)) == types.TypeType:
                        text.insert(_tk.END, doc_dict[item])
                        definition = "".join(_inspect.getsourcelines(
                            eval(item))[0])
                        start = definition.find("def __init__(self") + 17
                        end = definition.find(")", start)
                        if definition[start] == ",":
                            call = "(" + \
                                    definition[start + 1:end].lstrip() + ")"
                        else:
                            call = "()"
                        call = call.replace(" " * 16,
                                            " " * len(item.split(".")[-1]))
                        text.insert(_tk.END, "\n\n\n\n")
                        text.tag_config("item",
                                        font=("Courier", 10, "bold"))
                        text.tag_config("call", font=("Courier", 10,
                                                      "italic"))
                        text.insert(_tk.END, item.split(".")[-1], "item")
                        text.insert(_tk.END, call, "call")
                        text.insert(_tk.END, "\n\n")
                        text.insert(_tk.END, _getdoc(
                            eval(item + "." + "__init__")))
                    elif type(eval(item)) == types.FunctionType:
                        definition = "".join(_inspect.getsourcelines(
                            eval(item))[0])
                        text.tag_config("item",
                                        font=("Courier", 10, "bold"))
                        start = definition.find("(") + 1
                        end = definition.find(")", start)
                        call = "(" + definition[start:end].lstrip() + ")"
                        call = call.replace(
                            "    " + " "*len(item.split(".")[-1]) + " ",
                            " "*len(item.split(".")[-1] + " "))
                        text.tag_config("call", font=("Courier", 10, "italic"))
                        text.insert(_tk.END, item.split(".")[-1], "item")
                        text.insert(_tk.END, call, "call")
                        text.insert(_tk.END, "\n\n")
                        text.insert(_tk.END, doc_dict[item])
                    elif type(eval(item)) == types.MethodType:
                        definition = "".join(_inspect.getsourcelines(
                            eval(item))[0])
                        text.tag_config("item",
                                        font=("Courier", 10, "bold"))
                        start = definition.find("(self") + 1
                        end = definition.find(")", start)
                        if definition[start + 4] == ",":
                            call = "(" + \
                                    definition[start + 5:end].lstrip() + ")"
                        else:
                            call = "()"
                        call = call.replace(
                            "        " + " "*len(item.split(".")[-1]) + " ",
                            " "*len(item.split(".")[-1]) + " ")
                        text.tag_config("call", font=("Courier", 10, "italic"))
                        text.insert(_tk.END, item.split(".")[-1], "item")
                        text.insert(_tk.END, call, "call")
                        text.insert(_tk.END, "\n\n")
                        text.insert(_tk.END, doc_dict[item])
                    elif type(eval(item)) in (types.IntType, types.StringType,
                                              types.BooleanType,
                                              types.ListType,
                                              types.TupleType,
                                              types.DictionaryType):
                        pass
                    else:
                        if type(eval(item)) == property:
                            if eval(item).fset is None:
                                text.insert(_tk.END, "Read-only!")
                        else:
                            text.insert(_tk.END, doc_dict[item])

                    text.config(state=_tk.DISABLED)
Esempio n. 4
0
def _get_doc_and_function(obj):
    rtn = []
    for var in dir(obj):
        if not var.startswith("_"):
            rtn.append(var)
    return _getdoc(obj), rtn
Esempio n. 5
0
 def update_event(self, inp=-1):
     self.set_output_val(0, pydoc._getdoc(self.input(0)))