Timo wrote:
> On 20-06-10 04:06, Lang Hurst wrote:
>
>> I got this to work using what I think is an ugly hack, but may be how it
>> is supposed to be done. I created a whole bunch of textviews in glade,
>> and defaulted them to 'not visible'. Then, as I loop through my
>> results, I put in my information and then make the widget visible. It
>> works, just doesn't seem right. Oh well, back to it.
>>
>>
> That doesn't sound good to me. what if you have more records to show
> than textviews?
>
Pragmatically, I'm not worried about that. I'm making a very specific
program to keep track of credit information in my class. Unless the
State of California drastically changes graduation requirements, I'm
OK. I just really didn't like doing that because, well, because I knew
that it was 'wrong.'
> You will find that in some programs it's just impossible to only use
> Glade for your GUI, so it is advised to learn some plain PyGTK aswell.
> In your example, this is the case too.
>
>
This is where I'm running into documentation problems. I've found a
couple tutorials, examples on using glade and python. A lot on using
gtk and python, but I haven't seen one mixing the two.
> The best way (I think atleast) is to manually create your textview and
> append it to your VBox with vbox.pack_start(textview)
> Maybe even subclass gtk.Textview to have more control.
> This way you will not have to create numerous textviews or add a VBox
> with lot's of rows in Glade.
>
>
This is what I tried, and failed to do. I changed from a textview to a
button, looks about the same and has made opening a second window to
deal with specific credits much easier. Here is a screenshot of what
I'm doing with my first window.
snapshot of main screen
The two boxes in the middle are the ones that I've been showing/hiding.
In my code I have:
for credit in credits:
counter += 1
sub_buf = 15 - len(credit[0])
chap_buf = 15 - len(credit[1])
cred_buf = 5 - len(credit[2])
score_buf = 5 - len(credit[1])
temp = credit[0] + " " * sub_buf + credit[1] + " " * chap_buf +
"Credits: " + credit[2] + " " * chap_buf + "Score: " + credit[3] +
"\n\n\tNOTES: " + credit[4]
bttn_number = 'credit_button' + str(counter)
self.builder.get_object(bttn_number).set_label(temp)
self.builder.get_object(bttn_number).show()
return
In this case, I have two sample credits I manually put in the database.
I see that I should create a button and pack it in the box (vbox2 from
my glade file)
I tried replacing the last two lines with:
bttn = gtk.button(bttn_number)
self.builder.vbox2.pack_start(bttn_number)
Then
bttn = gtk.button()
bttn.set_label(temp)
self.builder.vbox2.pack_start(bttn)
And I keep getting 'AttributeError: 'module' object has no attribute
'button'
I know this is incredibly basic, and I apologize if it's annoying, but I
have looked and just can't find some basic answers. The documentation I
see makes me feel like the world of python will open up for me once I
make it up this steep hill. Again, thanks for any help, I really do
appreciate it.
-Lang
> Cheers,
> Timo
>
>
>> Lang Hurst wrote:
>>
>>
>>> I hope that I'm asking this in the right place.
>>>
>>> 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 clickable...)
>>>
>>> Right now, this part looks like:
>>>
>>> query = 'SELECT subject, chapter_module, credits, final_test_score,
>>> notes FROM credits WHERE id=' + student[0][6]
>>> cursor.execute(query)
>>> credits = cursor.fetchall()
>>> temp = ''
>>> for credit in credits:
>>> sub_buf = 15 - len(credit[0])
>>> chap_buf = 15 - len(credit[1])
>>> cred_buf = 5 - len(credit[2])
>>> score_buf = 5 - len(credit[1])
>>> temp = temp + credit[0] + " " * sub_buf + credit[1] + " " *
>>> chap_buf + "Credits: " + credit[2] + " " * chap_buf + "Score: " +
>>> credit[3] + "\n\nNOTES: " + credit[4] + "\n" + " " * 5 + "-" * 50 + "\n\n"
>>>
>>> # I would like to loop something here
>>> # to have multiple text areas added
>>>
>>> buff = self.builder.get_object('textview1').get_buffer()
>>> buff.set_text(temp)
>>>
>>> This works fine, I'm happy with the results, but I would like to be able
>>> to click on each record if I see something that needs to be modified.
>>> All the links I've found don't use glade. As always, any help is
>>> appreciated.
>>>
>>>
>>> -Lang
>>>
>>>
>>>
>>>
>>
>>
>
> _______________________________________________
> pygtk mailing list [email protected]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
>
>
>
--
There are no stupid questions, just stupid people.
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/