Verified Commit fe03fd9f authored by tallero's avatar tallero

References expansion stub

parent a9606185
......@@ -69,5 +69,33 @@
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="references_grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">True</property>
<property name="column_homogeneous">True</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">2</property>
</packing>
</child>
</template>
</interface>
......@@ -28,7 +28,7 @@ from gi import require_version
require_version('Gtk', '3.0')
require_version('Gdk', '3.0')
from gi.repository.GLib import idle_add #, PRIORITY_LOW
from gi.repository.Gtk import STYLE_PROVIDER_PRIORITY_APPLICATION, CssProvider, IconSize, StyleContext, Grid, Template
from gi.repository.Gtk import STYLE_PROVIDER_PRIORITY_APPLICATION, CssProvider, IconSize, Separator, StyleContext, Grid, Template
from .entity import Entity
from .qualifierproperty import QualifierProperty
......@@ -43,12 +43,14 @@ class Value(Grid):
icon = Template.Child("icon")
qualifiers = Template.Child("qualifiers")
mainsnak = Template.Child("mainsnak")
references_grid = Template.Child("references_grid")
def __init__(self, claim, *args, load=None, **kwargs):
Grid.__init__(self, *args, **kwargs)
self.load = load
self.extra = 0
self.references_expanded = False
context = self.get_style_context()
......@@ -72,8 +74,30 @@ class Value(Grid):
del claim
def references_expand_clicked_cb(self, widget):
for i,P in enumerate(self.references):
print(P.keys())
if not self.references_expanded:
for i, ref in enumerate(self.references):
for P in ref['snaks-order']:
values = ref['snaks']
#for j, value in enumerate(values):
download_light(P, self.load_reference, i, values)
self.references_expanded = True
# print(P.keys())
def load_reference(self, URI, property, error, i, values):
try:
i = i*2
property = QualifierProperty(property)
self.references_grid.attach(Separator(), 0, i, 1, 5)
self.references_grid.attach(property, 0, i+1, 1, 1)
self.references_grid.show_all()
#self.qualifiers.attach(qualifier, 0, i+self.extra, 1, 1)
#for j, claim in enumerate(claims):
# self.load_value_async(URI, claim, i+self.extra+j)
#self.extra += len(claims) - 1
#return None
except Exception as e:
print(URI)
raise e
def load_qualifiers(self, URI, qualifier, error, i, claims):
try:
......
......@@ -594,45 +594,43 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 29,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'hash': 'b1c1ada0ce9e910249001fded34b1774150a4005',\n",
" 'snaks': {'P577': [{'datatype': 'time',\n",
" 'datavalue': {'type': 'time',\n",
" 'value': {'after': 0,\n",
" 'before': 0,\n",
" 'calendarmodel': 'http://www.wikidata.org/entity/Q1985727',\n",
" 'precision': 9,\n",
" 'time': '+00000002011-00-00T00:00:00Z',\n",
" 'timezone': 0}},\n",
" 'property': 'P577',\n",
" 'snaktype': 'value'}],\n",
" 'P813': [{'datatype': 'time',\n",
" 'datavalue': {'type': 'time',\n",
" 'value': {'after': 0,\n",
" 'before': 0,\n",
" 'calendarmodel': 'http://www.wikidata.org/entity/Q1985727',\n",
" 'precision': 11,\n",
" 'time': '+00000002017-01-08T00:00:00Z',\n",
" 'timezone': 0}},\n",
" 'property': 'P813',\n",
" 'snaktype': 'value'}],\n",
" 'P854': [{'datatype': 'url',\n",
" 'datavalue': {'type': 'string',\n",
" 'value': 'http://abstractsearch.agu.org/meetings/2011/FM/OS13B-1517.html'},\n",
" 'property': 'P854',\n",
" 'snaktype': 'value'}]},\n",
" 'snaks-order': ['P854', 'P813', 'P577']}\n"
"{'P577': [{'datatype': 'time',\n",
" 'datavalue': {'type': 'time',\n",
" 'value': {'after': 0,\n",
" 'before': 0,\n",
" 'calendarmodel': 'http://www.wikidata.org/entity/Q1985727',\n",
" 'precision': 9,\n",
" 'time': '+00000002011-00-00T00:00:00Z',\n",
" 'timezone': 0}},\n",
" 'property': 'P577',\n",
" 'snaktype': 'value'}],\n",
" 'P813': [{'datatype': 'time',\n",
" 'datavalue': {'type': 'time',\n",
" 'value': {'after': 0,\n",
" 'before': 0,\n",
" 'calendarmodel': 'http://www.wikidata.org/entity/Q1985727',\n",
" 'precision': 11,\n",
" 'time': '+00000002017-01-08T00:00:00Z',\n",
" 'timezone': 0}},\n",
" 'property': 'P813',\n",
" 'snaktype': 'value'}],\n",
" 'P854': [{'datatype': 'url',\n",
" 'datavalue': {'type': 'string',\n",
" 'value': 'http://abstractsearch.agu.org/meetings/2011/FM/OS13B-1517.html'},\n",
" 'property': 'P854',\n",
" 'snaktype': 'value'}]}\n"
]
}
],
"source": [
"pprint(references[0])\n",
"pprint(references[0]['snaks'])\n",
"#properties = set(snak['property'] for snak in mainsnaks)\n",
"#print(\"Campione:\", len(properties))\n",
"#print(\"Values: [P1,...]\")"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment