2
Ich benutze Python GTK + 3. Ich kann Daten in GtkGrid in Button-Signal hinzufügen (nichts passiert, wenn ich attach-Methode in Signal aufrufen). Hier ist der Code:Dynamische Daten in GtkGrid
# -*- coding: utf-8 -*-
from gi.repository import Gtk, GObject, Gdk
import sqlite3
class MainWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="1")
self.fullscreen()
MainBox = Gtk.Box()
MainBox.set_orientation(Gtk.Orientation.VERTICAL)
self.add(MainBox)
self.table = Gtk.Grid()
self.table.set_column_spacing(10)
MainBox.pack_start(self.table, False, True, 0)
btn_add = Gtk.Button("ADD VALS")
btn_add.connect("clicked", self.add_kopd)
MainBox.pack_start(btn_add, False, True, 0)
self.table.attach(Gtk.Label("1"), 0,0,1,1)
self.table.attach(Gtk.Label("2"), 1,0,1,1)
self.table.attach(Gtk.Label("3"), 2,0,1,1)
def add_kopd(self, widget):
self.table.attach(Gtk.Label("4"), 0,1,1,1)
self.table.attach(Gtk.Label("5"), 1,1,1,1)
self.table.attach(Gtk.Label("6"), 2,1,1,1)
win = MainWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()