It looks like you're new here. If you want to get involved, click one of these buttons!
Pasting Matthias's code with a few modifications below:
(Note: this modified version is also found in E4K inside E4K > Examples menu > Qt > Screenshot)
## Qt and screenshot.lym
## By Matthias, http://www.klayout.de/rba_examples.html
## Example of how to do a Qt dialog and how to take a screenshot.
# This class implements a dialog with a screenshot display area and a
# screenshot button
class ScreenshotDialog < QDialog
def initialize(parent = nil)
layout = QVBoxLayout.new(self)
@image = QLabel.new("Press the button to fetch a screenshot", self)
button = QPushButton.new('Screenshot', self)
button.setFont(QFont.new('Times', 18, QFont::Bold))
view = Application.instance.main_window.current_view
@image.setText("No layout opened to take screenshot from")
# Instantiate the dialog and make it visible initially.
# Passing the $main_window will make it stay on top of the main window.
$dialog && $dialog.destroy
$dialog = ScreenshotDialog.new(Application::instance.main_window)
Is that something like what you wanted? Of course you can modify it, e.g. to save to a file instead of display it, if you prefer. You said 'entire layout' -- one way is to call LayoutView#zoom_fit before taking the screenshot, it will zoom to the entire layout.
Try to modify it for your needs. If you need help on a more specific implementation, please let us know.
@David: thanks for mentioning this solution!
A lean solution capable of producing big images is the screenshot script: http://www.klayout.de/useful_scripts.html#screenshot.lym.
If you're on a 64bit system, you can produce images of up to 500M pixels (width x height). There is a limitation in Qt's image writer implementation that prevents creating bigger images. 500M pixels will correspond to about 22k x 22k pixels for a square image.
Still with this limit you are able to resolve less than 500nm on a 10mm block. You'll just need enough memory (>= 8G) and a 64bit system.