2
使用Python GTK + 3的Im我不能將數據添加到按鈕信號中的GtkGrid(當我調用信號中的attach方法時,什麼都沒有發生)。代碼如下: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()