I picked up Boa as a replacement for Delphi here, as we are slowly switching
to Python over Fortran, C etc. Im rewriting my Tk GUI code with Boa and
mostly it's going alright, however I am running into some issues with Boa's
generated code and my own. I use a listbox to allow the user to choose
which device they wish to use, in TK this was straightforward and easy, as
it was entirely written by me, looks something like this:
devices = daq.GetDeviceList()
self.devicebox = Listbox(self)
self.devicebox.grid(row=1, column=0, rowspan=2)
for item in devices:
self.devicebox.insert(END, item)
Now, in Boa, I came up with mostly the same deal:
def __init__(self, parent):
devicesList = daq.GetDeviceList()
self.deviceList = devicesList
self.curdevice = False
self._init_ctrls(parent)
and then later in the __init__ctrls I changed the listbox's choices option
to: self.deviceList
self.allDevices = wx.ListBox(choices=self.deviceList,
id=wxID_CHOOSEDEVICEALLDEVICES,
name='allDevices', parent=self, pos=wx.Point(24, 32),
size=wx.Size(132, 63), style=0)
When it's run, the code run's fine, however when I try to use the
constructor again I get an error about either daq not being attribute of the
class, or deviceList not being an attribute of the class, so if I want to
alter the window I have to change the listbox's options back to normal, fix
use the constructor then switch the listbox back. I looked through the
documentation and it mentioned so long as I had declared it in the __init__
I would be able to put it in the __init__ctrls, but getting these errors is
kind of off putting.
--
Nathaniel Christopher Hayes
Third Year Mechanical Engineering
Email: nat...@ma...
|