Change graphicView text

Hi, i start building a plugin, and i tried to change the text in the graphicview

my code

# -*- coding: utf-8 -*-
"""Converts make Random Text."""
import random


Font = Glyphs.font
Doc = Glyphs.currentDocument
TextStoreage = Doc.windowController().activeEditViewController().graphicView().textStorage()
String = TextStoreage.text().string()
Range = Doc.windowController().activeEditViewController().graphicView().selectedRange()
if Range.length <= 0:
	Range.location = 0
	Range.length = len(String)

str='book pen paper pencil'

charString = Font.charStringFromDisplayString_(editString)
TextStoreage.replaceCharactersInRange_withString_(Range, random.choice(x))

once the random generator repeating the pervious value the script crashes

how can i change the text directly ?


What is editString in your example?

Sorry i tried to clean the code i forgot to delete
this part, you can just ignore this line

charString = Font.charStringFromDisplayString_(editString)

You can access a tab’s content directly with Glyphs.currentTab.text, both for getting and setting. No need to go the PyObjC way here. Does this help?

Yes it works, i correct your code to

Glyphs.font.currentTab.text ='your text here '

thank you