Changeset 105
- Timestamp:
- 02/01/06 22:55:29 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykoticon/trunk/bin/pykoticon
r104 r105 93 93 wx.CallAfter(self.frame.askDatas, labels, varnames, varvalues) 94 94 # ugly, isn't it ? 95 #while self.frame.dialogAnswer is None :96 #time.sleep(0.1)95 while self.frame.dialogAnswer is None : 96 time.sleep(0.1) 97 97 # TODO : add value extraction and return a mapping 98 retcode = self.frame.dialogAnswer 98 99 self.frame.dialogAnswer = None # prepare for next call, just in case 99 return True100 return retcode 100 101 101 102 def export_showDialog(self, message, yesno) : … … 140 141 sys.exit(0) 141 142 142 class GenericInputDialog(wx. Frame) :143 class GenericInputDialog(wx.Dialog) : 143 144 """Generic input dialog box.""" 144 145 def __init__(self, parent, id, labels, varnames, varvalues): 145 wx. Frame.__init__(self, parent, id, \146 wx.Dialog.__init__(self, parent, id, \ 146 147 _("PyKotIcon data input"), \ 147 size = (-1, -1), \ 148 style = wx.DEFAULT_FRAME_STYLE \ 149 | wx.SIZE_AUTO_HEIGHT \ 150 | wx.SIZE_AUTO_WIDTH \ 148 style = wx.CAPTION \ 149 | wx.THICK_FRAME \ 151 150 | wx.STAY_ON_TOP \ 152 | wx.NO_FULL_REPAINT_ON_RESIZE) 151 | wx.DIALOG_MODAL) 152 153 153 vsizer = wx.BoxSizer(wx.VERTICAL) 154 154 for i in range(len(varnames)) : … … 167 167 vsizer.Add(hsizer, 0, wx.ALIGN_CENTER | wx.ALL, 5) 168 168 169 buttonid = wx.NewId() 170 okbutton = wx.Button(self, buttonid, "OK") 171 wx.EVT_BUTTON(self, buttonid, self.OnOK) 172 173 wx.EVT_CLOSE(self, self.OnClose) 174 169 okbutton = wx.Button(self, wx.ID_OK, "OK") 175 170 vsizer.Add(okbutton, 0, wx.ALIGN_CENTER | wx.ALL, 5) 171 176 172 self.SetAutoLayout(True) 177 173 self.SetSizerAndFit(vsizer) 178 174 self.Layout() 179 self.Show(True) 180 181 def OnClose(self, event) : 182 """Closes the current frame.""" 183 self.Destroy() 184 185 def OnOK(self, event) : 186 """Sets the variables values.""" 187 # TODO : do something 188 self.Close() 189 175 190 176 class PyKotIcon(wx.Frame): 191 177 """Main class.""" … … 275 261 """Opens a dialog box asking for data entry.""" 276 262 # use it this way : self.askDatas(["Username", "Password", "Billing code"], ["username", "password", "billingcode"]) 277 frame = GenericInputDialog(self, wx.ID_ANY, labels, varnames, varvalues) 278 # TODO : wait for dialog to close, and return the values 279 return True 263 self.dialogAnswer = None 264 dialog = GenericInputDialog(self, wx.ID_ANY, labels, varnames, varvalues) 265 self.dialogAnswer = ((dialog.ShowModal() == wx.ID_OK) and "OK") or "CANCEL" 266 print "Result ===> %s" % self.dialogAnswer 267 dialog.Destroy() 280 268 281 269 def closeServer(self) :