1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import wx
20
21
22
23
24
25 BORDER = 5
26 unlock_function = None
27
28
30
32 self.name = name
33 self.ext_data = {}
34 self.ext_names = []
35 self._extract_ext_info(extensions)
36
38 return "%s (%s)|%s" % (
39 self.name,
40 ", ".join(["*." + e for e in self.ext_names]),
41 ";".join(["*." + e for e in self.ext_names]))
42
44 path = dialog.GetPath()
45 for ext_name in self.ext_names:
46 if path.endswith("." + ext_name):
47 return path
48 return "%s.%s" % (path, self.ext_names[0])
49
51 split_path = path.split(".")
52 if len(split_path) > 1:
53 ext_name = split_path[-1]
54 return self.ext_data.get(ext_name, None)
55 return None
56
58 for ext in extensions:
59 if isinstance(ext, tuple):
60 name, data = ext
61 self.ext_data[name] = data
62 self.ext_names.append(name)
63 else:
64 self.ext_names.append(ext)
65
66
68
70 self.timeout = timeout
71 wx.PopupTransientWindow.__init__(self, parent, wx.NO_BORDER)
72 self.SetBackgroundColour(color)
73 st = wx.StaticText(self, wx.ID_ANY, text, pos=(10, 10))
74 sz = st.GetBestSize()
75 self.SetSize((sz.width + 20, sz.height + 20))
76 if pos:
77 self.Position(pos, (-1, -1))
78 self.Popup()
79
82
84 super(PopupTextWindow, self).Popup()
85 wx.CallLater(self.timeout, self.Dismiss)
86
87
92
93
95 """Display an error message in a modal dialog box"""
96 dial = wx.MessageDialog(parent, message, _("Error"), wx.OK | wx.ICON_ERROR)
97 dial.ShowModal()
98
99
101 dial = wx.MessageDialog(parent, message, _("Warning"), wx.OK | wx.ICON_WARNING)
102 dial.ShowModal()
103
104
110
111
113 return wx.MessageBox(question, _("Question"),
114 wx.YES_NO | wx.CENTRE | wx.NO_DEFAULT, parent) == wx.YES
115
116
118 """Ask a yes/no question and return the reply."""
119 return wx.MessageBox(question, _("Question"),
120 wx.YES_NO | wx.CENTRE | wx.NO_DEFAULT, parent)
121
122
124 parent.SetCursor(wx.StockCursor(wx.CURSOR_WAIT))
125
126
129
130
136
137
141