Re: [Boa Constr] please help with wx.dialog
Status: Beta
Brought to you by:
riaan
From: Kevin L. <kl...@wa...> - 2008-05-29 15:41:23
|
----- "Fernando Paiva" <fer...@bm...> wrote: > Hello Kevin, thanks for your atention. > > The Search Customer form, stay on top of a Customer form, but after > the > consultation it closes. > I already had attemped the Refresh() of the controls, but I did not > have > success. > > > Here the bind of intCtrl. > self.intCtrlCodigo = wx.lib.intctrl.IntCtrl(allow_long=False, > allow_none=False, default_color=wx.BLACK, > id=wxID_DIALOGCLIENTESINTCTRLCODIGO, limited=False, > max=None, > min=None, name='intCtrlCode', oob_color=wx.RED, > parent=self, > pos=wx.Point(80, 34), size=wx.Size(58, 21), > style=wx.TE_RIGHT | wx.WANTS_CHARS, value=0) > self.intCtrlCode.Bind(wx.EVT_KEY_UP, self.OnIntCtrlCodeKeyUp) > > > See my new function, and look the comment. > > def receiveSearch(self, codeOfCustomer): > """ This function receives the code and makes the consultation > sql > and fills the fields """ > > self.intCtrlCode.SetValue(codeOfCustomer) > > try: > _sql = """ > SELECT customer_code, customer_name FROM customer > WHERE > customer_code = %s > """ % (codeOfCustomer) > self.cursor.execute(_sql) > registers = self.cursor.fetchall() > for x in registers: > self.textCtrlName.SetValue(x["customer_name"]) > except MySQLdb.Error, e: > wx.MessageBox("Error %d: %s" %(e.args[0], e.args[1])) > finally: > self.intCtrlCode.Refresh() > self.textCtrlName.Refresh() > # here I make I command print and all the data are > correct, but > the fields not fills > print self.intCtrlCode.GetValue() > > Here the function of SearchCustomer form. > def OnGridSearchCustomerGridCellLeftDclick(self, event): > """ This function get a code of Customer in wx.Grid and send > to > function receiveSearch in Customer form """ > import Customer > customer = Customer.Customer(self) > row = event.GetRow() > codeOfCustomer = self.gridSearchCustomer.GetCellValue(row, 0) > customer.receiveSearch(int(codeOfCustomer)) > self.Close() > > The command "print" show all values corretly, but the fields not. Fernando, Your code appears to be correct. I've built a quick demo of what you've provided and it works here. One of the things that I thought might be happening is that your try/except/finally might be masking a value error on your SetValue, but that does not appear to be the case. How is your search customer form being displayed? Is it a separate dialog or a form that is placed on top of the other form? The fact that the data value(s) appear in the controls but does not get displayed is very odd. Kevin |