当前位置: 首页>>代码示例>>Python>>正文


Python View.update_values方法代码示例

本文整理汇总了Python中View.View.update_values方法的典型用法代码示例。如果您正苦于以下问题:Python View.update_values方法的具体用法?Python View.update_values怎么用?Python View.update_values使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在View.View的用法示例。


在下文中一共展示了View.update_values方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: FormCreator

# 需要导入模块: from View import View [as 别名]
# 或者: from View.View import update_values [as 别名]

#.........这里部分代码省略.........
            dlg = wx.FileDialog(self, "Choose a JSON file to load", "", "", "", wx.SAVE)
            if dlg.ShowModal() == wx.ID_OK:
                filename = dlg.GetFilename()
                dirname = dlg.GetDirectory()
                dlg.Destroy()
            else:
                self.SetStatusText(Preferences.failedToOpen)
                return False
            rmap_data = self.view.rects
            try:
                with open(join(dirname, filename), "r") as f:
                    json_data = loads(f.read())
            except Exception as e:
                self.SetStatusText(Preferences.failedToExport)
                return False
            fd = self.img.split(".")
            fd.pop()
            fname = ".".join(fd)
            rmap_data = View.filter_list(rmap_data)
            rmap_data = View.clean_list(rmap_data)
            rmap_data = View.generate_data(rmap_data)
            self.write_html_printpage(self.filename, fname, rmap_data, json_data)
        else:
            self.SetStatusText(Preferences.noImageLoaded)

    def on_save(self, event):
        """
        Copy the image from SRC to the destination directory + folder
        Then write the rectangle data to HTML format
        and also a new readable JSON format (called .RMAP)
        """
        event.Skip()
        if self.view.image is not None:
            self.view.update_values()
            rmap_data = self.view.generate_rmap()

            if self.rmap_loaded:  # this means we previously had an RMAP file loaded, so save to that
                # Use self.img as the main determiner
                # remove extension of file
                fpath = self.img.split(".")
                ext = fpath.pop()
                fpath = ".".join(fpath)

                # rewrite the RMAP and HTML
                self.write_html_rmap(fpath, rmap_data,  fpath.split('\\').pop() + "." + ext)
                self.SetStatusText(Preferences.RmapSaved.format(fpath))
            else:
                dlg = wx.FileDialog(self, "Choose a name to save the file", "", "", "rmap", wx.SAVE)
                if dlg.ShowModal() == wx.ID_OK:
                    filename = dlg.GetFilename().replace(".rmap", "")
                    dirname = dlg.GetDirectory()
                    dlg.Destroy()
                else:
                    self.SetStatusText(Preferences.failedToSave)
                    return False
                # make a directory with the filename
                newdir = join(dirname, filename)
                mkdir(newdir)

                # Copy the original image
                copy(self.img, join(newdir, self.filename))
                fname = self.filename.split(".")
                new_fname = ".".join([filename, fname.pop()])
                rename(join(newdir, self.filename), join(newdir, new_fname))

                # export HTML/CSS data to a new HTML file
开发者ID:sleibrock,项目名称:form-creator,代码行数:70,代码来源:FormCreator.py


注:本文中的View.View.update_values方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。