mzGUI_standalone.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:multiplierz 作者: BlaisProteomics 项目源码 文件源码
def report_chooser(title=None, mode='r', parent = None, **kwargs):
    '''A specialized file_chooser function for multiplierz files. Otherwise,
    works just like file_chooser.

    'parent' is the parent of the dialog--used when this is called by a GUI
    element. It is perfectly fine to leave it as None, and the GUI frame will
    have no parent.

    'title' can be left blank for the following default titles based on mode:
    r - 'Choose multiplierz File:'
    w - 'Save File:'
    m - 'Choose multiplierz Files:'

    'mode' is one of 'r', 'w', and 'm', just as for file_chooser.

    **kwargs can include any additional options to pass to the FileDialog constructor,
    such as defaultDir (default directory).'''

    # For legacy reasons, these are often misplaced in scripts.
    # But they're both necessarily typed differently, so its sortable.
    if isinstance(parent, basestring) and not isinstance(title, basestring):
        title, parent = parent, title

    wildcard = ("Worksheets (*.xls; *.xlsx)|*.xls; *.xlsx|"
                "Comma-separated Values (*.csv)|*.csv|"
                "mzResults Database (*.mzd)|*.mzd|"
                "mzIdentML (*.mzid)|*.mzid")

    if not title:
        title = {'r': 'Choose multiplierz File:',
                 'w': 'Save File:',
                 'm': 'Choose multiplierz Files:'}[mode]

    style = { 'r': wx.FD_OPEN,
              'm': wx.FD_MULTIPLE,
              'w': wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT }[mode]

    #index = {'.xls': 0,
             #'.xlsx': 0,
             #'.csv': 1,
             #'.mzd': 2}[settings.default_format]

    index = 0

    try:
        file_dialog = wx.FileDialog(parent, title, wildcard=wildcard, style=style, **kwargs)
    except wx._core.PyNoAppError as err:
        app = mzApp()
        app.launch()
        file_dialog = wx.FileDialog(None, title, wildcard=wildcard, style=style, **kwargs)
    file_dialog.SetFilterIndex(index)

    file_name = None
    if file_dialog.ShowModal() == wx.ID_OK:
        if mode == 'm':
            file_name = file_dialog.GetPaths()
        else:
            file_name = file_dialog.GetPath()
    file_dialog.Destroy()

    return file_name
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号