mwpath = os.path.dirname(mwidgets.__file__) for mfile in os.listdir(mwpath): if mfile.endswith('.py') and not mfile.startswith('__'): modulename = "{0}.{1}".format(widgets_pkg, mfile[:-3]) importlib.import_module(modulename) #Initilize properties from custom widgets for pname, descr in builder.CUSTOM_PROPERTIES.items(): properties.register_custom(pname, descr) #Initialize images DESIGNER_DIR = os.path.dirname(os.path.abspath(__file__)) IMAGES_DIR = os.path.join(DESIGNER_DIR, "images") StockImage.register_from_dir(IMAGES_DIR) StockImage.register_from_dir( os.path.join(IMAGES_DIR, 'widgets', '22x22'), '22x22-') StockImage.register_from_dir( os.path.join(IMAGES_DIR, 'widgets', '16x16'), '16x16-') #Initialize logger logger = logging.getLogger('pygubu.designer') logger.setLevel(logging.INFO) class StatusBarHandler(logging.Handler): def __init__(self, tklabel, level=logging.NOTSET): super(StatusBarHandler, self).__init__(level) self.tklabel = tklabel self._clear = True
if dirname not in sys.path: sys.path.append(dirname) modulename = fname[:-3] try: importlib.import_module(modulename) except Exception as e: logger.exception(e) msg = _("Failed to load custom widget module: \n'{0}'") msg = msg.format(path) messagebox.showerror(_('Error'), msg) #Initialize images DESIGNER_DIR = os.path.dirname(os.path.abspath(__file__)) IMAGES_DIR = os.path.join(DESIGNER_DIR, "images") StockImage.register_from_dir(IMAGES_DIR) StockImage.register_from_dir(os.path.join(IMAGES_DIR, 'widgets', '22x22'), '22x22-') StockImage.register_from_dir(os.path.join(IMAGES_DIR, 'widgets', '16x16'), '16x16-') class StatusBarHandler(logging.Handler): def __init__(self, tklabel, level=logging.NOTSET): super(StatusBarHandler, self).__init__(level) self.tklabel = tklabel self._clear = True self._cb_id = None def emit(self, record): try:
import tkinter.ttk as ttk import tkinter.font except: import Tkinter as tk import ttk import tkFont tk.font = tkFont from pygubu.stockimage import StockImage, StockImageException from pygubudesigner.widgets.propertyeditor import * RE_FONT = re.compile("(?P<family>\{\w+(\w|\s)*\}|\w+)\s?(?P<size>-?\d+)?\s?(?P<modifiers>\{\w+(\w|\s)*\}|\w+)?") FILE_DIR = os.path.dirname(os.path.abspath(__file__)) IMAGES_DIR = os.path.join(FILE_DIR, "..", "images", "widgets", "fontentry") IMAGES_DIR = os.path.abspath(IMAGES_DIR) StockImage.register_from_dir(IMAGES_DIR) PREDEFINED_FONTS = [ 'TkDefaultFont', 'TkTextFont', 'TkFixedFont', 'TkMenuFont', 'TkHeadingFont', 'TkCaptionFont', 'TkSmallCaptionFont', 'TkIconFont', 'TkTooltipFont'] WIN_FONTS = ( 'system', 'ansi', 'device', 'systemfixed', 'ansifixed', 'oemfixed') MAC_FONTS = ( 'system','application','menu', 'systemSystemFont', 'systemEmphasizedSystemFont', 'systemSmallSystemFont', 'systemSmallEmphasizedSystemFont', 'systemApplicationFont', 'systemLabelFont', 'systemViewsFont', 'systemMenuTitleFont', 'systemMenuItemFont', 'systemMenuItemMarkFont', 'systemMenuItemCmdKeyFont', 'systemWindowTitleFont', 'systemPushButtonFont', 'systemUtilityWindowTitleFont', 'systemAlertHeaderFont',
try: import tkinter as tk import tkinter.ttk as ttk except: import Tkinter as tk import ttk from pygubu.stockimage import StockImage, StockImageException from pygubu.widgets.scrollbarhelper import ScrollbarHelper FILE_DIR = os.path.dirname(os.path.abspath(__file__)) IMAGES_DIR = os.path.join(FILE_DIR, "..", "images", "widgets", "propertyeditor") IMAGES_DIR = os.path.abspath(IMAGES_DIR) StockImage.register_from_dir(IMAGES_DIR) class PropertyEditor(ttk.Frame): def __init__(self, master=None, **kw): self._variable = tk.StringVar() self._initvalue = None self.value = '' ttk.Frame.__init__(self, master, **kw) self._create_ui() def _create_ui(self): pass def _validate(self): return True
DESIGNER_DIR = os.path.dirname(os.path.abspath(__file__)) imgformat = 'images-gif' if tk.TkVersion >= 8.6: imgformat = 'images-png' IMAGES_DIR = os.path.join(DESIGNER_DIR, "images") IMAGE_PATHS = [ #(dir, tag) (IMAGES_DIR, ''), (os.path.join(IMAGES_DIR, imgformat), ''), (os.path.join(IMAGES_DIR, imgformat, 'widgets', '22x22'), '22x22-'), (os.path.join(IMAGES_DIR, imgformat, 'widgets', '16x16'), '16x16-'), (os.path.join(IMAGES_DIR, imgformat, 'widgets', 'fontentry'), ''), ] for dir_, prefix in IMAGE_PATHS: StockImage.register_from_dir(dir_, prefix) class StatusBarHandler(logging.Handler): def __init__(self, app, level=logging.NOTSET): super(StatusBarHandler, self).__init__(level) self.app = app formatter = logging.Formatter('%(asctime)s %(levelname)s:%(message)s', datefmt='%H:%M:%S') self.setFormatter(formatter) def emit(self, record): try: msg = self.format(record) self.app.log_message(msg, record.levelno) except (KeyboardInterrupt, SystemExit):