Always visible and sticky columns in Gtk.TreeViewSelecting multiple columns in a pandas dataframeRenaming columns in pandasDelete column from pandas DataFrameWhat causes the different display behaviour for a GtkIconView between different GTK versions?What is the correct method to display a large popup menu?Python unity indicator applet and glade child windowSelect rows from a DataFrame based on values in a column in pandasHow to read all message from queue using stomp library in Python?TkInter Frame doesn't load if another function is called

In what language did Túrin converse with Mím?

Can I leave a large suitcase at TPE during a 4-hour layover, and pick it up 4.5 days later when I come back to TPE on my way to Taipei downtown?

How can I store milk for long periods of time?

Where does MyAnimeList get their data from?

Received email from ISP saying one of my devices has malware

How to run a command 1 out of N times in Bash

Where should I draw the line on follow up questions from previous employer

What's the origin of the concept of alternate dimensions/realities?

Heavy Box Stacking

Which is the correct version of Mussorgsky's Pictures at an Exhibition?

Why do presidential pardons exist in a country having a clear separation of powers?

Is there anything in the universe that cannot be compressed?

Given a specific computer system, is it possible to estimate the actual precise run time of a piece of Assembly code

Can two aircraft be allowed to stay on the same runway at the same time?

Does the Freedom of Movement spell prevent petrification by the Flesh to Stone spell?

I failed to respond to a potential advisor

Quick Tilepaint Puzzles: Corridors and Corners

How to differentiate between two people with the same name in a story?

Coupling two 15 Amp circuit breaker for 20 Amp

How to investigate an unknown 1.5GB file named "sudo" in my Linux home directory?

Using font to highlight a god's speech in dialogue

Is this statement about a motion being simple harmonic in nature strong?

Padding a column of lists

What is the motivation behind designing a control stick that does not move?



Always visible and sticky columns in Gtk.TreeView


Selecting multiple columns in a pandas dataframeRenaming columns in pandasDelete column from pandas DataFrameWhat causes the different display behaviour for a GtkIconView between different GTK versions?What is the correct method to display a large popup menu?Python unity indicator applet and glade child windowSelect rows from a DataFrame based on values in a column in pandasHow to read all message from queue using stomp library in Python?TkInter Frame doesn't load if another function is called






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I have this Gtk.TreeView with 3 columns embeded into a Gtk.Paned.



enter image description here



When I resize the window (or fill in more rows with longer text in the first column) the last two columns shouldn't disappear.



I want to have the last two columns always visible and sticky to the right side without loosing the left columns.



After clicking the button to add a very long string the first column should not grow. Kind of this (quick & dirty manipulated screenshot):



How it should look like



enter image description here



But how it looks (but shouldn't)



enter image description here



I don't see a way in the docu to implement this. In that example code below the Gtk.TreeView is embeded into a Gtk.ScrolledWindow to allow a vertical scrollbar.



#!/usr/bin/env python3
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GLib

class TreeView(Gtk.TreeView):
def __init__(self):
# model
self.model = Gtk.ListStore.new([str, int, int])
for i in range(1, 6):
self.model.append([('text '.format(i))*i, i*10, i])

# view
Gtk.TreeView.__init__(self, self.model)

col_a = Gtk.TreeViewColumn('str',
Gtk.CellRendererText(single_paragraph_mode=True),
text=0)
col_b = Gtk.TreeViewColumn('int',
Gtk.CellRendererText(),
text=1)
col_c = Gtk.TreeViewColumn('int',
Gtk.CellRendererText(),
text=2)
self.append_column(col_a)
self.append_column(col_b)
self.append_column(col_c)

# scrollable
self.scroll = Gtk.ScrolledWindow()
self.scroll.add(self)
self.scroll.set_policy(hscrollbar_policy=Gtk.PolicyType.NEVER,
vscrollbar_policy=Gtk.PolicyType.AUTOMATIC)

def on_button(self, event):
self.model.append(['long text '*20, 0, 0])

class Window(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title='Mein Gtk-Fenster')
#self.set_default_size(100, 120)

# tree & button
self.view = TreeView()
self.btn = Gtk.Button('add long row')
self.btn.connect('clicked', self.view.on_button)

# layout
#box = Gtk.VBox()
#box.pack_start(self.btn, False, False, 10)
#box.pack_start(self.view.scroll, True, True, 10)
#self.add(box)

self.paned = Gtk.Paned.new(orientation=Gtk.Orientation.HORIZONTAL)
self.paned.pack1(self.view.scroll)
self.paned.pack2(self.btn)
self.add(self.paned)

self.connect('destroy', Gtk.main_quit)
self.show_all()

if __name__ == '__main__':
win = Window()
Gtk.main()









share|improve this question
































    1















    I have this Gtk.TreeView with 3 columns embeded into a Gtk.Paned.



    enter image description here



    When I resize the window (or fill in more rows with longer text in the first column) the last two columns shouldn't disappear.



    I want to have the last two columns always visible and sticky to the right side without loosing the left columns.



    After clicking the button to add a very long string the first column should not grow. Kind of this (quick & dirty manipulated screenshot):



    How it should look like



    enter image description here



    But how it looks (but shouldn't)



    enter image description here



    I don't see a way in the docu to implement this. In that example code below the Gtk.TreeView is embeded into a Gtk.ScrolledWindow to allow a vertical scrollbar.



    #!/usr/bin/env python3
    import gi
    gi.require_version('Gtk', '3.0')
    from gi.repository import Gtk
    from gi.repository import GLib

    class TreeView(Gtk.TreeView):
    def __init__(self):
    # model
    self.model = Gtk.ListStore.new([str, int, int])
    for i in range(1, 6):
    self.model.append([('text '.format(i))*i, i*10, i])

    # view
    Gtk.TreeView.__init__(self, self.model)

    col_a = Gtk.TreeViewColumn('str',
    Gtk.CellRendererText(single_paragraph_mode=True),
    text=0)
    col_b = Gtk.TreeViewColumn('int',
    Gtk.CellRendererText(),
    text=1)
    col_c = Gtk.TreeViewColumn('int',
    Gtk.CellRendererText(),
    text=2)
    self.append_column(col_a)
    self.append_column(col_b)
    self.append_column(col_c)

    # scrollable
    self.scroll = Gtk.ScrolledWindow()
    self.scroll.add(self)
    self.scroll.set_policy(hscrollbar_policy=Gtk.PolicyType.NEVER,
    vscrollbar_policy=Gtk.PolicyType.AUTOMATIC)

    def on_button(self, event):
    self.model.append(['long text '*20, 0, 0])

    class Window(Gtk.Window):
    def __init__(self):
    Gtk.Window.__init__(self, title='Mein Gtk-Fenster')
    #self.set_default_size(100, 120)

    # tree & button
    self.view = TreeView()
    self.btn = Gtk.Button('add long row')
    self.btn.connect('clicked', self.view.on_button)

    # layout
    #box = Gtk.VBox()
    #box.pack_start(self.btn, False, False, 10)
    #box.pack_start(self.view.scroll, True, True, 10)
    #self.add(box)

    self.paned = Gtk.Paned.new(orientation=Gtk.Orientation.HORIZONTAL)
    self.paned.pack1(self.view.scroll)
    self.paned.pack2(self.btn)
    self.add(self.paned)

    self.connect('destroy', Gtk.main_quit)
    self.show_all()

    if __name__ == '__main__':
    win = Window()
    Gtk.main()









    share|improve this question




























      1












      1








      1








      I have this Gtk.TreeView with 3 columns embeded into a Gtk.Paned.



      enter image description here



      When I resize the window (or fill in more rows with longer text in the first column) the last two columns shouldn't disappear.



      I want to have the last two columns always visible and sticky to the right side without loosing the left columns.



      After clicking the button to add a very long string the first column should not grow. Kind of this (quick & dirty manipulated screenshot):



      How it should look like



      enter image description here



      But how it looks (but shouldn't)



      enter image description here



      I don't see a way in the docu to implement this. In that example code below the Gtk.TreeView is embeded into a Gtk.ScrolledWindow to allow a vertical scrollbar.



      #!/usr/bin/env python3
      import gi
      gi.require_version('Gtk', '3.0')
      from gi.repository import Gtk
      from gi.repository import GLib

      class TreeView(Gtk.TreeView):
      def __init__(self):
      # model
      self.model = Gtk.ListStore.new([str, int, int])
      for i in range(1, 6):
      self.model.append([('text '.format(i))*i, i*10, i])

      # view
      Gtk.TreeView.__init__(self, self.model)

      col_a = Gtk.TreeViewColumn('str',
      Gtk.CellRendererText(single_paragraph_mode=True),
      text=0)
      col_b = Gtk.TreeViewColumn('int',
      Gtk.CellRendererText(),
      text=1)
      col_c = Gtk.TreeViewColumn('int',
      Gtk.CellRendererText(),
      text=2)
      self.append_column(col_a)
      self.append_column(col_b)
      self.append_column(col_c)

      # scrollable
      self.scroll = Gtk.ScrolledWindow()
      self.scroll.add(self)
      self.scroll.set_policy(hscrollbar_policy=Gtk.PolicyType.NEVER,
      vscrollbar_policy=Gtk.PolicyType.AUTOMATIC)

      def on_button(self, event):
      self.model.append(['long text '*20, 0, 0])

      class Window(Gtk.Window):
      def __init__(self):
      Gtk.Window.__init__(self, title='Mein Gtk-Fenster')
      #self.set_default_size(100, 120)

      # tree & button
      self.view = TreeView()
      self.btn = Gtk.Button('add long row')
      self.btn.connect('clicked', self.view.on_button)

      # layout
      #box = Gtk.VBox()
      #box.pack_start(self.btn, False, False, 10)
      #box.pack_start(self.view.scroll, True, True, 10)
      #self.add(box)

      self.paned = Gtk.Paned.new(orientation=Gtk.Orientation.HORIZONTAL)
      self.paned.pack1(self.view.scroll)
      self.paned.pack2(self.btn)
      self.add(self.paned)

      self.connect('destroy', Gtk.main_quit)
      self.show_all()

      if __name__ == '__main__':
      win = Window()
      Gtk.main()









      share|improve this question
















      I have this Gtk.TreeView with 3 columns embeded into a Gtk.Paned.



      enter image description here



      When I resize the window (or fill in more rows with longer text in the first column) the last two columns shouldn't disappear.



      I want to have the last two columns always visible and sticky to the right side without loosing the left columns.



      After clicking the button to add a very long string the first column should not grow. Kind of this (quick & dirty manipulated screenshot):



      How it should look like



      enter image description here



      But how it looks (but shouldn't)



      enter image description here



      I don't see a way in the docu to implement this. In that example code below the Gtk.TreeView is embeded into a Gtk.ScrolledWindow to allow a vertical scrollbar.



      #!/usr/bin/env python3
      import gi
      gi.require_version('Gtk', '3.0')
      from gi.repository import Gtk
      from gi.repository import GLib

      class TreeView(Gtk.TreeView):
      def __init__(self):
      # model
      self.model = Gtk.ListStore.new([str, int, int])
      for i in range(1, 6):
      self.model.append([('text '.format(i))*i, i*10, i])

      # view
      Gtk.TreeView.__init__(self, self.model)

      col_a = Gtk.TreeViewColumn('str',
      Gtk.CellRendererText(single_paragraph_mode=True),
      text=0)
      col_b = Gtk.TreeViewColumn('int',
      Gtk.CellRendererText(),
      text=1)
      col_c = Gtk.TreeViewColumn('int',
      Gtk.CellRendererText(),
      text=2)
      self.append_column(col_a)
      self.append_column(col_b)
      self.append_column(col_c)

      # scrollable
      self.scroll = Gtk.ScrolledWindow()
      self.scroll.add(self)
      self.scroll.set_policy(hscrollbar_policy=Gtk.PolicyType.NEVER,
      vscrollbar_policy=Gtk.PolicyType.AUTOMATIC)

      def on_button(self, event):
      self.model.append(['long text '*20, 0, 0])

      class Window(Gtk.Window):
      def __init__(self):
      Gtk.Window.__init__(self, title='Mein Gtk-Fenster')
      #self.set_default_size(100, 120)

      # tree & button
      self.view = TreeView()
      self.btn = Gtk.Button('add long row')
      self.btn.connect('clicked', self.view.on_button)

      # layout
      #box = Gtk.VBox()
      #box.pack_start(self.btn, False, False, 10)
      #box.pack_start(self.view.scroll, True, True, 10)
      #self.add(box)

      self.paned = Gtk.Paned.new(orientation=Gtk.Orientation.HORIZONTAL)
      self.paned.pack1(self.view.scroll)
      self.paned.pack2(self.btn)
      self.add(self.paned)

      self.connect('destroy', Gtk.main_quit)
      self.show_all()

      if __name__ == '__main__':
      win = Window()
      Gtk.main()






      python python-3.x treeview gtk pygobject






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 10:16







      buhtz

















      asked Mar 27 at 23:21









      buhtzbuhtz

      2,7625 gold badges25 silver badges69 bronze badges




      2,7625 gold badges25 silver badges69 bronze badges

























          2 Answers
          2






          active

          oldest

          votes


















          2















          There are atleast two changes needed:



          1. To keep the column a normal size with a long string, set the ellipsize property of the GtkCellRendererText. It should be a PangoEllipsizeMode.


          2. To make the two right colums stick to the end, expand the first column to take all remaining space by setting the expand property to True.


          Your column creation with these changes:



          col_a = Gtk.TreeViewColumn('str',
          Gtk.CellRendererText(single_paragraph_mode=True,
          ellipsize=Pango.EllipsizeMode.END),
          text=0)
          col_a.set_expand(True)


          Don't think you need single-paragraph-mode, never used that before.






          share|improve this answer
































            1















            Besides the answer provided by @RandomUser, you could also use a fixed size column. Example:



            col_a.set_fixed_width(150)


            Adding set_expand will provide a different action yet:



            col_a.set_expand(True)





            share|improve this answer





























              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55387959%2falways-visible-and-sticky-columns-in-gtk-treeview%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2















              There are atleast two changes needed:



              1. To keep the column a normal size with a long string, set the ellipsize property of the GtkCellRendererText. It should be a PangoEllipsizeMode.


              2. To make the two right colums stick to the end, expand the first column to take all remaining space by setting the expand property to True.


              Your column creation with these changes:



              col_a = Gtk.TreeViewColumn('str',
              Gtk.CellRendererText(single_paragraph_mode=True,
              ellipsize=Pango.EllipsizeMode.END),
              text=0)
              col_a.set_expand(True)


              Don't think you need single-paragraph-mode, never used that before.






              share|improve this answer





























                2















                There are atleast two changes needed:



                1. To keep the column a normal size with a long string, set the ellipsize property of the GtkCellRendererText. It should be a PangoEllipsizeMode.


                2. To make the two right colums stick to the end, expand the first column to take all remaining space by setting the expand property to True.


                Your column creation with these changes:



                col_a = Gtk.TreeViewColumn('str',
                Gtk.CellRendererText(single_paragraph_mode=True,
                ellipsize=Pango.EllipsizeMode.END),
                text=0)
                col_a.set_expand(True)


                Don't think you need single-paragraph-mode, never used that before.






                share|improve this answer



























                  2














                  2










                  2









                  There are atleast two changes needed:



                  1. To keep the column a normal size with a long string, set the ellipsize property of the GtkCellRendererText. It should be a PangoEllipsizeMode.


                  2. To make the two right colums stick to the end, expand the first column to take all remaining space by setting the expand property to True.


                  Your column creation with these changes:



                  col_a = Gtk.TreeViewColumn('str',
                  Gtk.CellRendererText(single_paragraph_mode=True,
                  ellipsize=Pango.EllipsizeMode.END),
                  text=0)
                  col_a.set_expand(True)


                  Don't think you need single-paragraph-mode, never used that before.






                  share|improve this answer













                  There are atleast two changes needed:



                  1. To keep the column a normal size with a long string, set the ellipsize property of the GtkCellRendererText. It should be a PangoEllipsizeMode.


                  2. To make the two right colums stick to the end, expand the first column to take all remaining space by setting the expand property to True.


                  Your column creation with these changes:



                  col_a = Gtk.TreeViewColumn('str',
                  Gtk.CellRendererText(single_paragraph_mode=True,
                  ellipsize=Pango.EllipsizeMode.END),
                  text=0)
                  col_a.set_expand(True)


                  Don't think you need single-paragraph-mode, never used that before.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 28 at 11:27









                  RandomUserRandomUser

                  1184 bronze badges




                  1184 bronze badges


























                      1















                      Besides the answer provided by @RandomUser, you could also use a fixed size column. Example:



                      col_a.set_fixed_width(150)


                      Adding set_expand will provide a different action yet:



                      col_a.set_expand(True)





                      share|improve this answer































                        1















                        Besides the answer provided by @RandomUser, you could also use a fixed size column. Example:



                        col_a.set_fixed_width(150)


                        Adding set_expand will provide a different action yet:



                        col_a.set_expand(True)





                        share|improve this answer





























                          1














                          1










                          1









                          Besides the answer provided by @RandomUser, you could also use a fixed size column. Example:



                          col_a.set_fixed_width(150)


                          Adding set_expand will provide a different action yet:



                          col_a.set_expand(True)





                          share|improve this answer















                          Besides the answer provided by @RandomUser, you could also use a fixed size column. Example:



                          col_a.set_fixed_width(150)


                          Adding set_expand will provide a different action yet:



                          col_a.set_expand(True)






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Mar 28 at 12:04

























                          answered Mar 28 at 11:58









                          theGtknerdtheGtknerd

                          2,4961 gold badge9 silver badges25 bronze badges




                          2,4961 gold badge9 silver badges25 bronze badges






























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55387959%2falways-visible-and-sticky-columns-in-gtk-treeview%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                              Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                              Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript