# Copyright (C) 2017 Karel Kočí # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import os import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk, Gio, GObject from . import database class Handler: def __init__(self): pass def onDeleteWindow(self, *args): Gtk.main_quit(*args) def create_widget_func(item): "" box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6) label = Gtk.Label(item.name) box.pack_start(label, True, True, 5) date = Gtk.Label(item.date) box.pack_start(date, False, False, 5) used_time = Gtk.Label(item.used_time) box.pack_start(used_time, False, False, 5) return box def main(): main_frame = os.path.join(os.path.dirname(__file__), "primary.glade") global builder builder = Gtk.Builder() builder.add_from_file(main_frame) builder.connect_signals(Handler()) global window window = builder.get_object("window") item1 = database.DataLine(1, "Hello", "1.1.1", "22s") item2 = database.DataLine(2, "World", "2.2.2", "23s") liststore = Gio.ListStore() liststore.append(item1) liststore.append(item2) #treeview = builder.get_object("database_view") #treeview.bind_model(liststore, create_widget_func) window.show_all() Gtk.main() if __name__ == "__main__": main()