예제 #1
0
파일: ToLayout.py 프로젝트: hasii2011/PyUt
    def doAction(self, umlObjects, selectedObjects, umlFrame):
        """
        Do the tool's action

        @param OglObject [] umlObjects : list of the uml objects of the diagram
        @param OglObject [] selectedObjects : list of the selected objects
        @param UmlFrame umlFrame : the frame of the diagram
        @since 1.0
        @author C.Dutoit <*****@*****.**>
        """
        filename = FileSelector("Choose a layout file to import",
                                wildcard="Layout file (*.lay) | *.lay",
                                flags=FD_OPEN | FD_FILE_MUST_EXIST | FD_CHANGE_DIR)

        f = open(filename, "r")
        lstFile = f.readlines()
        f.close()
        lst = []
        for el in lstFile:
            spl = el.split(",")
            lst.append(spl)
        print(f"Read {lst}")

        for oglObject in umlObjects:
            for line in lst:
                if line[0] == oglObject.getPyutObject().getName():
                    oglObject.SetPosition(float(line[1]), float(line[2]))
                    oglObject.SetSize(float(line[3]), float(line[4]))
예제 #2
0
 def SaveAs(self, e=None):
     file = FileSelector("保存します", expanduser('~'), "untitled.wnf", "wnf",
                         "*.wnf")
     if not file:
         return
     self.File = file
     try:
         with open(self.File, 'w', encoding='utf-8') as f:
             f.write(self.editor.GetValue())
     except PermissionError as err:
         self.stat.SetStatusText(f"保存できませんでした。{str(err)}", 1)
         Timer(2, lambda: self.stat.SetStatusText("", 1)).start()
         return
     self.changed = False
     self.SetTitle(f"{BASETITLE} - {basename(self.File)}")
예제 #3
0
    def _askForFileExport(self, defaultFileName: str = '') -> str:
        """
        Called by a plugin to ask for the export file name

        Returns:
        """
        wxYield()

        outputFormat: OutputFormatType = self.getOutputFormat()

        wildCard:    str = f'{outputFormat[0]} (*. {outputFormat[1]} )|*.{outputFormat[1]}'
        file:        str = FileSelector("Choose the export file name",
                                        default_filename=defaultFileName,
                                        wildcard=wildCard,
                                        flags=FD_SAVE | FD_OVERWRITE_PROMPT | FD_CHANGE_DIR)

        return file
예제 #4
0
 def Open(self, e=None):
     if self.changed:
         dlg = MessageDialog(self,
                             "編集中の内容を保存して既存ファイルを開きますか?",
                             "確認",
                             style=OK | CANCEL)
         if dlg.ShowModal() == ID_OK:
             self.Save()
         dlg.Destroy()
     file = FileSelector("開くファイルを選択", expanduser('~'), "", "*.wnf")
     if not file:
         return
     self.File = file
     with open(self.File, encoding='utf-8') as f:
         self.editor.SetValue(f.read())
     self.SetTitle(f"{BASETITLE} - {basename(self.File)}")
     self.changed = False
예제 #5
0
    def _askForFileImport(self,
                          multiSelect: bool = False,
                          startDirectory: str = None):
        """
        Called by plugin to ask which file must be imported

        Args:
            multiSelect: True to allow multi-file selection

        Returns:
            filename or "" for multiple=False, fileNames[] or
            [] else
            "",
            [] indicates that the user pressed the cancel button
        """

        inputFormat: PyutPlugin.INPUT_FORMAT_TYPE = self.getInputFormat()

        defaultDir: str = startDirectory

        if defaultDir is None:
            defaultDir = self._ctrl.getCurrentDir()
        if multiSelect:
            dlg = FileDialog(self._umlFrame,
                             "Choose files to import",
                             wildcard=inputFormat[0] + " (*." +
                             inputFormat[1] + ")|*." + inputFormat[1],
                             defaultDir=defaultDir,
                             style=FD_OPEN | FD_FILE_MUST_EXIST | FD_MULTIPLE
                             | FD_CHANGE_DIR)
            dlg.ShowModal()
            if dlg.GetReturnCode() == ID_CANCEL:
                return [], ""

            return dlg.GetFilenames(), dlg.GetDirectory()
        else:
            file = FileSelector("Choose a file to import",
                                wildcard=inputFormat[0] + " (*." +
                                inputFormat[1] + ")|*." + inputFormat[1],
                                flags=FD_OPEN | FD_FILE_MUST_EXIST
                                | FD_CHANGE_DIR)
            return file
예제 #6
0
    def doAction(self, umlObjects, selectedObjects, umlFrame):
        """
        Do the tool's action

        @param OglObject [] umlObjects : list of the uml objects of the diagram
        @param OglObject [] selectedObjects : list of the selected objects
        @param UmlFrame umlFrame : the frame of the diagram
        @since 1.0
        @author C.Dutoit <*****@*****.**>
        """
        file = FileSelector("Choose a file name to export layout",
                            wildcard="Layout file (*.lay) |*.lay",
                            flags=FD_SAVE | FD_OVERWRITE_PROMPT
                            | FD_CHANGE_DIR)

        f = open(file, "w")
        for el in umlObjects:
            f.write(el.getPyutObject().getName() + "," +
                    str(el.GetPosition()[0]) + "," + str(el.GetPosition()[1]) +
                    "," + str(el.GetSize()[0]) + "," + str(el.GetSize()[1]) +
                    "\n")
        f.close()
예제 #7
0
    NCT_numbers = []
    for a in range(len(gantt_df)):
        ident = str(gantt_df['Alternative IDs'][a]).split(',')
        ident = re.findall(nct, ' '.join(ident))
        if len(ident) > 0:
            ident = ident[0]
        else:
            ident = 'No NCT Identifier'
        NCT_numbers.append(ident)
    ncts = pd.Series(NCT_numbers)
    gantt_df['NCT Number'] = ncts
    return gantt_df


app = App()
ta_file = FileSelector("Please select a TA-Scan Export Saved as an .xlsx file",
                       default_extension='.xlsx')
ctgov_file = FileSelector(
    "Please select a clinicaltrials.gov Export Saved as an .csv file",
    default_extension='.csv')

# Read in TA Scan data and format keeping only necessary columns to merge with the CT.gov data
ta_df = pd.read_excel(ta_file, header=0)
ta_df = remove_nonascii(ta_df)
ta_df = extract_NCT(ta_df)
ta_df = ta_df[ta_df['NCT Number'] != 'No NCT Identifier']
ta_df = ta_df[[
    'NCT Number', 'Enrollment', 'Nr sites', 'Study start', 'Study end'
]].reset_index(level=0, drop=True)
ta_df.columns = [
    'NCT Number', 'Enrollment', 'Num. of Sites', 'Start Date',
    'Completion Date'