Quite a regular
Joined: 2007/2/27 10:47 Last Login
: 9/1 14:15
From Gravity well
Group:
Registered Users
|
So I'm in early stages regarding working (python) on Proaction. I was able to get a chooser (cycle gadget) into the layout, but with a second gadget of the same kind I do not get the contents in. In more general terms, how should I debug Reaction/Intuition stuff? I tried using C first, but I just got system freezes from running the binary, all the time. Here's the lines of code in question, first the one that seems to work: Quote: (rc,rc2,app.cycl0_gid) = arexx.dorexx("PROACTION","ADDGADGET GUIID " + guikey + " GADGETCLASS \"chooser.gadget\" TAGSTRING \"CHOOSER_DropDown,True,CHOOSER_Labels," + app.cycl0 + ",TAG_DONE\"")
Not (quite) working: Quote: (rc,rc2,app.cycl1_gid) = arexx.dorexx("PROACTION","ADDGADGET GUIID " + guikey + " GADGETCLASS \"chooser.gadget\" TAGSTRING \"CHOOSER,DropDown,True,CHOOSER_Labels," + app.cycl1 + ",TAG_DONE\"")
... ... ... I hope the tabs are at least seemingly preserved (nope!)... All of the lines (yes, a mashup of shipped examples): Quote: #!python
import sys import os import arexx
def ErrorExit(msg): command = "RequestChoice TYPE \"ERROR\" \"" + sys.argv[0] + "\" \"" + msg + "\" \"OK\" >NIL:" os.system(command) exit()
def GetPorts(): try: ports = os.getports() ports = " ".join(ports) except AttributeError: (rc,rc2,ports) = arexx.dorexx("REXX","return show('P')") if rc != 0: ErrorExit("Couldn\'t find ARexx!") return ports
def MakeChooserNodeList(guikey, *strings): concstrings = [] # First we need an exec list to hold our ChooserNodes # We create this with a special command NEWGUIOBJECT and specify an object # of type GUIOBJ_List . An ID for the list object will be returned that # we can use in all further operations on it. (rc,rc2,cnlist) = arexx.dorexx("PROACTION","NEWGUIOBJECT GUIID " + guikey + " OBJECTTYPE \"GUIOBJ_List\"") if rc == 0: # Our function recives a tuple in the variable strings, which may consist of # separate strings or lists of strings, depending on how we call it. # We need a (python) list of strings so this next assembles that for us. for string in strings: if not isinstance(string,list): concstrings.append(string) else: concstrings.extend(string) # Now we process the list of strings we have for string in concstrings: cntags = "" cntags += "CNA_Text," + str(string) + "," cntags += "TAG_DONE" # The command ALLOCCHOOSERNODE is a Wrapper for the # AlloChooserNode() C function. It returns an ID for a # GUIOBJ_Node Object which we can add to the # growing choosernode list.
(rc,rc2,cn) = arexx.dorexx("PROACTION","ALLOCCHOOSERNODE GUIID " + guikey + " TAGSTRING \"" + cntags + "\"") if rc == 0: arexx.dorexx("PROACTION", "ADDTAIL GUIID " + guikey + " LISTID " + cnlist + " NODEID " + cn) return cnlist
def FreeChooserNodeList(guikey, rbnlist): # We remove each node in turn using the REMTAIL command. (rc, rc2, rbn) = arexx.dorexx("PROACTION","REMTAIL GUIID " + guikey + " LISTID " + rbnlist) while rc == 0: # if successful we pass the NODEID to the FREECHOOSERNODE command. arexx.dorexx("PROACTION","FREECHOOSERNODE GUIID " + guikey + " NODEID " + rbn) # remove next node and loop. (rc, rc2, rbn) = arexx.dorexx("PROACTION","REMTAIL GUIID " + guikey + " LISTID " + rbnlist)
ports = GetPorts() if -1 == ports.find("PROACTION"): os.system("RUN >\"T:proactionpid\" *>NIL: APPDIR:PROACTION") os.system("C:WaitForPort PROACTION") # Now check again ports = GetPorts() if -1 == ports.find("PROACTION"): ErrorExit("Unable to start or find ProAction GUIServer")
class Application:
def __init__(self): self.PORTNAME = "jkldba" self.UNIQUE = True
# application specific strings wititle = "something's up h" cycl0 = ['hub','bub','dub'] cyclbl0 = "Choices for me" cycl1 = ['atr','erc','rotterdim','ser','haa','iei','aqz','ppw','hji','frb'] cyclbl1 = "Choices for ya"
def HandleInput(pyport,guikey):
global app die = 0 # main loop while die == 0: pyport.wait() msg = pyport.getmsg() # Loop until all messages are processed while msg: cmd = msg.msg msg.reply() if cmd == "QUIT": die = 1 break elif cmd[:5] == "CLOSE": die = 1 break msg = pyport.getmsg()
def DoGUI(pubscreen):
global app
# Setting up ARexx port pyport = arexx.Port(app.PORTNAME) if pyport: if app.UNIQUE: if pyport.name != app.PORTNAME: ErrorExit("ARexx Port " + app.PORTNAME + " already exists!")
wintags = "" wintags += "WA_Width,300," wintags += "WA_Height,400," wintags += "WA_DragBar,1," wintags += "WA_DepthGadget,1," wintags += "WA_SizeGadget,1," wintags += "WA_CloseGadget,1," wintags += "WA_Title,"+wititle+"," wintags += "WA_PubScreenFallBack,1," wintags += "WA_PubScreenName," + pubscreen + "," wintags += "WINDOW_POSITION,WPOS_CENTERSCREEN," wintags += "WA_Activate,0," wintags += "TAG_DONE"
(rc,rc2,guikey) = arexx.dorexx("PROACTION","CREATEGUI PORTNAME " + pyport.name + " TAGSTRING \"" + wintags + "\"") if rc == 0: (rc,rc2,current_layout_gid) = arexx.dorexx("PROACTION","ADDLAYOUT GUIID " + guikey + " TAGSTRING LAYOUT_ORIENT_VERT,TAG_DONE") app.pagesizelist = 1 # not GetPageSizeList() # numlabels = len(app.pagesizelist) app.cycl0 = MakeChooserNodeList(guikey,cycl0) app.cycl1 = MakeChooserNodeList(guikey,cycl1) if (app.cycl0 != None and app.cycl1 != None): (rc,rc2,app.cycl0_gid) = arexx.dorexx("PROACTION","ADDGADGET GUIID " + guikey + " GADGETCLASS \"chooser.gadget\" TAGSTRING \"CHOOSER_DropDown,True,CHOOSER_Labels," + app.cycl0 + ",TAG_DONE\"") # (rc,rc2,dummy) = arexx.dorexx("PROACTION","SETATTRS GUIID " + guikey + " OBJECTID " + current_layout_gid + " TAGSTRING \"LAYOUT_ModifyChild," + app.cycl0_gid + ",CHILD_Label," + cyclbl0 + ",TAG_DONE\"") (rc,rc2,app.cycl1_gid) = arexx.dorexx("PROACTION","ADDGADGET GUIID " + guikey + " GADGETCLASS \"chooser.gadget\" TAGSTRING \"CHOOSER,DropDown,True,CHOOSER_Labels," + app.cycl1 + ",TAG_DONE\"") (rc,rc2,result) = arexx.dorexx("PROACTION","ADDGADGET GUIID " + guikey + " GADGETCLASS \"listbrowser.gadget\" TAGSTRING \"TAG_DONE\"") (rc,rc2,result) = arexx.dorexx("PROACTION","OPENGUIWINDOW GUIID " + guikey) # main loop called here HandleInput(pyport,guikey) # First get window out of the way, then nodelist arexx.dorexx("PROACTION","CLOSEGUIWINDOW GUIID " + guikey) FreeChooserNodeList(guikey, app.cycl0) FreeChooserNodeList(guikey, app.cycl1) arexx.dorexx("PROACTION","DESTROYGUI GUIID " + guikey) else: ErrorExit("Could not create port!")
app = Application(); DoGUI("Workbench")
Edited by Thematic on 2021/1/6 20:11:51
|