src/eric7/MicroPython/MicroPythonWindow.py

branch
eric7
changeset 10523
e4069ddd7dc7
parent 10518
1682f3203ae5
child 10683
779cda568acb
equal deleted inserted replaced
10522:c04e878aa308 10523:e4069ddd7dc7
41 41
42 class MicroPythonWindow(EricMainWindow): 42 class MicroPythonWindow(EricMainWindow):
43 """ 43 """
44 Class implementing the standalone MicroPython window. 44 Class implementing the standalone MicroPython window.
45 45
46 @signal editorCountChanged(count) emitted whenever the count of open editors
47 changed
46 @signal preferencesChanged() emitted after the preferences were changed 48 @signal preferencesChanged() emitted after the preferences were changed
47 """ 49 """
48 50
51 editorCountChanged = pyqtSignal(int)
49 preferencesChanged = pyqtSignal() 52 preferencesChanged = pyqtSignal()
50 53
51 def __init__(self, parent=None): 54 def __init__(self, parent=None):
52 """ 55 """
53 Constructor 56 Constructor
303 editor = MiniEditor(filename=fn, parent=self) 306 editor = MiniEditor(filename=fn, parent=self)
304 editor.closing.connect(lambda: self.__editorClosing(editor)) 307 editor.closing.connect(lambda: self.__editorClosing(editor))
305 editor.show() 308 editor.show()
306 309
307 self.__editors.append(editor) 310 self.__editors.append(editor)
311 self.editorCountChanged.emit(len(self.__editors))
308 312
309 def newEditorWithText(self, text, language="", fileName=""): 313 def newEditorWithText(self, text, language="", fileName=""):
310 """ 314 """
311 Public method to generate a new editor with a given text and associated file 315 Public method to generate a new editor with a given text and associated file
312 name. 316 name.
323 editor.setText(text, filetype=language) 327 editor.setText(text, filetype=language)
324 editor.setLanguage(fileName) 328 editor.setLanguage(fileName)
325 editor.show() 329 editor.show()
326 330
327 self.__editors.append(editor) 331 self.__editors.append(editor)
332 self.editorCountChanged.emit(len(self.__editors))
328 333
329 def __editorClosing(self, editor): 334 def __editorClosing(self, editor):
330 """ 335 """
331 Private method called, when an editor is closing. 336 Private method called, when an editor is closing.
332 337
334 @type MiniEditor 339 @type MiniEditor
335 """ 340 """
336 with contextlib.suppress(ValueError): 341 with contextlib.suppress(ValueError):
337 self.__editors.remove(editor) 342 self.__editors.remove(editor)
338 del editor 343 del editor
344 self.editorCountChanged.emit(len(self.__editors))
339 345
340 if self.__editors: 346 if self.__editors:
341 # make the last one (i.e. most recently opened one) the active editor 347 # make the last one (i.e. most recently opened one) the active editor
342 self.__activeEditor = self.__editors[-1] 348 self.__activeEditor = self.__editors[-1]
343 else: 349 else:
344 self.__activeEditor = None 350 self.__activeEditor = None
351
352 def getOpenEditorsCount(self):
353 """
354 Public method to get the number of open editors.
355
356 @return number of open editors
357 @rtype int
358 """
359 return len(self.__editors)
345 360
346 @pyqtSlot(QWidget, QWidget) 361 @pyqtSlot(QWidget, QWidget)
347 def __appFocusChanged(self, old, now): 362 def __appFocusChanged(self, old, now):
348 """ 363 """
349 Private slot to track the application focus. 364 Private slot to track the application focus.

eric ide

mercurial