Re: TypeError in GtkWindow
On 10/09/2015 09:25 AM, Felipe Borges wrote: As mentioned by Stefan, Coor2MASS was expecting a GtkWindow (the parent window), and you are passing a TitleBar object. Try something like this: diff --git a/q2MASS.py b/q2MASS.py index 43af88c..6b6a6d7 100644 --- a/q2MASS.py +++ b/q2MASS.py @@ -37,7 +37,7 @@ class Query2MASS(Gtk.Window): self.set_border_width(10) # add headerbar -tb = TitleBar() + tb = TitleBar(self) titlebar = tb.headerbar() self.set_titlebar(titlebar) @@ -62,7 +62,9 @@ class Query2MASS(Gtk.Window): class TitleBar: """Create the header bar""" -def __init__(self): +def __init__(self, parent): +self.parent = parent + """Initialize the class""" # create left and right headers self.left_header = Gtk.Grid() @@ -131,7 +133,7 @@ class TitleBar: def on_button_coor_clicked(self, widget): """Close popover and show Coordinates options""" self.popover_opts.hide() -coor = Coor2MASS(self) + coor = Coor2MASS(self.parent) resp = coor.run() if resp == Gtk.ResponseType.OK: print("Clicked OK!") Hi Felipe, That really worked! Thank you for your time! All the best, Germán. -- Germán A. Racca Fedora Package Maintainer https://fedoraproject.org/wiki/User:Skytux ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: TypeError in GtkWindow
On 10/09/2015 08:21 AM, Stefan Salewski wrote: On Thu, 2015-10-08 at 22:05 -0300, Germán Racca wrote: About "coor.run()", I have followed the exact steps in the official PyGObject tutorial: https://python-gtk-3-tutorial.readthedocs.org/en/latest/dialogs.html#c ustom-dialogs Good to know :-) Well, I do not know much about Python. But the difference seems to be obviously. You have class TitleBar: and call coor = Coor2MASS(self) So for you self is not a widget at all, but it should, it is used as parent widget! In the Python tutorial we have class DialogWindow(Gtk.Window): Here self is a Gtk.Window. Can not say you exactly how to solve your problems, but you should get the idea. Or maybe ask in a Python list/forum when Python itself is the problem. Thanks for your advises! As you can see, I'm not so good when it comes to OOP... All the best, Germán. -- Germán A. Racca Fedora Package Maintainer https://fedoraproject.org/wiki/User:Skytux ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
TypeError in GtkWindow
Hello guys, This is my first time posting in this list. My name is Germán, I'm from Argentina (currently living in Brazil) and I'm Astronomer. I use Fedora 22 with Gnome. I did some work with Python and Gtk+ before, but had to learn mostly everything again. I'm programming an interface to retrieve data from an online astronomical catalog, and I'm programming the main window. I have created a HeaderBar, put a Button and associated a PopOver to that button. The popover contains others buttons, something like this (see TitleBar class, https://gist.github.com/gracca/41a9cf28fa942d924e84#file-q2mass-py). The other file contains the GtkDialog that will open when clicking the button in the popover (see here, https://gist.github.com/gracca/41a9cf28fa942d924e84#file-opts-py). The problem is that I got the following error when I click that button: In [1] run q2MASS.py --- TypeError Traceback (most recent call last) /home/german/Documents/Python/myprogs/q2MASS/q2MASS.py in on_button_coor_clicked(self, widget) 132 """Close popover and show Coordinates options""" 133 self.popover_opts.hide() --> 134 coor = Coor2MASS(self) 135 resp = coor.run() 136 if resp == Gtk.ResponseType.OK: /home/german/Documents/Python/myprogs/q2MASS/opts.py in __init__(self, parent) 22 Gtk.Dialog.__init__(self, "Select columns to retrieve:", parent, 0, 23 (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, ---> 24 Gtk.STOCK_OK, Gtk.ResponseType.OK)) 25 self.set_modal(True) 26 #self.set_decorated(False) /usr/lib64/python2.7/site-packages/gi/overrides/Gtk.pyc in __init__(self, *args, **kwargs) 535 new_kwargs['destroy_with_parent'] = True 536 --> 537 self._init(*args, **new_kwargs) 538 539 if add_buttons: /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyc in new_init(self, *args, **kwargs) 311 new_kwargs.pop(key) 312 --> 313 return super_init_func(self, **new_kwargs) 314 315 return new_init /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyc in new_init(self, *args, **kwargs) 311 new_kwargs.pop(key) 312 --> 313 return super_init_func(self, **new_kwargs) 314 315 return new_init TypeError: could not convert value for property `transient_for' from instance to GtkWindow Any help is appreciated, thanks!! Germán. -- Germán A. Racca Fedora Package Maintainer https://fedoraproject.org/wiki/User:Skytux ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: TypeError in GtkWindow
On 10/08/2015 06:45 PM, Stefan Salewski wrote: On Thu, 2015-10-08 at 17:09 -0300, Germán Racca wrote: --> 134 coor = Coor2MASS(self) I do not use Python, but that line seems to make no sense. Self is class TitleBar: but later you call resp = coor.run(). So I guess for coor you want something like a dialog, so you have to create it. Thanks for your comment Stefan. I removed "self", and I get this: Traceback (most recent call last): File "./q2MASS.py", line 134, in on_button_coor_clicked coor = Coor2MASS() TypeError: __init__() takes exactly 2 arguments (1 given) About "coor.run()", I have followed the exact steps in the official PyGObject tutorial: https://python-gtk-3-tutorial.readthedocs.org/en/latest/dialogs.html#custom-dialogs Regards, Germán. -- Germán A. Racca Fedora Package Maintainer https://fedoraproject.org/wiki/User:Skytux ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list