Reputation: 1306
Using Python and Gtk3, I have created a Gtk.TreeView
and put it inside a Gtk.ScrolledWindow
. I don't like horizontal scroll bars, so I removed it using the Gtk.PolicyType.NEVER
, but now I can't resize the window in that direction.
So the question is: how can I get ride of the horizontal scroll bar and at the same time to be able to resize the window horizontally?
Any help is appreciated!
Obs: this is how I created the ScrolledWindow:
self.scrolledwindow = Gtk.ScrolledWindow()
self.scrolledwindow.set_policy(Gtk.PolicyType.NEVER,
Gtk.PolicyType.AUTOMATIC)
self.add(self.scrolledwindow)
Upvotes: 3
Views: 4506
Reputation: 1306
SOLUTION:
The problem was that the window couldn't be more narrow than the wider row in the Gtk.TreeView
, and I also wanted my window without horizontal scroll bars. The final code that solves my problem is this:
self.scrolledwindow = Gtk.ScrolledWindow()
self.scrolledwindow.set_policy(Gtk.PolicyType.NEVER,
Gtk.PolicyType.AUTOMATIC)
...
renderer_text = Gtk.CellRendererText(weight=600)
renderer_text.set_fixed_size(200, -1)
column_text = Gtk.TreeViewColumn('Name', renderer_text, text=1)
In that way, the Gtk.CellRendererText
has a minimum size and can be re-sized once the window is opened.
Upvotes: 4