| 92 | def export_askDatas(self, labels, varnames) : |
| 93 | """Asks some textual datas defined by a list of labels and a list of variables' names.""" |
| 94 | wx.CallAfter(self.frame.askDatas, labels, varnames) |
| 95 | # ugly, isn't it ? |
| 96 | while self.frame.dialogAnswer is None : |
| 97 | time.sleep(0.1) |
| 98 | # TODO : add value extraction and return a mapping |
| 99 | self.frame.dialogAnswer = None # prepare for next call, just in case |
| 100 | return True |
| 101 | |
| 247 | def askDatas(self, labels, varnames) : |
| 248 | """Opens a dialog box asking for data entry.""" |
| 249 | # use it this way : self.askDatas(["Username", "Password", "Billing code"], ["username", "password", "billingcode"]) |
| 250 | self.dialogAnswer = None |
| 251 | panel = wx.Panel(self, wx.ID_ANY) |
| 252 | values = {} |
| 253 | sizer = wx.BoxSizer(wx.VERTICAL) |
| 254 | for i in range(len(varnames)) : |
| 255 | varname = varnames[i] |
| 256 | values[varname] = None |
| 257 | try : |
| 258 | label = labels[i] |
| 259 | except IndexError : |
| 260 | label = "" |
| 261 | labelid = wx.NewId() |
| 262 | varid = wx.NewId() |
| 263 | label = wx.StaticText(panel, labelid, label) |
| 264 | variable = wx.TextCtrl(panel, varid, "Blah !") |
| 265 | sizer.Add(label, flag=wx.ALIGN_CENTER | wx.ALL) |
| 266 | sizer.Add(variable, flag=wx.ALIGN_CENTER | wx.ALL) |
| 267 | okbutton = wx.Button(panel, wx.ID_ANY, "OK") |
| 268 | sizer.Add(okbutton, flag=wx.ALIGN_CENTER | wx.ALL) |
| 269 | self.SetAutoLayout(True) |
| 270 | self.SetSizerAndFit(sizer) |
| 271 | self.Layout() |
| 272 | #panel.Destroy() |