From scm-commit at wald.intevation.org Sun Feb 6 20:02:23 2011 From: scm-commit at wald.intevation.org (scm-commit@wald.intevation.org) Date: Sun, 6 Feb 2011 20:02:23 +0100 (CET) Subject: [Skencil-commits] r794 - skencil/branches/skencil-0.6/src/Sketch/Base Message-ID: <20110206190223.08FAA80D90E9@pyrosoma.intevation.org> Author: bh Date: 2011-02-06 20:02:22 +0100 (Sun, 06 Feb 2011) New Revision: 794 Modified: skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py Log: Fix code formatting. Modified: skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py =================================================================== --- skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py 2010-12-22 18:31:08 UTC (rev 793) +++ skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py 2011-02-06 19:02:22 UTC (rev 794) @@ -37,42 +37,44 @@ font_style - list of font styles like 'bold' and 'italic' font_size - font size integer value """ - + try: tmpfile = NamedTemporaryFile() command = "import gtk;w = gtk.Window();w.realize();" command += "style=w.get_style(); print style.font_desc.to_string();" - if os.system('python -c "%s" >%s 2>/dev/null' % (command, tmpfile.name)): + if os.system('python -c "%s" >%s 2>/dev/null' + % (command, tmpfile.name)): raise Exception - + font = tmpfile.readline().strip() - + normal_font = process_gtk_font_string(font) small_font = copy.deepcopy(normal_font) small_font[2] -= 1 - + large_font = copy.deepcopy(normal_font) large_font[2] += 2 if not 'bold' in large_font[1]: large_font[1].append('bold') - + fixed_font = copy.deepcopy(normal_font) fixed_font[0] = 'monospace' except: - small_font = normal_font = large_font = fixed_font = ['helvetica', '', '9'] - + small_font = normal_font = large_font = fixed_font = \ + ['helvetica', '', '9'] + return [small_font, normal_font, large_font, fixed_font] - - + + def process_gtk_font_string(font): """ Converts Gtk font string to font description list So Gtk string like: San Serif Bold Italic 10 will be: ['San\ Serif', ['bold','italic'], 10] - Such form is much better for constructing of + Such form is much better for constructing of Tk font description. """ - + font_style = [] vals = font.split() font_size = int(vals[-1]) @@ -90,6 +92,7 @@ """ Constructs tk font string from font list. """ + print "tkfont_from_list", repr(font_list) return '%s %d ' % (font_list[0], font_list[2]) + string.join(font_list[1]) def set_ui_fonts(widget, font_list): @@ -106,7 +109,7 @@ SYSTEM_SCHEME = 'System' BUILTIN_SCHEME = 'Built-in' - + def gtk_to_tk_color(color): """ Converts gtk color representation to tk. @@ -125,18 +128,18 @@ def saturated_color(color): """ - Returns saturated color value. + Returns saturated color value. """ r, g, b = tkcolor_to_rgb(color) delta = 255 - max(r, g, b) return '#%02X%02X%02X' % (r + delta, g + delta, b + delta) - + def middle_color(dark, light, factor=0.5): """ Calcs middle color value. - + dark, light - tk color strings - factor - resulted color shift + factor - resulted color shift """ dark = tkcolor_to_rgb(dark) light = tkcolor_to_rgb(light) @@ -148,21 +151,22 @@ def lighter_color(color, factor): """ Calcs lighted color value according factor. - + color - tk color strings - factor - resulted color shift + factor - resulted color shift """ return middle_color(color, saturated_color(color), factor) - + class ColorScheme: + """ The class represents UI color scheme. Colors can be imported from system (SYSTEM_SCHEME) or built-in values (BUILTIN_SCHEME). """ - + bg = '#d4d0c8' fg = '#000000' highlightbackground = '#f3f2ef' @@ -170,43 +174,43 @@ disabledforeground = '#b0ada6' selectbackground = '#002468' selectforeground = '#ffffff' - + menubackground = '#dedad2' menuforeground = '#000000' menuselectbackground = '#002468' menuselectforeground = '#ffffff' menudisabledforeground = '#b0ada6' menubordercolor = '#7e7b77' - + editfieldbackground = '#ffffff' editfieldforeground = '#000000' treelinescolor = '#000000' - + d3_light = '#ffffff' d3_dark = '#b0ada6' - + light_border = '#b0ada6' normal_border = '#b0ada6' dark_border = '#b0ada6' - + evencolor = '#f0f0f0' - + name = BUILTIN_SCHEME - + def __init__(self, scheme=SYSTEM_SCHEME): self.name = scheme if scheme == BUILTIN_SCHEME: - return + return else: self.name = SYSTEM_SCHEME try: self.import_gtk_colors() except: scheme == BUILTIN_SCHEME - + def import_gtk_colors(self): """ - Imports system gtk color scheme using pygtk binding. + Imports system gtk color scheme using pygtk binding. """ colors = {} tmpfile = NamedTemporaryFile() @@ -231,10 +235,11 @@ " style.bg[gtk.STATE_PRELIGHT].to_string()," + \ " style.bg[gtk.STATE_SELECTED].to_string()," + \ " style.bg[gtk.STATE_INSENSITIVE].to_string();" - - if os.system('python -c "%s" >%s 2>/dev/null' % (command, tmpfile.name)): - raise Exception + if os.system('python -c "%s" >%s 2>/dev/null' + % (command, tmpfile.name)): + raise Exception + for type in ["base", "text", "fg", "bg"]: line = tmpfile.readline().strip().split() colors[type + ' normal'] = gtk_to_tk_color(line[0]) @@ -243,54 +248,55 @@ colors[type + ' selected'] = gtk_to_tk_color(line[3]) colors[type + ' insensitive'] = gtk_to_tk_color(line[4]) tmpfile.close() - + self.map_gtk_colors(colors) - + def map_gtk_colors(self, gtk_colors): """ Maps gtk colors to ColorScheme fields. """ - + self.bg = gtk_colors['bg normal'] self.fg = gtk_colors['text normal'] - + self.highlightbackground = gtk_colors['bg active'] self.highlightcolor = gtk_colors['fg active'] self.disabledforeground = gtk_colors['fg insensitive'] self.selectbackground = gtk_colors['bg selected'] self.selectforeground = gtk_colors['text selected'] - + self.menubackground = lighter_color(self.bg, .25) self.menuforeground = gtk_colors['fg normal'] self.menuselectbackground = gtk_colors['bg selected'] self.menuselectforeground = gtk_colors['fg selected'] self.menudisabledforeground = gtk_colors['text insensitive'] self.menubordercolor = gtk_colors['fg insensitive'] - + self.editfieldbackground = gtk_colors['base normal'] self.editfieldforeground = gtk_colors['text normal'] self.treelinescolor = gtk_colors['text normal'] - + self.d3_light = middle_color('#ffffff', gtk_colors['bg normal']) self.d3_dark = middle_color(gtk_colors['bg active'], gtk_colors['fg insensitive']) - + self.light_border = gtk_colors['bg active'] self.normal_border = middle_color(gtk_colors['bg active'], gtk_colors['fg insensitive']) self.dark_border = gtk_colors['fg insensitive'] - + self.evencolor = middle_color(self.bg, self.editfieldbackground, 0.7) - + + def set_ui_colors(widget, color_scheme): """ Applies ColorScheme object values to tk defaults. - """ + """ widget.tk.call('tk_setPalette', color_scheme.bg) - + cs = color_scheme - + options = [ ('*background', cs.bg), ('*foreground', cs.fg), @@ -302,32 +308,33 @@ ('*activeForeground', cs.fg), ('*Menu.activeBackground', cs.selectbackground), ('*Menu.activeForeground', cs.selectforeground), - + ('*Listbox.background', cs.editfieldbackground), ('*Listbox.foreground', cs.editfieldforeground), ('*Entry.background', cs.editfieldbackground), ('*Entry.foreground', cs.editfieldforeground), - + ('*tooltips*background', '#F6F6B9'), ('*tooltips.background', '#C2C24E'), - + ('*Menu.background', cs.menubackground), ('*Menu*background', cs.menubackground), ('*Menu.highlightColor', cs.menubordercolor), - + ('*canvas_frame.highlightColor', cs.normal_border), ('*canvas_frame.highlightBackground', cs.normal_border), - + ('*Darkline.background', cs.d3_dark), ('*Lightline.background', cs.d3_light), ] - + for key, value in options: widget.tk.call('option', 'add', key, value, 'interactive') - + + #module self testing if __name__ == '__main__': - + fonts = get_gtk_fonts() for item in fonts: print tkfont_from_list(item) From scm-commit at wald.intevation.org Sun Feb 6 20:10:04 2011 From: scm-commit at wald.intevation.org (scm-commit@wald.intevation.org) Date: Sun, 6 Feb 2011 20:10:04 +0100 (CET) Subject: [Skencil-commits] r795 - skencil/branches/skencil-0.6/src/Sketch/Base Message-ID: <20110206191004.E4BBA950430C@pyrosoma.intevation.org> Author: bh Date: 2011-02-06 20:10:04 +0100 (Sun, 06 Feb 2011) New Revision: 795 Modified: skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py Log: Fix fallback font in get_gtk_fonts. The font size needs to be an int. Modified: skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py =================================================================== --- skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py 2011-02-06 19:02:22 UTC (rev 794) +++ skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py 2011-02-06 19:10:04 UTC (rev 795) @@ -61,7 +61,7 @@ fixed_font[0] = 'monospace' except: small_font = normal_font = large_font = fixed_font = \ - ['helvetica', '', '9'] + ['helvetica', '', 9] return [small_font, normal_font, large_font, fixed_font] From scm-commit at wald.intevation.org Sun Feb 6 20:10:58 2011 From: scm-commit at wald.intevation.org (scm-commit@wald.intevation.org) Date: Sun, 6 Feb 2011 20:10:58 +0100 (CET) Subject: [Skencil-commits] r796 - skencil/branches/skencil-0.6/src/Sketch/UI Message-ID: <20110206191058.0900D950430C@pyrosoma.intevation.org> Author: bh Date: 2011-02-06 20:10:57 +0100 (Sun, 06 Feb 2011) New Revision: 796 Modified: skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py Log: Fix code formatting. Modified: skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py =================================================================== --- skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py 2011-02-06 19:10:04 UTC (rev 795) +++ skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py 2011-02-06 19:10:57 UTC (rev 796) @@ -38,7 +38,7 @@ tick_lengths = (8, 5, 3, 2) -# (base_unit_factor, (subdiv1, subdiv2,...)) +# (base_unit_factor, (subdiv1, subdiv2, ...)) tick_config = {'in': (1.0, (2, 2, 2, 2)), 'cm': (1.0, (2, 5)), 'mm': (10.0, (2, 5)), @@ -51,61 +51,71 @@ '-': (4, [(0, 2, 2, 2)]), '0': (5, [(0, 0, 3, 0), (3, 0, 3, 4), (3, 4, 0, 4), (0, 4, 0, 0)]), '1': (3, [(1, 0, 1, 4), (1, 4, 0, 4)]), - '2': (5, [(3, 0, 0, 0), (0, 0, 0, 2), (0, 2, 3, 2), (3, 2, 3, 4), (3, 4, 0, 4)]), + '2': (5, [(3, 0, 0, 0), (0, 0, 0, 2), (0, 2, 3, 2), (3, 2, 3, 4), + (3, 4, 0, 4)]), '3': (5, [(0, 0, 3, 0), (0, 2, 3, 2), (0, 4, 3, 4), (3, 4, 3, 0)]), '4': (5, [(0, 4, 0, 1), (0, 1, 3, 1), (3, 0, 3, 4)]), - '5': (5, [(0, 0, 3, 0), (3, 0, 3, 2), (3, 2, 0, 2), (0, 2, 0, 4), (0, 4, 3, 4)]), - '6': (5, [(2, 4, 0, 4), (0, 4, 0, 0), (0, 0, 3, 0), (3, 0, 3, 2), (3, 2, 0, 2)]), + '5': (5, [(0, 0, 3, 0), (3, 0, 3, 2), (3, 2, 0, 2), (0, 2, 0, 4), + (0, 4, 3, 4)]), + '6': (5, [(2, 4, 0, 4), (0, 4, 0, 0), (0, 0, 3, 0), (3, 0, 3, 2), + (3, 2, 0, 2)]), '7': (5, [(0, 4, 3, 4), (3, 3, 1, 1), (1, 1, 1, 0)]), - '8': (5, [(0, 0, 0, 4), (3, 0, 3, 4), (0, 0, 3, 0), (0, 2, 3, 2), (0, 4, 3, 4)]), - '9': (5, [(1, 0, 3, 0), (3, 0, 3, 4), (3, 4, 0, 4), (0, 4, 0, 2), (0, 2, 3, 2)]), - } + '8': (5, [(0, 0, 0, 4), (3, 0, 3, 4), (0, 0, 3, 0), (0, 2, 3, 2), + (0, 4, 3, 4)]), + '9': (5, [(1, 0, 3, 0), (3, 0, 3, 4), (3, 4, 0, 4), (0, 4, 0, 2), + (0, 2, 3, 2)]), + } VFONT = {'.': (2, [(0, 0, 0, 0),]), ',': (2, [(0, 0, 0, 0),]), '-': (4, [(2, 0, 2, 2),]), '0': (5, [(0, 0, 4, 0), (4, 0, 4, 3), (4, 3, 0, 3), (0, 3, 0, 0)]), '1': (3, [(0, 1, 4, 1), (4, 1, 4, 0)]), - '2': (5, [(0, 3, 0, 0), (0, 0, 2, 0), (2, 0, 2, 3), (2, 3, 4, 3), (4, 3, 4, 0)]), + '2': (5, [(0, 3, 0, 0), (0, 0, 2, 0), (2, 0, 2, 3), (2, 3, 4, 3), + (4, 3, 4, 0)]), '3': (5, [(0, 0, 0, 3), (0, 3, 4, 3), (4, 3, 4, 0), (2, 3, 2, 0)]), '4': (5, [(4, 0, 1, 0), (1, 0, 1, 3), (4, 3, 0, 3)]), - '5': (5, [(4, 3, 4, 0), (4, 0, 2, 0), (2, 0, 2, 3), (2, 3, 0, 3), (0, 3, 0, 0)]), - '6': (5, [(4, 2, 4, 0), (4, 0, 0, 0), (0, 0, 0, 3), (0, 3, 2, 3), (2, 3, 2, 0)]), + '5': (5, [(4, 3, 4, 0), (4, 0, 2, 0), (2, 0, 2, 3), (2, 3, 0, 3), + (0, 3, 0, 0)]), + '6': (5, [(4, 2, 4, 0), (4, 0, 0, 0), (0, 0, 0, 3), (0, 3, 2, 3), + (2, 3, 2, 0)]), '7': (5, [(4, 0, 4, 3), (3, 3, 1, 1), (1, 1, 0, 1)]), - '8': (5, [(0, 0, 0, 3), (0, 3, 4, 3), (4, 3, 4, 0), (2, 3, 2, 0), (4, 0, 0, 0)]), - '9': (5, [(0, 1, 0, 3), (0, 3, 4, 3), (4, 3, 4, 0), (4, 0, 2, 0), (2, 0, 2, 2)]), - } + '8': (5, [(0, 0, 0, 3), (0, 3, 4, 3), (4, 3, 4, 0), (2, 3, 2, 0), + (4, 0, 0, 0)]), + '9': (5, [(0, 1, 0, 3), (0, 3, 4, 3), (4, 3, 4, 0), (4, 0, 2, 0), + (2, 0, 2, 2)]), + } class Ruler(PyWidget): - def __init__(self, master=None, orient = HORIZONTAL, canvas = None, **kw): + def __init__(self, master=None, orient=HORIZONTAL, canvas=None, **kw): apply(PyWidget.__init__, (self, master), kw) self.orient = orient self.canvas = canvas - + self.gc_initialized = 0 self.gc = GraphicsDevice() self.gc.SetViewportTransform(1.0, Identity, Identity) self.positions = None - self.SetRange(0.0, 1.0, force = 1) + self.SetRange(0.0, 1.0, force=1) self['height'] = 19 self['width'] = 19 - + self.border_color = XRGBColor(ui_colors.light_border) self.bg_color = XRGBColor(ui_colors.menubackground) self.fg_color = XRGBColor(ui_colors.fg) - + self.gradient = [] start = ui_colors.menubackground stop = ui_colors.light_border for pos in range(20): color = gtkutils.middle_color(start, stop, pos * 3.5 /100) self.gradient.append(XRGBColor(color)) - + self.bind('', self.ButtonPressEvent) self.bind('', self.ButtonReleaseEvent) self.bind('', self.PointerMotionEvent) @@ -124,9 +134,9 @@ self.gc_initialized = 1 def ResizedMethod(self, width, height): - self.SetRange(self.start, self.pixel_per_pt, force = 1) + self.SetRange(self.start, self.pixel_per_pt, force=1) - def SetRange(self, start, pixel_per_pt, force = 0): + def SetRange(self, start, pixel_per_pt, force=0): if not force and start==self.start and pixel_per_pt==self.pixel_per_pt: return self.start = start @@ -228,7 +238,7 @@ return self.positions, self.texts - def RedrawMethod(self, region = None): + def RedrawMethod(self, region=None): if self.orient == HORIZONTAL: self.draw_ruler_horizontal() else: @@ -238,11 +248,11 @@ DrawLine = self.gc.gc.DrawLine height = self.tkwin.height width = self.tkwin.width - - for pos in range(0,20): + + for pos in range(0, 20): self.gc.SetFillColor(self.gradient[pos]) DrawLine(0, pos, width, pos) - + self.gc.SetFillColor(self.fg_color) ticks, texts = self.get_positions() for h, pos in ticks: @@ -256,7 +266,8 @@ data = HFONT[character] lines = data[1] for line in lines: - DrawLine(line[0] + pos, y - line[1], line[2] + pos, y - line[3]) + DrawLine(line[0] + pos, y - line[1], + line[2] + pos, y - line[3]) pos += data[0] self.gc.SetFillColor(self.border_color) @@ -268,7 +279,7 @@ height = self.tkwin.height width = self.tkwin.width - for pos in range(0,20): + for pos in range(0, 20): self.gc.SetFillColor(self.gradient[pos]) DrawLine(pos, 0, pos, height) @@ -287,9 +298,10 @@ data = VFONT[character] lines = data[1] for line in lines: - DrawLine(x - line[0], pos - line[1], x - line[2], pos - line[3]) + DrawLine(x - line[0], pos - line[1], + x - line[2], pos - line[3]) pos -= data[0] - + self.gc.SetFillColor(self.border_color) DrawLine(0, 0, width, 0) DrawLine(width - 1, 0, width - 1, height) From scm-commit at wald.intevation.org Sun Feb 6 20:21:22 2011 From: scm-commit at wald.intevation.org (scm-commit@wald.intevation.org) Date: Sun, 6 Feb 2011 20:21:22 +0100 (CET) Subject: [Skencil-commits] r797 - skencil/branches/skencil-0.6/src/Sketch/Base Message-ID: <20110206192122.29166950430F@pyrosoma.intevation.org> Author: bh Date: 2011-02-06 20:21:21 +0100 (Sun, 06 Feb 2011) New Revision: 797 Modified: skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py Log: Remove debug print from tkfont_from_list Modified: skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py =================================================================== --- skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py 2011-02-06 19:10:57 UTC (rev 796) +++ skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py 2011-02-06 19:21:21 UTC (rev 797) @@ -92,7 +92,6 @@ """ Constructs tk font string from font list. """ - print "tkfont_from_list", repr(font_list) return '%s %d ' % (font_list[0], font_list[2]) + string.join(font_list[1]) def set_ui_fonts(widget, font_list): From scm-commit at wald.intevation.org Sun Feb 6 20:38:46 2011 From: scm-commit at wald.intevation.org (scm-commit@wald.intevation.org) Date: Sun, 6 Feb 2011 20:38:46 +0100 (CET) Subject: [Skencil-commits] r798 - skencil/branches/skencil-0.6/src/Sketch/Base Message-ID: <20110206193846.E090680532C2@pyrosoma.intevation.org> Author: bh Date: 2011-02-06 20:38:45 +0100 (Sun, 06 Feb 2011) New Revision: 798 Modified: skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py Log: Do not suppress stderr of the pygtk sub-processes. The subprocesses should only print anything to stderr is something fails, and in that case the output is needed to determine what went wrong. Modified: skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py =================================================================== --- skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py 2011-02-06 19:21:21 UTC (rev 797) +++ skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py 2011-02-06 19:38:45 UTC (rev 798) @@ -42,8 +42,7 @@ tmpfile = NamedTemporaryFile() command = "import gtk;w = gtk.Window();w.realize();" command += "style=w.get_style(); print style.font_desc.to_string();" - if os.system('python -c "%s" >%s 2>/dev/null' - % (command, tmpfile.name)): + if os.system('python -c "%s" >%s' % (command, tmpfile.name)): raise Exception font = tmpfile.readline().strip() @@ -235,8 +234,7 @@ " style.bg[gtk.STATE_SELECTED].to_string()," + \ " style.bg[gtk.STATE_INSENSITIVE].to_string();" - if os.system('python -c "%s" >%s 2>/dev/null' - % (command, tmpfile.name)): + if os.system('python -c "%s" >%s' % (command, tmpfile.name)): raise Exception for type in ["base", "text", "fg", "bg"]: From scm-commit at wald.intevation.org Sun Feb 6 21:19:59 2011 From: scm-commit at wald.intevation.org (scm-commit@wald.intevation.org) Date: Sun, 6 Feb 2011 21:19:59 +0100 (CET) Subject: [Skencil-commits] r799 - skencil/branches/skencil-0.6/src/Sketch/UI Message-ID: <20110206201959.D707584FA53C@pyrosoma.intevation.org> Author: bh Date: 2011-02-06 21:19:59 +0100 (Sun, 06 Feb 2011) New Revision: 799 Modified: skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py Log: Remove unused imports. Modified: skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py =================================================================== --- skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py 2011-02-06 19:38:45 UTC (rev 798) +++ skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py 2011-02-06 20:19:59 UTC (rev 799) @@ -17,15 +17,10 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA from math import floor, ceil, hypot -from string import atoi -from types import TupleType import operator -import pax - -from Sketch import StandardColors, GraphicsDevice, Identity, gtkutils +from Sketch import GraphicsDevice, Identity, gtkutils from Sketch import config, const, GuideLine, Point, ui_colors -from Sketch.warn import warn, USER from Sketch.const import CHANGED from Sketch.Graphics.color import XRGBColor From scm-commit at wald.intevation.org Sun Feb 6 21:28:09 2011 From: scm-commit at wald.intevation.org (scm-commit@wald.intevation.org) Date: Sun, 6 Feb 2011 21:28:09 +0100 (CET) Subject: [Skencil-commits] r800 - skencil/branches/skencil-0.6/src/Sketch/UI Message-ID: <20110206202809.E6F9095042E5@pyrosoma.intevation.org> Author: bh Date: 2011-02-06 21:28:09 +0100 (Sun, 06 Feb 2011) New Revision: 800 Modified: skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py Log: Make the master and orient parameters of Ruler mandatory. They are always provided anyway and it prepares for more mandatory arguments. Adapt the caller in mainwindow. Modified: skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py =================================================================== --- skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py 2011-02-06 20:19:59 UTC (rev 799) +++ skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py 2011-02-06 20:28:09 UTC (rev 800) @@ -599,10 +599,10 @@ vbar.grid(in_ = frame, column = 2, row = 1, sticky = 'ns') hbar = Scrollbar(frame, orient = HORIZONTAL) hbar.grid(in_ = frame, column = 1, row = 2, sticky = 'ew') - hrule = ruler.Ruler(root, orient = ruler.HORIZONTAL) + hrule = ruler.Ruler(root, ruler.HORIZONTAL) hrule.grid(in_ = frame, column = 1, row = 0, sticky = 'ew', columnspan = 2) - vrule = ruler.Ruler(root, orient = ruler.VERTICAL) + vrule = ruler.Ruler(root, ruler.VERTICAL) vrule.grid(in_ = frame, column = 0, row = 1, sticky = 'ns', rowspan = 2) tmp = Frame(frame, name = 'rulercorner') Modified: skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py =================================================================== --- skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py 2011-02-06 20:19:59 UTC (rev 799) +++ skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py 2011-02-06 20:28:09 UTC (rev 800) @@ -84,7 +84,7 @@ class Ruler(PyWidget): - def __init__(self, master=None, orient=HORIZONTAL, canvas=None, **kw): + def __init__(self, master, orient, canvas=None, **kw): apply(PyWidget.__init__, (self, master), kw) self.orient = orient self.canvas = canvas From scm-commit at wald.intevation.org Sun Feb 6 21:32:30 2011 From: scm-commit at wald.intevation.org (scm-commit@wald.intevation.org) Date: Sun, 6 Feb 2011 21:32:30 +0100 (CET) Subject: [Skencil-commits] r801 - skencil/branches/skencil-0.6/src/Sketch/UI Message-ID: <20110206203230.3E9BA95042F1@pyrosoma.intevation.org> Author: bh Date: 2011-02-06 21:32:29 +0100 (Sun, 06 Feb 2011) New Revision: 801 Modified: skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py Log: Do not access the ui_colors directly in ruler.py. Pass the colors as a mandatory parameter into the class. This prepares for the removal of the gtkutils calls in the main Sketch package. Modified: skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py =================================================================== --- skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py 2011-02-06 20:28:09 UTC (rev 800) +++ skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py 2011-02-06 20:32:29 UTC (rev 801) @@ -599,10 +599,10 @@ vbar.grid(in_ = frame, column = 2, row = 1, sticky = 'ns') hbar = Scrollbar(frame, orient = HORIZONTAL) hbar.grid(in_ = frame, column = 1, row = 2, sticky = 'ew') - hrule = ruler.Ruler(root, ruler.HORIZONTAL) + hrule = ruler.Ruler(root, ruler.HORIZONTAL, Sketch.ui_colors) hrule.grid(in_ = frame, column = 1, row = 0, sticky = 'ew', columnspan = 2) - vrule = ruler.Ruler(root, ruler.VERTICAL) + vrule = ruler.Ruler(root, ruler.VERTICAL, Sketch.ui_colors) vrule.grid(in_ = frame, column = 0, row = 1, sticky = 'ns', rowspan = 2) tmp = Frame(frame, name = 'rulercorner') Modified: skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py =================================================================== --- skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py 2011-02-06 20:28:09 UTC (rev 800) +++ skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py 2011-02-06 20:32:29 UTC (rev 801) @@ -20,7 +20,7 @@ import operator from Sketch import GraphicsDevice, Identity, gtkutils -from Sketch import config, const, GuideLine, Point, ui_colors +from Sketch import config, const, GuideLine, Point from Sketch.const import CHANGED from Sketch.Graphics.color import XRGBColor @@ -84,7 +84,7 @@ class Ruler(PyWidget): - def __init__(self, master, orient, canvas=None, **kw): + def __init__(self, master, orient, colors, canvas=None, **kw): apply(PyWidget.__init__, (self, master), kw) self.orient = orient self.canvas = canvas @@ -99,13 +99,13 @@ self['height'] = 19 self['width'] = 19 - self.border_color = XRGBColor(ui_colors.light_border) - self.bg_color = XRGBColor(ui_colors.menubackground) - self.fg_color = XRGBColor(ui_colors.fg) + self.border_color = XRGBColor(colors.light_border) + self.bg_color = XRGBColor(colors.menubackground) + self.fg_color = XRGBColor(colors.fg) self.gradient = [] - start = ui_colors.menubackground - stop = ui_colors.light_border + start = colors.menubackground + stop = colors.light_border for pos in range(20): color = gtkutils.middle_color(start, stop, pos * 3.5 /100) self.gradient.append(XRGBColor(color)) From scm-commit at wald.intevation.org Sun Feb 6 21:36:54 2011 From: scm-commit at wald.intevation.org (scm-commit@wald.intevation.org) Date: Sun, 6 Feb 2011 21:36:54 +0100 (CET) Subject: [Skencil-commits] r802 - in skencil/branches/skencil-0.6/src/Sketch: . UI Message-ID: <20110206203654.EC4529504303@pyrosoma.intevation.org> Author: bh Date: 2011-02-06 21:36:54 +0100 (Sun, 06 Feb 2011) New Revision: 802 Modified: skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py skencil/branches/skencil-0.6/src/Sketch/UI/skapp.py skencil/branches/skencil-0.6/src/Sketch/__init__.py Log: Fetch the gtk settings only when instantiating a TkApplication. The color and font settings are made available as attributes of the application object. Adapt the mainwindow code accordingly. Now the gtkutils code is not called from the main Sketch package anymore and importing it will not try to run the gtk sub-processes at all. Modified: skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py =================================================================== --- skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py 2011-02-06 20:32:29 UTC (rev 801) +++ skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py 2011-02-06 20:36:54 UTC (rev 802) @@ -599,10 +599,10 @@ vbar.grid(in_ = frame, column = 2, row = 1, sticky = 'ns') hbar = Scrollbar(frame, orient = HORIZONTAL) hbar.grid(in_ = frame, column = 1, row = 2, sticky = 'ew') - hrule = ruler.Ruler(root, ruler.HORIZONTAL, Sketch.ui_colors) + hrule = ruler.Ruler(root, ruler.HORIZONTAL, self.application.ui_colors) hrule.grid(in_ = frame, column = 1, row = 0, sticky = 'ew', columnspan = 2) - vrule = ruler.Ruler(root, ruler.VERTICAL, Sketch.ui_colors) + vrule = ruler.Ruler(root, ruler.VERTICAL, self.application.ui_colors) vrule.grid(in_ = frame, column = 0, row = 1, sticky = 'ns', rowspan = 2) tmp = Frame(frame, name = 'rulercorner') Modified: skencil/branches/skencil-0.6/src/Sketch/UI/skapp.py =================================================================== --- skencil/branches/skencil-0.6/src/Sketch/UI/skapp.py 2011-02-06 20:32:29 UTC (rev 801) +++ skencil/branches/skencil-0.6/src/Sketch/UI/skapp.py 2011-02-06 20:36:54 UTC (rev 802) @@ -20,6 +20,7 @@ from Sketch.warn import pdebug from Sketch import _, config, plugins, Publisher, gtkutils import Sketch +import Sketch.gtkutils from Sketch.Graphics import document from Sketch.const import CLIPBOARD @@ -104,10 +105,13 @@ self.root = Tk(screenName = screen_name, baseName = self.tk_basename, className = self.tk_class_name) - - gtkutils.set_ui_fonts(self.root, Sketch.ui_fonts) - gtkutils.set_ui_colors(self.root, Sketch.ui_colors) - + + self.ui_fonts = Sketch.gtkutils.get_gtk_fonts() + self.ui_colors = Sketch.gtkutils.ColorScheme() + + gtkutils.set_ui_fonts(self.root, self.ui_fonts) + gtkutils.set_ui_colors(self.root, self.ui_colors) + # Reset locale again to make sure we get properly translated # messages if desired by the user. For some reason it may # have been reset by Tcl/Tk. Modified: skencil/branches/skencil-0.6/src/Sketch/__init__.py =================================================================== --- skencil/branches/skencil-0.6/src/Sketch/__init__.py 2011-02-06 20:32:29 UTC (rev 801) +++ skencil/branches/skencil-0.6/src/Sketch/__init__.py 2011-02-06 20:36:54 UTC (rev 802) @@ -53,10 +53,6 @@ pass _ = gettext -import gtkutils -ui_fonts = gtkutils.get_gtk_fonts() -ui_colors = gtkutils.ColorScheme() - import _sketch from _sketch import Point, Polar, PointType NullPoint = Point(0, 0) From scm-commit at wald.intevation.org Sun Feb 6 21:40:42 2011 From: scm-commit at wald.intevation.org (scm-commit@wald.intevation.org) Date: Sun, 6 Feb 2011 21:40:42 +0100 (CET) Subject: [Skencil-commits] r803 - skencil/branches/skencil-0.6/src/Sketch/Base Message-ID: <20110206204042.AC62A8502ADE@pyrosoma.intevation.org> Author: bh Date: 2011-02-06 21:40:42 +0100 (Sun, 06 Feb 2011) New Revision: 803 Modified: skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py Log: Print warnings if determining colors and fonts from GTK settings fails. Modified: skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py =================================================================== --- skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py 2011-02-06 20:36:54 UTC (rev 802) +++ skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py 2011-02-06 20:40:42 UTC (rev 803) @@ -21,7 +21,9 @@ import os, string, copy from tempfile import NamedTemporaryFile +from Sketch.warn import INTERNAL, warn_tb + ################################################## # Font routines ################################################## @@ -59,6 +61,8 @@ fixed_font = copy.deepcopy(normal_font) fixed_font[0] = 'monospace' except: + warn_tb(INTERNAL, "Cannot determine the font from the GTK settings." + " Using helvetica 9 instead") small_font = normal_font = large_font = fixed_font = \ ['helvetica', '', 9] @@ -204,6 +208,9 @@ try: self.import_gtk_colors() except: + warn_tb(INTERNAL, "Cannot determine the colors from the GTK" + " settings. Using built-in color scheme instead") + scheme == BUILTIN_SCHEME def import_gtk_colors(self): From scm-commit at wald.intevation.org Sun Feb 6 21:46:06 2011 From: scm-commit at wald.intevation.org (scm-commit@wald.intevation.org) Date: Sun, 6 Feb 2011 21:46:06 +0100 (CET) Subject: [Skencil-commits] r804 - skencil/branches/skencil-0.6/src/Sketch/Base Message-ID: <20110206204606.367C89504309@pyrosoma.intevation.org> Author: bh Date: 2011-02-06 21:46:06 +0100 (Sun, 06 Feb 2011) New Revision: 804 Modified: skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py Log: Use sys.exectuable as the python interpreter in the gtk subprocesses. This makes the behavior more predictable if multiple python interpreters are installed on a system, because the interpreter used to run Skencil is not necessarily the default interpreter. Modified: skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py =================================================================== --- skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py 2011-02-06 20:40:42 UTC (rev 803) +++ skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py 2011-02-06 20:46:06 UTC (rev 804) @@ -18,6 +18,7 @@ #License along with this library; if not, write to the Free Software #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +import sys import os, string, copy from tempfile import NamedTemporaryFile @@ -44,7 +45,8 @@ tmpfile = NamedTemporaryFile() command = "import gtk;w = gtk.Window();w.realize();" command += "style=w.get_style(); print style.font_desc.to_string();" - if os.system('python -c "%s" >%s' % (command, tmpfile.name)): + if os.system('%s -c "%s" >%s' % (sys.executable, command, + tmpfile.name)): raise Exception font = tmpfile.readline().strip() @@ -241,7 +243,8 @@ " style.bg[gtk.STATE_SELECTED].to_string()," + \ " style.bg[gtk.STATE_INSENSITIVE].to_string();" - if os.system('python -c "%s" >%s' % (command, tmpfile.name)): + if os.system('%s -c "%s" >%s' % (sys.executable, command, + tmpfile.name)): raise Exception for type in ["base", "text", "fg", "bg"]: