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;
I have this Gtk.TreeView
with 3 columns embeded into a Gtk.Paned
.
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
But how it looks (but shouldn't)
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
add a comment |
I have this Gtk.TreeView
with 3 columns embeded into a Gtk.Paned
.
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
But how it looks (but shouldn't)
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
add a comment |
I have this Gtk.TreeView
with 3 columns embeded into a Gtk.Paned
.
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
But how it looks (but shouldn't)
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
I have this Gtk.TreeView
with 3 columns embeded into a Gtk.Paned
.
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
But how it looks (but shouldn't)
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
python python-3.x treeview gtk pygobject
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
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
There are atleast two changes needed:
To keep the column a normal size with a long string, set the
ellipsize
property of theGtkCellRendererText
. It should be aPangoEllipsizeMode
.To make the two right colums stick to the end, expand the first column to take all remaining space by setting the
expand
property toTrue
.
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.
add a comment |
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)
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
There are atleast two changes needed:
To keep the column a normal size with a long string, set the
ellipsize
property of theGtkCellRendererText
. It should be aPangoEllipsizeMode
.To make the two right colums stick to the end, expand the first column to take all remaining space by setting the
expand
property toTrue
.
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.
add a comment |
There are atleast two changes needed:
To keep the column a normal size with a long string, set the
ellipsize
property of theGtkCellRendererText
. It should be aPangoEllipsizeMode
.To make the two right colums stick to the end, expand the first column to take all remaining space by setting the
expand
property toTrue
.
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.
add a comment |
There are atleast two changes needed:
To keep the column a normal size with a long string, set the
ellipsize
property of theGtkCellRendererText
. It should be aPangoEllipsizeMode
.To make the two right colums stick to the end, expand the first column to take all remaining space by setting the
expand
property toTrue
.
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.
There are atleast two changes needed:
To keep the column a normal size with a long string, set the
ellipsize
property of theGtkCellRendererText
. It should be aPangoEllipsizeMode
.To make the two right colums stick to the end, expand the first column to take all remaining space by setting the
expand
property toTrue
.
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.
answered Mar 28 at 11:27
RandomUserRandomUser
1184 bronze badges
1184 bronze badges
add a comment |
add a comment |
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)
add a comment |
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)
add a comment |
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)
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)
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
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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