svgui/pyjs/lib/sys.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 13 Jan 2017 19:51:36 +0300
changeset 1631 940e20a8865b
parent 728 e0424e96e3fd
child 1730 64d8f52bc8c8
permissions -rw-r--r--
fix issue with printing scheme (FBD, LD or SFC) with comment element on GNU/Linux

If you draw FBD scheme and place comment on it and then try to print
it, then no wires will be printed and comment box is empty (text is
missing). This happens only for wx.PrinterDC and not on wx.MemoryDC
that is used to draw print preview window in Beremiz IDE.
Looks like a bug in wxPython or wxWidgets.

There were found several workaround for this issue.
1) If some dc.DrawLines call is placed before dc.DrawPolygon, then the
problem is gone.

...
dc.DrawLines(polygon)
dc.DrawPolygon(polygon)
...

2) Reseting DC brush solves the problem as well (see this changeset).
# the platform name (PyV8, smjs, Mozilla, IE6, Opera, Safari etc.)
platform = '' # to be updated by app, on compile

# a dictionary of module override names (platform-specific)
overrides = None # to be updated by app, on compile

# the remote path for loading modules
loadpath = None 

stacktrace = None 

appname = None 

def setloadpath(lp):
    global loadpath
    loadpath = lp

def setappname(an):
    global appname
    appname = an

def getloadpath():
    global loadpath
    return loadpath

def addoverride(module_name, path):
    global overrides
    overrides[module_name] = path

def addstack(linedebug):
    JS("""
        if (pyjslib.bool((sys.stacktrace === null))) {
            sys.stacktrace = new pyjslib.List([]);
        }
        sys.stacktrace.append(linedebug);
    """)
def popstack():
    JS("""
        sys.stacktrace.pop()
    """)

def printstack():
    JS("""
        var res = '';

        var __l = sys.stacktrace.__iter__();
        try {
            while (true) {
                var l = __l.next();
                res +=  ( l + '\\n' ) ;
            }
        } catch (e) {
            if (e != pyjslib.StopIteration) {
                throw e;
            }
        }

        return res;
    """)