diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index ee957e2d..3c55e97e 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -32,6 +32,7 @@ import string import traceback import shutil import locale +import re import xml.dom.minidom from xml.dom.minidom import Node @@ -248,6 +249,8 @@ class Site: self.enabled = string_to_bool(node.getAttribute("enabled"), default=True) self.xpad = node.getAttribute("xpad") self.ypad = node.getAttribute("ypad") + self.xshift = node.getAttribute("xshift") + self.yshift = node.getAttribute("yshift") self.layout = {} print "Loading site", self.site_name @@ -259,6 +262,8 @@ class Site: # Site defaults self.xpad = 1 if self.xpad == "" else int(self.xpad) self.ypad = 0 if self.ypad == "" else int(self.ypad) + self.xshift = 1 if self.xshift == "" else int(self.xshift) + self.yshift = 0 if self.yshift == "" else int(self.yshift) self.font_size = 7 if self.font_size == "" else int(self.font_size) self.hudopacity = 1.0 if self.hudopacity == "" else float(self.hudopacity) @@ -296,12 +301,18 @@ class Game: self.cols = int( node.getAttribute("cols") ) self.xpad = node.getAttribute("xpad") self.ypad = node.getAttribute("ypad") + self.xshift = node.getAttribute("xshift") + self.yshift = node.getAttribute("yshift") # Defaults if self.xpad == "": self.xpad = 1 else: self.xpad = int(self.xpad) if self.ypad == "": self.ypad = 0 else: self.ypad = int(self.ypad) + if self.xshift == "": self.xshift = 1 + else: self.xshift = int(self.xshift) + if self.yshift == "": self.yshift = 0 + else: self.yshift = int(self.yshift) aux_text = node.getAttribute("aux") aux_list = aux_text.split(',') @@ -334,6 +345,8 @@ class Game: temp = temp + " cols = %d\n" % self.cols temp = temp + " xpad = %d\n" % self.xpad temp = temp + " ypad = %d\n" % self.ypad + temp = temp + " xshift = %d\n" % self.xshift + temp = temp + " yshift = %d\n" % self.yshift temp = temp + " aux = %s\n" % self.aux for stat in self.stats.keys(): @@ -662,7 +675,34 @@ class Config: pass with open(file, 'w') as f: - self.doc.writexml(f) + #self.doc.writexml(f) + f.write( self.wrap_long_lines( self.doc.toxml() ) ) + + def wrap_long_lines(self, s): + lines = [ self.wrap_long_line(l) for l in s.splitlines() ] + return('\n'.join(lines) + '\n') + + def wrap_long_line(self, l): + if 'config_wrap_len' in self.general: + wrap_len = int(self.general['config_wrap_len']) + else: + wrap_len = -1 # < 0 means no wrap + + if wrap_len >= 0 and len(l) > wrap_len: + m = re.compile('\s+\S+\s+') + mo = m.match(l) + if mo: + indent_len = mo.end() + #print "indent = %s (%s)" % (indent_len, l[0:indent_len]) + indent = '\n' + ' ' * indent_len + m = re.compile('(\S+="[^"]+"\s+)') + parts = [x for x in m.split(l[indent_len:]) if x] + if len(parts) > 1: + #print "parts =", parts + l = l[0:indent_len] + indent.join(parts) + return(l) + else: + return(l) def edit_layout(self, site_name, max, width = None, height = None, fav_seat = None, locations = None): @@ -951,6 +991,8 @@ class Config: parms["enabled"] = self.supported_sites[site].enabled parms["xpad"] = self.supported_sites[site].xpad parms["ypad"] = self.supported_sites[site].ypad + parms["xshift"] = self.supported_sites[site].xshift + parms["yshift"] = self.supported_sites[site].yshift return parms def set_site_parameters(self, site_name, converter = None, decoder = None, @@ -1002,6 +1044,8 @@ class Config: param['cols'] = self.supported_games[name].cols param['xpad'] = self.supported_games[name].xpad param['ypad'] = self.supported_games[name].ypad + param['xshift'] = self.supported_games[name].xshift + param['yshift'] = self.supported_games[name].yshift param['aux'] = self.supported_games[name].aux return param diff --git a/pyfpdb/GuiAutoImport.py b/pyfpdb/GuiAutoImport.py index 4db85872..6dd67ba5 100755 --- a/pyfpdb/GuiAutoImport.py +++ b/pyfpdb/GuiAutoImport.py @@ -214,8 +214,8 @@ class GuiAutoImport (threading.Thread): stderr=subprocess.PIPE, # only needed for py2exe universal_newlines=True ) - self.pipe_to_hud.stdout.close() - self.pipe_to_hud.stderr.close() + #self.pipe_to_hud.stdout.close() + #self.pipe_to_hud.stderr.close() except: err = traceback.extract_tb(sys.exc_info()[2])[-1] #self.addText( "\n*** GuiAutoImport Error opening pipe: " + err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1])) diff --git a/pyfpdb/GuiGraphViewer.py b/pyfpdb/GuiGraphViewer.py index eb1793d3..add48696 100644 --- a/pyfpdb/GuiGraphViewer.py +++ b/pyfpdb/GuiGraphViewer.py @@ -228,9 +228,9 @@ class GuiGraphViewer (threading.Thread): self.ax.plot(blue, color='blue', label='Showdown: $%.2f' %(blue[-1])) self.ax.plot(red, color='red', label='Non-showdown: $%.2f' %(red[-1])) if sys.version[0:3] == '2.5': - self.ax.legend(loc='best', shadow=True, prop=FontProperties(size='smaller')) + self.ax.legend(loc='upper left', shadow=True, prop=FontProperties(size='smaller')) else: - self.ax.legend(loc='best', fancybox=True, shadow=True, prop=FontProperties(size='smaller')) + self.ax.legend(loc='upper left', fancybox=True, shadow=True, prop=FontProperties(size='smaller')) self.graphBox.add(self.canvas) self.canvas.show() diff --git a/pyfpdb/GuiPrefs.py b/pyfpdb/GuiPrefs.py index b85b3f6a..e5458cc7 100755 --- a/pyfpdb/GuiPrefs.py +++ b/pyfpdb/GuiPrefs.py @@ -60,7 +60,7 @@ class GuiPrefs: configColumn.pack_start(cRender, True) configColumn.add_attribute(cRender, 'text', 1) - configColumn = gtk.TreeViewColumn("Value") + configColumn = gtk.TreeViewColumn("Value (double-click to change)") self.configView.append_column(configColumn) cRender = gtk.CellRendererText() configColumn.pack_start(cRender, True) diff --git a/pyfpdb/HUD_config.xml.example b/pyfpdb/HUD_config.xml.example index 5a72c4c6..af1d9395 100644 --- a/pyfpdb/HUD_config.xml.example +++ b/pyfpdb/HUD_config.xml.example @@ -2,6 +2,13 @@ + + +