Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

QT download progress (default on Win32)

* Updated tcx2web.exe in place of tcx2garmin
* Removed unnecessary antd code dependency on dbm
  • Loading branch information...
commit 4bc019972a3942de8d6e96deed67f6a3074673ce 1 parent cab6217
@mlt authored
View
27 src/Makefile
@@ -0,0 +1,27 @@
+#!/usr/bin/make -f
+
+SUBDIRS = core
+
+all: $(SUBDIRS)
+#doc
+
+$(SUBDIRS):
+ $(MAKE) -C $@
+
+apidoc:
+ sphinx-apidoc --force -o doc/source .
+
+#export PYTHONPATH:= "${OSGEO4W_ROOT}/apps/qgis/python;${OSGEO4W_ROOT}/apps/qgis/python/plugins;${HOME}/.qgis/python/plugins;${OSGEO4W_ROOT}/apps/python27/lib/site-packages"
+#export PATH:= "${PATH}:${OSGEO4W_ROOT}/bin:${OSGEO4W_ROOT}/bin:${OSGEO4W_ROOT}/apps/qgis/bin:${OSGEO4W_ROOT}/apps/qgis/plugins:${OSGEO4W_ROOT}/apps/Python27/Scripts"
+
+doc: apidoc
+ $(MAKE) -C doc html
+# cd doc && cmd \\/c make.bat html
+
+# @PATH=${PATH} echo %PATH%
+# @PATH=${PATH} $(MAKE) -C doc html
+
+zip:
+ 7z a -r -x!.ropeproject -x!doc schwinn810.zip ".\*.py"
+
+.PHONY: subdirs $(SUBDIRS) apidoc doc
View
5 src/core/Makefile
@@ -0,0 +1,5 @@
+#!/usr/bin/make -f
+
+include ../top.make
+
+all: ui_progress.py
View
91 src/core/progress.ui
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Dialog</class>
+ <widget class="QDialog" name="Dialog">
+ <property name="windowModality">
+ <enum>Qt::NonModal</enum>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>230</width>
+ <height>108</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle">
+ <string>Download</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="pointlLayout">
+ <item>
+ <widget class="QLabel" name="pointLabel">
+ <property name="text">
+ <string>Point</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="pointCountLabel">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QProgressBar" name="pointBar">
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="tracklLayout">
+ <item>
+ <widget class="QLabel" name="trackLabel">
+ <property name="text">
+ <string>Track</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="trackCountLabel">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QProgressBar" name="trackBar">
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ <zorder>pointBar</zorder>
+ <zorder>horizontalLayoutWidget</zorder>
+ <zorder>trackBar</zorder>
+ <zorder>horizontalLayoutWidget_2</zorder>
+ <zorder>trackCountLabel</zorder>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
View
34 src/core/progress_qt.py
@@ -0,0 +1,34 @@
+""" Simple QT progress indicator """
+
+from PyQt4.QtGui import QDialog, QMessageBox
+from PyQt4.QtCore import Qt
+from ui_progress import Ui_Dialog
+
+# Shall we use QProgressDialog instead?
+
+class QtProgress(QDialog):
+
+ def __init__(self):
+ super(QtProgress, self).__init__()
+ self.ui = Ui_Dialog()
+ self.ui.setupUi(self)
+
+ self.show()
+ self._update()
+
+ def _update(self):
+ pass
+ # while Gtk.events_pending(): Gtk.main_iteration()
+
+ def track(self, name, at, end, points):
+ self.ui.trackBar.setMaximum(end)
+ self.ui.trackBar.setValue(at-1)
+ self.ui.trackCountLabel.setText("{:d}/{:d}".format(at, end))
+ self._update()
+
+ def point(self, at, end):
+ if at % 100 == 0:
+ self.ui.pointBar.setMaximum(end)
+ self.ui.pointBar.setValue(at-1)
+ self.ui.pointCountLabel.setText("{:d}/{:d}".format(at, end))
+ self._update()
View
22 src/download.py
@@ -3,7 +3,7 @@
from core.device import Device, SerialException
from core.writer_csv import Writer
from core.progress_text import TextProgress
-import argparse, os
+import argparse, os, sys
import logging
_log = logging.getLogger(__name__)
@@ -29,7 +29,7 @@ def main():
help='Dump all replies in a binary form into a single file schwinn810.bin in TEMP dir')
parser.add_argument('--delete', action='store_true',
help='Delete all data from watches after download?')
- parser.add_argument('--progress', choices=['text', 'gtk'],
+ parser.add_argument('--progress', choices=['none', 'text', 'gtk', 'qt'],
default=['text'],
help='Progress indicator')
# parser.add_argument('--add-year', dest='add_year', action='store_true',
@@ -39,22 +39,32 @@ def main():
args = parser.parse_args()
- d = Device(args.port[0])
- d.debug = args.debug
try:
+ d = Device(args.port[0])
+ d.debug = args.debug
w = Writer(args.dir[0], args.hook[0])
- p = TextProgress()
+ p = None
+ if args.progress != 'none':
+ p = TextProgress() # default progress
if args.progress == 'gtk':
try:
from core.progress_gtk import GtkProgress
p = GtkProgress()
except ImportError:
_log.error('Failed to create GTK backend')
+ elif args.progress == 'qt':
+ try:
+ from PyQt4.QtGui import QApplication
+ from core.progress_qt import QtProgress
+ app = QApplication(sys.argv)
+ p = QtProgress()
+ except ImportError:
+ _log.error('Failed to create QT backend')
d.read(w, p)
d.close()
except SerialException as e:
_log.fatal("Port can't be opened :(")
- exit(-1)
+ sys.exit(-1)
print("Done")
View
1  src/schwinn810.cmd
@@ -6,6 +6,7 @@ SET "DIR=%USERPROFILE%\Documents\My Runs"
download.exe ^
--port COM1 ^
--hook %~dp0\babelize.cmd ^
+ --progress qt ^
--dir "%DIR%"
SET "GPSBABEL=C:\Program Files\GPSBabel\gpsbabel.exe"
View
3  src/setup.py
@@ -4,6 +4,7 @@
# C:\Python27\python setup.py build
# 7z a -xr!*.py* build\exe.win32-2.7\library.zip C:\Python27\Lib\site-packages\pytz
+sys.path.append('web')
# Dependencies are automatically detected, but it might need fine tuning.
#"build_exe": "schwinn810_win32",
@@ -27,4 +28,4 @@
executables = [Executable("download.py", base=base), \
Executable("settings.py", base=base), \
Executable("csv2tcx.py", base=base), \
- Executable("tcx2garmin.py", base=base)])
+ Executable("web/tcx2web.py", base=base)])
View
5 src/top.make
@@ -0,0 +1,5 @@
+# handy stuff
+
+ui_%.py : %.ui
+ python -m PyQt4.uic.pyuic -x -o $@ $^
+
View
1  src/web/antd/plugin.py
@@ -28,7 +28,6 @@
import logging
-import dbm
import os
_log = logging.getLogger("antd.plugin")
Please sign in to comment.
Something went wrong with that request. Please try again.