[Urwid] putting answer on Attribute problem

SHAIKH TAUSEEF HUSSAIN tauseef at nitc.ac.in
Mon Jul 29 15:47:51 EDT 2013


Thanks to Ian for replying to my question  at :
http://lists.excess.org/pipermail/urwid/2013-July/001308.html

I have put the same question at
http://stackoverflow.com/questions/17908588/attributeerror-while-trying-to-create-a-console-screen-using-urwid

If you have a stackoverflow account then could you put your answers on the
stackoverflow link as well
for the benefit of people.

thanks and regards
Tauseef
(tauseef at nitc dot ac dot in)

On Mon, Jul 29, 2013 at 7:00 PM, <urwid-request at lists.excess.org> wrote:

> Send Urwid mailing list submissions to
>         urwid at lists.excess.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://lists.excess.org/mailman/listinfo/urwid
> or, via email, send a message with subject or body 'help' to
>         urwid-request at lists.excess.org
>
> You can reach the person managing the list at
>         urwid-owner at lists.excess.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Urwid digest..."
>
>
> Today's Topics:
>
>    1. Re: attribute error encountered while using a render function
>       from Frame class. (Ian Ward)
>    2. Re: Align buttons to the border of the screen (Oscar)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 28 Jul 2013 12:36:47 -0400
> From: Ian Ward <ian at excess.org>
> Subject: Re: [Urwid] attribute error encountered while using a render
>         function from Frame class.
> To: Urwid General Discussion <urwid at lists.excess.org>
> Message-ID:
>         <
> CAA3rUNep10HUUkKvTOKeCAiSuWEkdfbxpYWKyNc3nCLZcSQCjQ at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Sun, Jul 28, 2013 at 11:35 AM, SHAIKH TAUSEEF HUSSAIN
> <tauseef at nitc.ac.in> wrote:
> > Uwid code below creates a layout and displays some text in the layout.
> Next
> > the layout is displayed on the console screen using raw display module
> from
> > urwid library. (More info on my complete project can be gleaned from
> > questions at [widget advice for a console
> > project](
> http://stackoverflow.com/questions/17846930/required-widgets-for-displaying-a-1d-console-application
> )
> > and [urwid for a console
> > project](
> http://stackoverflow.com/questions/17381319/using-urwid-to-create-a-2d-console-application
> ).
> > My skype help request being
> > [here](
> http://stackoverflow.com/questions/17846113/widget-to-choose-for-1d-urwid-application)
> .)
> > However running the code fails as an AttributeError is raised as
> described
> > below. On looking at source code for urwid at
> > /usr/lib64/python2.7/site-packages/urwid I see that both main_loop.py and
> > curses_display.py have a draw_screen function with different arguments :
> > main_loop.py ->    def draw_screen(self):
> >
> > curses_display.py > def draw_screen(self, (cols, rows), r ):
> >
> > Do I have to specify which one to use by something like **import
> draw_screen
> > from specificFile** command ? Or is there anything fundamentally wrong I
> am
> > looking at the canvas concept ? I can also see that the frame class
> (**class
> > Frame(BoxWidget):** ) in the file
> > /usr/lib64/python2.7/site-packages/urwid/**container.py** has a render
> > function  (**def render(self, size, focus=False):**)
>
> These two methods don't conflict in any way, and importing doesn't
> affect which is used.
>
> MainLoop is a thing that wants to be responsible for handling user
> input and redrawing the screen when necessary. Its draw_screen()
> method lets you force a screen redraw in cases where the MainLoop
> can't tell that it needs to redraw the screen. Since MainLoop has a
> screen and widgets to draw its draw_screen() method has no additional
> parameters.
>
> raw_display.Screen.draw_screen() takes a rendered canvas and actually
> redraws all or part of the whole screen, so it takes the size and
> canvas to draw.
>
> > Traceback (most recent call last):
> >       File "./yamlUrwidUIPhase6.py", line 104, in <module>
> >         main()
> >       File "./yamlUrwidUIPhase6.py", line 98, in main
> >         form.main()
> >       File "./yamlUrwidUIPhase6.py", line 51, in main
> >         self.loop.run()
> >       File "/usr/lib64/python2.7/site-packages/urwid/main_loop.py", line
> > 274, in run
> >         self.screen.run_wrapper(self._run)
> >       File "/usr/lib64/python2.7/site-packages/urwid/raw_display.py",
> line
> > 237, in       run_wrapper
> >     return fn()
> >       File "/usr/lib64/python2.7/site-packages/urwid/main_loop.py", line
> > 285, in _run
> >     self.draw_screen()
> >       File "/usr/lib64/python2.7/site-packages/urwid/main_loop.py", line
> > 508, in draw_screen
> >     canvas = self._topmost_widget.render(self.screen_size, focus=True)
> > AttributeError: 'NoneType' object has no attribute 'render'
>
> This Python error says that self._topmost_widget is None.  We can see
> that that value is the loop.widget set in the MainLoop initializer.
> Following your code here is where you pass in the widget for the
> MainLoop to use:
>
> >         def main(self):
> >             global ui
> >             #self.view = ui.run_wrapper(formLayout)
> >             self.ui.start()
> >             self.view = formLayout()
> >
> >             self.loop = urwid.MainLoop(self.view, self.palette,
> > unhandled_input=self.unhandled_input)
>
> so, self.view here is None too.  So it looks like formLayout() is not
> returning a widget.
>
> Hope this helps.
>
> Ian
>
>
>
> ------------------------------
>
> Message: 2
> Date: Mon, 29 Jul 2013 17:22:05 +0200
> From: Oscar <oscar at naiandei.net>
> Subject: Re: [Urwid] Align buttons to the border of the screen
> To: <urwid at lists.excess.org>
> Message-ID: <783e0df724572dd468646aabb4c34a3d at naiandei.net>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> Reading the docs I discovered that one of my problems can be solved
> using a "Divider" widget between of the buttons.
>
> Now only remains the other problem: How do I "pack" each button so
> their width is not the maximum width available but the minimum width
> needed to show them OK? I think that what I'm trying to do is convert
> them from "box" widget to "fixed" widget but I cannot find a way to do
> this in the docs.
>
> Thanks!
>
> --
> Oscar
>
> El 2013-07-28 12:19, Oscar escribi?:
> > Hi,
> >
> > I'm new to urwid but alhough I'm following all examples and trying
> > all
> > the widgets of the reference guide, I can't get two buttons aligned
> > to
> > the border of the screen. With the following code I get both buttons
> > centered on the screen:
> >
> > import urwid
> > palette = [ ('head','yellow','black'),
> >
> > ('reversed','standout',''),('hola','white','black'),('gg','black','dark
> > cyan')]
> >
> > helpa=urwid.Button("help_A")
> > helpb=urwid.Button("help_B")
> >
> > everything=urwid.GridFlow((helpa, helpb), 10, 3, 1, "center")
> > loop = urwid.MainLoop(urwid.Filler(everything),palette)
> > loop.run()
> >
> > Current 0utput:
> >
> >
> > ????????????????????????????????????????????????????????
> > ?                                                      ?
> > ?                                                      ?
> > ?                                                      ?
> > ?                                                      ?
> > ?                                                      ?
> > ?                                                      ?
> > ?              <help_A>   <help_B>>                    ?
> > ?                                                      ?
> > ?                                                      ?
> > ?                                                      ?
> > ?                                                      ?
> > ????????????????????????????????????????????????????????
> >
> > Output wanted:
> >
> > ????????????????????????????????????????????????????????
> > ?                                                      ?
> > ?                                                      ?
> > ?                                                      ?
> > ?                                                      ?
> > ?                                                      ?
> > ?                                                      ?
> > ? <help_A>                                   <help_B>> ?
> > ?                                                      ?
> > ?                                                      ?
> > ?                                                      ?
> > ?                                                      ?
> > ????????????????????????????????????????????????????????
> >
> > Thanks in advance!
> >
> > --
> > Oscar
> >
> > _______________________________________________
> > Urwid mailing list
> > Urwid at lists.excess.org
> > http://lists.excess.org/mailman/listinfo/urwid
>
>
>
> ------------------------------
>
> _______________________________________________
> Urwid mailing list
> Urwid at lists.excess.org
> http://lists.excess.org/mailman/listinfo/urwid
>
>
> End of Urwid Digest, Vol 92, Issue 5
> ************************************
>



-- 
Kind Regards
Tauseef Hussain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.excess.org/pipermail/urwid/attachments/20130729/ecb5243a/attachment.htm 


More information about the Urwid mailing list