Changeset 103 for pykoticon

Show
Ignore:
Timestamp:
01/30/06 19:27:57 (18 years ago)
Author:
jerome
Message:

Generic dialog sort of works. Some cleaning and result data extraction
still need to be done.

Location:
pykoticon/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pykoticon/trunk/bin/pykoticon

    r102 r103  
    9090        return True 
    9191         
    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) 
     92    def export_askDatas(self, labels, varnames, varvalues) : 
     93        """Asks some textual datas defined by a list of labels, a list of variables' names and a list of variables values in a mapping.""" 
     94        wx.CallAfter(self.frame.askDatas, labels, varnames, varvalues) 
    9595        # ugly, isn't it ? 
    96         while self.frame.dialogAnswer is None : 
    97             time.sleep(0.1) 
     96        #while self.frame.dialogAnswer is None : 
     97        #    time.sleep(0.1) 
    9898        # TODO : add value extraction and return a mapping 
    9999        self.frame.dialogAnswer = None # prepare for next call, just in case 
     
    245245        dialog.Destroy() 
    246246         
    247     def askDatas(self, labels, varnames) : 
     247    def askDatas(self, labels, varnames, varvalues) : 
    248248        """Opens a dialog box asking for data entry.""" 
    249249        # use it this way : self.askDatas(["Username", "Password", "Billing code"], ["username", "password", "billingcode"]) 
     250        frame = wx.Frame(self, wx.ID_ANY, \ 
     251               _("Enter PyKota information"), \ 
     252               size = (-1, -1), \ 
     253               style = wxPython.wx.wxDEFAULT_FRAME_STYLE \ 
     254                     | wxPython.wx.wxSIZE_AUTO_HEIGHT \ 
     255                     | wxPython.wx.wxSIZE_AUTO_WIDTH \ 
     256                     | wxPython.wx.wxNO_FULL_REPAINT_ON_RESIZE) 
    250257        self.dialogAnswer = None 
    251         panel = wx.Panel(self, wx.ID_ANY) 
    252258        values = {} 
    253         sizer = wx.BoxSizer(wx.VERTICAL) 
     259        vsizer = wx.BoxSizer(wx.VERTICAL) 
    254260        for i in range(len(varnames)) : 
    255261            varname = varnames[i] 
     
    261267            labelid = wx.NewId()     
    262268            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() 
     269            label = wx.StaticText(frame, labelid, label) 
     270            variable = wx.TextCtrl(frame, varid, varvalues.get(varname, "")) 
     271            hsizer = wx.BoxSizer(wx.HORIZONTAL) 
     272            hsizer.Add(label, 0, wx.ALIGN_CENTER | wx.ALIGN_RIGHT | wx.ALL, 5) 
     273            hsizer.Add(variable, 0, wx.ALIGN_CENTER | wx.ALIGN_LEFT | wx.ALL, 5) 
     274            vsizer.Add(hsizer, 0, wx.ALIGN_CENTER | wx.ALL, 5) 
     275        okbutton = wx.Button(frame, wx.ID_ANY, "OK")     
     276        vsizer.Add(okbutton, 0, wx.ALIGN_CENTER | wx.ALL, 5) 
     277        frame.SetAutoLayout(True) 
     278        frame.SetSizerAndFit(vsizer) 
     279        frame.Layout() 
     280        frame.Show(True) 
    273281 
    274282class PyKotIconApp(wx.PySimpleApp): 
  • pykoticon/trunk/tests/test.py

    r101 r103  
    3535    jobtitle = os.environ.get("PYKOTATITLE", "Unknown") 
    3636    jobsize = os.environ.get("PYKOTAPRECOMPUTEDJOBSIZE", "Unknown") 
    37      
     37    billingcode = os.environ.get("PYKOTAJOBBILLING", "") 
    3838    if len(arguments) < 3 : 
    3939        message = """Hello %(username)s, 
     
    5151    server = xmlrpclib.ServerProxy("http://%s:%s" % (arguments[0], arguments[1])) 
    5252    result = server.showDialog(message, yesno) 
     53    """ 
     54    result = server.askDatas(["Username", "Password", "Billing code"], \ 
     55                             ["username", "password", "billingcode"], \ 
     56                             {"username": username, \ 
     57                              "password": "******", \ 
     58                              "billingcode" : billingcode}) 
     59    """                           
    5360    print result # printing OK is safe. 
    5461