[wxPython] Problems and Questions

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] Problems and Questions

Joel Lucsy-3
Hello all. So, I was trying to use the wxp tags to implement a simple GUI
layout scheme but ran into some problems. First, I tried placing a
wxRadioBox. For the life of me I couldn't figure out what the keyword for
the choices was. Had to download the source to find out it's called LIST.
Seems a bit inconsistent. The documentation(I realize it's not done)
mentioned choices, the note mentioned list, it actually LIST.
Second, now that my html window is populated with wxp controls, how do I use
them? I tried using FindWindowById but it returns generic window pointers,
which when you go to use them doesn't contain the methods needed. I checked
the source once again, and yes it simply retruns a generic pointer. Is there
some way to cast it? Or does FindWindowByID need to be changed? I've
included source below.
BTW, lets say I have a list of strings, what the quickest way to concatenate
them all together into a comma seperated string. And whats the quickest way
to delete a string from anywhere in the list? I'm using this code, but it's
slow:
list1 = ['test1','test2','test3']
for x in list1:
    text = text + list1 + ', '
item = 'test2'
list1 = filter( lambda x, n = item: x != n, list1 )

#wxHtmlWindow wxpTag code sample
from wxPython.wx import *
from wxPython.html import *
import wxPython.lib.wxpTag

class TestBase ( wxFrame ):
    def __init__ ( self, parent, id, title ):

        #Create a reasonably sized frame
        wxFrame.__init__( self, parent, id, title, size = (200, 200) )
        self.Centre( wxBOTH )

        htmlID = wxNewId()
        listID = wxNewId()
        radioID = wxNewId()
        ids = { 'htmlID':htmlID,
            'listID':listID,
            'radioID':radioID
        }

        self.html = wxHtmlWindow( self, htmlID, size=self.GetClientSize() )
        self.html.SetBorders( 0 )
        html = """
        <wxp class="wxRadioBox">
            <param name="id" value=%(radioID)d>
            <param name="label" value="Radio:">
            <param name="LIST" value="['Choice 1','Choice 2']">
        </wxp>
        <wxp class="wxListBox" height=100>
            <param name="id" value=%(listID)d>
        </wxp>
        """ % ids
        self.html.SetPage( html )
        self.list = self.html.FindWindowById( listID )
        self.radio = self.html.FindWindowById( radioID )

        #This is broke
        self.list.Append( 'Test 1' )

class MyApp( wxApp ):
    def OnInit ( self ):
        frame = TestBase( NULL, wxNewId(), "Test" )
        frame.Show( true )
        self.SetTopWindow( frame )
        return true

app = MyApp(0)
app.MainLoop()




_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users