wkn grundfunktionalitaet steht jetzt mit gui
This commit is contained in:
parent
0d801e346b
commit
6b5a8467ca
7 changed files with 1510 additions and 330 deletions
|
@ -1,5 +1,7 @@
|
||||||
[.] eingelesenen srcfile Namen, aus dem Textfeld wieder auslesen
|
[ ] intervallcheckboxen auswerten
|
||||||
[ ] mehrere intervalle holen (30, 300, 10000, 30000)
|
[ ] zielverzeichnis auswerten
|
||||||
[ ] dateinamen besser vergeben
|
[ ] dateinamen besser vergeben
|
||||||
[ ] datum einbringen
|
[ ] datum einbringen
|
||||||
|
[ ] bilder im programm anzeigen
|
||||||
|
[ ] download in threads laufen lassen
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ class WKNCharts:
|
||||||
'''fetches images from stocks'''
|
'''fetches images from stocks'''
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.wkn_dict = {}
|
self.wkn_dict = {}
|
||||||
|
self.times = [300]
|
||||||
|
|
||||||
def readwkndictfromfile(self, filename):
|
def readwkndictfromfile(self, filename):
|
||||||
'''reads lines like "wkn name\n" from a file and fills a dictionary'''
|
'''reads lines like "wkn name\n" from a file and fills a dictionary'''
|
||||||
|
@ -20,34 +21,51 @@ class WKNCharts:
|
||||||
if tmp[0] and tmp[1]: self.wkn_dict[tmp[0]] = tmp[1]
|
if tmp[0] and tmp[1]: self.wkn_dict[tmp[0]] = tmp[1]
|
||||||
wknfile.close()
|
wknfile.close()
|
||||||
|
|
||||||
def getchart(self, wkn):
|
def readwkndictfromstring(self, wknstring):
|
||||||
|
'''takes the given string into a "wkn name" dictionary'''
|
||||||
|
tmp2 = wknstring.splitlines()
|
||||||
|
print len(tmp2)
|
||||||
|
for i in tmp2:
|
||||||
|
tmp = i.split()
|
||||||
|
if tmp[0] and tmp[1]: self.wkn_dict[tmp[0]] = tmp[1]
|
||||||
|
|
||||||
|
def getchart(self, wkn, time, width=400, height=240):
|
||||||
'''fetches the images via http'''
|
'''fetches the images via http'''
|
||||||
host = "http://gfx.finanztreff.de/charts/cc_gatrixx.gfx?"
|
host = "http://gfx.finanztreff.de/charts/cc_gatrixx.gfx?"
|
||||||
params = urllib.urlencode({
|
params = urllib.urlencode({
|
||||||
'string':wkn,
|
'string':wkn,
|
||||||
'b':400,
|
'b':width,
|
||||||
'h':240,
|
'h':height,
|
||||||
'out':"png",
|
'out':"png",
|
||||||
'zeit':300,
|
'zeit':time,
|
||||||
'typ':0,
|
'typ':0,
|
||||||
'boerse':1,
|
'boerse':1,
|
||||||
'land':276,
|
'land':276,
|
||||||
'seite':"kurse",
|
'seite':"kurse",
|
||||||
'herkunft':123
|
'herkunft':123
|
||||||
})
|
})
|
||||||
print "ich hole jetzt \"%s\":" % self.wkn_dict[wkn]
|
#print "ich hole jetzt \"%s\" %i:" % (self.wkn_dict[wkn], time)
|
||||||
print host + params
|
#print host + params
|
||||||
|
self.gui.add_log(host + params)
|
||||||
try:
|
try:
|
||||||
f = urllib.urlopen(host + params)
|
f = urllib.urlopen(host + params)
|
||||||
png = open(self.wkn_dict[wkn]+".png", "w")
|
png = open("images/"+self.wkn_dict[wkn]+str(time)+".png", "w")
|
||||||
png.write(f.read())
|
png.write(f.read())
|
||||||
png.close()
|
png.close()
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
print e
|
self.gui.add_log(e)
|
||||||
|
#print e
|
||||||
|
|
||||||
def getallcharts(self):
|
def set_times(self, times):
|
||||||
|
self.times = times
|
||||||
|
|
||||||
|
def getallcharts(self, gui):
|
||||||
|
self.gui = gui
|
||||||
for wkn in self.wkn_dict.keys():
|
for wkn in self.wkn_dict.keys():
|
||||||
self.getchart(wkn)
|
for time in self.times:
|
||||||
|
self.gui.add_log("hole: %s %i" % (wkn, time))
|
||||||
|
self.getchart(wkn, time)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -7,37 +7,82 @@ class WknGUI:
|
||||||
"""
|
"""
|
||||||
This is a GTK-Frontend for getWKNcharts.py
|
This is a GTK-Frontend for getWKNcharts.py
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys, time
|
||||||
|
wkns = ""
|
||||||
|
log = ""
|
||||||
|
|
||||||
def __init__(self, gtk):
|
def __init__(self, gtk):
|
||||||
self.gladefile = "wkncharts.glade"
|
self.gladefile = "wkncharts.glade"
|
||||||
self.gtk = gtk
|
self.gtk = gtk
|
||||||
self.gladefile = "wkncharts.glade"
|
self.gladefile = "wkncharts.glade"
|
||||||
self.wkngui = self.gtk.glade.XML(self.gladefile)
|
self.wkngui = self.gtk.glade.XML(self.gladefile)
|
||||||
actions = { "on_read_srcfile_clicked": self.clicked_read_srcfile,
|
actions = { "on_read_settings_clicked": self.clicked_read_settings,
|
||||||
|
"on_cancel_settings_clicked": self.clicked_cancel_settings,
|
||||||
"on_choose_srcfile_clicked": self.clicked_choose_srcfile,
|
"on_choose_srcfile_clicked": self.clicked_choose_srcfile,
|
||||||
|
"on_bu_wget_charts_clicked": self.clicked_wget_charts,
|
||||||
|
"on_bu_exit_clicked": self.exit,
|
||||||
"on_window1_destroy": self.exit
|
"on_window1_destroy": self.exit
|
||||||
}
|
}
|
||||||
self.wkngui.signal_autoconnect (actions)
|
self.wkngui.signal_autoconnect (actions)
|
||||||
|
self.log += "\n"+self.time.strftime('%H:%M:%S')+" "
|
||||||
|
self.log += "Programm gestartet "
|
||||||
|
self.clicked_read_settings(self)
|
||||||
|
|
||||||
def clicked_read_srcfile(self, widget):
|
def clicked_wget_charts(self, widget):
|
||||||
file = self.wkngui.get_widget("tf_srcfile").get_text()
|
import getWKNcharts
|
||||||
|
'''the real download logic lies in getWKNcharts
|
||||||
|
that's why, we let it read in the wkn file'''
|
||||||
|
charts = getWKNcharts.WKNCharts()
|
||||||
|
charts.readwkndictfromstring(self.wkns)
|
||||||
|
charts.set_times([30, 300])
|
||||||
|
self.add_log("beginne Download der WKNS")
|
||||||
|
charts.getallcharts(self)
|
||||||
|
self.add_log("Download abgeschlossen")
|
||||||
|
|
||||||
|
def clicked_read_settings(self, widget):
|
||||||
|
self.outputfield = self.wkngui.get_widget("tf_srcfile")
|
||||||
|
self.textbuffer = self.outputfield.get_buffer()
|
||||||
|
file = self.textbuffer.get_text(*self.textbuffer.get_bounds ())
|
||||||
|
try:
|
||||||
|
tmpfile = open(file, "r")
|
||||||
|
filecontent = tmpfile.read()
|
||||||
|
tmpfile.close()
|
||||||
|
self.add_log("%s erfolgreich eingelesen" % file)
|
||||||
|
except:
|
||||||
|
self.buffer.set_text(filecontent)
|
||||||
|
self.log = "Achtung: Konnte %s nicht einlesen" % file
|
||||||
|
self.wkns = (filecontent)
|
||||||
|
self.tf_wknlist = self.wkngui.get_widget("tf_wknlist")
|
||||||
|
self.wknlistbuffer = self.tf_wknlist.get_buffer()
|
||||||
|
self.wknlistbuffer.set_text(self.wkns)
|
||||||
|
self.add_log("neue Einstellungen gespeichert")
|
||||||
|
|
||||||
|
def clicked_cancel_settings(self, widget):
|
||||||
|
'''TODO:
|
||||||
|
self.add_log("alte Einstellungen wieder hergestellt")
|
||||||
|
'''
|
||||||
|
pass
|
||||||
|
|
||||||
def clicked_choose_srcfile(self, widget):
|
def clicked_choose_srcfile(self, widget):
|
||||||
import filechooser
|
import filechooser
|
||||||
fcd = filechooser.FileChooserDialog()
|
fcd = filechooser.FileChooserDialog()
|
||||||
filename = fcd.getfilename()
|
filename = fcd.getfilename()
|
||||||
|
self.outputfield = self.wkngui.get_widget("tf_srcfile")
|
||||||
|
self.textbuffer = self.outputfield.get_buffer()
|
||||||
if filename:
|
if filename:
|
||||||
self.outputfield = self.wkngui.get_widget("tf_srcfile")
|
|
||||||
self.textbuffer = self.outputfield.get_buffer()
|
|
||||||
self.textbuffer.set_text(filename)
|
self.textbuffer.set_text(filename)
|
||||||
else:
|
else:
|
||||||
self.outputfield = self.wkngui.get_widget("tf_srcfile")
|
|
||||||
self.textbuffer = self.outputfield.get_buffer()
|
|
||||||
self.textbuffer.set_text("keine Datei ausgewaehlt")
|
self.textbuffer.set_text("keine Datei ausgewaehlt")
|
||||||
|
|
||||||
|
def add_log(self, text):
|
||||||
|
self.logbuch = self.wkngui.get_widget("tf_logbook")
|
||||||
|
self.buffer = self.logbuch.get_buffer()
|
||||||
|
self.log += "\n"+self.time.strftime('%H:%M:%S')+" "
|
||||||
|
self.log += text
|
||||||
|
self.buffer.set_text(self.log)
|
||||||
|
|
||||||
def exit(self, widget):
|
def exit(self, widget):
|
||||||
print "ciao ciao"
|
print "ciao ciao"
|
||||||
self.sys.exit(1)
|
self.sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,2 +1,2 @@
|
||||||
881823 samsung
|
881823 samsung
|
||||||
|
661823 sumsang
|
||||||
|
|
Loading…
Reference in a new issue