Fixes a few bugs and adds a rudimentary GUI with edje
git-svn-id: http://www.neo1973-germany.de/svn@165 46df4e5c-bc4e-4628-a0fc-830ba316316d
This commit is contained in:
parent
9b28aae05a
commit
e2ba31e402
7 changed files with 340 additions and 4 deletions
|
@ -64,6 +64,7 @@ class TrackClient:
|
||||||
self.course_iface = Interface(self.ogpsd_proxy, 'org.freedesktop.Gypsy.Course')
|
self.course_iface = Interface(self.ogpsd_proxy, 'org.freedesktop.Gypsy.Course')
|
||||||
self.pos_iface = Interface(self.ogpsd_proxy, 'org.freedesktop.Gypsy.Position')
|
self.pos_iface = Interface(self.ogpsd_proxy, 'org.freedesktop.Gypsy.Position')
|
||||||
|
|
||||||
|
self.terminator=""
|
||||||
|
|
||||||
def UpdateData(self, fields, timestamp, lat, lon, alt):
|
def UpdateData(self, fields, timestamp, lat, lon, alt):
|
||||||
# get UTC time from gypsy timestamp
|
# get UTC time from gypsy timestamp
|
||||||
|
@ -94,14 +95,15 @@ class TrackClient:
|
||||||
|
|
||||||
def StartTrack(self):
|
def StartTrack(self):
|
||||||
self.SendData(self.__username, self.__pwhash, action="START")
|
self.SendData(self.__username, self.__pwhash, action="START")
|
||||||
|
|
||||||
# call self.UpdatePosition() when a dbus signal "PositionChanged" comes along the system bus
|
# call self.UpdatePosition() when a dbus signal "PositionChanged" comes along the system bus
|
||||||
|
if self.terminator:
|
||||||
|
self.terminator.delete()
|
||||||
self.terminator = self.pos_iface.connect_to_signal("PositionChanged", self.UpdateData)
|
self.terminator = self.pos_iface.connect_to_signal("PositionChanged", self.UpdateData)
|
||||||
|
|
||||||
|
|
||||||
def StopTrack(self):
|
def StopTrack(self):
|
||||||
self.SendData(self.__username, self.__pwhash, action="STOP")
|
self.SendData(self.__username, self.__pwhash, action="STOP")
|
||||||
|
|
||||||
# remove connect_to_signal event
|
# remove connect_to_signal event
|
||||||
self.terminator.remove()
|
self.terminator.remove()
|
||||||
self.usage_iface.ReleaseResource("GPS")
|
|
||||||
|
# self.usage_iface.ReleaseResource("GPS")
|
||||||
|
|
106
PyTracker/trunk/clientscriptGUI.py
Normal file
106
PyTracker/trunk/clientscriptGUI.py
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
from PyTrackerClient import *
|
||||||
|
import ecore
|
||||||
|
import ecore.evas
|
||||||
|
import edje
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
test=TrackClient('edistar','refeco3','80.61.221.9')
|
||||||
|
|
||||||
|
|
||||||
|
# Parse command line
|
||||||
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
def parse_geometry(option, opt, value, parser):
|
||||||
|
try:
|
||||||
|
w, h = value.split("x")
|
||||||
|
w = int(w)
|
||||||
|
h = int(h)
|
||||||
|
except Exception, e:
|
||||||
|
raise optparse.OptionValueError("Invalid format for %s" % option)
|
||||||
|
parser.values.geometry = (w, h)
|
||||||
|
|
||||||
|
usage = "usage: %prog [options]"
|
||||||
|
op = OptionParser(usage=usage)
|
||||||
|
op.add_option("-e", "--engine", type="choice",
|
||||||
|
choices=("x11", "x11-16"), default="x11-16",
|
||||||
|
help=("which display engine to use (x11, x11-16), "
|
||||||
|
"default=%default"))
|
||||||
|
op.add_option("-n", "--no-fullscreen", action="store_true",
|
||||||
|
help="do not launch in fullscreen")
|
||||||
|
op.add_option("-g", "--geometry", type="string", metavar="WxH",
|
||||||
|
action="callback", callback=parse_geometry,
|
||||||
|
default=(480, 640),
|
||||||
|
help="use given window geometry")
|
||||||
|
op.add_option("-f", "--fps", type="int", default=50,
|
||||||
|
help="frames per second to use, default=%default")
|
||||||
|
|
||||||
|
|
||||||
|
# Handle options and create output window
|
||||||
|
options, args = op.parse_args()
|
||||||
|
if options.engine == "x11":
|
||||||
|
f = ecore.evas.SoftwareX11
|
||||||
|
elif options.engine == "x11-16":
|
||||||
|
if ecore.evas.engine_type_supported_get("software_x11_16"):
|
||||||
|
f = ecore.evas.SoftwareX11_16
|
||||||
|
else:
|
||||||
|
print "warning: x11-16 is not supported, fallback to x11"
|
||||||
|
f = ecore.evas.SoftwareX11
|
||||||
|
|
||||||
|
w, h = options.geometry
|
||||||
|
ee = f(w=w, h=h)
|
||||||
|
ee.fullscreen = 0 # not options.no_fullscreen
|
||||||
|
edje.frametime_set(1.0 / options.fps)
|
||||||
|
|
||||||
|
|
||||||
|
# Load and setup UI
|
||||||
|
ee.title = "test"
|
||||||
|
ee.name_class = ("test", "test")
|
||||||
|
canvas = ee.evas
|
||||||
|
#edje_file = os.path.join(os.path.dirname(sys.argv[0]), "PyTracker.edj")
|
||||||
|
edje_file = 'data/PyTracker.edj'
|
||||||
|
try:
|
||||||
|
edje_obj = edje.Edje(canvas, file=edje_file, group="test")
|
||||||
|
except Exception, e: # should be EdjeLoadError, but it's wrong on python2.5
|
||||||
|
raise SystemExit("Failed to load Edje file: %s" % edje_file)
|
||||||
|
|
||||||
|
# resize edje to fit our window, show and remember it for later use
|
||||||
|
edje_obj.size = canvas.size
|
||||||
|
edje_obj.show()
|
||||||
|
ee.data["edje"] = edje_obj
|
||||||
|
|
||||||
|
|
||||||
|
# Setup callbacks for resize, keydown and selected item
|
||||||
|
def resize_cb(ee):
|
||||||
|
r = ee.evas.rect
|
||||||
|
ee.data["edje"].size = r.size
|
||||||
|
|
||||||
|
ee.callback_resize = resize_cb
|
||||||
|
|
||||||
|
|
||||||
|
def key_down_cb(bg, event, ee):
|
||||||
|
k = event.key
|
||||||
|
if k == "Escape":
|
||||||
|
ecore.main_loop_quit()
|
||||||
|
if k in ("F6", "f"):
|
||||||
|
ee.fullscreen = not ee.fullscreen
|
||||||
|
|
||||||
|
edje_obj.on_key_down_add(key_down_cb, ee)
|
||||||
|
|
||||||
|
|
||||||
|
def icon_selected(edje_obj, signal, source):
|
||||||
|
if signal == "StartSelected":
|
||||||
|
test.StartTrack()
|
||||||
|
elif signal == "StopSelected":
|
||||||
|
test.StopTrack()
|
||||||
|
|
||||||
|
edje_obj.signal_callback_add("StartSelected", "*", icon_selected)
|
||||||
|
edje_obj.signal_callback_add("StopSelected", "*", icon_selected)
|
||||||
|
|
||||||
|
# Give focus to object, show window and enter event loop
|
||||||
|
edje_obj.focus = True
|
||||||
|
ee.show()
|
||||||
|
|
||||||
|
#ecore.main_loop_begin()
|
||||||
|
ee.evas.image_cache_set( 6*1024*1024 )
|
||||||
|
ecore.main_loop_begin()
|
228
PyTracker/trunk/data/PyTracker.edc
Normal file
228
PyTracker/trunk/data/PyTracker.edc
Normal file
|
@ -0,0 +1,228 @@
|
||||||
|
// Sample EDC
|
||||||
|
images {
|
||||||
|
image, "background.jpg" LOSSY 95;
|
||||||
|
image, "start.png" COMP;
|
||||||
|
image, "stop.png" COMP;
|
||||||
|
}
|
||||||
|
|
||||||
|
collections {
|
||||||
|
group {
|
||||||
|
name, "test";
|
||||||
|
min, 480 640;
|
||||||
|
max, 1024 768;
|
||||||
|
|
||||||
|
parts {
|
||||||
|
part {
|
||||||
|
name, "background";
|
||||||
|
type, IMAGE;
|
||||||
|
mouse_events, 0;
|
||||||
|
|
||||||
|
description {
|
||||||
|
state, "default" 0.0;
|
||||||
|
|
||||||
|
rel1 {
|
||||||
|
relative, 0.0 0.0;
|
||||||
|
offset, 0 0;
|
||||||
|
}
|
||||||
|
rel2 {
|
||||||
|
relative, 1.0 1.0;
|
||||||
|
offset, -1 -1;
|
||||||
|
}
|
||||||
|
image {
|
||||||
|
normal, "background.jpg";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
part {
|
||||||
|
name, "button_start";
|
||||||
|
type, RECT;
|
||||||
|
mouse_events, 1;
|
||||||
|
|
||||||
|
description {
|
||||||
|
state, "default" 0.0;
|
||||||
|
min, 480 100;
|
||||||
|
max, 1028 150;
|
||||||
|
align, 0.5 0.0;
|
||||||
|
|
||||||
|
color, 211 168 234 200;
|
||||||
|
|
||||||
|
rel1 {
|
||||||
|
relative, 0.0 0.0;
|
||||||
|
offset, 0 0;
|
||||||
|
}
|
||||||
|
rel2 {
|
||||||
|
relative, 1.0 0.0;
|
||||||
|
offset, -1 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
description {
|
||||||
|
state, "clicked" 0.0;
|
||||||
|
min, 480 100;
|
||||||
|
max, 1028 100;
|
||||||
|
align, 0.5 0.0;
|
||||||
|
|
||||||
|
color, 170 89 214 200;
|
||||||
|
|
||||||
|
rel1 {
|
||||||
|
relative, 0.0 0.0;
|
||||||
|
offset, 2 3;
|
||||||
|
}
|
||||||
|
rel2 {
|
||||||
|
relative, 1.0 0.0;
|
||||||
|
offset, 1 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
part {
|
||||||
|
name, "button_stop";
|
||||||
|
type, RECT;
|
||||||
|
mouse_events, 1;
|
||||||
|
|
||||||
|
description {
|
||||||
|
state, "default" 0.0;
|
||||||
|
min, 480 100;
|
||||||
|
max, 1028 150;
|
||||||
|
align, 0.5 1.0;
|
||||||
|
|
||||||
|
color, 211 168 234 200;
|
||||||
|
|
||||||
|
rel1 {
|
||||||
|
relative, 0.0 1.0;
|
||||||
|
offset, 0 0;
|
||||||
|
}
|
||||||
|
rel2 {
|
||||||
|
relative, 1.0 1.0;
|
||||||
|
offset, -1 -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
description {
|
||||||
|
state, "clicked" 0.0;
|
||||||
|
min, 480 100;
|
||||||
|
max, 1028 100;
|
||||||
|
align, 0.5 1.0;
|
||||||
|
|
||||||
|
color, 170 89 214 200;
|
||||||
|
|
||||||
|
rel1 {
|
||||||
|
relative, 0.0 1.0;
|
||||||
|
offset, 2 3;
|
||||||
|
}
|
||||||
|
rel2 {
|
||||||
|
relative, 1.0 1.0;
|
||||||
|
offset, 1 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
part {
|
||||||
|
name, "text_start";
|
||||||
|
type, TEXT;
|
||||||
|
mouse_events, 0;
|
||||||
|
|
||||||
|
description {
|
||||||
|
state, "default" 0.0;
|
||||||
|
|
||||||
|
rel1 {
|
||||||
|
|
||||||
|
relative, 0.0 0.0;
|
||||||
|
offset, 0 0;
|
||||||
|
to, "button_start";
|
||||||
|
}
|
||||||
|
rel2 {
|
||||||
|
relative, 1.0 1.0;
|
||||||
|
offset, -1 -1;
|
||||||
|
to, "button_start";
|
||||||
|
}
|
||||||
|
text {
|
||||||
|
text, "START";
|
||||||
|
font, "sans serif";
|
||||||
|
size, 20;
|
||||||
|
align, 0.5 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
part {
|
||||||
|
name, "text_stop";
|
||||||
|
type, TEXT;
|
||||||
|
mouse_events, 0;
|
||||||
|
|
||||||
|
description {
|
||||||
|
state, "default" 0.0;
|
||||||
|
|
||||||
|
rel1 {
|
||||||
|
|
||||||
|
relative, 0.0 0.0;
|
||||||
|
offset, 0 0;
|
||||||
|
to, "button_stop";
|
||||||
|
}
|
||||||
|
rel2 {
|
||||||
|
relative, 1.0 1.0;
|
||||||
|
offset, -1 -1;
|
||||||
|
to, "button_stop";
|
||||||
|
}
|
||||||
|
text {
|
||||||
|
text, "STOP";
|
||||||
|
font, "sans serif";
|
||||||
|
size, 20;
|
||||||
|
align, 0.5 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* Close Parts */
|
||||||
|
|
||||||
|
programs {
|
||||||
|
|
||||||
|
program {
|
||||||
|
name, "button_click";
|
||||||
|
signal, "mouse,down,1";
|
||||||
|
source, "button_start";
|
||||||
|
action, STATE_SET "clicked" 0.0;
|
||||||
|
target, "button_start";
|
||||||
|
}
|
||||||
|
|
||||||
|
program {
|
||||||
|
name, "button_unclick";
|
||||||
|
signal, "mouse,up,1";
|
||||||
|
source, "button_start";
|
||||||
|
action, STATE_SET "default" 0.0;
|
||||||
|
target, "button_start";
|
||||||
|
}
|
||||||
|
|
||||||
|
program {
|
||||||
|
name, "start_signal";
|
||||||
|
signal, "mouse,down,1";
|
||||||
|
source, "button_start";
|
||||||
|
action, SIGNAL_EMIT "StartSelected" "button_start";
|
||||||
|
in, 0.0 0.0;
|
||||||
|
}
|
||||||
|
program {
|
||||||
|
name, "stop_click";
|
||||||
|
signal, "mouse,down,1";
|
||||||
|
source, "button_stop";
|
||||||
|
action, STATE_SET "clicked" 0.0;
|
||||||
|
target, "button_stop";
|
||||||
|
}
|
||||||
|
|
||||||
|
program {
|
||||||
|
name, "stop_unclick";
|
||||||
|
signal, "mouse,up,1";
|
||||||
|
source, "button_stop";
|
||||||
|
action, STATE_SET "default" 0.0;
|
||||||
|
target, "button_stop";
|
||||||
|
}
|
||||||
|
|
||||||
|
program {
|
||||||
|
name, "stop_signal";
|
||||||
|
signal, "mouse,down,1";
|
||||||
|
source, "button_stop";
|
||||||
|
action, SIGNAL_EMIT "StopSelected" "button_stop";
|
||||||
|
in, 0.0 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} /* Close Prog */
|
||||||
|
} /* Close Group */
|
||||||
|
} /* Close Coll */
|
BIN
PyTracker/trunk/data/PyTracker.edj
Normal file
BIN
PyTracker/trunk/data/PyTracker.edj
Normal file
Binary file not shown.
BIN
PyTracker/trunk/data/background.jpg
Normal file
BIN
PyTracker/trunk/data/background.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 150 KiB |
BIN
PyTracker/trunk/data/start.png
Normal file
BIN
PyTracker/trunk/data/start.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
BIN
PyTracker/trunk/data/stop.png
Normal file
BIN
PyTracker/trunk/data/stop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
Loading…
Reference in a new issue