-
Notifications
You must be signed in to change notification settings - Fork 0
/
dm_admin_side.html
125 lines (110 loc) · 5.72 KB
/
dm_admin_side.html
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!DOCTYPE html>
<html>
<head>
<title>skarphed - Documentation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="static/logo_32.png" rel="icon" type="image/png">
<link href="static/mainsite.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="body_overlay" >
<header>
<div id="headercontent">
<a class="bclink" href="http://skarphed.org">
<img src="static/logo_32.png" alt="skarphed" style="float:left; margin-right: 10px;"></a>
<a class="bclink" href="index.html">Documentation
</a>
<a class="bclink" href="dev_man.html">
→ Developers Manual
</a>
<a class="bclink" href="dm_modules.html">
→ Admin Side Development
</a>
</div>
</header>
<div id="space_content">
<span class="headerlink_nohover"><h2> Admin Side Development </h2></span>
<p>
In order to manage the settings of your module and represent the
data to an adminstrator or content-editor, you want to write a GUI for the
module. The GUI is a gtk-script that is being loaded seemlessly into
<i>skarphed-admin</i>.
</p>
<h3> Creating a GUI with Glade </h3>
<p>
In this documentation i will not discuss, how to create GUIs in Glade
but how to integrate them into the module along some things special about
using Glade in skarphed.<br>
When designing the GUI, don't start with a toplevel-widget. Start with a
container instead (like <code>gtk.VBox</code>, <code>gtk.HBox</code> or
<code>gtk.Table</code>). You will need to build two GUIs. One for the
context of the whole module and one for the context of the widget.
Name them widget.ui and module.ui accordingly.
</p>
<h3> Building python-frames for the gladefiles </h3>
<p>
You will then need to write the frames in python for the GUIs. The frame itself
will look like this:
</p>
<code><pre>
import pygtk
pygtk.require("2.0")
import gtk
import os
class ModulePage(gtk.VBox):
def __init__(self, parent, module):
self.par = parent
gtk.VBox.__init__(self)
self.moduleId = module.getLocalId()
path = os.path.realpath(__file__)
path = path.replace("module.pyc","")
self._path = path.replace("module.py","")
self.builder = gtk.Builder()
self.builder.add_from_file(self._path+"module.glade")
self.content = self.builder.get_object("module")
self.add(self.content)
def render(self):
pass
def getPar(self):
return self.par
def getApplication(self):
return self.par.getApplication()
</pre></code>
<p>
This just loads the module gui and displays it. Of course, if you want to
create a little more interactive interface you will have to code more logic.
</p>
<h3> Communication with the core </h3>
<p>
At one point you will have to communicate with the code on the core-side
in order to read and write data. Skarphed gives you a convenient decorator
to do that. In your <i>skarphed-admin</i>-side code you can import it with
<code> from data.skarphed.Skarphed import module_rpc </code>. If you have
a method foobar() at the core side which looks like this:
</p>
<code><pre>
def foobar(self, widget_id, a, b):
return a+b
</pre></code>
<p>
Then you can call it in your <i>skarphed-admin</i>-side code by:
</p>
<code><pre>
def foobarCallback(self, result):
print result
@module_rpc(foobarCallback)
def foobar(self, a, b):
pass
foobar(3,2)
</pre></code>
<p>
You can call foobar as it was a local method in the module object.
Note that any code in the method's body will not be executed.
</p>
</div>
<footer id="space_footer"></p><a href="../imprint.html">Imprint / Impressum</a></p>
<a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.
</footer>
</div>
</body>
</html>