Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Simpler way to Print Editor code to the physical Printer
-
Right now to print, from the tab where the Python code is, I have to Create a PDF from the Share Menu (Wrench), then once the PDF file has been created as an additional tab in the editor, I can access the Print menu, then I have to delete the PDF file created in the folder where the script is stored.
Is there a simpler more straightforward approach to this? Maybe a custom script that I can trigger from the Share Menu (Wrench) directly from the tab where the Python code is?
Thank you
-
@OI quick and dirty code (as usual) to define as tool to print directly the edited file.
You can test it by running itself but you will only print this code.
Remark that you can change font and font size.import editor from objc_util import * @on_main_thread def print_text(text, font_name='Helvetica', font_size=12): UIPrintInteractionController = ObjCClass('UIPrintInteractionController') UIPrintSimpleTextFormatter = ObjCClass('UISimpleTextPrintFormatter') controller = UIPrintInteractionController.sharedPrintController() formatter = UIPrintSimpleTextFormatter.alloc().initWithText_(text) font = ObjCClass('UIFont').fontWithName_size_(font_name, font_size) if font: formatter.setFont_(font) controller.setPrintFormatter_(formatter) controller.presentAnimated_completionHandler_(True, None) print_text(editor.get_text(), 'Courier', 10)
-
@OI You can also take a screenshot, select "Full Page" in the screenshot UI, then choose "Print" from the share menu.
-
@omz I didn't even know this iOS feature, thanks. But, so, you also print line numbers, I don't know if he wants that.