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


Python Loader.get_wildcards方法代码示例

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


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

示例1: choose_data_file

# 需要导入模块: from sas.sascalc.dataloader.loader import Loader [as 别名]
# 或者: from sas.sascalc.dataloader.loader.Loader import get_wildcards [as 别名]
    def choose_data_file(self, location=None):
        """
        Open a file dialog to allow loading a file
        """
        path = None
        if location == None:
            location = os.getcwd()

        l = Loader()
        cards = l.get_wildcards()
        wlist = '|'.join(cards)

        dlg = wx.FileDialog(self, "Choose a file", location, "", wlist, wx.OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()
            mypath = os.path.basename(path)
        dlg.Destroy()
        return path
开发者ID:ianhi,项目名称:sasview,代码行数:20,代码来源:data_editor.py

示例2: Plugin

# 需要导入模块: from sas.sascalc.dataloader.loader import Loader [as 别名]
# 或者: from sas.sascalc.dataloader.loader.Loader import get_wildcards [as 别名]
class Plugin(PluginBase):

    def __init__(self):
        PluginBase.__init__(self, name="DataLoader")
        # Default location
        self._default_save_location = DEFAULT_OPEN_FOLDER
        self.loader = Loader()
        self._data_menu = None

    def populate_file_menu(self):
        """
        get a menu item and append it under file menu of the application
        add load file menu item and load folder item
        """
        # menu for data files
        menu_list = []
        data_file_hint = "load one or more data in the application"
        menu_list = [('&Load Data File(s)', data_file_hint, self.load_data)]
        gui_style = self.parent.get_style()
        style = gui_style & GUIFRAME.MULTIPLE_APPLICATIONS
        style1 = gui_style & GUIFRAME.DATALOADER_ON
        if style == GUIFRAME.MULTIPLE_APPLICATIONS:
            # menu for data from folder
            data_folder_hint = "load multiple data in the application"
            menu_list.append(('&Load Data Folder', data_folder_hint,
                              self._load_folder))
        return menu_list

    def load_data(self, event):
        """
        Load data
        """
        path = None
        self._default_save_location = self.parent._default_save_location
        if self._default_save_location == None:
            self._default_save_location = os.getcwd()

        cards = self.loader.get_wildcards()
        temp = [APPLICATION_WLIST] + PLUGINS_WLIST
        for item in temp:
            if item in cards:
                cards.remove(item)
        wlist = '|'.join(cards)
        style = wx.OPEN | wx.FD_MULTIPLE
        dlg = wx.FileDialog(self.parent,
                            "Choose a file",
                            self._default_save_location, "",
                            wlist,
                            style=style)
        if dlg.ShowModal() == wx.ID_OK:
            file_list = dlg.GetPaths()
            if len(file_list) >= 0 and not file_list[0] is None:
                self._default_save_location = os.path.dirname(file_list[0])
                path = self._default_save_location
        dlg.Destroy()

        if path is None or not file_list or file_list[0] is None:
            return
        self.parent._default_save_location = self._default_save_location
        self.get_data(file_list)


    def can_load_data(self):
        """
        if return True, then call handler to laod data
        """
        return True


    def _load_folder(self, event):
        """
        Load entire folder
        """
        path = None
        self._default_save_location = self.parent._default_save_location
        if self._default_save_location == None:
            self._default_save_location = os.getcwd()
        dlg = wx.DirDialog(self.parent, "Choose a directory",
                           self._default_save_location,
                           style=wx.DD_DEFAULT_STYLE)
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()
            self._default_save_location = path
        dlg.Destroy()
        if path is not None:
            self._default_save_location = os.path.dirname(path)
        else:
            return
        file_list = self.get_file_path(path)
        self.get_data(file_list)
        self.parent._default_save_location = self._default_save_location

    def load_error(self, error=None):
        """
        Pop up an error message.

        :param error: details error message to be displayed
        """
        if error is not None or str(error).strip() != "":
            dial = wx.MessageDialog(self.parent, str(error), 'Error Loading File',
#.........这里部分代码省略.........
开发者ID:ianhi,项目名称:sasview,代码行数:103,代码来源:data_loader.py

示例3: Plugin

# 需要导入模块: from sas.sascalc.dataloader.loader import Loader [as 别名]
# 或者: from sas.sascalc.dataloader.loader.Loader import get_wildcards [as 别名]
class Plugin(PluginBase):

    def __init__(self):
        PluginBase.__init__(self, name="DataLoader")
        # Default location
        self._default_save_location = DEFAULT_OPEN_FOLDER
        self.loader = Loader()
        self._data_menu = None

    def populate_file_menu(self):
        """
        get a menu item and append it under file menu of the application
        add load file menu item and load folder item
        """
        # menu for data files
        data_file_hint = "load one or more data in the application"
        menu_list = [('&Load Data File(s)', data_file_hint, self.load_data)]
        gui_style = self.parent.get_style()
        style = gui_style & GUIFRAME.MULTIPLE_APPLICATIONS
        if style == GUIFRAME.MULTIPLE_APPLICATIONS:
            # menu for data from folder
            data_folder_hint = "load multiple data in the application"
            menu_list.append(('&Load Data Folder', data_folder_hint,
                              self._load_folder))
        return menu_list

    def load_data(self, event):
        """
        Load data
        """
        path = None
        self._default_save_location = self.parent._default_save_location
        if self._default_save_location is None:
            self._default_save_location = os.getcwd()

        cards = self.loader.get_wildcards()
        temp = [APPLICATION_WLIST] + PLUGINS_WLIST
        for item in temp:
            if item in cards:
                cards.remove(item)
        wlist = '|'.join(cards)
        style = wx.OPEN | wx.FD_MULTIPLE
        dlg = wx.FileDialog(self.parent,
                            "Choose a file",
                            self._default_save_location, "",
                            wlist,
                            style=style)
        if dlg.ShowModal() == wx.ID_OK:
            file_list = dlg.GetPaths()
            if len(file_list) >= 0 and file_list[0] is not None:
                self._default_save_location = os.path.dirname(file_list[0])
                path = self._default_save_location
        dlg.Destroy()

        if path is None or not file_list or file_list[0] is None:
            return
        self.parent._default_save_location = self._default_save_location
        self.get_data(file_list)

    def can_load_data(self):
        """
        if return True, then call handler to load data
        """
        return True

    def _load_folder(self, event):
        """
        Load entire folder
        """
        path = None
        self._default_save_location = self.parent._default_save_location
        if self._default_save_location is None:
            self._default_save_location = os.getcwd()
        dlg = wx.DirDialog(self.parent, "Choose a directory",
                           self._default_save_location,
                           style=wx.DD_DEFAULT_STYLE)
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()
            self._default_save_location = path
        dlg.Destroy()
        if path is not None:
            self._default_save_location = os.path.dirname(path)
        else:
            return
        file_list = self.get_file_path(path)
        self.get_data(file_list)
        self.parent._default_save_location = self._default_save_location

    def load_error(self, error=None):
        """
        Pop up an error message.

        :param error: details error message to be displayed
        """
        if error is not None or str(error).strip() != "":
            dial = wx.MessageDialog(self.parent, str(error),
                                    'Error Loading File',
                                    wx.OK | wx.ICON_EXCLAMATION)
            dial.ShowModal()

#.........这里部分代码省略.........
开发者ID:rprospero,项目名称:sasview,代码行数:103,代码来源:data_loader.py


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