Text output

Georgia Tech has just started a Corsera Massive Open Online Course (MOOC, www.coursera.org/course/phys1) in which students use their smartphones to capture video of moving objects and then model the motion in 3D using VPython (vpython.org). As some of you know, the recent VPython 6.x is based on wxPython, whereas VPython 5.x had platform-dependent C++ code for key elements of the module.

VPython has a “label” object which displays 2D text “billboarded” in the scene – that is, the text always faces forward. The implementation is quite different between VPython 5.x and 6.x. For some students in the Georgia Tech MOOC, trying to execute the label object causes a crash. Based on reports in the course forum, the number of students experiencing the bug is very small. Nearly all of the MOOC students use the python.org 32-bit Windows Python 2.7, including all those who have reported the label problem. None of the Windows computers I have access to show this bug, nor has it been previously reported outside the MOOC.

Below I display the guts of the VPython 6.x implementation of label (there’s also some platform-independent C++ code). Because I don’t have access to the computers that have the bug, I don’t have any detailed information, just that there is a crash. I realize that it’s a very long shot, but does this ring any bells with anyone? Thanks.

dc = _wx.MemoryDC() # wx was imported as _wx; currently using classic wxPython

height = int(fudge*height + 0.5)

dc.SetFont(_wx.Font(height, wfont, wstyle, wweight))

while text and text[0] == ‘\n’: text = text[1:]

while text and text[-1] == ‘\n’: text = text[:-1]

lines = text.split(’\n’)

maxwidth = 0

totalheight = 0

heights = []

for line in lines:

if line == ‘’: line = ’ ’

w,h = dc.GetTextExtent(line)

h += 1

w += 2

if w > maxwidth: maxwidth = w

heights.append(totalheight)

totalheight += h

if ‘phoenix’ in _wx.PlatformInfo:

bmp = _wx.Bitmap(maxwidth,totalheight) # Phoenix

else:

bmp = _wx.EmptyBitmap(maxwidth,totalheight) # classic

dc.SelectObject(bmp)

fore = (int(255*color[0]),

int(255*color[1]),

int(255*color[2]))

dc.SetTextForeground(fore)

back = (int(255*background[0]),

int(255*background[1]),

int(255*background[2]))

if (back == fore):

if fore == (0,0,0): back = (255,255,255)

elif fore == (255,255,255): back = (0,0,0)

else: back = (fore[0]//2, fore[1]//2, fore[2]//2)

brush = _wx.Brush(back)

dc.SetBackground(brush)

dc.Clear()

for n, line in enumerate(lines):

dc.DrawText(line, 1, heights[n])

dc.SelectObject( _wx.NullBitmap )

if ‘phoenix’ in _wx.PlatformInfo:

img = bmp.ConvertToImage() # Phoenix

data = asarray(img.GetData()) # Phoenix; maybe should be GetDataBuffer()

else:

img = _wx.ImageFromBitmap(bmp) # classic

data = fromstring(img.GetData(), dtype=uint8) # classic

I should have mentioned that these same students don’t have a bug with the older VPython 5.x.

Bruce Sherwood wrote:

Georgia Tech has just started a Corsera Massive Open Online Course
(MOOC, www.coursera.org/course/phys1) in which students use their
smartphones to capture video of moving objects and then model the motion
in 3D using VPython (vpython.org). As some of you know, the recent
VPython 6.x is based on wxPython, whereas VPython 5.x had
platform-dependent C++ code for key elements of the module.

VPython has a "label" object which displays 2D text "billboarded" in the
scene -- that is, the text always faces forward. The implementation is
quite different between VPython 5.x and 6.x. For some students in the
Georgia Tech MOOC, trying to execute the label object causes a crash.
Based on reports in the course forum, the number of students
experiencing the bug is very small. Nearly all of the MOOC students use
the python.org 32-bit Windows Python 2.7, including all those who have
reported the label problem. None of the Windows computers I have access
to show this bug, nor has it been previously reported outside the MOOC.

Below I display the guts of the VPython 6.x implementation of label
(there's also some platform-independent C++ code). Because I don't have
access to the computers that have the bug, I don't have any detailed
information, just that there is a crash. I realize that it's a very long
shot, but does this ring any bells with anyone? Thanks.

Nothing jumps out at me as being problematic. Sorry.

···

--
Robin Dunn
Software Craftsman

A user who sees the problem volunteered to do tests for me, in which I give him special versions of the software that output special debugging information. We’ve verified that the bitmap being sent from the wxPython code to the C++ code is correct, which would seem to confirm that there’s nothing wrong in this part of the wxPython world.

Ultimately it turned out that it was just a need to update the graphics driver. All is well. I apologize for bothering people about this!

Oh well,

Nice to get updated on how wx-based VPython is doing, in any case.

-Chris

···

On Thu, May 30, 2013 at 10:09 AM, Bruce Sherwood <bruce.sherwood@gmail.com> wrote:

Ultimately it turned out that it was just a need to update the graphics
driver. All is well. I apologize for bothering people about this!

--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Since you asked, Chris, wx-based VPython is doing very well indeed:

Mike Schatz teaches Matter & Interactions (matterandinteractions.org) at Georgia Tech. He has developed a Coursera MOOC (Massive Open On-line Course) on mechanics which started May 20 (www.coursera.org/course/phys1). It is unusual for a MOOC in having a strong experimental component and a strong computational modeling component. Students use their smartphones to capture video of motion, extract coordinates and times using Tracker (www.cabrillo.edu/~dbrown/tracker/), and model the motion in 3D using VPython (vpython.org). The slogan for the course is “Your world is your lab.” Student experimental and computational work is evaluated by other students.

The textbook is the first 11 chapters of Matter & Interactions, whose publisher, John Wiley & Sons, has partnered with Coursera and a company named Chegg to produce an ebook version that is freely available to students in the MOOC during the course. Students have an option to buy permanent access to the ebook.

Judging from the number of VPython downloads, there are about 5000 students actively engaged with the course. I volunteered to help with VPython installation issues, which have almost entirely fallen into two categories: misunderstanding the installation instructions, or a need to update the graphics driver (to support the OpenGL 3D graphics library used by VPython).

I personally am happy to see all the ferment in the world of MOOCs. Trying new things is a Good Thing, even if the eventual value of MOOCs remains to be established. In this context, Mike has done something particularly interesting and innovative.