Python Forum
xvfb - Python Module - simpe_3dviz - wxpython - gui
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
xvfb - Python Module - simpe_3dviz - wxpython - gui
#1
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.py
this happens....
   


Any knowledge that could get me closer to a screen? maybe on the web too...
Reply
#2
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.
« We can solve any problem by introducing an extra level of indirection »
Reply
#3
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:
   

Attached Files

Thumbnail(s)
   
Reply
#4
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....
Reply
#5
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.



   
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [WxPython] wxpython and python 3.6 on linux Barrowman 3 6,852 Mar-15-2018, 06:57 PM
Last Post: Larz60+
  wxPython install on raspberry pi3 and python 3.6.2. djdan_23 3 7,188 Sep-13-2017, 11:49 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020