aboutsummaryrefslogtreecommitdiff
path: root/lidt-sample-database
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-10-04 23:48:37 +0200
committerKarel Kočí <cynerd@email.cz>2018-01-26 17:24:26 +0100
commitc4466a07c446e177dc3104f82e44569f30f04d8a (patch)
tree8fae3197fcebcb21347960d6308ff7b0c759969c /lidt-sample-database
downloadlidt-sample-database-c4466a07c446e177dc3104f82e44569f30f04d8a.tar.gz
lidt-sample-database-c4466a07c446e177dc3104f82e44569f30f04d8a.tar.bz2
lidt-sample-database-c4466a07c446e177dc3104f82e44569f30f04d8a.zip
Initial commitHEADmaster
Diffstat (limited to 'lidt-sample-database')
-rw-r--r--lidt-sample-database/__init__.py75
-rw-r--r--lidt-sample-database/__main__.py18
-rw-r--r--lidt-sample-database/database.py31
-rw-r--r--lidt-sample-database/primary.glade257
4 files changed, 381 insertions, 0 deletions
diff --git a/lidt-sample-database/__init__.py b/lidt-sample-database/__init__.py
new file mode 100644
index 0000000..63ac845
--- /dev/null
+++ b/lidt-sample-database/__init__.py
@@ -0,0 +1,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()
diff --git a/lidt-sample-database/__main__.py b/lidt-sample-database/__main__.py
new file mode 100644
index 0000000..d6cde67
--- /dev/null
+++ b/lidt-sample-database/__main__.py
@@ -0,0 +1,18 @@
+# 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/>.
+
+from . import main
+
+main()
diff --git a/lidt-sample-database/database.py b/lidt-sample-database/database.py
new file mode 100644
index 0000000..9472883
--- /dev/null
+++ b/lidt-sample-database/database.py
@@ -0,0 +1,31 @@
+# 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/>.
+
+from gi.repository import GObject
+
+
+class DataLine(GObject.GObject):
+ "Single line of data"
+ uniq_id = GObject.property(type=int)
+ name = GObject.property(type=str)
+ date = GObject.property(type=str) # TODO change type
+ used_time = GObject.property(type=str) # TODO change type
+
+ def __init__(self, uniq_id, name, date, used_time):
+ GObject.GObject.__init__(self)
+ self.uniq_id = uniq_id
+ self.name = name
+ self.date = date
+ self.used_time = used_time
diff --git a/lidt-sample-database/primary.glade b/lidt-sample-database/primary.glade
new file mode 100644
index 0000000..491379a
--- /dev/null
+++ b/lidt-sample-database/primary.glade
@@ -0,0 +1,257 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.0 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkListStore" id="data_model">
+ <columns>
+ <!-- column-name Name -->
+ <column type="gchararray"/>
+ <!-- column-name Date -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0">Test1</col>
+ <col id="1" translatable="yes">1.11.</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Test2</col>
+ <col id="1" translatable="yes">2.11.</col>
+ </row>
+ </data>
+ </object>
+ <object class="GtkWindow" id="window">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">LIDT sample database</property>
+ <signal name="delete-event" handler="onDeleteWindow" swapped="no"/>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkMenuBar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuItem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Database</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkImageMenuItem">
+ <property name="label">gtk-new</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem">
+ <property name="label">gtk-open</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem">
+ <property name="label">gtk-save</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparatorMenuItem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem">
+ <property name="label">gtk-quit</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_View</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Help</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkImageMenuItem">
+ <property name="label">gtk-about</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkButton">
+ <property name="label" translatable="yes">+</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSearchEntry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="primary_icon_name">edit-find-symbolic</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">data_model</property>
+ <property name="search_column">0</property>
+ <property name="enable_grid_lines">both</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes">Name</property>
+ <property name="expand">True</property>
+ <property name="clickable">True</property>
+ <property name="sort_indicator">True</property>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes">Date</property>
+ <property name="clickable">True</property>
+ <property name="reorderable">True</property>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkStatusbar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">10</property>
+ <property name="margin_right">10</property>
+ <property name="margin_start">10</property>
+ <property name="margin_end">10</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>