Author Topic: RaspberryBASIC.org Forum  (Read 99477 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: RaspberryBASIC.org Forum
« Reply #225 on: December 25, 2019, 12:31:17 PM »
I used fresh unzips of the IUP/CD/IM/FTGL/LUA53 and used the two make files you posted.

I can try recompiling IUP again.

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: RaspberryBASIC.org Forum
« Reply #226 on: December 25, 2019, 01:42:36 PM »
This time I ran make from the root iup directory rather than src. It looks good.



ubuntu@rpi4b:~/iup-dev/iup/lib/Linux53_arm64$ ls -l
total 22172
drwxr-xr-x 2 ubuntu ubuntu    4096 Dec 25 13:37 Lua53
-rw-r--r-- 1 ubuntu ubuntu 2627956 Dec 25 13:23 libiup.a
-rwxr-xr-x 1 ubuntu ubuntu 1258520 Dec 25 13:23 libiup.so
-rw-r--r-- 1 ubuntu ubuntu 4819946 Dec 25 13:28 libiup_mglplot.a
-rwxr-xr-x 1 ubuntu ubuntu 2942288 Dec 25 13:28 libiup_mglplot.so
-rw-r--r-- 1 ubuntu ubuntu  490624 Dec 25 13:24 libiup_plot.a
-rwxr-xr-x 1 ubuntu ubuntu  299800 Dec 25 13:24 libiup_plot.so
-rw-r--r-- 1 ubuntu ubuntu 4603046 Dec 25 13:35 libiup_scintilla.a
-rwxr-xr-x 1 ubuntu ubuntu 3003640 Dec 25 13:35 libiup_scintilla.so
-rw-r--r-- 1 ubuntu ubuntu   29132 Dec 25 13:23 libiupcd.a
-rwxr-xr-x 1 ubuntu ubuntu   29856 Dec 25 13:23 libiupcd.so
-rw-r--r-- 1 ubuntu ubuntu  627932 Dec 25 13:24 libiupcontrols.a
-rwxr-xr-x 1 ubuntu ubuntu  338848 Dec 25 13:24 libiupcontrols.so
-rw-r--r-- 1 ubuntu ubuntu   21882 Dec 25 13:24 libiupgl.a
-rwxr-xr-x 1 ubuntu ubuntu   24056 Dec 25 13:24 libiupgl.so
-rw-r--r-- 1 ubuntu ubuntu  252126 Dec 25 13:24 libiupglcontrols.a
-rwxr-xr-x 1 ubuntu ubuntu  132872 Dec 25 13:24 libiupglcontrols.so
-rw-r--r-- 1 ubuntu ubuntu   16554 Dec 25 13:35 libiupim.a
-rwxr-xr-x 1 ubuntu ubuntu   23992 Dec 25 13:35 libiupim.so
-rw-r--r-- 1 ubuntu ubuntu  292404 Dec 25 13:35 libiupimglib.a
-rwxr-xr-x 1 ubuntu ubuntu  271600 Dec 25 13:35 libiupimglib.so
-rw-r--r-- 1 ubuntu ubuntu  315412 Dec 25 13:36 libiuptuio.a
-rwxr-xr-x 1 ubuntu ubuntu  176664 Dec 25 13:36 libiuptuio.so
-rw-r--r-- 1 ubuntu ubuntu   19950 Dec 25 13:35 libiupweb.a
-rwxr-xr-x 1 ubuntu ubuntu   25688 Dec 25 13:35 libiupweb.so
ubuntu@rpi4b:~/iup-dev/iup/lib/Linux53_arm64$

« Last Edit: December 25, 2019, 05:15:45 PM by John »

Offline AIR

  • BASIC Developer
  • Posts: 932
  • Coder
Re: RaspberryBASIC.org Forum
« Reply #227 on: December 25, 2019, 01:47:30 PM »
That's where you're supposed to run make, otherwise it can't find what it needs.
BTW, your issue with NIUP is the compiler; you're using the bleeding edge version, which has a bunch of changes.
Using the stable version, the NIUP example compiles fine.  No changes required to the import.


Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: RaspberryBASIC.org Forum
« Reply #228 on: December 25, 2019, 02:29:30 PM »
I was able to compile all the IUP Examples from the repo.


Offline jalih

  • Advocate
  • Posts: 111
Re: RaspberryBASIC.org Forum
« Reply #229 on: December 25, 2019, 02:40:59 PM »
I wrote 8th entry for your GUI Login challenge:

Code: [Select]
requires gui

var gui

{ guest: "pa$$w0rd!" } constant passwords

: authenticate
  "edit1" g:child g:text? passwords swap m:@ nip null? if
    "User not found!" . cr
    2drop
  else
    swap
    "edit2" g:child g:text? nip s:= if
      "Authenticated!" . cr
      bye
    else
      "Username and password don't match!" . cr
    then
  then ;

{
  kind: "win",
  buttons: 5,
  title: "Login",
  wide: 360,
  high: 160,
  resizable: false,
  bg:"lightgray",
  center: true,
  init: ( gui ! ),
  children:
  [
    {
      kind: "box",
      name: "frame",
      bounds: "10, 10, parent.width-10, parent.height-10",
      bg: "gray",
      children:
      [
        {
          kind: "label",
          label: "Username:",
          bounds: "parent.left, parent.top+10, 80, top+24 ",
          name: "lbl1"
},
        {
          kind: "edit",
          bounds: "lbl1.right+10, lbl1.top, parent.width-10, top+24",
          name: "edit1",
          max-text: 32
        },
        {
          kind: "label",
          label: "Password:",
          bounds: "lbl1.left, lbl1.bottom+10, 80, top+24 ",
          name: "lbl2"
},
        {
          kind: "edit",
          bounds: "edit1.left, lbl2.top, parent.width-10, top+24",
          name: "edit2",
          max-text: 32,
          password-char: "*"
        },
        {
          kind: "btn",
          label: "Login",
          bg: "darkgray",
          bounds: "lbl2.left, lbl2.bottom+20, edit2.right, top+30",
          name: "button",
          tooltip: "Login to account",
          click: ' authenticate
        }
      ]
    }
  ]
} var, gui-desc

: app:main
  gui-desc @ g:new ;

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: RaspberryBASIC.org Forum
« Reply #230 on: December 25, 2019, 03:50:02 PM »
Quote from: AIR
BTW, your issue with NIUP is the compiler; you're using the bleeding edge version, which has a bunch of changes.

I'm out of Band-Aids so I compiled Nim 1.0.4 from source.

Code: Text
  1. import niup
  2. import niupext
  3.  
  4. proc btn_exit_cb(ih:PIhandle):cint {.cdecl.}=
  5.   # Exits the main loop
  6.   return IUP_CLOSE
  7.  
  8. proc mainProc =
  9.   var dlg, button, label, vbox: PIhandle
  10.  
  11.   Open()
  12.  
  13.   label =  Label("Hello world from IUP.")
  14.   button = Button("OK", nil)
  15.  
  16.   vbox = Vbox(label, button, nil)
  17.   withPIhandle vbox:
  18.     "ALIGNMENT" "ACENTER"
  19.     "GAP"       "10"
  20.     "MARGIN"    "10x10"
  21.  
  22.   dlg = Dialog(vbox)
  23.   SetAttribute(dlg, "TITLE", "Hello World with callback")
  24.  
  25.   # Registers callbacks
  26.   SetCallback(button, "ACTION", btn_exit_cb)
  27.  
  28.   ShowXY(dlg, IUP_CENTER, IUP_CENTER)
  29.  
  30.   MainLoop()
  31.  
  32.   Close()
  33.  
  34. if isMainModule:
  35.   mainProc()
  36.  

The isxxxx const's are working again and so is with.

« Last Edit: December 25, 2019, 06:21:24 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: RaspberryBASIC.org Forum
« Reply #231 on: December 26, 2019, 05:03:58 PM »
Here is a preview of what the ScriptBasic login submission will look like. I'm cleaning up the code and will post it on the Raspberry BASIC forum soon.



« Last Edit: December 26, 2019, 05:08:12 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: RaspberryBASIC.org Forum
« Reply #232 on: December 26, 2019, 07:35:50 PM »
AIR,

The only issue I have with my submission is IUP isn't toggling the password text box when I change the "PASSWORD" attribute. It's like once it's set as a password text box that is what it remains.

Offline AIR

  • BASIC Developer
  • Posts: 932
  • Coder
Re: RaspberryBASIC.org Forum
« Reply #233 on: December 26, 2019, 07:43:53 PM »
Don't know what to tell you, I don't use IUP.

Here's my almost finished version 1.1  using C and GTK3....
AIR.

Offline AIR

  • BASIC Developer
  • Posts: 932
  • Coder
Re: RaspberryBASIC.org Forum
« Reply #234 on: December 26, 2019, 08:34:29 PM »
Code: C
  1. /* logon2.c
  2.  *
  3.  * version 1.1
  4.  *
  5.  * GUI Logon Screen Challenge Submission
  6.  * C version, using GTK+-3.0
  7.  *
  8.  * Written by Armando I. Rivera (AIR)
  9.  *
  10.  * Compile:  gcc logon2.c $(pkg-config --libs --cflags gtk+-3.0) -o logon2
  11. */
  12.  
  13.  
  14. #include <gtk/gtk.h>
  15.  
  16. GtkWidget *err_label;
  17.  
  18. void onClick( GtkWidget *widget, gpointer   data ) {
  19.     gchar *stupid_password = "pa$$w0rd!";
  20.     gchar *user_password;
  21.     g_object_get(data,"text",&user_password,NULL);
  22.  
  23.     if (g_strcmp0 (stupid_password,user_password) == 0) {
  24.         g_print("Your are now logged in!\n");
  25.         gtk_main_quit();
  26.     }else{
  27.         gtk_label_set_markup(GTK_LABEL(err_label), "<span color=\"red\" font_desc=\"16.0\">** Invalid Password **</span>");
  28.         g_print("Username or Password is Incorrect!\n");
  29.  
  30.     }
  31. }
  32.  
  33. int main( int argc, char *argv[])
  34. {
  35.     GtkWidget *window, *layout, *image, *btnLogin;
  36.     GtkWidget *lblUser, *lblPass, *txtUser, *txtPass;
  37.  
  38.     gtk_init(&argc, &argv);
  39.    
  40.     layout = gtk_layout_new(NULL, NULL);
  41.  
  42.     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  43.     g_object_set(window,
  44.                 "title","Login",
  45.                 "default-width",660,
  46.                 "default-height",370,
  47.                 "resizable",FALSE,
  48.                 "window-position",GTK_WIN_POS_CENTER,
  49.                 "child",layout,
  50.                 "decorated",0,
  51.                 NULL);
  52.  
  53.  
  54.     image = gtk_image_new_from_file("logon.png");
  55.     g_object_set(layout,"child",image,"margin",10,NULL);
  56.    
  57.     lblUser = gtk_label_new("");
  58.     lblPass = gtk_label_new("");
  59.     err_label = gtk_label_new("");
  60.     g_object_set(err_label,"width-request",270,NULL);
  61.    
  62.     gtk_label_set_markup(GTK_LABEL(lblUser), "<span font_desc=\"16.0\">Username:</span>");
  63.     gtk_label_set_markup(GTK_LABEL(lblPass), "<span font_desc=\"16.0\">Password:</span>");
  64.    
  65.     txtUser = gtk_entry_new();
  66.     txtPass = gtk_entry_new();
  67.    
  68.    
  69.     g_object_set(txtPass,"visibility", FALSE,NULL);
  70.    
  71.     btnLogin = gtk_button_new_with_label("Login");
  72.     g_object_set(btnLogin,"width-request",170,NULL);
  73.  
  74.  
  75.     gtk_layout_put(GTK_LAYOUT(layout), lblUser, 330, 112);
  76.     gtk_layout_put(GTK_LAYOUT(layout), lblPass, 330, 162);
  77.     gtk_layout_put(GTK_LAYOUT(layout), txtUser, 460, 110);
  78.     gtk_layout_put(GTK_LAYOUT(layout), txtPass, 460, 160);
  79.     gtk_layout_put(GTK_LAYOUT(layout), btnLogin, 460, 210);
  80.     gtk_layout_put(GTK_LAYOUT(layout), err_label, 300, 16);
  81.  
  82.     g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
  83.     g_signal_connect (btnLogin, "clicked", G_CALLBACK (onClick), txtPass);
  84.  
  85.     gtk_widget_show_all(window);
  86.  
  87.     gtk_main();
  88.  
  89.     return 0;
  90. }
  91.  
  92.  

Source and graphic attached in archive below....

AIR.

Offline AIR

  • BASIC Developer
  • Posts: 932
  • Coder
Re: RaspberryBASIC.org Forum
« Reply #235 on: December 26, 2019, 08:58:13 PM »
AIR,

The only issue I have with my submission is IUP isn't toggling the password text box when I change the "PASSWORD" attribute. It's like once it's set as a password text box that is what it remains.

Going back to my Hotbasic and BCX Linux days, when I was neck deep in the GTK implementation for both, I recall that whenever you changed attributes like this you needed to tell the library to redraw the objects/form in order to show the up-to-date representation.

I don't know how you would do that with IUP, but since it's using the GTK backend, there should be a function call that does this.

AIR.

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: RaspberryBASIC.org Forum
« Reply #236 on: December 26, 2019, 09:33:50 PM »
Nice thought but didn't work.

Code: ScriptBasic
  1. SUB show_password
  2.   showcb = Iup::GetAttribute(showpwd, "VALUE")
  3.   IF showcb = "ON" THEN
  4.     Iup::SetAttribute(pwdtxt, "PASSWORD", "NO")
  5.     Iup::Refresh(pwdtxt)
  6.   ELSE
  7.     Iup::SetAttribute(pwdtxt, "PASSWORD", "YES")
  8.     Iup::Refresh(pwdtxt)
  9.   END IF
  10. END SUB
  11.  

Offline AIR

  • BASIC Developer
  • Posts: 932
  • Coder
Re: RaspberryBASIC.org Forum
« Reply #237 on: December 26, 2019, 09:52:39 PM »
You may want to try this in C to see if there's a problem with the library or your implemented interface...

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: RaspberryBASIC.org Forum
« Reply #238 on: December 27, 2019, 05:42:41 AM »
I think I this is a bug. I'll ask Antonio to look into it.

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: RaspberryBASIC.org Forum
« Reply #239 on: December 27, 2019, 07:23:08 AM »
I posted an issue on the niup repo and the maintainer responded.

Quote from: Dario Lah@niup repo
I'm not following devel branch, only stable releases of Nim.

First issue looks like it could be fixed with new c2nim, problem code is result of c2nim.

Second is possibly because of changes in macros API, I need changelog for Nim.

Once there is new stable Nim release, I'll update NIUP.

Thank you for notice