# Linux: G4P and dialog windows

**URL:** <https://discourse.processing.org/t/linux-g4p-and-dialog-windows/9841>\
**Category:** Processing for Pi\
**Created:** [April 1, 2019, 4:59pm UTC](https://discourse.processing.org/t/linux-g4p-and-dialog-windows/9841 "2019-04-01T16:59:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcduino](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jcduino](https://discourse.processing.org/u/jcduino)\
**Post date:** [April 1, 2019, 4:59pm UTC](https://discourse.processing.org/t/linux-g4p-and-dialog-windows/9841/1 "2019-04-01T16:59:29Z")

</div>

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:

```auto
#!/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.

```auto
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

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [April 1, 2019, 5:43pm UTC](https://discourse.processing.org/t/linux-g4p-and-dialog-windows/9841/2 "2019-04-01T17:43:42Z")

</div>

> [@jcduino](#):
>
> 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

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

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [April 2, 2019, 12:06am UTC](https://discourse.processing.org/t/linux-g4p-and-dialog-windows/9841/3 "2019-04-02T00:06:40Z")

</div>

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](https://discourse.processing.org/t/3d-terrain-standalone-display-project/4162/5) ,

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 )

---

<div class="post-metadata">

**Author:** ![jcduino](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jcduino](https://discourse.processing.org/u/jcduino)\
**Post date:** [April 2, 2019, 6:57am UTC](https://discourse.processing.org/t/linux-g4p-and-dialog-windows/9841/4 "2019-04-02T06:57:07Z")

</div>

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.

> [@kll](#):
>
> sorry first: why you use LITE?  
> i can not see a reason for this?

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.

> [@kll](#):
>
> other question is if the processing sketch runs ( incl the buttons )  
> if you start it from IDE? or same problem?

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

> [@kll](#):
>
> if you want i can test your sketch here ( or a reduced version just with the buttons )

```auto
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.

> [@quark](#):
>
> I suggest you change the discussion title to  
> **Linux: G4P and dialog windows**  
> to try and get the Linux users to come here.

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.

---

<div class="post-metadata">

**Author:** ![jcduino](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jcduino](https://discourse.processing.org/u/jcduino)\
**Post date:** [April 2, 2019, 8:50am UTC](https://discourse.processing.org/t/linux-g4p-and-dialog-windows/9841/5 "2019-04-02T08:50:58Z")

</div>

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://pi.processing.org/technical/)

[https://eltechs.com/how-to-enable-opengl-on-raspberry-pi/](https://eltechs.com/how-to-enable-opengl-on-raspberry-pi/)

Regards

---

<div class="post-metadata">

**Author:** ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)\
**Post date:** [April 2, 2019, 9:04am UTC](https://discourse.processing.org/t/linux-g4p-and-dialog-windows/9841/6 "2019-04-02T09:04:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [April 2, 2019, 10:31am UTC](https://discourse.processing.org/t/linux-g4p-and-dialog-windows/9841/7 "2019-04-02T10:31:00Z")

</div>

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:

 ![2019-04-02_16-08-50_snap](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/0abcd5ac93bc9cbd5516286b73d10421a1ffacdb.png)  
start processing:  
 ![2019-04-02_16-17-42_snap](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/36a48ed854c777e6852312d4cbcf03eed04cc58d.png)  
run your sketch  
 ![2019-04-02_16-19-02_snap](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/4ce706a74b10c4bfd323639ce53607b466527212.png)

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 )

```auto
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? )

* * *

---

<div class="post-metadata">

**Author:** ![jcduino](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jcduino](https://discourse.processing.org/u/jcduino)\
**Post date:** [April 4, 2019, 7:05am UTC](https://discourse.processing.org/t/linux-g4p-and-dialog-windows/9841/8 "2019-04-04T07:05:29Z")

</div>

Hi,

> [@kll](#):
>
> - 
> - when fullscreen can not use?
> 
> ( insofar, changing the GL driver to ?FULL? KMS did change that? )

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.
