1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import wx
20
21 from timelinelib.canvas.data import sort_categories
22
23
24
25
26 BORDER = 5
27 unlock_function = None
28
29
31
33 self.name = name
34 self.ext_data = {}
35 self.ext_names = []
36 self._extract_ext_info(extensions)
37
39 return "%s (%s)|%s" % (
40 self.name,
41 ", ".join(["*." + e for e in self.ext_names]),
42 ";".join(["*." + e for e in self.ext_names]))
43
45 path = dialog.GetPath()
46 for ext_name in self.ext_names:
47 if path.endswith("." + ext_name):
48 return path
49 return "%s.%s" % (path, self.ext_names[0])
50
52 split_path = path.split(".")
53 if len(split_path) > 1:
54 ext_name = split_path[-1]
55 return self.ext_data.get(ext_name, None)
56 return None
57
59 for ext in extensions:
60 if isinstance(ext, tuple):
61 name, data = ext
62 self.ext_data[name] = data
63 self.ext_names.append(name)
64 else:
65 self.ext_names.append(ext)
66
67
69
71 self.timeout = timeout
72 wx.PopupTransientWindow.__init__(self, parent, wx.NO_BORDER)
73 self.SetBackgroundColour(color)
74 st = wx.StaticText(self, wx.ID_ANY, text, pos=(10, 10))
75 sz = st.GetBestSize()
76 self.SetSize((sz.width + 20, sz.height + 20))
77 if pos:
78 self.Position(pos, (-1, -1))
79 self.Popup()
80
83
85 super(PopupTextWindow, self).Popup()
86 wx.CallLater(self.timeout, self.Dismiss)
87
88
90 """
91 Transform flat list of categories to a tree based on parent attribute.
92
93 The top-level categories have the given parent and each level in the tree
94 is sorted.
95
96 If remove is given then the subtree with remove as root will not be
97 included.
98
99 The tree is represented as a list of tuples, (cat, sub-tree), where cat is
100 the parent category and subtree is the same tree representation of the
101 children.
102 """
103 children = [child for child in category_list
104 if (child._get_parent() is parent and child is not remove)]
105 sorted_children = sort_categories(children)
106 tree = [(x, category_tree(category_list, x, remove))
107 for x in sorted_children]
108 return tree
109
110
115
116
118 """Display an error message in a modal dialog box"""
119 dial = wx.MessageDialog(parent, message, _("Error"), wx.OK | wx.ICON_ERROR)
120 dial.ShowModal()
121
122
124 dial = wx.MessageDialog(parent, message, _("Warning"), wx.OK | wx.ICON_WARNING)
125 dial.ShowModal()
126
127
133
134
140
141
143 return wx.MessageBox(question, _("Question"),
144 wx.YES_NO | wx.CENTRE | wx.NO_DEFAULT, parent) == wx.YES
145
146
148 """Ask a yes/no question and return the reply."""
149 return wx.MessageBox(question, _("Question"),
150 wx.YES_NO | wx.CENTRE | wx.NO_DEFAULT, parent)
151
152
154 parent.SetCursor(wx.StockCursor(wx.CURSOR_WAIT))
155
156
158 parent.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))
159
160
166
167
171