[Tutor] How to add extra Vbox fields dynamically
lang at tharin.com
Mon Jun 21 00:42:42 CEST 2010
OK, figured that was probably bad etiquette, but there doesn't seem to
be close to the same traffic. Mea culpa. I won't do it again. I think
most of my issues have to do with the gtk part, so I'll post there for
the most part. Thanks.
> On 20-06-10 04:04, Lang Hurst wrote:
>> OK, I just did the ugliest hack, from someone who only seems to do
>> ugly hacks. I set up a bunch of textview areas and defaulted them to
>> 'not visible'. Then as I loop through my query results, I make them
>> visible one at a time. Well, it works perfect, but it just doesn't
>> seem right for some reason.
> You also posted this on the PyGTK mailing list, which is the correct
> place for these problems. Please post your PyGTK questions only there,
> do not double post. I'll answer you there.
>> Lang Hurst wrote:
>>> I hope that I'm asking this in the right place. I don't have too
>>> much trouble hacking together command line stuff, but the GUI part
>>> is a struggle for me.
>>> I created a UI in glade. It has a couple of Vboxes for
>>> information. The final box is filled with a TextView. In my
>>> program, I'm connecting to a database and pulling out a series of
>>> records. As it stands, I can pull out all the records and view them
>>> in the TextView, but I would like to be able to have each result be
>>> a separate TextView (which I then have to figure out how to make
>>> Right now, this part looks like:
>>> query = 'SELECT subject, chapter_module, credits, final_test_score,
>>> notes FROM credits WHERE id=' + student
>>> credits = cursor.fetchall()
>>> temp = ''
>>> for credit in credits:
>>> sub_buf = 15 - len(credit)
>>> chap_buf = 15 - len(credit)
>>> cred_buf = 5 - len(credit)
>>> score_buf = 5 - len(credit)
>>> temp = temp + credit + " " * sub_buf + credit + " " *
>>> chap_buf + "Credits: " + credit + " " * chap_buf + "Score: " +
>>> credit + "\n\nNOTES: " + credit + "\n" + " " * 5 + "-" * 50 +
>>> # I would like to loop something here
>>> # to have multiple text areas added
>>> buff = self.builder.get_object('textview1').get_buffer()
>>> This works fine. It pulls the records out of the database, and then
>>> cats the results together and throws it into my TextView. I'm happy
>>> with the results so far, but I would like to be able to click on
>>> each record if I see something that needs to be modified. As
>>> always, any help is appreciated.
>>> Also, can anyone recommend a good book for gtk + glade + python? I
>>> went out and bought Learning Python, but book at B&N that were
>>> remotely GUI related seems very outdated or just tkinter related,
>>> and just about all the gtk+python examples and tutorials don't use
>>> glade. Thanks again.
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
There are no stupid questions, just stupid people.
More information about the Tutor