本文整理匯總了Python中ij.gui.GenericDialog.getStringFields方法的典型用法代碼示例。如果您正苦於以下問題:Python GenericDialog.getStringFields方法的具體用法?Python GenericDialog.getStringFields怎麽用?Python GenericDialog.getStringFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ij.gui.GenericDialog
的用法示例。
在下文中一共展示了GenericDialog.getStringFields方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: GenericDialog
# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import getStringFields [as 別名]
from java.awt import Color
from java.awt.event import TextListener
from ij import IJ
from ij import Menus
from ij.gui import GenericDialog
#commands = [c for c in ij.Menus.getCommands().keySet()]
# Above, equivalent list as below:
commands = Menus.getCommands().keySet().toArray()
gd = GenericDialog('Command Launcher')
gd.addStringField('Command: ', '');
prompt = gd.getStringFields().get(0)
prompt.setForeground(Color.red)
class TypeListener(TextListener):
def textValueChanged(self, tvc):
if prompt.getText() in commands:
prompt.setForeground(Color.black)
return
prompt.setForeground(Color.red)
# or loop:
#for c in commands:
# if c == text:
# prompt.setForeground(Color.black)
# return
#
#prompt.setForeground(Color.red)
prompt.addTextListener(TypeListener())
gd.showDialog()
if not gd.wasCanceled(): IJ.doCommand(gd.getNextString())