Linux: G4P and dialog windows

Hi,

I’m programming a GUI with processing using the nice G4P library and running in a Raspberry Pi with the lastest Raspbian stretch lite.

I’ve installed X and openbox.

When raspbian starts the cron runs this script:

#!/bin/bash
startx &
export display=:0
/home/pi/processingAppExported/processingAppExported
chvt 1

I run my processing aplication (that I’ve exportes previosly) in fullscreen, like a “kiosk mode”, when system starts, and runs pretty well, but I’ve 3 buttons that freeze the system.
The first it’s to update the app. If it doesn’t find a file (updater.sh) let the user know with a G4P call to a system dialog. The second it’s to shutdown the system and the third it’s for restart. I show you an example.

if (G4P.selectOption(this, "Do you really want to turn off the system?", "Turn off?", G4P.QUERY, G4P.YES_NO) == G4P.YES) {
        System.exit(0);
}

As I’ve said before, the system freezes when I touch these buttons…

When I’m programming and testing in my desktop PC with Windows 10 all run well and I can see the system dialogs so I think that it’s not a G4P issue and may be my question would be better for a linux forum, but may be here there someone who can help me.

Best regards

jcduino

1 Like

I suggest you change the discussion title to
Linux: G4P and dialog windows
to try and get the Linux users to come here.

1 Like

sorry first: why you use LITE?
i can not see a reason for this?

here a other version for a autostart of a exported app
on raspberry pi
3D terrain standalone display project ,

other question is if the processing sketch runs ( incl the buttons )
if you start it from IDE? or same problem?

if you want i can test your sketch here ( or a reduced version just with the buttons )

Hi!

First, I’ve to say that it’s working well now. I’ve removed P2D render from fullScreen() and works well.
I had seen some issues with P2D render in raspbian and I thought in trying without the P2D and it worked…So may be it’s a processing issue.

I need all the avaible resources, I don’t need a environment like gnome, kde or xfce, only a minimun like openbox. Something similar to a kiosk mode.

I haven’t test it but I think that I would have the same problem, the P2D render.

import g4p_controls.*;

GButton buttonOff;

void setup() {
    //size(300, 300);
    size(300, 300, P2D);

    buttonOff =  new GButton(this, width/2-75, height/2-75, 150, 150, "Turn off");
    buttonOff.addEventHandler(this, "buttonOffClick");
}

void draw() {
    background(0);
}

public void buttonOffClick(GButton button, GEvent event){
    if (G4P.selectOption(this, "Do you want to turn off the system?", "Turn off?", G4P.QUERY, G4P.YES_NO) == G4P.YES) {
        System.exit(0);
    }
}

This code have the same behavior than mine. I don’t use a VNC viewer so, please, don’t use a VNC viewer, use a screen connected to your raspberry pi.

Thank you for your suggestion and your library! May be you know somethink about this issue with P2D render.
I’ve to say that in Windows 10 the P2D render works and show the dialog box, but the first time it’s not in the foreground, I have to “navigate” (Alt+Tab) to find it, and then, the next times the dialog box is already in the foreground while running the same sketch.
If I don’t use de P2D render the dialog box is always in the foreground. I don’t know if I have explained well, sorry.

Best regards.

1 Like

Hi again!

I’ve been reviewing the documentation and I have a little update. I haven’t GL driver enabled in the Pi. I was using the Legacy graphics because Processing docs say that they support P2D and P3D render with some limitations and possible bugs, so may be this is one of these bugs.
I’ve changed to the Experimental graphics and all works fine with P2D render.

https://pi.processing.org/technical/

https://eltechs.com/how-to-enable-opengl-on-raspberry-pi/

Regards

2 Likes

I was about to ask you if you were using the legacy driver. Pretty sure what you’re trying to do couldn’t work with that. In fact, using multiple windows in general is rather error / crash prone.

1 Like

thanks, but would be interesting to know if there is really
a better performance with LITE + OPENBOX
hardware: Raspberry Pi 3B+

or RASPBIAN ( i use the DESKTOP FULL )
( and SSH VNC enabled )
work many years headless but now also HDMI -> TV connected
( and my wife got a new big TV )

install processing with
curl https://processing.org/download/install-arm.sh | sudo sh

have some rare P3D sketch what not work in LEGACY GL
but that is my usual mode.
also memory split is set to 128
taskmanager show:


start processing:

run your sketch

that is only for info,
i did not test with FULL KMS, not with run a EXPORTED APP
so what i talk here is only regarding my question to your LITE setup
( for hardware RPI zero (W) i can not comment )


i never used that G4P question ( G4P.selectOption ) , but used my own
Button ask question ( INT or FLOAT input )

import javax.swing.JOptionPane;
//_________________________________________________________________ askF  call: A = askF("A",A);
float askF(String ask, float F) {
  String r = JOptionPane.showInputDialog(null, "new Setpoint for "+ask+" (now "+F+" )", "Input (FLOAT)", JOptionPane.QUESTION_MESSAGE);
  if (r == null ) { 
    print(" NULL "); 
    r = str(F);
  }                           // handle CANCEL
  try { 
    F = Float.parseFloat(r);
  } 
  catch(NumberFormatException e) { 
    println("you did not enter a int or float number!");
  }
  println("new "+ask, F);
  return F;
}

//_________________________________________________________________ mouse position over rectangle yes/no
boolean overRect(int x, int y, int width, int height) {
  if (mouseX >= x && mouseX <= x+width && 
    mouseY >= y && mouseY <= y+height) {
    return true;
  } else {
    return false;
  }
}


//_________________________________________________________________ show_button
void show_button(int xpos, int ypos, int xwide, int ywide, String Btxt, color border, color filler, color texter) {
  textAlign(CENTER);
  textSize(B_textsize);
  strokeWeight(2);                                                               // Button border width
  stroke(border);                                                                // Button border color
  fill(filler);                                                                  // Button fill color
  rect(xpos, ypos, xwide, ywide);                                                // Button rectangle
  fill(texter);                                                                  // text color
  text(Btxt, xpos + xwide/2, ypos+ywide/2+B_textsize/2);                         // some pix too low
  noStroke();
}

there also have the problem that that little window is behind main window
( when you start it first time )
even when have focus… so must move it

    • when fullscreen can not use?

( insofar, changing the GL driver to ?FULL? KMS did change that? )


1 Like

Hi,

I changed my sketch to fullScreen(P2D) with FULL KMS and works.

Thank you for the answers, helped me very much to solve the problem.

Best Regards.

2 Likes