Raspberry BASIC > ScriptBasic

IUP GUI Toolkit

(1/1)

John Spikowski:
I created an IUP distibution for the Raspberry Pi 3B class boards. I also include the IUP extension module for ScriptBasic.

IUP (Portable User Interface) is a multi-platform toolkit for building graphical user interfaces.
IUP Project Site
IUP Download


CD (Canvas Draw) is a vector graphics toolkit with device independent output.
CD Project Site
CD Download


IM (Imaging) is a toolkit for image representation, storage, capture and processing.
IM Project Site
IM Download


ScriptBasic IUP Extension Module Download


Install Instructions

Download / extract each of the zips into a temporary work directory. Run sudo ./install in the IUP, CD and IM directories. If you want to install the development files, run sudo ./install_dev as well. Copy the iup.bas to your /usr/local/include/scriba directory. Copy the pui.so to your /usr/local/lib/scriba directory.

IUP ScriptBasic Online Dictionary

--- Code: Script BASIC ---IMPORT iup.bas servers[0]="dict.org"servers[1]="dict1.us.dict.org"servers[2]="all.dict.org" about="""This is a Demoof the IUP GUI Bindingfor Scriptbasic""" ' Initialize IUPIup::Open() ' Create main window win = Iup::Create("dialog")  Iup::SetAttributes(win, "TITLE=\"ScriptBasic IUP Online Dictionary\", SIZE=500x300")  Iup::SetCallback(win,"CLOSE_CB",ADDRESS(Win_exit())) ' Create container to house ALL GUI objects vbox = Iup::Create("vbox")  Iup::SetAttributes(vbox, "MARGIN=10x10") ' Create server panel topBox = Iup::Create("hbox")  Iup::SetAttributes(topBox, "GAP=10")  Iup::Append(vbox, topBox)serverFrame = Iup::Create("frame")  Iup::SetAttributes(serverFrame, "TITLE=Servers, EXPAND=YES")  Iup::Append(topBox, serverFrame)serverBox = Iup::Create("hbox")  Iup::SetAttributes(serverBox, "GAP=5")  Iup::Append(serverFrame, serverBox)serverCombo = Iup::Create("list")  Iup::SetAttributes(serverCombo, "DROPDOWN=YES, SIZE=120x, EXPAND=HORIZONTAL, VALUE=1")  Iup::Append(serverBox, serverCombo)  Iup::SetCallback(serverCombo, "ACTION", ADDRESS(serverCombo_selected()))btnFetch = Iup::Create("button")  Iup::SetAttributes(btnFetch, "TITLE=Fetch, SIZE = 50x")  Iup::Append(serverBox, btnFetch)  Iup::SetCallback(btnFetch, "ACTION", ADDRESS(btnFetch_clicked())) ' Create control panel controlFrame = Iup::Create("frame")  Iup::SetAttributes(controlFrame, "TITLE=Controls")  Iup::Append(topBox, controlFrame)controlBox = Iup::Create("hbox")  Iup::SetAttributes(controlBox, "GAP=5")  Iup::Append(controlFrame, controlBox)btnAbout = Iup::Create("button")  Iup::SetAttributes(btnAbout, "TITLE=About, SIZE = 50x")  Iup::Append(controlBox, btnAbout)  Iup::SetCallback(btnAbout, "ACTION", ADDRESS(btnAbout_clicked()))btnClear = Iup::Create("button")  Iup::SetAttributes(btnClear, "TITLE=Clear, SIZE = 50x")  Iup::Append(controlBox, btnClear)  Iup::SetCallback(btnClear, "ACTION", ADDRESS(btnClear_clicked()))btnExit = Iup::Create("button")  Iup::SetAttributes(btnExit, "TITLE=Exit, SIZE = 50x")  Iup::Append(controlBox, btnExit)  Iup::SetCallback(btnExit,"ACTION",ADDRESS(Win_exit())) ' Create dictionary panel dictFrame = Iup::Create("frame")  Iup::SetAttributes(dictFrame, "TITLE=Dictionaries")  Iup::Append(vbox, dictFrame)serverList = Iup::Create("list")  Iup::SetAttributes(serverList, "EXPAND=YES, VISIBLELINES=1")  Iup::Append(dictFrame, serverList)  Iup::SetCallback(serverList, "ACTION", ADDRESS(serverList_selected())) ' Create text part transFrame = IUP::Create("frame")  Iup::SetAttributes(transFrame, "TITLE=Translation")  Iup::Append(vbox, transFrame)text = Iup::Create("text")  Iup::SetAttributes(text, "MULTILINE=YES, EXPAND=YES")  Iup::Append(transFrame, text) ' Create entry and search button bottomBox = Iup::Create("hbox")  Iup::SetAttributes(bottomBox, "GAP=10")  Iup::Append(vbox, bottomBox)label = Iup::Create("label")  Iup::SetAttributes(label, "TITLE=\"Enter Word to Search For:\", SIZE=x12")  Iup::Append(bottomBox, label)entry = Iup::Create("text")  Iup::SetAttributes(entry, "EXPAND=HORIZONTAL")  Iup::Append(bottomBox, entry)btnSearch = Iup::Create("button")  Iup::SetAttributes(btnSearch,"TITLE=Search, SIZE=50x")  Iup::Append(bottomBox, btnSearch)  Iup::SetCallback(btnSearch, "ACTION", ADDRESS(btnSearch_clicked()))chkAll = Iup::Create("toggle")  Iup::SetAttributes(chkAll, "TITLE=ALL, SIZE=x12")  Iup::Append(bottomBox, chkAll)chkUTF = Iup::Create("toggle")  Iup::SetAttributes(chkUTF, "TITLE=UTF-8, SIZE=x12")  Iup::Append(bottomBox, chkUTF) ' Add the main GUI container to the Window Iup::Append(win, vbox) ' Setup dialog defaults Iup::Show(win)Iup::SetFocus(btnFetch)FOR i = 0 TO UBOUND(servers)  Iup::SetAttribute(serverCombo, "APPENDITEM", servers[i])NEXTIup::SetAttribute(serverCombo, "VALUE", "1")Iup::Update(serverCombo)server_selection = servers[0] ' Main processing loop Iup::MainLoop()Iup::Close()END ' Callback routines SUB Win_exit  Iup::ExitLoop = TRUEEND SUB SUB btnAbout_clicked  Iup::Message("ABOUT", about)END SUB SUB serverCombo_selected  server_selection = Iup::GetListText()END SUB SUB serverList_selected  whichDictionary = Iup::GetListText()END SUB SUB btnFetch_clicked  LOCAL dat, total, count  ON ERROR GOTO G_NetError  OPEN server_selection & ":2628" FOR SOCKET AS #1  PRINT#1,"SHOW DB\n"  LINE INPUT#1, dat  LINE INPUT#1, dat  count = 0  WHILE LEFT(dat, 1) <> "."    LINE INPUT#1, dat    IF LEFT(dat, 1) <> "." THEN total[count] = TRIM(dat)    count+=1  WEND  PRINT#1,"QUIT\n"  CLOSE(#1)  FOR cnt = 0 TO count - 2    Iup::SetAttribute(serverList, "APPENDITEM", total[cnt])  NEXT  Iup::SetAttribute(serverList, "VALUE", "1")  Iup::Update(serverCombo)  whichDictionary = total[0]  EXIT SUB   G_NetError:  PRINT "Server ",server_selection," not available. (",ERROR,")\n"END SUB SUB btnClear_clicked  Iup::ClearList(serverList)  Iup::SetAttribute(text, "VALUE", "")  Iup::SetAttribute(entry, "VALUE", "")END SUB SUB btnSearch_clicked  LOCAL dict, dat, total, info  IUP::SetAttribute(text, "VALUE","Fetching....")  ON ERROR GOTO L_NetError  dict = LEFT(whichDictionary, INSTR(whichDictionary, " "))  OPEN server_selection & ":2628" FOR SOCKET AS 1  IF Iup::GetAttribute(chkAll, "VALUE") THEN    PRINT#1,"DEFINE * " & Iup::GetAttribute(entry,"VALUE") & "\n"  ELSE    PRINT#1,"DEFINE " & dict & " " & Iup::GetAttribute(entry,"VALUE") & "\n"  END IF  REPEAT    LINE INPUT#1, dat    IF LEFT(dat, 3) = "151" THEN      total$ &= "------------------------------\r\n"      total$ &= RIGHT(dat, LEN(dat) - LEN(Iup::GetAttribute(entry, "VALUE")) - LEN(dict))      total$ &= "------------------------------\r\n"      REPEAT        LINE INPUT#1, info        info = REPLACE(info, CHR(34), CHR(92) & CHR(34))        IF LEFT(info, 1) <> "." THEN total &= TRIM(info) & "\n"      UNTIL LEFT(info, 1) = "."      total &= "\n"    END IF  UNTIL LEFT(dat, 3) = "250" OR VAL(LEFT(dat, 3)) > 499  PRINT#1,"QUIT\n"  CLOSE(#1)  IF LEFT(dat, 3) = "552" THEN    total = "No match found."  ELSE IF LEFT(dat, 3) = "501" THEN    total = "Select a dictionary first!"  ELSE IF LEFT(dat, 3) = "550" THEN    total = "Invalid database!"  END IF  Iup::SetAttribute(text, "VALUE", total)EXIT SUB L_NetError:  dat[0] = "Could not lookup word! (" & ERROR & ")"  Iup::SetAttribute(text, "VALUE", dat)END SUB 

John Spikowski:
I was able to get the ScriptBasic IUP extension module built under Ubuntu 64 on the RPI 4B.


--- Code: Script BASIC ---' IUP Button / Event Example IMPORT iup.bas SUB Btn1_clicked  PRINT "BUTTON 1 Event\n"END SUB SUB Btn2_clicked  PRINT "BUTTON 2 Event\n"END SUB SUB Btn3_clicked  PRINT "BUTTON 3 Event\n"END SUB SUB Win_exit  Iup::ExitLoop = TRUEEND SUB Iup::Open()win = Iup::Create("dialog")Iup::SetAttributes(win, "TITLE=\"Test Dialog\", SIZE=300x")horzbox = Iup::Create("hbox")Iup::SetAttributes(horzbox, "GAP=5")btn1 = Iup::Create("button")Iup::SetAttributes(btn1, "TITLE=Button1, EXPAND=HORIZONTAL")btn2 = Iup::Create("button")Iup::SetAttributes(btn2, "TITLE=Button2, EXPAND=HORIZONTAL")btn3 = Iup::Create("button")Iup::SetAttributes(btn3, "TITLE=Button3, EXPAND=HORIZONTAL")Iup::Append(horzbox, btn1)Iup::Append(horzbox, btn2)Iup::Append(horzbox, btn3)Iup::Append(win, horzbox)Iup::SetCallback(win,"CLOSE_CB",ADDRESS(Win_exit()))Iup::SetCallback(btn1,"ACTION",ADDRESS(Btn1_clicked()))Iup::SetCallback(btn2,"ACTION",ADDRESS(Btn2_clicked()))Iup::SetCallback(btn3,"ACTION",ADDRESS(Btn3_clicked()))Iup::Show(win)Iup::MainLoop()Iup::Close() 

ubuntu@rpi4b:~/sbrt/examples$ scriba iup3buttons.sb
BUTTON 1 Event
BUTTON 2 Event
BUTTON 3 Event
ubuntu@rpi4b:~/sbrt/examples$

John Spikowski:
This is the ScriptBasic IUP Online Dictionary running under Ubuntu 64 on the RPi 4B.


--- Code: Script BASIC ---IMPORT iup.bas servers[0]="dict.org"servers[1]="dict1.us.dict.org"servers[2]="all.dict.org" about="""This is a Demoof the IUP GUI Bindingfor Scriptbasic""" ' Initialize IUPIup::Open() ' Create main window win = Iup::Create("dialog")  Iup::SetAttributes(win, "TITLE=\"ScriptBasic IUP Online Dictionary\", SIZE=500x300")  Iup::SetCallback(win,"CLOSE_CB",ADDRESS(Win_exit())) ' Create container to house ALL GUI objects vbox = Iup::Create("vbox")  Iup::SetAttributes(vbox, "MARGIN=10x10") ' Create server panel topBox = Iup::Create("hbox")  Iup::SetAttributes(topBox, "GAP=10")  Iup::Append(vbox, topBox)serverFrame = Iup::Create("frame")  Iup::SetAttributes(serverFrame, "TITLE=Servers, EXPAND=YES")  Iup::Append(topBox, serverFrame)serverBox = Iup::Create("hbox")  Iup::SetAttributes(serverBox, "GAP=5")  Iup::Append(serverFrame, serverBox)serverCombo = Iup::Create("list")  Iup::SetAttributes(serverCombo, "DROPDOWN=YES, SIZE=120x, EXPAND=HORIZONTAL, VALUE=1")  Iup::Append(serverBox, serverCombo)  Iup::SetCallback(serverCombo, "ACTION", ADDRESS(serverCombo_selected()))btnFetch = Iup::Create("button")  Iup::SetAttributes(btnFetch, "TITLE=Fetch, SIZE = 50x")  Iup::Append(serverBox, btnFetch)  Iup::SetCallback(btnFetch, "ACTION", ADDRESS(btnFetch_clicked())) ' Create control panel controlFrame = Iup::Create("frame")  Iup::SetAttributes(controlFrame, "TITLE=Controls")  Iup::Append(topBox, controlFrame)controlBox = Iup::Create("hbox")  Iup::SetAttributes(controlBox, "GAP=5")  Iup::Append(controlFrame, controlBox)btnAbout = Iup::Create("button")  Iup::SetAttributes(btnAbout, "TITLE=About, SIZE = 50x")  Iup::Append(controlBox, btnAbout)  Iup::SetCallback(btnAbout, "ACTION", ADDRESS(btnAbout_clicked()))btnClear = Iup::Create("button")  Iup::SetAttributes(btnClear, "TITLE=Clear, SIZE = 50x")  Iup::Append(controlBox, btnClear)  Iup::SetCallback(btnClear, "ACTION", ADDRESS(btnClear_clicked()))btnExit = Iup::Create("button")  Iup::SetAttributes(btnExit, "TITLE=Exit, SIZE = 50x")  Iup::Append(controlBox, btnExit)  Iup::SetCallback(btnExit,"ACTION",ADDRESS(Win_exit())) ' Create dictionary panel dictFrame = Iup::Create("frame")  Iup::SetAttributes(dictFrame, "TITLE=Dictionaries")  Iup::Append(vbox, dictFrame)serverList = Iup::Create("list")  Iup::SetAttributes(serverList, "EXPAND=YES, VISIBLELINES=1")  Iup::Append(dictFrame, serverList)  Iup::SetCallback(serverList, "ACTION", ADDRESS(serverList_selected())) ' Create text part transFrame = IUP::Create("frame")  Iup::SetAttributes(transFrame, "TITLE=Translation")  Iup::Append(vbox, transFrame)text = Iup::Create("text")  Iup::SetAttributes(text, "MULTILINE=YES, EXPAND=YES")  Iup::Append(transFrame, text) ' Create entry and search button bottomBox = Iup::Create("hbox")  Iup::SetAttributes(bottomBox, "GAP=10")  Iup::Append(vbox, bottomBox)label = Iup::Create("label")  Iup::SetAttributes(label, "TITLE=\"Enter Word to Search For:\", SIZE=x12")  Iup::Append(bottomBox, label)entry = Iup::Create("text")  Iup::SetAttributes(entry, "EXPAND=HORIZONTAL")  Iup::Append(bottomBox, entry)btnSearch = Iup::Create("button")  Iup::SetAttributes(btnSearch,"TITLE=Search, SIZE=50x")  Iup::Append(bottomBox, btnSearch)  Iup::SetCallback(btnSearch, "ACTION", ADDRESS(btnSearch_clicked()))chkAll = Iup::Create("toggle")  Iup::SetAttributes(chkAll, "TITLE=ALL, SIZE=x12")  Iup::Append(bottomBox, chkAll)chkUTF = Iup::Create("toggle")  Iup::SetAttributes(chkUTF, "TITLE=UTF-8, SIZE=x12")  Iup::Append(bottomBox, chkUTF) ' Add the main GUI container to the Window Iup::Append(win, vbox) ' Setup dialog defaults Iup::Show(win)Iup::SetFocus(btnFetch)FOR i = 0 TO UBOUND(servers)  Iup::SetAttribute(serverCombo, "APPENDITEM", servers[i])NEXTIup::SetAttribute(serverCombo, "VALUE", "1")Iup::Update(serverCombo)server_selection = servers[0] ' Main processing loop Iup::MainLoop()Iup::Close()END ' Callback routines SUB Win_exit  Iup::ExitLoop = TRUEEND SUB SUB btnAbout_clicked  Iup::Message("ABOUT", about)END SUB SUB serverCombo_selected  server_selection = Iup::GetListText()END SUB SUB serverList_selected  whichDictionary = Iup::GetListText()END SUB SUB btnFetch_clicked  LOCAL dat, total, count  ON ERROR GOTO G_NetError  OPEN server_selection & ":2628" FOR SOCKET AS #1  PRINT#1,"SHOW DB\n"  LINE INPUT#1, dat  LINE INPUT#1, dat  count = 0  WHILE LEFT(dat, 1) <> "."    LINE INPUT#1, dat    IF LEFT(dat, 1) <> "." THEN total[count] = TRIM(dat)    count+=1  WEND  PRINT#1,"QUIT\n"  CLOSE(#1)  FOR cnt = 0 TO count - 2    Iup::SetAttribute(serverList, "APPENDITEM", total[cnt])  NEXT  Iup::SetAttribute(serverList, "VALUE", "1")  Iup::Update(serverCombo)  whichDictionary = total[0]  EXIT SUB   G_NetError:  PRINT "Server ",server_selection," not available. (",ERROR,")\n"END SUB SUB btnClear_clicked  Iup::ClearList(serverList)  Iup::SetAttribute(text, "VALUE", "")  Iup::SetAttribute(entry, "VALUE", "")END SUB SUB btnSearch_clicked  LOCAL dict, dat, total, info  IUP::SetAttribute(text, "VALUE","Fetching....")  ON ERROR GOTO L_NetError  dict = LEFT(whichDictionary, INSTR(whichDictionary, " "))  OPEN server_selection & ":2628" FOR SOCKET AS 1  IF Iup::GetAttribute(chkAll, "VALUE") THEN    PRINT#1,"DEFINE * " & Iup::GetAttribute(entry,"VALUE") & "\n"  ELSE    PRINT#1,"DEFINE " & dict & " " & Iup::GetAttribute(entry,"VALUE") & "\n"  END IF  REPEAT    LINE INPUT#1, dat    IF LEFT(dat, 3) = "151" THEN      total$ &= "------------------------------\r\n"      total$ &= RIGHT(dat, LEN(dat) - LEN(Iup::GetAttribute(entry, "VALUE")) - LEN(dict))      total$ &= "------------------------------\r\n"      REPEAT        LINE INPUT#1, info        info = REPLACE(info, CHR(34), CHR(92) & CHR(34))        IF LEFT(info, 1) <> "." THEN total &= TRIM(info) & "\n"      UNTIL LEFT(info, 1) = "."      total &= "\n"    END IF  UNTIL LEFT(dat, 3) = "250" OR VAL(LEFT(dat, 3)) > 499  PRINT#1,"QUIT\n"  CLOSE(#1)  IF LEFT(dat, 3) = "552" THEN    total = "No match found."  ELSE IF LEFT(dat, 3) = "501" THEN    total = "Select a dictionary first!"  ELSE IF LEFT(dat, 3) = "550" THEN    total = "Invalid database!"  END IF  Iup::SetAttribute(text, "VALUE", total)EXIT SUB L_NetError:  dat[0] = "Could not lookup word! (" & ERROR & ")"  Iup::SetAttribute(text, "VALUE", dat)END SUB 

Navigation

[0] Message Index

Go to full version