[Tutor] Need help printing a pickled data
Matt D
md123 at nycap.rr.com
Wed Jun 26 03:06:43 CEST 2013
> You are better off polling a directory for a text file with a
> specified format and reading that file. Construct the dictionary from
> that file and call update with it. Delete the file when done.
>
> An even easier solution is to call update() with a hard coded
> dictionary in TrafficPane.__init__. Or create a temporary button with
> a function that generates random data for the UI and passes it to
> update.
>
> I really think focusing on pickle is really a red herring and not
> related to any bit you are interested in.
>
>
Like I said, currently two of the the TextCtrl fields, don't receive their
values because the 'data_unit' object ldu1.h, containing those two values,
does not go through the pickling process, or more precisely it does not
have
an '#include pickle.h'.
Note that the Python UI gets its display values from the 'data_unit'
object hdu.h which has the '#include pickle.h' and its called like:
std::string
hdu::snapshot() const
{
pickle p;
p.add("duid", duid_str());
p.add("nac", nac_str());
p.add("mfid", mfid_str());
p.add("algid", algid_str());
p.add("kid", kid_str());
p.add("mi", mi_str());
p.add("tgid", tgid_str());
return p.to_string();
}
And then the strings are given values like this:
string
hdu::algid_str() const
{
const size_t ALGID_BITS[] = {
356, 357, 360, 361, 374, 375, 376, 377
};
const size_t ALGID_BITS_SZ = sizeof(ALGID_BITS) / sizeof(ALGID_BITS[0]);
uint8_t algid = extract(frame_body(), ALGID_BITS, ALGID_BITS_SZ);
return lookup(algid, ALGIDS, ALGIDS_SZ);
}
which seem to me to be rather lengthy but thats the way its done.
So given that I have to do something like this for the another data_unit
object, in order to pass the two missing values to the UI, do you still
think I can escape this pickle issue?
More information about the Tutor
mailing list