當前位置: 首頁>>代碼示例>>Python>>正文


Python GenericDialog.add方法代碼示例

本文整理匯總了Python中ij.gui.GenericDialog.add方法的典型用法代碼示例。如果您正苦於以下問題:Python GenericDialog.add方法的具體用法?Python GenericDialog.add怎麽用?Python GenericDialog.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ij.gui.GenericDialog的用法示例。


在下文中一共展示了GenericDialog.add方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: dialog

# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import add [as 別名]
    def dialog(self):
        """
        Open the classifier dialog window and return the paramters
        chosen.
        """

        # determine how many images are currently open
        image_count = WindowManager.getImageCount()
        image_titles = list(WindowManager.getImageTitles())
        image_titles.append("None")

        # now open a dialog to let the user set options
        path_listener = SetPathListener(self.path)
        path_button = TrimmedButton("Output directory",0)
        path_button.addActionListener(path_listener)

        dlg = GenericDialog("Create classifier data (v"+__version__+")")
        dlg.addMessage("Session ID: "+ str(self.session_id))
        dlg.addMessage("")
        dlg.addMessage("Select the ROI you want to save")
        dlg.addNumericField("Window size (pixels): ", self.window_size, 0)
        dlg.addChoice("Class label: ", DEFAULT_CLASSES+['Other...'], DEFAULT_CLASSES[0])
        dlg.addStringField("Class label (if other): ", "")
        dlg.addChoice("Image file #1 (BF):",image_titles,"None")
        dlg.addChoice("Image file #2 (GFP):",image_titles,"None")
        dlg.addChoice("Image file #3 (RFP):",image_titles,"None")
        dlg.addChoice("Mask file:",image_titles,"None")
        dlg.addCheckbox("Rename ROIs", True)
        dlg.addCheckbox("Exclude edges", True)
        dlg.addCheckbox("Save ROI zip", True)
        dlg.addCheckbox("Save classifier details", True)
        dlg.add(path_button)
        dlg.showDialog()

        # handle the cancelled dialog box
        if dlg.wasCanceled():
            return None


        label_option = dlg.getNextChoice()
        if label_option == 'Other...':
            label = dlg.getNextString()
        else:
            label = label_option



        # get the root path from the path listener
        root_path = path_listener.path

        if not os.path.isdir(root_path):
            w_dlg = GenericDialog("Warning")
            w_dlg.addMessage("Root path does not exist!!")
            w_dlg.showDialog()
            return None

        # try to make the directory for the label if it does not exist
        label_path = os.path.join(root_path, label)
        check_and_makedir(label_path)

		# get the options
        dialog_options = {'window_size': dlg.getNextNumber(),
                            'label': label,
                            'BF': dlg.getNextChoice(),
                            'GFP': dlg.getNextChoice(),
                            'RFP': dlg.getNextChoice(),
                            'mask': dlg.getNextChoice(),
                            'rename': dlg.getNextBoolean(),
                            'edges': dlg.getNextBoolean(),
                            'zip': dlg.getNextBoolean(),
                            'save': dlg.getNextBoolean(),
                            'path': label_path}

        # check that we actually selected an image file
        if all([dialog_options[d] == "None" for d in ['BF','GFP','RFP']]):
            w_dlg = GenericDialog("Warning")
            w_dlg.addMessage("You must select an image stream.")
            w_dlg.showDialog()
            return None

        # grab the contents and return these as a dictionary
        return dialog_options
開發者ID:quantumjot,項目名稱:impy-tools,代碼行數:84,代碼來源:IJClassifier_.py


注:本文中的ij.gui.GenericDialog.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。