def __init__(self): _path = path.dirname(sys.modules[self.__module__].__file__) _conf_filename = '%s/config' %_path _conf_dict = { 'Menu': {'Layer': 'gimp-layer*'}, 'Templates': {'Get first layer': 'layer = image.layers[0]'} } if not(path.isfile(_conf_filename)): self._create_conf_file(_conf_filename, _conf_dict) self.config = ConfigParser() self.config.read(_conf_filename) self._check_conf(_conf_filename, _conf_dict) self.ui = gtk.Builder() self.ui.set_translation_domain('GEB') self.ui.add_from_file('%s/batch_ex.ui' %_path) self.ui.connect_signals(self) self.status = self.ui.get_object('status') #Check Gimp version and updade syntax file, if needed self._check_syntax('%s/python-fu.xml' %_path) add_syntax_path(_path) buff = CodeBuffer(lang=SyntaxLoader("python-fu")) self.ui.get_object('code').set_buffer(buff) buff.connect('changed', self.code_changed) self.base = shelve.open('%s/batch_base' %_path) self._get_macro_list() self._ckey = "" self.browse_dlg = None # Menu self._create_menu() # colors self.red_color = pango.AttrList() self.red_color.insert(pango.AttrForeground(65535, 0, 0, 0, -1)) self.red_color.insert(pango.AttrWeight(pango.WEIGHT_HEAVY, 0, -1)) self.green_color = pango.AttrList() self.green_color.insert(pango.AttrForeground(0, 65535, 0, 0, -1)) self.green_color.insert(pango.AttrWeight(pango.WEIGHT_HEAVY, 0, -1)) self.blue_color = pango.AttrList() self.blue_color.insert(pango.AttrForeground(0, 0, 65535, 0, -1)) self.blue_color.insert(pango.AttrWeight(pango.WEIGHT_HEAVY, 0, -1)) # Log self._log = self.ui.get_object('log').get_buffer() self._log.create_tag('alert', foreground='red', weight=700) self._log.create_tag('ok', foreground='black') self._log.create_tag('done', foreground='blue', weight=700) self._set_status(ST_NEW) self.format_changed(self.ui.get_object('format_combo')) self._add_log(_('GEB started!'), 'done')
def _setupTextbuffer(self): #import pdb; pdb.set_trace() from gtkcodebuffer import CodeBuffer, SyntaxLoader, add_syntax_path # comment-out if CodeBuffer is installed add_syntax_path("%s/syntax" % os.path.dirname(__file__)) lang = SyntaxLoader("python") self._textbuffer = buff = CodeBuffer(lang=lang) self._textview.set_buffer(self._textbuffer) for k, txt in shell.EXAMPLES: buff.insert(buff.get_end_iter(), txt) # hack - clicking when not focused doesn't set the cursor self._cur = None
#!/usr/bin/env python # System modules import sys,os import unittest import threading, time import gtk # TREX modules import TREX.util from TREX.core.assembly import Assembly,Entity,Rule,Token,Slot,Variable # GTKCodeBuffer for doing syntax hilighting for NDDL file display from gtkcodebuffer import CodeBuffer, SyntaxLoader, add_syntax_path add_syntax_path(TREX.util.trex_path("tools/ext/PyGTKCodeBuffer-1.0-RC2/syntax")) ############################################################################## # PropertyWindow # This window provides a user with a list of token or rule variables. ############################################################################## # Spawn a property window def PropertyWindowFactory(assembly,entity): if entity not in PropertyWindow.window_dict: # Create new window property_window = PropertyWindow(assembly,entity) # Add it to the dict PropertyWindow.window_dict[entity] = property_window else: PropertyWindow.window_dict[entity].present()
__version__ = "0.0.1" __author__ = "Harry van Haaren <*****@*****.**>" #--- I realize this is program is quite messy and sloppy,it has thought me a lot about python, # And in my next project, I do think that I will adhere to the OOP standards a bit more ;) #--- Define sys.path so it loads LOCAL modules before modules in /usr/lib/python #--- Allows me to have a "customized" colour scheme by editing gtkcodebuffer.py in the syntax folder. sys.path.insert(0,"./lib/") sys.path.insert(0,"./lib/codebuffer/") sys.path.insert(0,"./lib/resources/") import compile import gtkcodebuffer #-- Must be loaded AFTER sys.path.insert. Otherwise the wrong version is used. import serial #-- Same. gtkcodebuffer.add_syntax_path("./lib/codebuffer/syntax") # Must be done after importing the module. print "" if DEBUG: print "Serial loaded from:",serial.__file__ if DEBUG: print "Compile loaded from:", compile.__file__ if DEBUG: print "GtkCodeBuffer loaded from:",gtkcodebuffer.__file__ if DEBUG: print "" #--- Start Main Program print "Click Connect to turn on Serial Monitoring." class main: # --- Default Enviromental Variables --- Filename = "" arduinoLocation = "/dev/ttyUSB0"
__version__ = "0.0.1" __author__ = "Harry van Haaren <*****@*****.**>" #--- I realize this is program is quite messy and sloppy,it has thought me a lot about python, # And in my next project, I do think that I will adhere to the OOP standards a bit more ;) #--- Define sys.path so it loads LOCAL modules before modules in /usr/lib/python #--- Allows me to have a "customized" colour scheme by editing gtkcodebuffer.py in the syntax folder. sys.path.insert(0, "./lib/") sys.path.insert(0, "./lib/codebuffer/") sys.path.insert(0, "./lib/resources/") import compile import gtkcodebuffer #-- Must be loaded AFTER sys.path.insert. Otherwise the wrong version is used. import serial #-- Same. gtkcodebuffer.add_syntax_path( "./lib/codebuffer/syntax") # Must be done after importing the module. print "" if DEBUG: print "Serial loaded from:", serial.__file__ if DEBUG: print "Compile loaded from:", compile.__file__ if DEBUG: print "GtkCodeBuffer loaded from:", gtkcodebuffer.__file__ if DEBUG: print "" #--- Start Main Program print "Click Connect to turn on Serial Monitoring." class main: # --- Default Enviromental Variables --- Filename = "" arduinoLocation = "/dev/ttyUSB0"
#!/usr/bin/python import gtk import sys # comment-out if CodeBuffer is installed sys.path.insert(0, "..") from gtkcodebuffer import CodeBuffer, SyntaxLoader, add_syntax_path # comment-out if CodeBuffer is installed add_syntax_path("../syntax") lang = SyntaxLoader("python") buff = CodeBuffer(lang=lang) win = gtk.Window(gtk.WINDOW_TOPLEVEL) scr = gtk.ScrolledWindow() win.add(scr) scr.add(gtk.TextView(buff)) win.set_default_size(300,200) win.show_all() win.connect("destroy", lambda w: gtk.main_quit()) buff.set_text(open(__file__,'r').read()) gtk.main()
#!/usr/bin/python import gtk # not needed if you have codebuffer installed: import sys sys.path.insert(0, "..") from gtkcodebuffer import CodeBuffer, SyntaxLoader, add_syntax_path # also not needed if installed: add_syntax_path("../syntax/") txt = """ # About This example shows you a markdown with XML file syntax-definition. Supporting `code-segments`, **emphasized text** or *emphasized text*. Alterative emphasis style: _single underscores_ and __double underscores__. Note that a variable like some_stuff_list is not _emphasized_. See "Middle-World Emphasis" at <http://www.freewisdom.org/projects/python-markdown/Features> along with <http://six.pairlist.net/pipermail/markdown-discuss/2005-October/001610.html> This is simply multiplication, 3 * 23 + constant * 11 = x. I.e. it is not emphasized.