Last active
October 17, 2024 14:12
-
-
Save petebankhead/20bada82db388a4af5e98219c46e0ab9 to your computer and use it in GitHub Desktop.
Example QuPath startup script showing how to open specific dialogs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Example QuPath startup script to open the brightness/contrast dialog & channel viewer, | |
* optionally setting their location. | |
* | |
* Originally posted at https://forum.image.sc/t/saving-window-layout/103763/3 | |
* | |
* Written for QuPath v0.5.x | |
*/ | |
import javafx.application.Platform | |
import javafx.stage.Stage | |
import qupath.lib.gui.QuPathGUI | |
import qupath.lib.gui.commands.Commands | |
import javafx.stage.Window | |
Platform.runLater { | |
// Show brightness/contrast dialog | |
QuPathGUI.getInstance().getCommonActions().BRIGHTNESS_CONTRAST.handle(null) | |
moveWindow("Brightness & contrast", 10, 50) | |
// Show channel viewer | |
Commands.showChannelViewer(getCurrentViewer()) | |
moveWindow("Channel viewer", 200, 100, 400, 200) | |
} | |
def moveWindow(String title, double x, double y, double width=-1, double height=-1) { | |
var window = Window.getWindows() | |
.stream() | |
.filter(w -> w instanceof Stage) | |
.map(w -> (Stage)w) | |
.filter(s -> s.getTitle() == title) | |
.findFirst() | |
.orElse(null) | |
if (window != null) { | |
window.x = x | |
window.y = y | |
if (width > 0) | |
window.width = width | |
if (height > 0) | |
window.height = height | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment