annotate feedworm.py @ 241:e0e7459556bc

use Qt to open the selected article in the system browser
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 28 Apr 2015 02:50:57 +0200
parents e34c53a3e407
children 7c719c4f5655
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
217
bb3c851b18b1 add source file endcoding header
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 195
diff changeset
1 # -*- coding: utf-8 -*-
225
f6dcc85cd8ca use SIP API v2
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
2
f6dcc85cd8ca use SIP API v2
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
3 # see http://stackoverflow.com/questions/6238193/pyqt-new-api-with-python-2
f6dcc85cd8ca use SIP API v2
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
4 import sip
f6dcc85cd8ca use SIP API v2
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
5 sip.setapi('QString', 2)
f6dcc85cd8ca use SIP API v2
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
6 sip.setapi('QVariant', 2)
f6dcc85cd8ca use SIP API v2
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
7
24
6b5ceffabe49 MainWindowController -> MainWindow
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 14
diff changeset
8 from MainWindow import MainWindow
14
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
9 from PyQt4 import QtGui
87
b8bfd1bd6c55 use a proxy if one is configured. TODO: GUI for configuring the proxy server
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
10 from PyQt4.QtNetwork import QNetworkProxy
137
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 133
diff changeset
11 import BackendFactory
119
04a730f9d07d move all sqlalchemy related classes to the respective sub-package. use a backend to abstract from access to the data
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 87
diff changeset
12 import logging
14
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
13 import sys
195
66d1efcb8e8a filter out warnings that we cannot handle
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 194
diff changeset
14 import warnings
14
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
15
225
f6dcc85cd8ca use SIP API v2
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
16 def filterWarnings():
f6dcc85cd8ca use SIP API v2
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
17 # filter out the warnings about duplicate inclusion of argparse
f6dcc85cd8ca use SIP API v2
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
18 warnings.filterwarnings("ignore", category=UserWarning)
f6dcc85cd8ca use SIP API v2
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
19
f6dcc85cd8ca use SIP API v2
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
20 def configureLogging():
f6dcc85cd8ca use SIP API v2
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
21 logging.basicConfig(level=logging.DEBUG)
233
e34c53a3e407 fixes from eric's style check
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 225
diff changeset
22
87
b8bfd1bd6c55 use a proxy if one is configured. TODO: GUI for configuring the proxy server
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
23 def setupProxy(preferences):
194
2c91b5653878 enable/disable using the proxy via a preference setting
dirk
parents: 137
diff changeset
24 if preferences.isProxyConfigured() and preferences.useProxy():
87
b8bfd1bd6c55 use a proxy if one is configured. TODO: GUI for configuring the proxy server
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
25 proxyHost = preferences.proxyHost()
b8bfd1bd6c55 use a proxy if one is configured. TODO: GUI for configuring the proxy server
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
26 proxyPort = preferences.proxyPort()
b8bfd1bd6c55 use a proxy if one is configured. TODO: GUI for configuring the proxy server
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
27 proxy = QNetworkProxy(QNetworkProxy.HttpProxy, proxyHost, proxyPort)
b8bfd1bd6c55 use a proxy if one is configured. TODO: GUI for configuring the proxy server
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
28 QNetworkProxy.setApplicationProxy(proxy)
194
2c91b5653878 enable/disable using the proxy via a preference setting
dirk
parents: 137
diff changeset
29
14
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
30 if __name__ == '__main__':
225
f6dcc85cd8ca use SIP API v2
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
31 filterWarnings()
f6dcc85cd8ca use SIP API v2
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
32 configureLogging()
f6dcc85cd8ca use SIP API v2
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
33
137
5b131f82057d allow choosing the backend via commandline option
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 133
diff changeset
34 backend = BackendFactory.createBackend()
119
04a730f9d07d move all sqlalchemy related classes to the respective sub-package. use a backend to abstract from access to the data
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 87
diff changeset
35 preferences = backend.preferences()
87
b8bfd1bd6c55 use a proxy if one is configured. TODO: GUI for configuring the proxy server
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
36 setupProxy(preferences)
b8bfd1bd6c55 use a proxy if one is configured. TODO: GUI for configuring the proxy server
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
37
14
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
38 app = QtGui.QApplication(sys.argv)
119
04a730f9d07d move all sqlalchemy related classes to the respective sub-package. use a backend to abstract from access to the data
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 87
diff changeset
39 mainWindow = MainWindow(backend)
87
b8bfd1bd6c55 use a proxy if one is configured. TODO: GUI for configuring the proxy server
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
40
b8bfd1bd6c55 use a proxy if one is configured. TODO: GUI for configuring the proxy server
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
41 maximized = preferences.startMaximized()
43
12ed8b5fa08c first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 38
diff changeset
42 if maximized:
12ed8b5fa08c first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 38
diff changeset
43 mainWindow.showMaximized()
12ed8b5fa08c first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 38
diff changeset
44 else:
12ed8b5fa08c first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 38
diff changeset
45 mainWindow.show()
12ed8b5fa08c first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 38
diff changeset
46
14
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
47 sys.exit(app.exec_())