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

Matt D md123 at nycap.rr.com
Thu Jun 13 02:46:22 CEST 2013


On 06/12/2013 05:59 PM, Dave Angel wrote:
> On 06/12/2013 05:32 PM, Matt D wrote:
>> On 06/10/2013 12:23 PM, Prasad, Ramit wrote:
>>> 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
>>>
>>>
>> Hey,
>> if i put:
>>
>>   self.logfile = open('logfile.csv', 'w')
>>
>> in the .py file, within the 'class TrafficPane', then shouldn't
>> logfile.csv be written to the directory the .py file is in?  because its
>> not there after running the program?  Where should i look for it?
>> Thanks
>> Matt
>>
> 
> It should put it in the current directory.  That *may* be the directory
> the script is in, but not necessarily.  It's easy to run something like:
> 
> python somdir/myscript.py
> 
> in which case the file would be in the parent directory to myscript.py
> 
> Note that in some environments, the current directory is invisibly set
> to some convenient place.  For example, when right-clicking on a script
> in Windows Explorer, they make the bald assumption that you want to set
> the current directory the same as the location of the script. That's
> about the worse place for it, but nevermind.
> 
> 
> 
Yes, that was my assumption (even thought I am using linux); and right
again, it is a very inconvenient place for it to be.  however in the
interest of speed of testing i figured i would make sure the log was
logging the way i want it to and then try to find some sort of wx wigit
to let the user of the gui name/save to desired location. meanwhile . .
. so you think it saved somewhere right?


More information about the Tutor mailing list