python / cpython

The Python programming language
https://www.python.org
Other
63.19k stars 30.26k forks source link

Printing: No print dialog or page setup #43720

Open ronaldoussoren opened 18 years ago

ronaldoussoren commented 18 years ago
BPO 1528593
Nosy @terryjreedy, @ronaldoussoren, @roseman

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = None closed_at = None created_at = labels = ['expert-IDLE', 'type-feature', '3.10'] title = 'Printing: No print dialog or page setup' updated_at = user = 'https://github.com/ronaldoussoren' ``` bugs.python.org fields: ```python activity = actor = 'terry.reedy' assignee = 'none' closed = False closed_date = None closer = None components = ['IDLE'] creation = creator = 'ronaldoussoren' dependencies = [] files = [] hgrepos = [] issue_num = 1528593 keywords = [] message_count = 4.0 messages = ['54867', '54868', '54869', '114809'] nosy_count = 3.0 nosy_names = ['terry.reedy', 'ronaldoussoren', 'markroseman'] pr_nums = [] priority = 'low' resolution = None stage = 'test needed' status = 'open' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue1528593' versions = ['Python 3.10'] ```

ronaldoussoren commented 18 years ago

The printing solution for IDLE on OSX is lacking a page setup dialog, or even a print dialog. This means output will also be sent to the default printer.

If there is no default printer (which means the user hasn't defined a printer at all) the user will get a confusing message (lpr failed). BTW. the message is clear for technical users, but not for mac users that aren't unix saffy.

It would be nice if IDLE could interface with the Carbon/Cocoa print system using a real print dialog. That way users can select another than the default printer, change page settings and can even print to PDF.

I've filed this as a low-priority issue for 2.6 because there's no way this will get into 2.5 and it likey non-trivial as well.

BTW. this might be a feature-request rather than a bug.

kbkaiser commented 18 years ago

Logged In: YES user_id=149084

It's not just an OSX problem. Printing in IDLE is very rudimentary at this point.

Making this an RFE.

taleinat commented 17 years ago

This is a problem on all platforms.

We have recently been discussing possible solutions for Windows platforms, but until now haven't found a solution that doesn't require the 'win32' package.

The Unix/Linux platforms could probably be addressed without special modules/packages...

terryjreedy commented 10 months ago

Accessing OS-specific dialogs with a cross-platform function is something tk does for open, save, and color selection. Failing tk doing that for printing, which is possibly more common than color selection, this seems more like something tkinter should do.

59de44955ebd commented 1 month ago

FYI, in Windows you don't need win32/pywin at all for showing page setup and print dialogs, just plain ctypes for accessing win32 API functions, nothing else. Here a simple demo app I just created: https://gist.github.com/59de44955ebd/ed6e721c3350fe16a97dbcfb4c9378bf

terryjreedy commented 1 month ago

This is interesting. I would worry about maintainability, but I could must label the dialog as 'experimental'. Would you expect this to work the same on both Win 10 and Win 11? (I will eventually be able to test on the latter also.)

59de44955ebd commented 1 month ago

My minimal demo exclusively uses win32 APIs that exist since back then in the 90ies, so I would expect it to even run in Win XP, provided that Python and Tk support it ;-)

59de44955ebd commented 1 month ago

ps: I now realized that you referred to Win 11 with "latter also", so see the screenshot attached to the gist, I had written and tested the demo in Windows 11.

zware commented 1 month ago

Very nice demo! However, I do not think we should add a ctypes-based print dialog; as a general rule, we avoid using ctypes if at all possible. I'm not familiar with how the current print implementation works in IDLE, but I did find that Tcl/Tk 9.0 (due for release very shortly) apparently supports printing with a dialog.

terryjreedy commented 4 weeks ago

IDLE's print text window runs one of the following

print-command-posix=lpr %%s
print-command-win=start /min notepad /p %%s

with %%s replaced with a file name. So everything except the file is default. This is yet another reason to include 9.0 in our installers.

I am reducing IDLE's use of a (hidden) canvas but maybe they will someday support other widgets. Turtle could use a good canvas printer, and tk users also. A canvas printer vis GDI will be especially helpful on Windows where postscript is not a thing.

59de44955ebd commented 4 weeks ago

I fully understand the point about avoiding ctypes-based stuff in IDLE. But anyway - O.T. - here, just for fun, another hack that implements dark UI mode for IDLE in Windows 10/11, in particular for UI elements that in Windows can't be styled with Tk alone (window caption, menubar, scrollbars), see attached screenshot. https://gist.github.com/59de44955ebd/175fc0af5047be2eddb31ebb6c065720 idle_dark_windows

terryjreedy commented 4 weeks ago

Impressive. (BTW the official way to start IDLE is idlelib.__main__ or idlelib.idle. ;-) It show how powerful ctypes is for people who can use it. DND support would be a separate issue. Does tk/tkinter dnd support (never tested) only include between tk windows?

59de44955ebd commented 4 weeks ago

I'm not sure about Tkinter dnd, never used it before. The DND files from explorer stuff in this demo is just a gimmick, since it only required a few extra lines, I thought, why not ;-)

59de44955ebd commented 4 weeks ago

ps: another "gimmick" in this demo is my "text in clipboard lost after IDLE closes" bug fix, I also posted about it this fix at https://github.com/python/cpython/issues/84632