Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GFX processes running in pty4j on Windows appear behind existing windows #102

Open
clivehaworth opened this issue Apr 1, 2021 · 2 comments

Comments

@clivehaworth
Copy link

I'm using pty4j in my Java servlet to run a Python interpreter. The servlet uses a websocket to communicate with xterm.js running in a browser on Windows. The whole thing works really well, except..

If I run a eg. Python turtle program, The Python window appears behind the browser. I'm guessing the fact the WinPTY console is hidden isn't helping.

Have you come across this sort of thing and do you know of a workaround?

Thx, Clive

@segrey
Copy link
Collaborator

segrey commented Apr 1, 2021

@clivehaworth Good to hear it works overall. Unfortunately, no ideas what can be wrong off the top of my head. Maybe you could provide a small reproducing example? Maybe it will be fixed after adding ConPTY support (ETA - this year).

@clivehaworth
Copy link
Author

Thanks for getting back Sergey.

Difficult to provide a self-contained example as it involves servlets, websockets, browsers, Python etc. Here's the gist..

Start a python process on the server to run the Python file.

String command = new String[] { "python", "-u", pyFile };
PtyProcess process = PtyProcess.exec(command, env, folder);
process.setWinSize(new WinSize(cols, rows));

Attach io to websocket...

stdin = process.getOutputStream();
stdout = process.getInputStream();

The Python file contains something like:

import turtle
screen = turtle.Screen() 
screen.title("Just wanted to say..")
screen.setup(500, 400)
screen.bgcolor("lightgreen")
turtle.write("Hello world!", font=("Courier", 30, "italic"), align="center")
screen.mainloop()

The resulting Python window is created behind all other windows. Looking at the source to WinPTY, it creates and hides the console (for good reason). I'm guessing any program running inside that console (in this case Python) will inherit the Window Manager settings of the parent process. Given the console is hidden, the Python program goes to to the back...

Hope this clarifies it!

Clive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants