wkn grundfunktionalitaet steht jetzt mit gui

This commit is contained in:
age 2006-06-09 07:20:21 +00:00
parent 0d801e346b
commit 6b5a8467ca
7 changed files with 1510 additions and 330 deletions

View file

@ -1,5 +1,7 @@
[.] eingelesenen srcfile Namen, aus dem Textfeld wieder auslesen
[ ] mehrere intervalle holen (30, 300, 10000, 30000)
[ ] intervallcheckboxen auswerten
[ ] zielverzeichnis auswerten
[ ] dateinamen besser vergeben
[ ] datum einbringen
[ ] bilder im programm anzeigen
[ ] download in threads laufen lassen

View file

@ -10,6 +10,7 @@ class WKNCharts:
'''fetches images from stocks'''
def __init__(self):
self.wkn_dict = {}
self.times = [300]
def readwkndictfromfile(self, filename):
'''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]
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'''
host = "http://gfx.finanztreff.de/charts/cc_gatrixx.gfx?"
params = urllib.urlencode({
'string':wkn,
'b':400,
'h':240,
'b':width,
'h':height,
'out':"png",
'zeit':300,
'zeit':time,
'typ':0,
'boerse':1,
'land':276,
'seite':"kurse",
'herkunft':123
})
print "ich hole jetzt \"%s\":" % self.wkn_dict[wkn]
print host + params
#print "ich hole jetzt \"%s\" %i:" % (self.wkn_dict[wkn], time)
#print host + params
self.gui.add_log(host + params)
try:
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.close()
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():
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__":

View file

@ -7,37 +7,82 @@ class WknGUI:
"""
This is a GTK-Frontend for getWKNcharts.py
"""
import sys
import sys, time
wkns = ""
log = ""
def __init__(self, gtk):
self.gladefile = "wkncharts.glade"
self.gtk = gtk
self.gladefile = "wkncharts.glade"
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_bu_wget_charts_clicked": self.clicked_wget_charts,
"on_bu_exit_clicked": self.exit,
"on_window1_destroy": self.exit
}
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):
file = self.wkngui.get_widget("tf_srcfile").get_text()
def clicked_wget_charts(self, widget):
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):
import filechooser
fcd = filechooser.FileChooserDialog()
filename = fcd.getfilename()
if filename:
self.outputfield = self.wkngui.get_widget("tf_srcfile")
self.textbuffer = self.outputfield.get_buffer()
if filename:
self.textbuffer.set_text(filename)
else:
self.outputfield = self.wkngui.get_widget("tf_srcfile")
self.textbuffer = self.outputfield.get_buffer()
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):
print "ciao ciao"
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

View file

@ -1,2 +1,2 @@
881823 samsung
661823 sumsang