Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation warnings #156

Closed
wants to merge 1 commit into from
Closed

Fix deprecation warnings #156

wants to merge 1 commit into from

Conversation

cas--
Copy link
Contributor

@cas-- cas-- commented Jun 4, 2019

Fixes the PyGTKDeprecationWarning outputs in terminal, mostly related
to positional arguments.

Added a make test command to quickly check that examples run and view
output in terminal for deprecated warnings.

Fixes: #150, #78

Copy link
Owner

@sebp sebp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your work. The changes look mostly good, I just marked a couple of issues.


self.set_default_size(150, 100)

label = Gtk.Label("This is a dialog to display additional information")
label = Gtk.Label.new("This is a dialog to display additional information")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer Gtk.Label(label="…") here.

label = Gtk.Label("This is a normal label")

label = Gtk.Label.new("This is a normal label")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Gtk.Label(label="…").

label = Gtk.Label(

label = Gtk.Label.new(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Gtk.Label(label="…").

label = Gtk.Label("This is an example of a line-wrapped label. It "

label = Gtk.Label.new("This is an example of a line-wrapped label. It "
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Gtk.Label(label="…").

box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
Gtk.StyleContext.add_class(box.get_style_context(), "linked")

button = Gtk.Button()
button.add(Gtk.Arrow(Gtk.ArrowType.LEFT, Gtk.ShadowType.NONE))
button = Gtk.Button.new_from_icon_name("pan-start-symbolic", Gtk.IconSize.MENU)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"pan-start-symbolic" is a different symbol from Gtk.ArrowType.LEFT

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know but this was the suggested replacement in my searching

@@ -13,12 +13,12 @@ def __init__(self):

self.page1 = Gtk.Box()
self.page1.set_border_width(10)
self.page1.add(Gtk.Label('Default Page!'))
self.notebook.append_page(self.page1, Gtk.Label('Plain Title'))
self.page1.add(Gtk.Label.new("Default Page!"))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use keyword arguments instead of .new.


self.page2 = Gtk.Box()
self.page2.set_border_width(10)
self.page2.add(Gtk.Label('A page with an image for a Title.'))
self.page2.add(Gtk.Label.new("A page with an image for a Title."))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use keyword arguments instead of .new.

vbox.pack_start(Gtk.ModelButton("Item 1"), False, True, 10)
vbox.pack_start(Gtk.Label("Item 2"), False, True, 10)
vbox.pack_start(Gtk.ModelButton(label="Item 1"), False, True, 10)
vbox.pack_start(Gtk.Label.new("Item 2"), False, True, 10)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use keyword arguments instead of .new.


box = self.get_content_area()

label = Gtk.Label("Insert text you want to search for:")
label = Gtk.Label.new("Insert text you want to search for:")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use keyword arguments instead of .new.

Makefile Outdated Show resolved Hide resolved
@cas--
Copy link
Contributor Author

cas-- commented Jun 19, 2019

My reasoning for using new method is that it follows the GTK3 documentation as suggested in InitializerDeprecations

With GtkLabel it seems better to use new method rather than adding 'duplicate' attribute, plus it's two characters shorter ;)

Gtk.Label.new("Item 2")
Gtk.Label(label="Item 2")

Also it ties in with the associated method new_with_mnemonic:

Gtk.Label.new_with_mnemonic("_Item 2")

Another reason to avoid using the default class constructor with attributes is that Gtk deprecation warnings will be missed: #156 (comment)

Fixes the PyGTKDeprecationWarning outputs in terminal, mostly related
to positional arguments.

Added a `make test` command to quickly check that examples run and view
output in terminal for deprecated warnings.

Fixes: sebp#150
@cas-- cas-- force-pushed the fix-deprecation branch from dba418b to a598ead Compare June 19, 2019 11:32
@cas-- cas-- closed this Apr 19, 2022
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.

Update examples to fix initializer deprecation warnings
2 participants