Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pynxc/waxy/filedialog.py
blob: a11141e46d2843089eb71bc9bb8d5aad3c8d933e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# filedialog.py

import wx
import waxyobject

class FileDialog(wx.FileDialog, waxyobject.WaxyObject):

    def __init__(self, parent, title="Choose a file", default_dir="",
                 default_file="", wildcard="*.*", open=0, save=0, multiple=0):
        style = 0
        if open:
            style |= wx.OPEN
        elif save:
            style |= wx.SAVE
            style |= wx.OVERWRITE_PROMPT
        if multiple:
            style |= wx.MULTIPLE

        self.multiple=multiple
            
        wx.FileDialog.__init__(self, parent, title, default_dir, default_file,
         wildcard, style)

    def ShowModal(self):
        """ Simplified ShowModal(), returning strings 'ok' or 'cancel'. """
        result = wx.FileDialog.ShowModal(self)
        if result == wx.ID_OK:
            return 'ok'
        else:
            return 'cancel'

        
    def GetChosenFile(self):
        """ Shorthand... """
        data = self.GetPaths()
        
        if not self.multiple:
            data=data[0]
        
        return data