[Tutor] How to print ALL contents of a scrolled Tkinter window?

Laura Creighton lac at openend.se
Sat Apr 18 02:04:11 CEST 2015


In a message of Fri, 17 Apr 2015 21:06:35 +0100, Alan Gauld writes:
>On 17/04/15 15:29, Laura Creighton wrote:
>
>> just use kivy, which has the advantage that is runs under IOS and
>> Android out of the box.
>
>But does Kivy support hard copy printing?
>That's pretty unusual behaviour on
>tablets/phones.

Every kivy app lives in precisely one window.  This window has a screenshot
method.  You can bind it to a button, and you will get a png of exactly
what your app looks like. 

Also, every widget has an export_to_png method which you can use to
capture the widget and its children.

So inside your program you can say -- start at the top of this widget,
display the first page, take screenshot, then scroll it one page, take
screenshot, repeat until done.  Which is a whole lot easier than fidding
with your app and taking screenshots from the outside.

Once you have the filename(s) you can print it/them however you normally print
files.  My printer lives on a wireless conection and my laptop, my desktop
and my tablet know how to talk to it.  (My phone does not, but it's over
5 years old now, and the android it runs is very old.  I'd upgrade it
in a second if some manufacturer would go back to making a 3.5 inch screen.
A phone that I cannot dial phone numbers on, one handed,  is of no use to
me. Grumble grumble.)

>> The whole point of kivy is to create better, new paradigm user interfaces,
>> where scrolling surfaces are built-in.
>
>That wouldn't be on mobile devices then,
>where the UIs are universally horrible IMHO! :-)
>They are the very antithesis of good user
>interface design.

You might enjoy playing with kivy, then, where the philosophy is 'we
can do much better than what we have now'.  Thinking about touch devices
and how to best use them (rather than how to emulate a mouse) is fun.

>Alan G
>Author of the Learn to Program web site
>http://www.alan-g.me.uk/
>http://www.amazon.com/author/alan_gauld

Laura Creighton




More information about the Tutor mailing list