(self, app_window, def_text='', placeholder_text='', file=None, flags=None, *args, **kwargs)
self.editor_font = QFont()
        self.editor_font.setFamily('Courier')
        self.editor_font.setFixedPitch(True)
self.editor_font = QFont()
        self.editor_font.setFamily('Courier')
        self.editor_font.setFixedPitch(True)
self . editor_font = QFont () self . editor_font . setFamily ( Courier ) self . editor_font . setFixedPitch ( True )
def __init__(self, app_window, def_text='', placeholder_text='', file=None, flags=None, *args, **kwargs):
        super().__init__(flags, *args, **kwargs)

        self.title = 'CodeEditor'
        self._app_window = app_window
        self.file = file

        font_size_pref = self._app_window.prefs.get('dwarf_ui_theme_editor_fs')
        if font_size_pref:
            try:
                font_size_pref = int(font_size_pref)
            except ValueError:
                # default size
                font_size_pref = 11

        # todo: add font selector
        self.editor_font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
        """
        self.editor_font = QFont()
        self.editor_font.setFamily('Courier')
        self.editor_font.setFixedPitch(True)
        """

        if font_size_pref:
            if font_size_pref >= 9 and font_size_pref <= 15:
                self.editor_font.setPointSize(font_size_pref)
            else:
                self.editor_font.setPointSize(11)
        else:
            # default size
            self.editor_font.setPointSize(11)

        self.input_widget = JsCodeEditor(completer=False)
        self.input_widget.setMinimumSize(800, 450)
        self.input_widget.line_numbers = True
        self.input_widget.setFont(self.editor_font)
        self.input_widget.setPlainText(def_text)
        self.input_widget.setPlaceholderText(placeholder_text)

        layout = QVBoxLayout()
        top_buttons = QHBoxLayout()
        bottom_buttons = QHBoxLayout()

        open_button = QPushButton('open')
        open_button.clicked.connect(self.handler_open)
        top_buttons.addWidget(open_button)
        if file is None:
            self.btn_save = QPushButton('save')
            self.btn_save.clicked.connect(self.handler_save)
            top_buttons.addWidget(self.btn_save)
        dwarf = QPushButton('dwarf')
        dwarf.clicked.connect(self.handler_dwarf_scripts)
        top_buttons.addWidget(dwarf)

        inject = QPushButton('inject')
        inject.clicked.connect(self.handler_inject)
        bottom_buttons.addWidget(inject)

        box = QHBoxLayout()
        fzl = QLabel('Font Size (pt):')
        fzl.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        fzl.setFixedWidth(100)
        box.addWidget(fzl)
        font_size = QSpinBox()
        font_size.setRange(9, 15)
        font_size.setSingleStep(1)
        font_size.setValue(self.editor_font.pointSize())
        font_size.setFixedWidth(40)
        font_size.valueChanged.connect(self.change_font_size)
        box.addWidget(font_size)
        bottom_buttons.addLayout(box)

        layout.addLayout(top_buttons)
        layout.addWidget(self.input_widget)
        layout.addLayout(bottom_buttons)

        #self.setMinimumWidth(app.width() - (app.width() / 10))
        #self.setMinimumHeight(app.height() - (app.height() / 10))

        self.setLayout(layout)
def __init__ ( self , app_window , def_text = '' , placeholder_text = '' , file = None , flags = None , * args , * * kwargs ) : super ( ) . __init__ ( flags , * args , * * kwargs ) self . title = 'CodeEditor' self . _app_window = app_window self . file = file font_size_pref = self . _app_window . prefs . get ( 'dwarf_ui_theme_editor_fs' ) if font_size_pref : try : font_size_pref = int ( font_size_pref ) except ValueError : # default size font_size_pref = 11 # todo: add font selector self . editor_font = QFontDatabase . systemFont ( QFontDatabase . FixedFont ) if font_size_pref : if font_size_pref >= 9 and font_size_pref <= 15 : self . editor_font . setPointSize ( font_size_pref ) else : self . editor_font . setPointSize ( 11 ) else : # default size self . editor_font . setPointSize ( 11 ) self . input_widget = JsCodeEditor ( completer = False ) self . input_widget . setMinimumSize ( 800 , 450 ) self . input_widget . line_numbers = True self . input_widget . setFont ( self . editor_font ) self . input_widget . setPlainText ( def_text ) self . input_widget . setPlaceholderText ( placeholder_text ) layout = QVBoxLayout ( ) top_buttons = QHBoxLayout ( ) bottom_buttons = QHBoxLayout ( ) open_button = QPushButton ( 'open' ) open_button . clicked . connect ( self . handler_open ) top_buttons . addWidget ( open_button ) if file is None : self . btn_save = QPushButton ( 'save' ) self . btn_save . clicked . connect ( self . handler_save ) top_buttons . addWidget ( self . btn_save ) dwarf = QPushButton ( 'dwarf' ) dwarf . clicked . connect ( self . handler_dwarf_scripts ) top_buttons . addWidget ( dwarf ) inject = QPushButton ( 'inject' ) inject . clicked . connect ( self . handler_inject ) bottom_buttons . addWidget ( inject ) box = QHBoxLayout ( ) fzl = QLabel ( 'Font Size (pt):' ) fzl . setAlignment ( Qt . AlignRight | Qt . AlignVCenter ) fzl . setFixedWidth ( 100 ) box . addWidget ( fzl ) font_size = QSpinBox ( ) font_size . setRange ( 9 , 15 ) font_size . setSingleStep ( 1 ) font_size . setValue ( self . editor_font . pointSize ( ) ) font_size . setFixedWidth ( 40 ) font_size . valueChanged . connect ( self . change_font_size ) box . addWidget ( font_size ) bottom_buttons . addLayout ( box ) layout . addLayout ( top_buttons ) layout . addWidget ( self . input_widget ) layout . addLayout ( bottom_buttons ) #self.setMinimumWidth(app.width() - (app.width() / 10)) #self.setMinimumHeight(app.height() - (app.height() / 10)) self . setLayout ( layout )