[Tutor] Need Help Modifying a wxPython GUI (scrolling display and logging)

Prasad, Ramit ramit.prasad at jpmorgan.com
Mon Jun 10 18:23:35 CEST 2013


Matt D wrote:
> Ramit Prasad wrote: 
> >>> Scrolled panel is just a graphical container that allows for scrolling inside,
> >>> but it is the window that scrolls not widgets inside it. This of it like
> >>> a webpage that scrolls. If you use web email the text widget in the
> >>> email needs to scroll so you can see your full email context and not
> >>> just scroll the page.
> >>>
> >>> You will probably need to create a TextCtrl with the appropriate style
> >>> and append your new data. I have given an example below that should
> >>> automatically scroll with your new data.
> >>>
> >>> #in __init__
> >>> self.scrolling_widget = wx.TextCtrl( self, wx.ID_ANY, '', size=(-1, 275),
> >> style=wx.TE_AUTO_SCROLL|wx.TE_READONLY|wx.TE_PROCESS_ENTER|wx.TE_WORDWRAP|wx.TE_MULTILINE )
> >>>
> Hey,
> I added this the above 3 lines of code to my file and ran it.  the box
> shows up on the far left, mostly of the pane, to the left of the current
> text feilds.  I am having trouble positioning this textbox under where
> the current text fields are.
> I am not sure but maybe this sets up the grid on the pane:
> 	sizer = wx.GridBagSizer(hgap=10, vgap=10)
>         self.fields = {}
> all the current TextCtrl fields are positioned at (1,1) through (5,5).
> I tried adding:
> 	sizer.Add(field, pos=(1,6))
> but it did not move the box to the position?

Just to make sure, you did call it field and not self.scrolling_widget
(which was in my example)? 

Odd that they don't start at (0,0) when adding to the bag. This is
more a wxpython question and their mailing list might prove more
useful. I could figure it out, but I cannot run the app. Trial
and error here will probably help you the most. You can also
try looking at a different sizer (like BoxSizer and GridSizer).

Personally, I think BoxSizer is the most intuitive as it matches
my thought process. You just set an orientation (vertical/horizontal) 
and add widgets to it. To get something in the other direction, you 
create another box sizer with the opposite orientation, add widgets
to that sizer, and then add the new sizer to the original sizer. Not 
nearly as pretty as grid/grid bag though (by default), but super simple.

BoxSizer API
http://wxpython.org/docs/api/wx.BoxSizer-class.html
Some other sizers are listed here: 
http://wxpython.org/docs/api/wx.Sizer-class.html

> 
> THanks,
> Matt


~Ramit


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  


More information about the Tutor mailing list