def get_style(self, key): postfix = '' if self.is_enabled: postfix = 'enabled' else: postfix = 'disabled' return imp.IMP().styles.try_get('{}_{}'.format(key, postfix), style.Style())
def __init__(self, parent=None): # init just one of two supers? Can't call list.__init__() ? # FIXME inconsistent use of super() transformer.Transformer.__init__(self) # self.stroke_width = 1 # TODO style self.style = style.Style() if parent: self.parent = None else: self.parent = parent
def __init__(self, da): # formerly subclassed: gtk.DrawingArea.__init__(self) da.connect("expose_event", self.expose) # TODO scraps for a pixbuf background # global pb # self.connect_after('draw_background', self.draw_background, pb) self.surface = da.window self.da = da # self.da.set_double_buffered(False) # for animation TODO Port.__init__(self) self.style = style.Style()
def load_from_file(self): ls = os.listdir(utils.musicpath) if not os.path.isfile(self.listpath): utils.dumpjsonfile(self.listpath, self.jsondata) else: alldata = utils.loadjsonfile(self.listpath) if "songs" in alldata: self.allsongs = { k: Song(k, dict=v) for k, v in alldata["songs"].items() } else: print("Didn't find any songs in songs.json") if "lostfiles" in alldata: prevlost = alldata["lostfiles"] else: prevlost = {} for fn in ls: if not fn.endswith('.ogg'): continue if fn not in self.allsongs: if fn in prevlost: self.allsongs[fn] = Song(fn, dict=prevlost[fn]) else: self.allsongs[fn] = Song(fn) print("added new song: " + fn) if fn in self.allsongs and fn in prevlost: del (prevlost[fn]) self.lostfiles = {k: Song(k, dict=v) for k, v in prevlost.items()} for fn, s in list(self.allsongs.items()): if not os.path.isfile(s.filepath): print("lost file: " + fn) del (self.allsongs[fn]) self.lostfiles[fn] = s else: for t in s.styles: if t not in self.styles: self.styles[t] = style.Style(t) self.styles[t].addsong(s) if not s.styles: self.tosort.append(s)
def __init__(self, **params): #object.Object.__init__(self) self.connects = {} params.setdefault('decorate', True) params.setdefault('style', {}) params.setdefault('focusable', True) params.setdefault('disabled', False) self.focusable = params['focusable'] self.disabled = params['disabled'] self.rect = pygame.Rect(params.get('x', 0), params.get('y', 0), params.get('width', 0), params.get('height', 0)) s = params['style'] #some of this is a bit "theme-ish" but it is very handy, so these #things don't have to be put directly into the style. for att in ('align', 'valign', 'x', 'y', 'width', 'height', 'color', 'font', 'background'): if att in params: s[att] = params[att] self.style = style.Style(self, s) self.cls = 'default' if 'cls' in params: self.cls = params['cls'] if 'name' in params: import form self.name = params['name'] if hasattr(form.Form, 'form') and form.Form.form != None: form.Form.form.add(self) self.form = form.Form.form if 'value' in params: self.value = params['value'] self.pcls = "" if params['decorate'] != False: if (not pguglobals.app): # TODO - fix this somehow import app print 'gui.widget: creating an App' app.App() pguglobals.app.theme.decorate(self, params['decorate'])
def generate_result(form, user_style=None): """Convert the request to the PTT-style result.""" author = form['author'] date = form['date'] number = form['number'] headline = form['headline'] content = form['content'] if user_style is None: user_style = style.Style() ret = '' ret += style.header(author, number, date, headline) for line in content.split('\n'): if line[:2] == '##': line = user_style.h2(line[2:]) elif line[:1] == '#': line = user_style.h1(line[1:]) ret += line ret += user_style.footer return ret.replace('*[', '\025[')
def __init__(self, window, x=0, y=0, z=0, width=None, height=None): super(GUI, self).__init__() self.window = window self.style = style.Style() # element.Element stuff self.x, self.y, self.z = x, y, z self.width = self.inner_width = width or window.width self.height = self.inner_height = height or window.height self.children = [] # map Element id, class and name to Element self._by_id = {} self._by_class = collections.defaultdict(set) self._by_name = collections.defaultdict(set) # list Element.ids in the order they're registered for tabbing self._focus_order = [] self.debug_display = None self.debug = '--debug' in sys.argv if self.debug: self.debug_display = widgets.Label(self, 'dummy', bgcolor="white", padding=1, width=self.width)
def __init__(self, name=None, health=100): self.name = name self.health = health self.style = style.Style()
def __init__(self, **params): """Create a new Widget instance given the style parameters. Keyword arguments: decorate -- whether to call theme.decorate(self) to allow the theme a chance to decorate the widget. (default is true) style -- a dict of style parameters. x, y -- position parameters width, height -- size parameters align, valign -- alignment parameters, passed along to style font -- the font to use with this widget color -- the color property, if applicable background -- the widget used to paint the background cls -- class name as used by Theme name -- name of widget as used by Form. If set, will call form.add(self,name) to add the widget to the most recently created Form. focusable -- True if this widget can receive focus via Tab, etc. (default is True) disabled -- True of this widget is disabled (defaults is False) value -- initial value """ #object.Object.__init__(self) self.connects = {} params.setdefault('decorate', True) params.setdefault('style', {}) params.setdefault('focusable', True) params.setdefault('disabled', False) self.focusable = params['focusable'] self.disabled = params['disabled'] self.rect = pygame.Rect(params.get('x', 0), params.get('y', 0), params.get('width', 0), params.get('height', 0)) s = params['style'] #some of this is a bit "theme-ish" but it is very handy, so these #things don't have to be put directly into the style. for att in ('align', 'valign', 'x', 'y', 'width', 'height', 'color', 'font', 'background'): if att in params: s[att] = params[att] self.style = style.Style(self, s) self.cls = 'default' if 'cls' in params: self.cls = params['cls'] if 'name' in params: import form self.name = params['name'] if form.Form.form: form.Form.form.add(self) self.form = form.Form.form if 'value' in params: self.value = params['value'] self.pcls = "" if params['decorate'] != False: if (not pguglobals.app): # TODO - fix this somehow import app app.App() pguglobals.app.theme.decorate(self, params['decorate'])
def OpenDocumentText(): doc = OpenDocument('application/vnd.oasis.opendocument.text') doc.text = Text() doc.body.addElement(doc.text) return doc if __name__ == '__main__': import style from text import H, P textdoc = OpenDocumentText() # Styles s = textdoc.styles h1style = style.Style(name="Heading 1", family="paragraph") h1style.addElement( style.TextProperties(attributes={ 'fontsize': "24pt", 'fontweight': "bold" })) s.addElement(h1style) h = H(outlinelevel=1, stylename=h1style, text="Climate change impact in Europe") textdoc.text.addElement(h) p = P( text= "The earth's climate has not changed many times in the course of its long history." )
def get_style(self): if self.is_enabled and self.is_active: return imp.IMP().styles.try_get('btn_active', style.Style()) return super().get_style('default')
def __init__(self, left_top, size, font_style): super().__init__(left_top, size) self.font_style = self.font_style = font_style if font_style else style.Style( ) self.font = self.create_font()
def __init__(self, left_top, size): super().__init__(left_top, size, width=1) self.border_color = imp.IMP().styles.try_get('default_border_enabled', style.Style()).color self.inner_rect = Rect((self.left + 1, self.top + 1), (self.w - 2, self.h - 2))