Reputation: 423
the code of my program becomes heavier and I would like to separate it into many files.
I found a single tutorial whose code here is:
#!/usr/bin/env python3
# coding: utf-8
#Box.py
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GdkPixbuf
from BoxBoutton import BoxBoutton
class MainWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self)
box = Gtk.Box()
sublayout = BoxBoutton()
box.pack_start(sublayout, True, True, 0)
self.add(box)
win = MainWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
The second:
#!/usr/bin/env python3
# coding: utf-8
#BoxBoutton.py
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class BoxBoutton(Gtk.Grid):
def __init__(self):
Gtk.Grid.__init__(self)
btn = Gtk.Button(label="Mon super bouton")
self.attach(0, 0, 1, 1)
but I have this error:
TypeError: Gtk.Grid.attach() takes exactly 6 arguments (5 given)
Thank you very much for your help
Upvotes: 0
Views: 78
Reputation: 26
You forgot the child in the attach
method of Gtk.Grid.
attach(child, left, top, width, height)
try the following:
self.attach(btn, 0, 0, 1, 1)
Upvotes: 1