I am using glade to generate the GTK application layout and using the python application for event handling. I have added a ScrolledWindow Component:
<child>
<object class="GtkScrolledWindow" id="GraphWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
Now I trying to draw a chart using matplotlib in the above-given window.
class WeatherForecastApplicationBuilder(Gtk.Builder):
def __init__(self, *args, **kwargs):
Gtk.Builder.__init__(self, *args, **kwargs)
self.add_from_file("layout.glade")
self.window = self.get_object("WeatherForecastWindow")
self.graph_window = self.get_object("GraphWindow")
self._get_widgets_()
self.connect_signals(self)
self.window.show_all()
Gtk.main()
def _draw_chart_(self):
figure = Figure()
subplot = figure.add_subplot(111)
subplot.plot(
[1, 2, 3],
[4, 5, 6],
)
subplot.set(xlabel='Date', ylabel='Temp', title='Temprature Change')
canvas = FigureCanvas(figure)
self.graph_window.add(canvas)
self.window.show_all()
The issue is that the height of ScrolledWindow is fixed and not expanding. I want it to cover the whole window. The scrolled window is rendering like this:
How to expand the height of the ScrolledWindow Component so that the blank space at the bottom is covered.
Link to the complete glade layout file.
I fixed this issue by setting the following property to true
in the ScrolledWindow object in layout.glade
file.
<property name="vexpand">True</property>