G4C WINBIG 0 -10 1000 600 P_Docstring.gc WINTYPE 11110001 xONLOAD Gosub #this Default xONRELOAD Gosub #this Default xONCLOSE Delete env:.P_ModulesS GuiQuit #this xROUTINE Default SetGad #this 101 HIDE cd python:lib target = Lib IFEXISTS VARIABLE ~*ReqL ReqL = 100 ReqW = 400 ReqH = 400 ENDIF Gosub #this GenerateMainLists GuiOpen #this xROUTINE GenerateMainLists Gosub #this GenerateList "modules" "env:.P_Modules" Gosub #this GenerateList "keywords" "env:.P_Keywords" Gosub #this GenerateList "topics" "env:.P_Topics" xROUTINE GenerateList which? where? LVuse #this 101 LVChange env:.P_GetModHelp.py LVRep @mod2help '"$which?"' CS LVRep "env:.P_GotModHelp.txt" "$where?" CS LVSave env:.pdc_exec CLI "Python env:.pdc_exec " ; created .P_Modules LVUse #this 101 LVChange $where? LVGo first LVDel -1 LVDel -1 LVDel -1 LVGo last LVDel -1 LVDel -1 LVDel -1 LVDel -1 LVDel -1 LVSave $where? ;LVUse #this 2 ;>>>>>>>>>> ;LVChange $where? ;EzReq okNo? ok|no var ;IF $var = 0 ;RETURN ;ENDIF Gosub #this List4To1 $where? LVChange $where?\S LVSort Asc LVSave $where?\S RETURN LVuse #this 101 LVChange env:.P_GetModHelp.py LVRep @mod2help '"modules"' CS LVRep "env:.P_GotModHelp.txt" "env:.P_Modules" CS LVSave env:.pdc_exec CLI "Python env:.pdc_exec " ; created .P_Modules LVUse #this 101 LVChange env:.P_Modules LVGo first LVDel -1 LVDel -1 LVDel -1 LVGo last LVDel -1 LVDel -1 LVDel -1 LVDel -1 LVDel -1 LVSave env:.P_Modules LVUse #this 2 ;>>>>>>>>>> LVChange env:.P_Modules EzReq okNo? ok|no var IF $var = 0 RETURN ENDIF Gosub #this List4To1 env:.P_Modules LVChange env:.P_ModulesS LVSort Asc LVSave env:.P_ModulesS RETURN ; LVuse #this 101 LVChange env:.P_GetModHelp.py LVRep '@mod2help' '"keywords"' CS LVRep "env:.P_GotModHelp.txt" "env:.P_KeyWordsS" CS LVSave env:.pdc_exec CLI "Python env:.pdc_exec " ; created .P_KeyWordssS ; Gosub #this Sort4 env:.PModulesS LVuse #this 101 LVChange env:.P_GetModHelp.py LVRep @mod2help '"topics"' CS LVRep "env:.P_GotModHelp.txt" "env:.P_KeyWordsS" CS LVSave env:.pdc_exec CLI "Python env:.pdc_exec " ; created .P_KeyWordssS xROUTINE List4To1 file2list LVUse #this 101 LVChange env:.P_List4To1.py LVRep @file2list '"$file2list"' CS LVRep @file2sort '"$file2list\S"' CS LVSave env:.P_List4To1T.py ;pdc_exec CLI "Python env:.P_List4To1T.py " TEXTFILE env:.P_List4To1.py #generate ordered lists of modules, keywords, links to be loade in left listvies allmods = [] mfile = open(@file2list) for Line in mfile: Line = Line.replace("\n","") mods = Line.split() #print mods #print len(mods) if len(mods) != 0: allmods.append(mods[0]) #print "hi" #print allmods allmods.append(mods[1]) allmods.append(mods[2]) if len(mods) == 4: allmods.append(mods[3]) #print "hello" #print "NOW IT COMES UNSORTED\n\n\n" #print allmods allmods = sorted(allmods) #print "NOW IT COMES SORTED\n\n\n" #print allmods mfile.close() mfsorted = open(@file2sort,"w") for mod in allmods: #print "hi" mfsorted.write(mod + "\n") mfsorted.close() #try: # except IndexError, e: # print e# or pass, do nothing just ignore that row... ### ;see XML p 1096 TEXTFILE env:.pdc_Goal help() information is only available for modules and their content that are in the PYTHONPATH Even if you start python from within some Lib/subdrawer (except those in PYTHONPATH you get a "non defined" error As we still are unable to modify this environmental variable PYTHONPATH, this gui was developed to get easy acces one click away form all available help Standard modules not in pythonpath may however be described in the html documentation of the current Python version Once downloades, installed and its drawer defined in the PYTHONDOCS environmental variable, you have acces to help with the >>>help("myitem4whichhelpasked") (*) help("modules") help("keywords") help("topics") are particularly important All deliver lists of items on which help is available with the (*) query. We intend to have this info readily available from the gui. We intend to have other points of view, eg statements, built-in functions(1) with corresponding lists and easy acces to help on a chosen (clicked, 1st highlighted) it (1) Done, for Built_ins the thisbifunc.__doc__ infor is far shorter than the help("hisbifunc") info We will have the following cyclers - Viewer (choice between Multiview, Next, the right Listview - targetlist: the listview content (list or directory drawer from which we selected the item .. The Python:Lib directory (eventually also those in the subdrawers in the path: .. The help("modules") list .. the help("keywords") list .. the help("topics") list .. the list of builtin functions ( generated with dir(__buitlin__) ) - source of the info .. the __doc__ method .. the help("myitem") method .. the (txt) python source of the module itself & direct analysis of the module source (Gui4Cli) Respective qualities (completeness, readability) The __doc__ method is often only a rude description of the module's content and goal The Not all sources are available for all targets, and without checking we are not sure about it. The table below is a first try in synthesizing this +--------+------------------------------------------------------------------------------------------------+ | | targets | +--------+------------------------------------------------+----------+---------+--------+--------+--------+ | | Modules |Functions | Classes | Statms | Keys | Topics | | +--------+------------------------------------------------+----+-----+---------+--------+--------+--------+ |source | Lib&SDrIPth | SDrNtIPth | ModLIPth | ModLNIPth | BI | NBI | +--------+-------------+-----------+----------+-----------+----------+---------+--------+--------+--------+ +--------+-------------+-----------+----------+-----------+-----------+--------+--------+---------+ |__doc__ | V | V | N | +--------+-----+----------+-----------+--------+----------+-----------|--------+--------+---------+ |"help" | V1 | +--------+-----+----------+-----------+--------+----------+-----------|--------+--------+---------+ | text | V | V | V +--------+-----+----------+-----------+--------+----------+-----------|--------+--------+---------+ V all are V1 If in HTML documentation all tested are V2 If in HTML doc, some tested are not, most tested are V3 If in HTML doc, most tested are not, some tested are N Not available ### TEXTFILE env:.P_BuiltIns.py blist = dir(__builtins__) bfile = open("env:.P_BuiltIns.txt","w") for item in blist: bfile.write(item + "\n") bfile.close() ### xTEXTIN 780 0 180 17 Search SchWd "" 150 GadHelp "Search in right LV" LVUse #this 2 LVMulti NONE LVSearch $SchWd CI first WHILE $$LV.LINE > "" LVMulti ON LVSearch $SchWd CI next ENDWHILE xBUTTON 940 0 60 17 "Save" ; <> Gadhelp "Save the right listvieuws content" ReqFile $*ReqL 10 $*ReqW $*ReqH "Save right LV as" SAVE LV2Save "" LVUse #this 2 LVSave $LV2Save xBUTTON 0 0 40 17 "Vw" ; <> LVuse #this 1 LVMulti first Line = $$LV.LIne IF $target = Lib ; Directory LV; path to the full .py file known ;__doc__- if in PythonPath, "help" should work too if html doc exists IF $viewer = MVw RUN 'Multiview $LVVar1' ELSEIF $viewer = Nxt RUN 'Next $LVVar1' ELSE LVUse #this 2 LVChange $LVVar1 ENDIF ELSE ; IF $target = B_In ; "help" from htmldoc (not the __doc__ )available too by double clickin the LV ; and IF $target = Mod ; we don't know their path Gosub #this GetModHelp $LVVar1 IF $viewer = MVw RUN 'Multiview $LVVar1' ELSEIF $viewer = Nxt RUN 'Next $LVVar1' ELSE LVUse #this 2 LVChange $LVVar1 ENDIF ENDIF LVUse #this 1 LVMulti None Update #this 1 $Line xBUTTON 40 0 40 17 "VwNxtPy" LVUse #this 1 LVSearch .py CS next ; OS4 next CS gives nor error IF $$LV.LINE > "" IF $LVVar1[-1][1] = c LVSearch .py CS next Line = $$LV.LIne ELSE Line = $$LV.LINE ENDIF RUN 'Multiview $LVVar1' LVMulti None Update #this 1 $Line ENDIF xBUTTON 80 0 40 17 "__doc" ; <<__doc>> LVuse #this 1 xBUTTON 120 0 60 17 "Classes" ; <> Gadhelp "Get Classes of 1st highlighted py module" Gosub #this GetCl& xBUTTON 180 0 60 17 "Funcs" ; <> Gadhelp "Get Functions of 1st highlighted py module" Gosub #this GetFc& xBUTTON 240 0 60 17 "Docs" ; <> Gadhelp "Get Docstrings of 1st highlighted py module" Gosub #this GetDoc& xBUTTON 300 0 60 17 "Cl&Fcs" ; <> Gadhelp "Get Classes & Functions of 1st highlighted py module" Gosub #this GetCl&Fc xBUTTON 360 0 60 17 "Cl&Docs" ; <> Gadhelp "Classes & & Docstrings of 1st highlighted py module" Gosub #this GetCl&Doc xBUTTON 420 0 60 17 "Fc&Doc" ; <> Gadhelp "Get Functions & Docstings of 1st highlighted py module" Gosub #this GetFc&Doc xBUTTON 480 0 60 17 "C&F&D" ; <> Gadhelp "Get Classes & Functions & Docstrings of 1st highlighted py module" Gosub #this GetCl&Fc&Doc xBUTTON 600 0 60 17 "getLsts" ; Gosub #this GenerateMainLists LVUse #this 1 LVMode Multi LVChange env:.P_ModulesS xCYCLER 540 0 60 17 target target GadHelp "modules in python/lib or builtIn functions" CSTR Lib Lib CSTR Mod Mod CSTR Key Key CSTR Topc Topc CSTR B_In B_In LVUse #this 1 DOCASE $target CASE = B_In CLI "python env:.P_BuiltIns.py" LVMode Multi LVChange env:.P_BuiltIns.txt BREAK CASE = Lib LVMode Dir LVDir Refresh BREAK CASE = Mod LVMode Multi LVChange env:.P_ModulesS BREAK CASE = Key LVMode Multi LVChange env:.P_KeywordsS BREAK CASE = Topc LVMode Multi LVChange env:.P_TopicsS ENDCASE xCYCLER 600 0 60 17 viewer viewer GadHelp "View with Multiview, Next or right LV" CSTR MVw MVw CSTR Nxt Nxt CSTR rLV rLV xCYCLER 600 0 60 17 generate generate GadHelp "View with Multiview, Next or right LV" CSTR _doc _doc CSTR help help CSTR txt txt xROUTINE GetCl&Fc LVUse #this 2 LVClear LVuse #this 1 LVMulti first Line1 = $$LV.LIne LVUse #this 101 LVChange $LVVar1 LVMulti NONE ;Gosub #this GetDoc Gosub #this Getclasses Gosub #this GetFunctions Gosub #this ShowResult xROUTINE GetCl&Doc LVUse #this 2 LVClear LVuse #this 1 LVMulti first Line1 = $$LV.LIne LVUse #this 101 LVChange $LVVar1 LVMulti NONE Gosub #this GetDoc Gosub #this Getclasses ;Gosub #this GetFunctions Gosub #this ShowResult xROUTINE GetFc&Doc LVUse #this 2 LVClear LVuse #this 1 LVMulti first Line1 = $$LV.LIne LVUse #this 101 LVChange $LVVar1 LVMulti NONE Gosub #this GetDoc ;Gosub #this Getclasses Gosub #this GetFunctions Gosub #this ShowResult xROUTINE GetDoc& LVUse #this 2 LVClear LVuse #this 1 LVMulti first Line1 = $$LV.LIne LVUse #this 101 LVChange $LVVar1 LVMulti NONE Gosub #this GetDoc ;Gosub #this Getclasses ;Gosub #this GetFunctions Gosub #this ShowResult xROUTINE GetFc& LVUse #this 2 LVClear LVuse #this 1 LVMulti first Line1 = $$LV.LIne LVUse #this 101 LVChange $LVVar1 LVMulti NONE ;Gosub #this GetDoc ;Gosub #this Getclasses Gosub #this GetFunctions Gosub #this ShowResult xROUTINE GetCl& LVUse #this 2 LVClear LVuse #this 1 LVMulti first Line1 = $$LV.LIne LVUse #this 101 LVChange $LVVar1 LVMulti NONE ; Gosub #this GetDoc Gosub #this Getclasses ; Gosub #this GetFunctions Gosub #this ShowResult xROUTINE ShowResult LVMulti first WHILE $$LV.LINE > "" LineNr = $$LV.LINE Gosub #this AlignNr LVPut "$LineNr $$LV.REC" LVMulti next ENDWHILE LVClip COPY SELECTED ADD #this 2 LVUse #this 2 ; LVGo fo .OS4 raises no error LVSort ASC LVMulti None Update #this 1 $Line1 xROUTINE GetCl&Fc&Doc LVUse #this 2 LVClear LVuse #this 1 LVMulti first Line1 = $$LV.LIne LVUse #this 101 LVChange $LVVar1 LVMulti NONE Gosub #this GetDoc Gosub #this Getclasses Gosub #this GetFunctions Gosub #this ShowResult xROUTINE GetClasses LVUse #this 101 LVSearch class CS first ; EXP check if not preceded with chars WHILE $$LV.LINE > "" Parsevar LVVar101 IF $$Parse.0 = class LVMulti ON ENDIF LVSearch class CS next ENDWHILE xROUTINE AlignNr IF $LineNr < 10 LineNr = 00$LineNr ELSEIF $LineNr < 100 LineNr = 0$LineNr ENDIF xROUTINE GetFunctions LVSearch def CS first ; EXP check if not preceded with chars WHILE $$LV.LINE > "" Parsevar LVVar101 IF $$Parse.0 = def LVMulti ON Gosub #this GetArgs ENDIF LVSearch def CS next ENDWHILE xROUTINE GetArgs LVUse #this 101 SearchVar LVVar101 ')' CS first Pos = $$Search.Pos WHILE $Pos = "" AND $$LV.LINE > "" LVMulti ON LVGo next SearchVar LVVar101 ')' CS first Pos = $$Search.Pos ENDWHILE LVMulti ON xROUTINE GetDoc LVUse #this 101 LVSearch '"""' CS first Pos = $$Search.Pos WHILE $Pos > "" AND $$LV.LINE > "" IF $$LV.LINE > 68 ;stop ENDIF LVMulti ON SearchVar LVVar101 '"""' CS next ; on same line. WHILE $$Search.Pos = '' AND $$LV.LINE > "" LVMulti ON LVGo next SearchVar LVVar101 '"""' CS first ENDWHILE LVMulti ON LVGo next LVSearch '"""' CS next ENDWHILE xROUTINE GetDoc2 LVUse #this 101 LVSearch '"' CS first Pos = $$Search.Pos WHILE $Pos > "" LineNr = $$LV.LINE Gosub #this AlignNr ;LVPut "$LineNr $$LV.REC" LVMulti ON IF $LVVar101[$Pos][3] = '"""' LVGo next SearchVar LVVar101 '"""' CS first WHILE $$Search.Pos = '' AND $$LV.LINE > "" LineNr = $$LV.LINE Gosub #this AlignNr ;LVPut "$LineNr $$LV.REC" LVMulti ON LVGo next SearchVar LVVar101 '"""' CS first ENDWHILE LineNr = $$LV.LINE Gosub #this AlignNr ;LVPut "$LineNr $$LV.REC" LVMulti ON LVGo next ELSE ; ENDIF LVSearch '"' CS next ENDWHILE xROUTINE GetDoc_ LVUse #this 101 LVGo first SearchVar LVVar101 '"' CS first Pos = $$Search.Pos IF $Pos > "" LineNr = $$LV.LINE Gosub #this AlignNr LVPut "$LineNr $$LV.REC" LVMulti ON IF $LVVar101[$Pos][3] = '"""' LVGo next SearchVar LVVar101 '"""' CS first WHILE $$Search.Pos = '' AND $$LV.LINE > "" LineNr = $$LV.LINE Gosub #this AlignNr LVPut "$LineNr $$LV.REC" LVMulti ON LVGo next SearchVar LVVar101 '"""' CS first ENDWHILE LineNr = $$LV.LINE Gosub #this AlignNr LVPut "$LineNr $$LV.REC" LVMulti ON ELSE ; ENDIF ELSE ; ENDIF xROUTINE GetDoc LVUse #this 101 LVGo first SearchVar LVVar101 '"' CS first Pos = $$Search.Pos IF $Pos > "" LineNr = $$LV.LINE Gosub #this AlignNr LVPut "$LineNr $$LV.REC" LVMulti ON IF $LVVar101[$Pos][3] = '"""' LVGo next SearchVar LVVar101 '"""' CS first WHILE $$Search.Pos = '' AND $$LV.LINE > "" LineNr = $$LV.LINE Gosub #this AlignNr LVPut "$LineNr $$LV.REC" LVMulti ON LVGo next SearchVar LVVar101 '"""' CS first ENDWHILE LineNr = $$LV.LINE Gosub #this AlignNr LVPut "$LineNr $$LV.REC" LVMulti ON ELSE ; ENDIF ELSE ; ENDIF xROUTINE Get_Doc (after a class or def LVUse #this 101 LVGo next LineCntt = $LVVar101 SearchVar LineCntt '"' CS first Pos = $$Search.Pos IF $Pos > "" LineNr = $$LV.LINE Gosub #this AlignNr LVPut "$LineNr $$LV.REC" LVMulti ON IF $LineCntt[$Pos][3] = '"""' LVGo next LineCntt = $LVVar101 SearchVar LineCntt '"""' CS first WHILE $$Search.Pos = '' AND $$LV.LINE > "" LineNr = $$LV.LINE Gosub #this AlignNr LVPut "$LineNr $$LV.REC" LVMulti ON LVGo next LineCntt = $LVVar101 SearchVar LineCntt '"""' CS first ENDWHILE LineNr = $$LV.LINE Gosub #this AlignNr LVPut "$LineNr $$LV.REC" LVMulti ON ELSE ; ENDIF ELSE ; ENDIF ;xBUTTON 180 0 60 17 "" ; <<>> ;xBUTTON 240 0 60 17 "" ; <<>> xLISTVIEW 0 17 150 580 '' LVVar1 Python:lib 30 DIR GadHelp "LV1" Gadfont #MONO 8 000 GadID 1 DOCASE $target CASE = Lib ; directory Listvw PyModule = $$LV.REC ; no path RepVar PyModule .py "" CS LVUse #this 101 LVClear LVAdd 'import $PyModule' ; ImportError: No module named dep_util if not in PYTHONPATH LVAdd 'print $PyModule\.__doc__' Gosub #this Read__doc BREAK CASE = B_In PyFunction = $$LV.REC ; no path LVUse #this 101 LVClear LVAdd 'print $PyFunction\.__doc__' ; will always work Gosub #this Read__doc BREAK CASE = Mod CASE = Key CASE = Topc Gosub #this GetModHelp $LVVar1 LVUse #this 2 LVChange env:.P_GotModHelp.txt ENDCASE xROUTINE Read__doc LVSave env:.pdc_exec CLI 'python >env:.pdc_written env:.pdc_exec' LVUse #this 2 LVChange env:.pdc_written xROUTINE GetModHelp mod2help LVUse #this 101 LVChange env:.P_GetModHelp.py LVRep @mod2help '"$mod2help"' CS LVSave env:.pdc_exec CLI 'python env:.pdc_exec' TEXTFILE env:.P_GetModHelp.py # simplified version of sending help() output to a file import sys # save present stdout out = sys.stdout fname = "env:.P_GotModHelp.txt" # set stdout to file handle sys.stdout = open(fname, "w") # run your help code # its console output goes to the file now help(@mod2help) sys.stdout.close() # reset stdout sys.stdout = out ### xLISTVIEW 150 17 850 580 '' LVVar2 "" 30 Multi GadId 2 GadHelp "LV2" xLISTVIEW 150 17 850 600 '' LVVar101 "" 30 Multi GadID 101 GadHelp "LV101"