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

2015-04-18 Thread boB Stepp
On Fri, Apr 17, 2015 at 7:04 PM, Laura Creighton l...@openend.se wrote:
 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.

Have these types of methods ever been considered for tkinter? They
would go a long way to giving people a way to print, while not getting
into a lot of OS hassle. In my particular scenario I would desire the
ability to output both postscript and pdf, though if I have the first
it is easy to get the latter.

boB Stepp
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


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

2015-04-18 Thread Alan Gauld

On 18/04/15 18:03, boB Stepp wrote:


Have these types of methods ever been considered for tkinter?


I don't follow the TK and Tkinter mailing lists closely.
You are probably better asking there.

There is a gmane news feed for a Tkinter mailing list
as well as an archive

gmane.comp.python.tkinter

And the general Tk fora at:

www.tcl.tk

They may even have a solution, in which case let us know.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


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

2015-04-18 Thread boB Stepp
On Fri, Apr 17, 2015 at 2:28 PM, Alan Gauld alan.ga...@btinternet.com wrote:
 On 17/04/15 14:26, boB Stepp wrote:

 Solaris 10, Python 2.4.4


[...]

 That's why GUI printing generally uses an entirely different
 technique to print things (see my earlier email). In essence
 this requires you to separate the data content and format
 from the GUI presentation. The printed presentation must be
 prepared by you the programmer and output to the new display
 context(a printer). This means you need to decide how to
 handle page breaks, page width and orientation etc etc.

I had started thinking along these lines, but realized that I possess
a severe lack of knowledge as to the details of the printer does its
*magic*. I used to know a bit about how dot-matrix printers
(non-color) worked, but that has been a very long time ago...

You mentioned groff in the other thread. Is this relatively easy to
adapt to its formatting commands? Is it likely to be on my bare-bones
Solaris 10 workstation? I will have to check to see what is present
Monday.

 Its a whole different ballgame and much more complex than
 simply issuing a print command. Hard copy output from a
 GUI is one of the hardest things to do in almost any GUI,
 especially if you want it truly WYSIWYG.

I am surprised that Python does not have a standard library module to
help with this. I see that there are third-party modules, but that
does not help me within my work environment constraints.

 My personal favourite approach is to abandon WYSIWYG and
 go for WYSRWYG - What you see resembles what you'll get...
 And then I reformat the data using HTML, send it to a file
 and print that file using whatever HTML rendering engine
 I can find.

Are there such HTML rendering engines likely to be present in a
Solaris 10 environment, which is a rather bare-bones environment? I
mean outside of a web browser. I can already use my existing template
to auto-generate the appropriate HTML formatting (Once I write the
needed functions to do so. But it should logically no different than
how I interpret my template to render the Tkinter GUI display.), save
that in a file and then? This would be needed to be done
programmatically, not manually by the user. The desired end result is
a pdf document to be stored electronically for posterity.

 wxPython makes printing easier but even there its a
 whole chapter(ch17) of the book and its at the end so
 assumes you already know all the background around sizers,
 device context and the like The example program - for
 printing a formatted text document - runs to 2.5 pages of
 code. And that's the easiest printing framework I've seen.

Which book are you referencing here? Would it be Wxpython in Action?

 are along the lines of: 1) Determine how many rows of information
 appear in the viewing area. 2) Determine how many total rows of
 information exist to be printed. 3) Figure out how to programmatically
 do a *manual* scroll to bring up the hidden scrolled information. 4)
 Repeatedly apply the printing method. While I can probably make this
 approach work (It *seems* conceptually simple.), I cannot help but
 feel there is a much better way...


 Its never going to be pretty but multiple screen captures
 can work. Its certainly easy enough to reposition a scroll
 bar programmatically from within a while loop. Figuring out
 how many lines will depend on all sorts of things like
 the size of fonts being used, how widgets are laid out.
 That's what gets tricky, especially if users don't have
 standardised screen sizes etc.

I may or may not go this way. I already wrote a set of scripts (in
shell and Perl) a few years ago to allow the user to click and drag an
area of their screen to capture into a pdf document. It leverages the
existing printer configurations and tools in the planning software.
When the user is finishing making captures, he clicks the Print to
pdf button and it converts the captures into a single pdf document,
which it then ftps to the desired destination folder on a different
portion of our intranet. This would provide a workable solution until
I learn more.

 I intend to scour my available Tkinter documentation to see if there
 are root window level and scrolled area commands that might suggest
 another approach.


 Not really. Tkinter (and Tk) basically sidesteps printing
 to hard copy. There simply is no built in support. You have
 to format it yourself.

I did not find even a hint of anything beyond the already known Canvas
widget postscript capability.

 Check out IDLE - even it doesn't have any built in
 formatted print. It only has 'Print Window', which is
 just plain text.
 Although even looking at how they did that might
 help too. Remember you have the code to IDLE and
 its built using Tkinter...

I will make time to do this. Hopefully it will provide better modes of
thinking on my part!

Thanks, Alan!

boB
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or 

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

2015-04-18 Thread Laura Creighton
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


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


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

2015-04-17 Thread boB Stepp
On Fri, Apr 17, 2015 at 9:29 AM, Laura Creighton l...@openend.se wrote:
While I can probably make this
approach work (It *seems* conceptually simple.), I cannot help but
feel there is a much better way...

 Tkinter is very old software.  This sort of scrolling you want was
 in no way common when Tkinter was new.  For things like this, I
 just use kivy, which has the advantage that is runs under IOS and
 Android out of the box.

 The whole point of kivy is to create better, new paradigm user interfaces,
 where scrolling surfaces are built-in.

 It may be faster for you to reimplement what you have in kivy than to
 try to get Tkinter to do what you want.

Alas! I am not allowed to install any new software on these systems
(Which use Python 2.4.4 or 2.6.4.). So I am stuck with whatever tools
are installed by default, and that does not include your suggestion.
However, I will look into kivy for my at-home studies/projects!


-- 
boB
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


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

2015-04-17 Thread Alan Gauld

On 17/04/15 14:26, boB Stepp wrote:

Solaris 10, Python 2.4.4

Thanks to earlier help from this list, I can now print a particular
Tkinter-generated window. But this will only print what is currently
viewable on the screen.


Because it is effectively taking a screen shot.


In the case of scrolled information that is
currently outside the viewing area, it would be missed by such a print


That's why GUI printing generally uses an entirely different
technique to print things (see my earlier email). In essence
this requires you to separate the data content and format
from the GUI presentation. The printed presentation must be
prepared by you the programmer and output to the new display
context(a printer). This means you need to decide how to
handle page breaks, page width and orientation etc etc.

Its a whole different ballgame and much more complex than
simply issuing a print command. Hard copy output from a
GUI is one of the hardest things to do in almost any GUI,
especially if you want it truly WYSIWYG.

My personal favourite approach is to abandon WYSIWYG and
go for WYSRWYG - What you see resembles what you'll get...
And then I reformat the data using HTML, send it to a file
and print that file using whatever HTML rendering engine
I can find.

wxPython makes printing easier but even there its a
whole chapter(ch17) of the book and its at the end so
assumes you already know all the background around sizers,
device context and the like The example program - for
printing a formatted text document - runs to 2.5 pages of
code. And that's the easiest printing framework I've seen.


are along the lines of: 1) Determine how many rows of information
appear in the viewing area. 2) Determine how many total rows of
information exist to be printed. 3) Figure out how to programmatically
do a *manual* scroll to bring up the hidden scrolled information. 4)
Repeatedly apply the printing method. While I can probably make this
approach work (It *seems* conceptually simple.), I cannot help but
feel there is a much better way...


Its never going to be pretty but multiple screen captures
can work. Its certainly easy enough to reposition a scroll
bar programmatically from within a while loop. Figuring out
how many lines will depend on all sorts of things like
the size of fonts being used, how widgets are laid out.
That's what gets tricky, especially if users don't have
standardised screen sizes etc.


I intend to scour my available Tkinter documentation to see if there
are root window level and scrolled area commands that might suggest
another approach.


Not really. Tkinter (and Tk) basically sidesteps printing
to hard copy. There simply is no built in support. You have
to format it yourself.

Check out IDLE - even it doesn't have any built in
formatted print. It only has 'Print Window', which is
just plain text.
Although even looking at how they did that might
help too. Remember you have the code to IDLE and
its built using Tkinter...

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


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

2015-04-17 Thread Laura Creighton
While I can probably make this
approach work (It *seems* conceptually simple.), I cannot help but
feel there is a much better way...

Tkinter is very old software.  This sort of scrolling you want was
in no way common when Tkinter was new.  For things like this, I
just use kivy, which has the advantage that is runs under IOS and
Android out of the box.

The whole point of kivy is to create better, new paradigm user interfaces,
where scrolling surfaces are built-in.

It may be faster for you to reimplement what you have in kivy than to
try to get Tkinter to do what you want.

Laura
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


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

2015-04-17 Thread Alan Gauld

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.

If so can you show us a short example of
how it works. (Technically off-topic for
the tutor list but I'm curious to see
how it compares to say, Tkinter)


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.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor