Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 32

Thread: [PyGTK]TextView Margin line

  1. #21
    Join Date
    May 2008
    Beans
    61

    Re: [PyGTK]TextView Margin line

    @BloGTK using a liststore would be way harder, using colors... and how would word wrap work with that?

    @smartbei i looked at xchats source code, but it's really hard to understand, i's written in C and there is so many files.

  2. #22
    Join Date
    Mar 2005
    Beans
    34
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: [PyGTK]TextView Margin line

    I decided that this was an intriguing enough challenge to see if I could do what you want to do with a list store. Here's some sample code that demonstrates how this work.

    Now, the problem is that the width of the cell is a fixed size. If that works for you, great. If not, then here's a quick HOWTO on how to let the wrap width change as the column size changes.

    You can change the font formatting by setting other properties in the cellrenderer.

    Feel free to steal this code if it helps you.

    I hope this helps!
    Attached Files Attached Files
    Last edited by BloGTK; September 19th, 2009 at 04:35 AM. Reason: Fixed error in sample code.
    BloGTK - An Open Source Weblog Editor

    BloGTK 2.0 -- available now. Details at the official blog or the Launchpad project page

  3. #23
    Join Date
    May 2008
    Beans
    61

    Re: [PyGTK]TextView Margin line

    Thanks a lot for taking the time to put this together!
    This is a solution but a lot of the features that the TextView has aren't there for example, you can't select and copy text and i'm sure there is more that i would need, images in text, links in text.

    Would there be anyway to make it act just like the TextView?
    If not then is there anyone who knows C and could easily look at xchats source code to check how they do it ? i would really appreciate it.

  4. #24
    Join Date
    Mar 2005
    Beans
    34
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: [PyGTK]TextView Margin line

    I'm not sure exactly how flexible that would be.

    The other solution is to completely cheat and use python-webkit and do the interface in HTML. That would give you tons of flexibility. The downside is that part of your interface would have to be programmed in HTML, CSS, and JavaScript. But, I believe that the WebKit bindings let you go between JavaScript and Python objects.
    BloGTK - An Open Source Weblog Editor

    BloGTK 2.0 -- available now. Details at the official blog or the Launchpad project page

  5. #25
    Join Date
    May 2008
    Beans
    61

    Re: [PyGTK]TextView Margin line

    Yeah that's an option too, but that would propably waste way too many resources.
    And anyway xchat does it, there must be a way to do it.

  6. #26
    Join Date
    May 2008
    Beans
    61

    Re: [PyGTK]TextView Margin line

    Is there anyone who could take a look at xchats source to see how xchat does it ?

  7. #27
    Join Date
    May 2008
    Beans
    61

    Re: [PyGTK]TextView Margin line

    anyone ?

  8. #28
    Join Date
    Oct 2006
    Beans
    69
    Distro
    Xubuntu 11.04 Natty Narwhal

    Re: [PyGTK]TextView Margin line

    dom96, have you thought of using a number of gtk.ListStore's packed in a table rather using a textView as it looks like you are only displaying data?

  9. #29
    Join Date
    May 2008
    Beans
    61

    Re: [PyGTK]TextView Margin line

    Yes, BloGTK suggested that

  10. #30
    Join Date
    May 2008
    Beans
    61

    Re: [PyGTK]TextView Margin line

    By the way i understand it, this should work.
    PHP Code:
    #!/usr/bin/env python
    import gtk
    import gtksourceview2 
    as gtksv

    window 
    gtk.Window()
    window.set_default_size(400400)
    window.connect("destroy"gtk.main_quit)

    vp gtk.Viewport()
    sv gtksv.View()

    sv.set_right_margin_position(10)
    sv.set_show_right_margin(True)

    sb gtksv.Buffer()

    msgTag sb.create_tag(None)
    msgTag.set_property("justification",gtk.JUSTIFY_RIGHT)

    msgTag1 sb.create_tag(None)
    msgTag1.set_property("justification",gtk.JUSTIFY_LEFT)

    sb.insert_with_tags(sb.get_end_iter(),"dom96",msgTag1)
    sb.insert_with_tags(sb.get_end_iter(),"Message",msgTag)

    sv.set_buffer(sb)

    vp.add(sv)

    window.add(vp)

    window.show_all()

    gtk.main() 
    but doesn't "dom96" and "Message" is just LEFT ALIGNED!
    Could someone tell me why ?

Page 3 of 4 FirstFirst 1234 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •