Skip to content

Conversation

@WhiteSymmetry
Copy link

@WhiteSymmetry WhiteSymmetry commented Nov 17, 2025

Requirements.txt for Ubuntu 25.10.

mesa-utils for "import gi"

fixing warnings and deprecated calls:

test.py:24: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
from gi.repository import Gtk
test.py:47: DeprecationWarning: Gtk.ScrolledWindow.add_with_viewport is deprecated
sw.add_with_viewport(canvas)

Primary Change: Version Specification

  • Old Code: Imported Gtk directly without specifying which version to use. This triggered a warning because the binding is not future-proof.
  • New Code: Explicitly specifies gi.require_version('Gtk', '3.0') before the import. This ensures the correct API version is loaded and eliminates the warning.

Structural & Maintenance Improvements

  • Old Code: Used a simple procedural script. The UI was built directly in the global scope.
  • New Code: Encapsulates the application logic within a MatplotlibGTKWindow class. This is a better practice for organization, reusability, and managing the state of the application.

UI/UX Refinements

  • Old Code: Used the deprecated add_with_viewport method to add the widget to the Gtk.ScrolledWindow.
  • New Code: Uses the modern and correct add method for Gtk.ScrolledWindow.
  • New Code: Explicitly sets the scrollbar policy to Gtk.PolicyType.AUTOMATIC, making the scrollbars appear only when needed.
  • New Code: Enhances the plot with labels, a title, a grid, and a specific line style for better readability and a more complete example.

In summary, the update focuses on correctness (fixing warnings and deprecated calls), modern structure (using a class), and improved user experience (better plot and scrollbar behavior).

Screenshot From 2025-11-17 15-05-32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant