Note that there are some explanatory texts on larger screens.

plurals
  1. POwxPython; passing a value to wx.TextCtrl from another class
    primarykey
    data
    text
    <p>I'd like to thank everyone in advance for taking the time to review this question and I'm sure a lot of people get hung up on this at first and I am also a bit new to OOP, I've primarily done vbscripts in the past, so this is a new frontier to me.</p> <p>My problem is that I need to:</p> <p>pass a value from one panel to another... I'm sure its something simple, but my hair is getting grey over this one.</p> <pre><code>import wx import win32com.client class FinanceInfo(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) zbox = wx.BoxSizer(wx.VERTICAL) self.Description = wx.TextCtrl(self, -1, style=wx.TE_READONLY|wx.TE_MULTILINE, size=(200,204)) zbox.Add(self.Description,0, wx.EXPAND,15) self.SetSizer(zbox) class Frame(wx.Frame): def __init__(self, *args, **kwargs): super(Frame, self).__init__(*args, **kwargs) self.InitUI() def InitUI(self): panel = wx.Panel(self, -1) box1 = wx.BoxSizer(wx.HORIZONTAL) box2 = wx.BoxSizer(wx.HORIZONTAL) box3 = wx.BoxSizer(wx.HORIZONTAL) box4 = wx.BoxSizer(wx.HORIZONTAL) box5 = wx.BoxSizer(wx.HORIZONTAL) all_box = wx.BoxSizer(wx.VERTICAL) overall = wx.BoxSizer(wx.HORIZONTAL) nb = wx.Notebook(panel) page2 = FinanceInfo(nb) nb.AddPage(page2, "Finance Information") first = wx.StaticText(panel, label="First Name: ") last = wx.StaticText(panel, label="Last Name: ") self.DATA = wx.ListBox(panel, style=wx.LB_SINGLE, size=(100,100)) self.Bind(wx.EVT_LISTBOX, self.OnSelection, id=self.DATA.GetId()) self.CLYa = wx.StaticText(panel, label="") self.P2Da = wx.StaticText(panel, label="") self.PLYa = wx.StaticText(panel, label="") self.FN = wx.TextCtrl(panel, size=(75,-1)) self.LN = wx.TextCtrl(panel, size=(75,-1)) Search = wx.Button(panel, label="Search Patient") self.Bind(wx.EVT_BUTTON, self.pulldata, id=Search.GetId()) Close = wx.Button(panel, label="Close Viewer") self.Bind(wx.EVT_BUTTON, self.OnClose, id=Close.GetId()) box1.Add(first, 0, wx.ALL, 5) box2.Add(last, 0, wx.ALL, 5) box1.Add(self.FN, 1, wx.ALL, 5) box2.Add(self.LN, 1, wx.ALL, 5) box3.Add(self.DATA, 1 , wx.ALL, 5) box4.Add(Search, 0, wx.ALL, 5) box5.Add(Close, 0, wx.ALL, 5) all_box.Add(box1, 0, wx.LEFT) all_box.Add(box2, 0, wx.LEFT) all_box.Add(wx.StaticLine(panel), 0, wx.ALL|wx.EXPAND, 5) all_box.Add(box3, 0, wx.CENTER) all_box.Add(box4, 0, wx.CENTER) all_box.Add(box5, 0, wx.CENTER) overall.Add(all_box,0,wx.EXPAND) overall.Add(nb, 1, wx.EXPAND) panel.SetSizer(overall) self.SetSize((500, 275)) self.SetTitle("Maxident Historical Data Viewer") self.Centre() self.Show(True) def OnClose(self, event): quit() def pulldata(self, event): firstname = str(self.FN.GetValue()) lastname = str(self.LN.GetValue()) access = pullID(lastname.strip(), firstname.strip()) access.MoveFirst dat = "" while not access.EOF: a = str(access.Fields("First Name").value) b = str(access.Fields("Last Name").value) PID = str(access.Fields("Patient Number").value) name = str(a + " " + b + " :" + PID) self.DATA.Insert(name, 0) access.MoveNext() def OnSelection(self, event): x = str(self.DATA.GetStringSelection()) y = x.split(":") PID = y[1] pullfinancedata(PID) def pullID(lastname, firstname): DB = r"C:\Converted DBases\DATA.mdb" engine = win32com.client.Dispatch("DAO.DBEngine.36") db = engine.OpenDatabase(DB) sql = "select [Patient Number], [First Name], [Last Name] from [tPatients] where [Last Name]='" + lastname.upper() + "' and [First Name]='" + firstname.upper() + "'" access = db.OpenRecordset(sql) return access def pullfinancedata(PID): DB = r"C:\Converted DBases\DATA.mdb" engine = win32com.client.Dispatch("DAO.DBEngine.36") db = engine.OpenDatabase(DB) sql = "select * from [tPayment History] where [Patient Number]=" + PID access = db.OpenRecordset(sql) dat = "" while not access.EOF: PD = "Payment Date:\t" + str(access.Fields("Payment Date").value) + '\n' PM = "Payment Method:\t" + str(access.Fields("Payment Method").value) + '\n' PP = "Patient Payment:\t" + str(access.Fields("Patient Payment").value) + '\n' IP = "Insurance Payment:\t" + str(access.Fields("Insurance Payment").value) + '\n' dat = dat + PD + PM + PP + IP + "\n ------------------ \n" access.MoveNext() """ THIS IS WHERE I NEED HELP! """ print dat """ I need this dat variable to be passed to the FinanceInfo class and i've tried FinanceInfo.Description.SetValue(dat) but its not working """ def main(): ex = wx.App() Frame(None) ex.MainLoop() if __name__ == '__main__': main() </code></pre> <p>I would also be grateful for any other tips or tricks. Not sure if my BoxSizer's make any sense, I mostly got the examples around other places.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload