Changeset 105 for pykoticon

Show
Ignore:
Timestamp:
02/01/06 22:55:29 (18 years ago)
Author:
jerome
Message:

Generic modal dialog now works.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykoticon/trunk/bin/pykoticon

    r104 r105  
    9393        wx.CallAfter(self.frame.askDatas, labels, varnames, varvalues) 
    9494        # 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) 
    9797        # TODO : add value extraction and return a mapping 
     98        retcode = self.frame.dialogAnswer     
    9899        self.frame.dialogAnswer = None # prepare for next call, just in case 
    99         return True 
     100        return retcode 
    100101         
    101102    def export_showDialog(self, message, yesno) : 
     
    140141        sys.exit(0) 
    141142     
    142 class GenericInputDialog(wx.Frame) :     
     143class GenericInputDialog(wx.Dialog) : 
    143144    """Generic input dialog box.""" 
    144145    def __init__(self, parent, id, labels, varnames, varvalues): 
    145         wx.Frame.__init__(self, parent, id, \ 
     146        wx.Dialog.__init__(self, parent, id, \ 
    146147               _("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 \ 
    151150                     | wx.STAY_ON_TOP \ 
    152                      | wx.NO_FULL_REPAINT_ON_RESIZE) 
     151                     | wx.DIALOG_MODAL) 
     152 
    153153        vsizer = wx.BoxSizer(wx.VERTICAL) 
    154154        for i in range(len(varnames)) : 
     
    167167            vsizer.Add(hsizer, 0, wx.ALIGN_CENTER | wx.ALL, 5) 
    168168             
    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")     
    175170        vsizer.Add(okbutton, 0, wx.ALIGN_CENTER | wx.ALL, 5) 
     171         
    176172        self.SetAutoLayout(True) 
    177173        self.SetSizerAndFit(vsizer) 
    178174        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         
    190176class PyKotIcon(wx.Frame): 
    191177    """Main class.""" 
     
    275261        """Opens a dialog box asking for data entry.""" 
    276262        # 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() 
    280268         
    281269    def closeServer(self) :