scrolled panel with vpython 6

29 views
Skip to first unread message

newbie

unread,
Nov 8, 2015, 12:54:34 PM11/8/15
to VPython-users
Hello,

I'm new in vpython with wxpython. I tried to make a window with a small visual-window inside and some static_text. But I wanted to let the static_text scrollable. I tried following small example, but the text and the scrollbar won't appear. Can you help me to see what is wrong? Thanks!

from visual import *
import wx
import wx.lib.scrolledpanel as scrolled

f = window(title='test', width=200,height=200)
scene = display(window=f, x=10, y=10, width=100, height=100)
mypanel = f.panel
myscrolled = scrolled.ScrolledPanel(mypanel)
myscrolled.SetupScrolling()
sizer=wx.BoxSizer(wx.VERTICAL)
for i in range(200):
    text=wx.StaticText(myscrolled,pos=(120,i*20),label='test')
    sizer.Add(text,wx.EXPAND)
myscrolled.SetSizer(sizer)

ball=sphere()

Bruce Sherwood

unread,
Nov 8, 2015, 10:30:40 PM11/8/15
to vpytho...@googlegroups.com
I tried the following based on the link shown below and no text appears. I don't have experience with wx scrolling text, but Iwonder whether perhaps the VPython machinery doesn't play well with sizers?

from visual import *
import wx
import wx.lib.scrolledpanel as scrolled

text = ''
for i in range(20):
    text += 'test\n'

class TestPanel(scrolled.ScrolledPanel):

    def __init__(self, parent):

        scrolled.ScrolledPanel.__init__(self, parent, -1)

        vbox = wx.BoxSizer(wx.VERTICAL)

        desc = wx.StaticText(self, -1, text)

        desc.SetForegroundColour("Blue")
        vbox.Add(desc, 0, wx.ALIGN_LEFT | wx.ALL, 5)
        vbox.Add(wx.StaticLine(self, -1, size=(1024, -1)), 0, wx.ALL, 5)
        vbox.Add((20, 20))

        self.SetSizer(vbox)
        self.SetupScrolling()

f = window(title='test', width=600,height=600)
p = TestPanel(f.win)
f.win.Show()
display(window=f, x=400, y=400, width=100, height=100)
sphere()

Robert A. Knop Jr.

unread,
Nov 9, 2015, 7:14:44 AM11/9/15
to vpytho...@googlegroups.com
On Sun, Nov 08, 2015 at 08:30:39PM -0700, Bruce Sherwood wrote:
> I tried the following based on the link shown below and no text appears. I
> don't have experience with wx scrolling text, but Iwonder whether perhaps
> the VPython machinery doesn't play well with sizers?

That has been my experience in the past. I've resorted to having
separate windows for the VPython display and for all the wxpython
controls.

-Rob

--
--Rob Knop
E-mail: rk...@pobox.com
Home Page: http://www.pobox.com/~rknop/
Blog: http://www.galacticinteractions.org/
signature.asc
Reply all
Reply to author
Forward
Message has been deleted
0 new messages