This topic contains 10 replies, has 2 voices, and was last updated by frederik 6 years, 5 months ago.
-
AuthorPosts
-
April 16, 2014 at 07:17 #5852
is it possible to add a line break in GlyphLineView?
or do I have to use MultiLineView then?
thank you!
April 16, 2014 at 07:33 #5853I just realized that GlyphLineView comes from DefconAppKit – so I guess I have to use MultiLineView.
April 16, 2014 at 07:35 #5854Space center is a multi line view, add “\n” in you input string and a new line is being added
good luck!
April 16, 2014 at 08:01 #5856thank you – that is clear! I am appending glyphs to a list which are displayed by a MultiLineView. Maybe you can help how I can do that in this case? do i have to somehow use: createNewLineGlyph(self)? thank you!
April 16, 2014 at 11:58 #5858I would use a spaceCenter object to manage input and change it there
from mojo.UI import OpenSpaceCenter # open a space center or get the current one spaceCenter = OpenSpaceCenter(CurrentFont()) # get the input as a list print spaceCenter.get() # get the input as raw string (same as you see in the edit text view) print spaceCenter.getRaw() # set the input as raw string spaceCenter.setRaw("hello\\nworld")
April 16, 2014 at 13:41 #5861Unfortunately I have to use MultiLineView or GlyphLineView – which only displays glyphs (setGlyphs) – so I guess there is no easy solution.
April 16, 2014 at 14:43 #5862oke, you want to use a MultiLineView, I misunderstood :)
a small example:
from mojo.UI import MultiLineView from vanilla import * inputText = """Hello world""" class LineController(object): def __init__(self): self.w = Window((400, 400), minSize=(200, 200)) self.w.lineView = MultiLineView((0, 0, -0, -0)) font = CurrentFont() charMap = font.getCharacterMapping() glyphs = [] for char in inputText: if char == "\n": glyph = self.w.lineView.createNewLineGlyph() else: uni = ord(char) glyphName = charMap.get(uni) if glyphName: glyphName = glyphName[0] glyph = font[glyphName] glyphs.append(glyph) self.w.lineView.set(glyphs) self.w.open() LineController()
April 16, 2014 at 15:13 #5863great!
thats what i needed! thanks!if you could (whenever you find time) show how to setDisplayStates, that would be awesome!
April 20, 2014 at 11:41 #5870see what the
getDisplayStates()
returns :)from mojo.UI import MultiLineView view = MultiLineView((0, 0, 0, 0)) print view.getDisplayStates()
{ 'Inverse': False, 'xHeight Cut': False, 'Show Kerning': True, 'Left to Right': True, 'Show Metrics': False, 'Show Space Matrix': True, 'Upside Down': False, 'Right to Left': False, 'Stroke': False, 'Beam': False, 'Water Fall': False, 'Multi Line': True, 'Single Line': False, 'Show Control glyphs': False, 'Fill': True }
good luck
April 21, 2014 at 08:57 #5871Thank you, Frederik!
this is more than clear – but I was never able to set them – not sure if this is the right way – e.g.view.setDisplayStates({‘Inverse’: True})
if you then:
print view.getDisplayStates()
nothing changed.April 29, 2014 at 07:16 #5876I see
bug will be solved in the next update
good luck
-
AuthorPosts
You must be logged in to reply to this topic.