xvfb - Python Module - simpe_3dviz - wxpython - gui - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: xvfb - Python Module - simpe_3dviz - wxpython - gui (/thread-41936.html) |
xvfb - Python Module - simpe_3dviz - wxpython - gui - JayToll - Apr-11-2024 Hello all - Jayson Here... and i have an issue with a Program that uses WxPython now for a gui, hopefully with flask later for web visability on my Virtual Machine. The .py file makes an solid.stl file reads it and displays the stl mesh, however, my issue comes up on the last line of code. and it is with the x display. Code: stl.py from solid2 import * from jupyterscad import view from simple_3dviz import Mesh from simple_3dviz.window import show from simple_3dviz.utils import render import os import subprocess from subprocess import Popen, PIPE, STDOUT subprocess.Popen('sudo Xvfb :1', shell=True, stdout=subprocess.PIPE, stderr=STDOUT) os.environ['DISPLAY'] = '127.0.0.1:1' d = cube(5) + sphere(5).right(5) - cylinder(r=2, h=6) scad = (scad_render(d)) view(scad, outfile='/var/www/design.stl') m = Mesh.from_file('/var/www/design.stl', color=(0.1,0.5,0.1)) show(m, camera_position=(-60., -160, 120), camera_target=(0., 0, 40), light=(-60, -160, 120))say i run the program, with sudo python3 /var/www/cgi-bin/stl.pythis happens.... [attachment=2814] Any knowledge that could get me closer to a screen? maybe on the web too... RE: xvfb - Python Module - simpe_3dviz - wxpython - gui - Gribouillis - Apr-11-2024 It's only a conjecture but I find the way you start the Xvfb process a little strange. Why use shell=True? Why use stdout=PIPE? The problem with stdout=PIPE is that if the process attempts to print some output it will block because you didn't add code to read in the pipe. I suggest that you try xproc = subprocess.Popen(['sudo', 'Xvfb', ':1'])You may also consider to terminate the subprocess at some point. RE: xvfb - Python Module - simpe_3dviz - wxpython - gui - JayToll - Apr-12-2024 I suggest that you try xproc = subprocess.Popen(['sudo', 'Xvfb', ':1'])You may also consider to terminate the subprocess at some point. And I did get further, as well it is a new day. my current code further investigates the main issue: x display Code: from solid2 import * from jupyterscad import view from simple_3dviz import Mesh from simple_3dviz.window import show from simple_3dviz.utils import render from subprocess import Popen import os os.environ['DISPLAY'] = ':1' cmd = "sudo x11vnc -rfbport 8087 -create -env FD_PROG=/usr/bin/fluxbox -env X11VNC_FINDDISPLAY_ALWAYS_FAILS=1 -env X11VNC_CREATE_GEOM=${1:-1024x768x16} -gone 'killall Xvfb' -bg -nopw" xproc = Popen(cmd, shell=True) d = cube(5) + sphere(5).right(5) - cylinder(r=2, h=6) scad = (scad_render(d)) view(scad, outfile='/var/www/design.stl') m = Mesh.from_file('/var/www/design.stl', color=(0.1,0.5,0.1)) show(m, camera_position=(-60., -160, 120), camera_target=(0., 0, 40), light=(-60, -160, 120)) Popen("TASKKILL /F /PID {pid} /T".format(pid=xproc.pid))and this is my output: [attachment=2816] RE: xvfb - Python Module - simpe_3dviz - wxpython - gui - JayToll - Apr-12-2024 Hello again, Jayson Here - Well, I have worked all day with multiple options and this is likely my code for now: #!/usr/bin/env python3 # -*- coding: UTF-8 -*- # enable debugging from solid2 import * from jupyterscad import view from simple_3dviz import Mesh from simple_3dviz.window import show from simple_3dviz.utils import render import os os.environ['DISPLAY'] = ':1' os.environ['wxUSE_DISPLAY'] = '1' d = cube(5) + sphere(5).right(5) - cylinder(r=2, h=6) scad = (scad_render(d)) view(scad, outfile='/var/www/design.stl') m = Mesh.from_file('/var/www/design.stl', color=(0.1,0.5,0.1)) os.system("sudo x11vnc -rfbport 8087 -create -env FD_PROG=/usr/bin/fluxbox -env X11VNC_FINDDISPLAY_ALWAYS_FAILS=1 -env X11VNC_CREATE_GEOM=${1:-1024x768x16} -gone 'killall Xvfb' -bg -nopw &") print ('x11vnc Started') show(m, camera_position=(-60., -160, 120), camera_target=(0., 0, 40), light=(-60, -160, 120)) print ('Visualization displayed')IT MOSTLY WORKS GOOD.... The issue arrises with wxPython not adapting to display :1 somehow and i do not now how to get it to accept the display variable.... RE: xvfb - Python Module - simpe_3dviz - wxpython - gui - JayToll - Apr-12-2024 The issue arrises with wxPython not adapting to display :1 somehow and i do not now how to get it to accept the display variable.... .... well, I am doing research and i find this on Google. [attachment=2817] |