* bildbetrachter eingebaut

* loglevel eingefuehrt
 * bildtab aus notepad entfernt
This commit is contained in:
age 2006-06-15 09:10:52 +00:00
parent 3abb7f3841
commit 2a2986996a
8 changed files with 94 additions and 163 deletions

View file

@ -18,7 +18,7 @@ class WknCharts:
import wknGUI
wg = wknGUI.WknGUI(gtk)
# this is necessary for using threads later
# this is necessary for using threads in "wg"
gtk.gdk.threads_init()
gtk.gdk.threads_enter()
gtk.main()

11
WKNcharts/guiShowPics.py Normal file
View file

@ -0,0 +1,11 @@
#!/bin/env/python
class GuiShowPics:
'''this class will soon substitute pyview.py'''
import sys,os,stat,re,locale
match_pics=re.compile(r".*\.(png|tiff|jpg|jpeg|xpm)$")
def __init__(self, gui):
self.gui = gui

View file

@ -2,7 +2,6 @@
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<requires lib="gnome"/>
<widget class="GtkWindow" id="pyview">
<property name="visible">True</property>
@ -12,6 +11,11 @@
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<signal name="destroy" handler="on_pyview_destroy" last_modification_time="Fri, 28 Nov 2003 07:32:36 GMT"/>
<child>
@ -35,14 +39,17 @@
<child>
<widget class="GtkHPaned" id="hpaned1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<widget class="GtkVPaned" id="vpaned1">
<property name="width_request">240</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow5">
<property name="height_request">60</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
@ -107,6 +114,8 @@
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow8">
<property name="width_request">440</property>
<property name="height_request">280</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>

View file

@ -13,12 +13,7 @@ match_pics=re.compile(r".*\.(png|tiff|jpg|jpeg|xpm)$")
import sys
if len(sys.argv) == 2:
start_dir=sys.argv[1]
else:
start_dir="."
class pyview(libglade.GladeWrapper):
class PyView(libglade.GladeWrapper):
def __init__(self, Filename, WindowName, start_dir="."):
libglade.GladeWrapper.__init__(self, Filename, WindowName)
@ -44,6 +39,9 @@ class pyview(libglade.GladeWrapper):
self._chdir(start_dir)
def show_window(self):
gtk.main()
def _chdir(self,newdir):
try:
os.chdir(newdir)
@ -79,15 +77,20 @@ class pyview(libglade.GladeWrapper):
filename=model.get_value(iter,0)
self.image.set_from_file(filename)
size=locale.format("%d",os.stat(filename).st_size,1)
self.status.push(self.status_id,size+" bytes")
#self.status.push(self.status_id,size+" bytes")
self.status.push(self.status_id,os.getcwd()+"/"+filename)
def quit(self, *args):
gtk.main_quit()
#def quit(self, *args):
#gtk.main_quit()
def on_pyview_destroy(self, event):
self.quit()
PYVIEW = pyview("./pyview.glade", "pyview", start_dir)
gtk.main()
if __name__ == "__main__":
if len(sys.argv) == 2:
start_dir=sys.argv[1]
else:
start_dir="./images"
pv = PyView("./pyview.glade", "pyview", start_dir)
pv.show_window()

View file

@ -1,33 +0,0 @@
#This requires pygtk2
import gettext
import gtk
import gtk.glade
class GladeWrapper:
"""
Superclass for glade based applications. Just derive from this
and your subclass should create methods whose names correspond to
the signal handlers defined in the glade file. Any other attributes
in your class will be safely ignored.
This class will give you the ability to do:
subclass_instance.GtkWindow.method(...)
subclass_instance.widget_name...
"""
def __init__(self, Filename, WindowName):
#load glade file.
self.widgets = gtk.glade.XML(Filename, WindowName, gettext.textdomain())
self.GtkWindow = getattr(self, WindowName)
instance_attributes = {}
for attribute in dir(self.__class__):
instance_attributes[attribute] = getattr(self, attribute)
self.widgets.signal_autoconnect(instance_attributes)
def __getattr__(self, attribute): #Called when no attribute in __dict__
widget = self.widgets.get_widget(attribute)
if widget is None:
raise AttributeError("Widget [" + attribute + "] not found")
self.__dict__[attribute] = widget #add reference to cache
return widget

View file

@ -8,8 +8,11 @@ class WknGUI:
This is a GTK-Frontend for getWKNcharts.py
"""
import sys, time
from threading import Thread
wkns = ""
log = ""
maxloglevel = 1
'''0:no logging; 1:errors; 2:status messages; 3:all '''
def __init__(self, gtk):
self.gladefile = "wkncharts.glade"
@ -25,26 +28,24 @@ class WknGUI:
"on_window1_destroy": self.exit
}
self.wkngui.signal_autoconnect (actions)
self.log += "\n"+self.time.strftime('%H:%M:%S')+" "
self.log += "Programm gestartet "
# read the config at program start
self.clicked_read_settings(self)
def clicked_wget_charts(self, widget):
import getWKNcharts
from threading import Thread
'''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])
charts.set_times([30])
self.add_log("beginne Download der WKNS")
self.add_log("beginne Download der WKNS",2)
## downlaoding in threads, so the gui won't hang
## giving it 'self', so that it can use the logging window
Thread(target=charts.getallcharts,args=(self,)).start()
self.Thread(target=charts.getallcharts,args=(self,)).start()
## unthreaded version
#charts.getallcharts(self)
self.add_log("Download abgeschlossen")
self.add_log("Download abgeschlossen",2)
def clicked_read_settings(self, widget):
self.outputfield = self.wkngui.get_widget("tf_srcfile")
@ -54,15 +55,18 @@ class WknGUI:
tmpfile = open(file, "r")
filecontent = tmpfile.read()
tmpfile.close()
self.add_log("%s erfolgreich eingelesen" % file)
log = "\"%s\" erfolgreich eingelesen" % file
self.add_log(log, 2)
except:
self.buffer.set_text(filecontent)
self.log = "Achtung: Konnte %s nicht einlesen" % file
log = "Achtung: Konnte \"%s\" nicht einlesen!" % file
self.add_log("verdammt: "+str(self.sys.exc_info()[0]),1)
self.add_log(log, 1)
return
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")
self.add_log("neue Einstellungen gespeichert", 2)
def clicked_cancel_settings(self, widget):
'''TODO:
@ -71,9 +75,14 @@ class WknGUI:
pass
def clicked_choose_srcfile(self, widget):
import filechooser
fcd = filechooser.FileChooserDialog()
filename = fcd.getfilename()
try:
import filechooser
fcd = filechooser.FileChooserDialog()
filename = fcd.getfilename()
except:
self.add_log("Dateiauswahl Dialog konnte nicht gestartet werden",1)
self.add_log("verdammt: "+str(self.sys.exc_info()[0]),1)
raise
self.outputfield = self.wkngui.get_widget("tf_srcfile")
self.textbuffer = self.outputfield.get_buffer()
if filename:
@ -81,18 +90,30 @@ class WknGUI:
else:
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 add_log(self, text, loglevel=2):
if loglevel <= self.maxloglevel:
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 += " (L" + str(loglevel) + ") "
self.log += text
self.buffer.set_text(self.log)
def clicked_show_pics(self, widget):
'''this is for now 'cause i'm to lazy to implement the viewer
atm'''
self.ci = self.wkngui.get_widget("chartimage")
self.ci.set_from_file("foo.png")
in a better way'''
#self.ci = self.wkngui.get_widget("chartimage")
#self.ci.set_from_file("foo.png")
self.add_log("Bildbetrachter gestartet", 2)
try:
import pyview
pv = pyview.PyView("pyview.glad","pyview","./images")
pv.show_window
except:
self.add_log("konnte Bildbetrachter nicht laden", 1)
self.add_log(str(self.sys.exc_info()[0]),1)
raise
def exit(self, widget):
print "ciao ciao"

Binary file not shown.

View file

@ -113,13 +113,14 @@
<child>
<widget class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<property name="homogeneous">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkButton" id="bu_wget_charts">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_bu_wget_charts_clicked" last_modification_time="Thu, 08 Jun 2006 14:52:07 GMT"/>
@ -186,7 +187,7 @@
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">False</property>
</packing>
</child>
@ -220,7 +221,7 @@
<child>
<widget class="GtkImage" id="image8">
<property name="visible">True</property>
<property name="stock">gtk-zoom-in</property>
<property name="stock">gtk-zoom-fit</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
@ -261,7 +262,7 @@
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">False</property>
</packing>
</child>
@ -336,7 +337,7 @@
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">False</property>
</packing>
</child>
@ -374,87 +375,6 @@
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkImage" id="image7">
<property name="visible">True</property>
<property name="stock">gtk-zoom-fit</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">7</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow5">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkViewport" id="viewport1">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkImage" id="chartimage">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label" translatable="yes">Bilder</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox3">
<property name="visible">True</property>
@ -531,13 +451,12 @@
<child>
<widget class="GtkTextView" id="tf_srcfile">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="can_focus">True</property>
<property name="extension_events">GDK_EXTENSION_EVENTS_ALL</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="accepts_tab">False</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
@ -577,7 +496,7 @@
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="accepts_tab">False</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
@ -890,13 +809,14 @@
<child>
<widget class="GtkButton" id="cancel_settings">
<property name="visible">True</property>
<property name="has_default">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_cancel_settings_clicked" last_modification_time="Thu, 08 Jun 2006 20:15:42 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment2">
<widget class="GtkAlignment" id="alignment8">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
@ -908,15 +828,15 @@
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox6">
<widget class="GtkHBox" id="hbox13">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image2">
<widget class="GtkImage" id="image9">
<property name="visible">True</property>
<property name="stock">gtk-undo</property>
<property name="stock">gtk-cancel</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
@ -931,7 +851,7 @@
</child>
<child>
<widget class="GtkLabel" id="labelschnabel">
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="label" translatable="yes">Rückgängig</property>
<property name="use_underline">True</property>