aboutsummaryrefslogtreecommitdiff
path: root/lidt-sample-database/__init__.py
blob: 63ac8451da76bc29b00831d35567431c9f5a5229 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# 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 <http://www.gnu.org/licenses/>.

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()