def paintEvent(self, event): """QToolBar.paintEvent reimplementation Draws buttons, dock icon and text """ rect = self._spacer.rect() painter = QPainter(self) transform = QTransform() transform.translate(self._spacer.pos().x(), self._spacer.pos().y()) painter.setTransform(transform) """ Not supported currently if self._dock.features() & QDockWidget.DockWidgetVerticalTitleBar : transform = QTransform() rect.setSize(QSize(rect.height(), rect.width())) transform.rotate(-90) transform.translate(-rect.width(), 0) painter.setTransform(transform) """ # icon / title optionB = QStyleOptionButton() optionB.initFrom(self._dock) optionB.rect = rect optionB.text = self._dock.windowTitle() optionB.iconSize = self.iconSize() optionB.icon = self._dock.windowIcon() self.style().drawControl(QStyle.CE_PushButtonLabel, optionB, painter, self._dock)
def __updateText(self): self.prepareGeometryChange() if self.__sourceName or self.__sinkName: if self.__sourceName != self.__sinkName: text = u"{0} \u2192 {1}".format(self.__sourceName, self.__sinkName) else: # If the names are the same show only one. # Is this right? If the sink has two input channels of the # same type having the name on the link help elucidate # the scheme. text = self.__sourceName else: text = "" self.linkTextItem.setPlainText(text) path = self.curveItem.path() if not path.isEmpty(): center = path.pointAtPercent(0.5) angle = path.angleAtPercent(0.5) brect = self.linkTextItem.boundingRect() transform = QTransform() transform.translate(center.x(), center.y()) transform.rotate(-angle) # Center and move above the curve path. transform.translate(-brect.width() / 2, -brect.height()) self.linkTextItem.setTransform(transform)
class Curve1(Curve): def __init__(self): Curve.__init__(self) self.setPen( QColor( 150, 150, 200 ), 2 ) self.setStyle( Qwt.QwtPlotCurve.Lines ) curveFitter = Qwt.QwtSplineCurveFitter() curveFitter.setSplineSize( 150 ) self.setCurveFitter( curveFitter ) self.setCurveAttribute( Qwt.QwtPlotCurve.Fitted, True ) symbol = Qwt.QwtSymbol( Qwt.QwtSymbol.XCross ) symbol.setPen( Qt.yellow ) symbol.setSize( 7 ) self.setSymbol( symbol ) # somewhere to the left self.transform = QTransform() self.transform.scale( 1.5, 1.0 ); self.transform.translate( 1.5, 3.0 ); self.setTransformation( self.transform ) def points(self, phase ): pnts = QPolygonF() numSamples = 15; for i in range(numSamples): v = 6.28 * i / ( numSamples - 1 ) pnts += QPointF( math.sin( v - phase ), v ) return pnts def updateSamples( self, phase ): self.setSamples( self.d_transform.map( self.points( phase )))
def paintEvent(self, event ): """QToolBar.paintEvent reimplementation Draws buttons, dock icon and text """ rect = self._spacer.rect() painter = QPainter( self ) transform = QTransform() transform.translate(self._spacer.pos().x(), self._spacer.pos().y()) painter.setTransform( transform ) """ Not supported currently if self._dock.features() & QDockWidget.DockWidgetVerticalTitleBar : transform = QTransform() rect.setSize( QSize( rect.height(), rect.width() ) ) transform.rotate( -90 ) transform.translate( -rect.width(), 0 ) painter.setTransform( transform ) """ # icon / title optionB = QStyleOptionButton() optionB.initFrom( self._dock ) optionB.rect = rect optionB.text = self._dock.windowTitle() optionB.iconSize = self.iconSize() optionB.icon = self._dock.windowIcon() self.style().drawControl( QStyle.CE_PushButtonLabel, optionB, painter, self._dock )
def updateTransfrom( self ): if self.updating : return self.updating = True trans = QTransform() trans.translate( self.valueToX( -self.scrollX ) + self.offsetX, self.valueToY( -self.scrollY ) ) self.setTransform( trans ) self.update() self.updating = False
def updateTransfrom(self): if self.updating: return self.updating = True trans = QTransform() trans.translate( self.valueToX(-self.scrollX) + self.offsetX, self.valueToY(-self.scrollY)) self.setTransform(trans) self.update() self.updating = False
def __init__(self): Curve.__init__(self) self.d_points = QPolygonF() self.setStyle( Qwt.QwtPlotCurve.Lines ) self.setPen( Qt.red, 2 ) self.initSamples() # somewhere in the center transform = QTransform() transform.translate( 7.0, 3.0 ) transform.scale( 1.5, 1.5 ) self.setTransformation( transform )
def transform(self): try: return self.__dict__['transform'] if self.scale else QTransform() except KeyError: transform = QTransform() image = self.client.image if image is not None and not image.isNull(): scale = min(self.width()/image.width(), self.height()/image.height()) transform.translate((self.width() - image.width()*scale)/2, (self.height() - image.height()*scale)/2) transform.scale(scale, scale) transform = self.__dict__.setdefault('transform', transform) return transform
def transform(self): try: return self.__dict__['transform'] if self.scale else QTransform() except KeyError: transform = QTransform() image = self.client.image if image is not None and not image.isNull(): scale = min(self.width() / image.width(), self.height() / image.height()) transform.translate( (self.width() - image.width() * scale) / 2, (self.height() - image.height() * scale) / 2) transform.scale(scale, scale) transform = self.__dict__.setdefault('transform', transform) return transform
def setImageMove(self, scale, pos, angle): log_debug("New scale = %s" % (scale,)) self.scale = scale self.min_scale = self.data_manager.minScale() self.img_scale = (scale[0]/self.min_scale, scale[1]/self.min_scale) back_matrix = QTransform() back_matrix.scale(*self.img_scale) back_matrix.translate(pos.x(), pos.y()) back_matrix.rotate(angle) self.back_matrix = back_matrix rect = back_matrix.mapRect(QRectF(self.background_image.rect())) inv, ok = back_matrix.inverted() if not ok: raise ValueError("The movement is not invertible !?!") self.invert_back_matrix = inv self.real_scene_rect = rect
def paintEvent(self, event): painter = QPainter(self) painter.fillRect(self.rect(), QColor('#101010')) image = self._image if image is not None: if self.height() < 240: fast_scaler = QTransform() scale = 297 / image.height() if self.mirror: fast_scaler.scale(-scale, scale) else: fast_scaler.scale(scale, scale) rect = event.rect() painter.drawPixmap( rect, QPixmap.fromImage( image.transformed(fast_scaler)).scaledToHeight( self.height(), Qt.SmoothTransformation), rect) else: transform = QTransform() scale = min(self.width() / image.width(), self.height() / image.height()) if self.mirror: transform.translate( (self.width() + image.width() * scale) / 2, (self.height() - image.height() * scale) / 2) transform.scale(-scale, scale) else: transform.translate( (self.width() - image.width() * scale) / 2, (self.height() - image.height() * scale) / 2) transform.scale(scale, scale) inverse_transform, invertible = transform.inverted() rect = inverse_transform.mapRect(event.rect()).adjusted( -1, -1, 1, 1).intersected(image.rect()) painter.setTransform(transform) if self.height() > 400: painter.drawPixmap(rect, QPixmap.fromImage(image), rect) else: painter.drawImage(rect, image, rect) painter.end()
def __init__(self): Curve.__init__(self) self.setStyle( Qwt.QwtPlotCurve.Lines ) self.setPen( QColor( 100, 200, 150 ), 2 ) curveFitter = Qwt.QwtSplineCurveFitter() curveFitter.setFitMode( Qwt.QwtSplineCurveFitter.ParametricSpline ) curveFitter.setSplineSize( 200 ) self.setCurveFitter( curveFitter ) self.setCurveAttribute( Qwt.QwtPlotCurve.Fitted, True ) # somewhere in the top right corner transform = QTransform() transform.translate( 7.0, 7.5 ) transform.scale( 2.0, 2.0 ) self.setTransformation( transform )
def paintEvent(self, event): """ On paint event @param txt: @type txt: """ painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing) size = QSize(1, 1) size.scale(self.width() - 1, self.height() - 1, Qt.KeepAspectRatio) matrix = QTransform() matrix.translate((self.width() - size.width()) / 2, (self.height() - size.height()) / 2) painter.setWorldTransform(matrix) self.__startAngle = 0 for __data in self.__datas: self.drawData(painter, size, __data[0], __data[1], __data[2]) self.__startAngle = 0 for __data in self.__datas: self.drawText(painter, size, __data[0], __data[1], __data[2])
def paintEvent(self, event): painter = QPainter(self) painter.fillRect(self.rect(), QColor('#101010')) image = self._image if image is not None: if self.height() < 240: fast_scaler = QTransform() scale = 297/image.height() if self.mirror: fast_scaler.scale(-scale, scale) else: fast_scaler.scale(scale, scale) rect = event.rect() painter.drawPixmap(rect, QPixmap.fromImage(image.transformed(fast_scaler)).scaledToHeight(self.height(), Qt.SmoothTransformation), rect) else: transform = QTransform() scale = min(self.width()/image.width(), self.height()/image.height()) if self.mirror: transform.translate((self.width() + image.width()*scale)/2, (self.height() - image.height()*scale)/2) transform.scale(-scale, scale) else: transform.translate((self.width() - image.width()*scale)/2, (self.height() - image.height()*scale)/2) transform.scale(scale, scale) inverse_transform, invertible = transform.inverted() rect = inverse_transform.mapRect(event.rect()).adjusted(-1, -1, 1, 1).intersected(image.rect()) painter.setTransform(transform) if self.height() > 400: painter.drawPixmap(rect, QPixmap.fromImage(image), rect) else: painter.drawImage(rect, image, rect) painter.end()
def paintEvent(self, event): painter = QPainter(self) width = self.width() height = self.height() if DEBUG: painter.fillRect(0, 0, width, height, Qt.blue) else: painter.fillRect(event.rect(), self.plot.canvas_color) y_min_scale = self.plot.y_scale.value_min y_max_scale = self.plot.y_scale.value_max factor_x = float(width) / self.plot.x_diff factor_y = float(height - 1) / max( y_max_scale - y_min_scale, EPSILON) # -1 to accommodate the 1px width of the curve if self.plot.x_min != None and self.plot.x_max != None: x_min = self.plot.x_min x_max = self.plot.x_max if self.plot.curve_start == 'left': curve_x_offset = 0 else: curve_x_offset = round( (self.plot.x_diff - (x_max - x_min)) * factor_x) transform = QTransform() transform.translate( curve_x_offset, height - 1 + self.plot.curve_y_offset ) # -1 to accommodate the 1px width of the curve transform.scale(factor_x, -factor_y) transform.translate(-x_min, -y_min_scale) if self.plot.curve_motion_granularity > 1: self.plot.partial_update_width = math.ceil( transform.map(QLineF(0, 0, 1.5, 0)).length()) inverted_event_rect = transform.inverted()[0].mapRect( QRectF(event.rect())) painter.save() painter.setTransform(transform) if False and self.plot.curves_visible[0]: # Currently unused support for bar graphs. # If we need this later on we should add an option to the # PlotWidget for it. # I tested this for the Sound Pressure Level Bricklet and it works, # but it didnt't look good. curve_x = self.plot.curves_x[0] curve_y = self.plot.curves_y[0] t = time.time() if self.max_points == None: self.max_points = [] for y in curve_y: self.max_points.append((t, y)) else: for i in range(len(curve_y)): if (curve_y[i] > self.max_points[i][1]) or ( (t - self.max_points[i][0]) > 5): self.max_points[i] = (t, curve_y[i]) for i in range(len(self.plot.curves_x[0])): painter.setPen(self.plot.curve_configs[0].color) painter.drawLine(QPoint(curve_x[i], 0), QPoint(curve_x[i], curve_y[i])) painter.setPen(Qt.white) painter.drawLine(QPoint(curve_x[i], curve_y[i]), QPoint(curve_x[i], y_max_scale)) painter.setPen(Qt.darkGreen) painter.drawPoint(QPoint(curve_x[i], self.max_points[i][1])) else: for c in range(len(self.plot.curves_x)): if not self.plot.curves_visible[c]: continue curve_x = self.plot.curves_x[c] curve_y = self.plot.curves_y[c] path = QPainterPath() lineTo = path.lineTo if self.plot.curve_motion_granularity > 1: start = max( min( bisect.bisect_left(curve_x, inverted_event_rect.left()), len(curve_x) - 1) - 1, 0) else: start = 0 path.moveTo(curve_x[start], curve_y[start]) for i in xrange(start + 1, len(curve_x)): lineTo(curve_x[i], curve_y[i]) painter.setPen(self.plot.curve_configs[c].color) painter.drawPath(path) painter.restore()
def paintEvent(self, event): painter = QPainter(self) width = self.width() height = self.height() if DEBUG: painter.fillRect(0, 0, width, height, Qt.blue) else: painter.fillRect(event.rect(), self.plot.canvas_color) y_min_scale = self.plot.y_scale.value_min y_max_scale = self.plot.y_scale.value_max factor_x = float(width) / self.plot.history_length_x factor_y = float(height - 1) / max( y_max_scale - y_min_scale, EPSILON ) # -1 to accommodate the 1px width of the curve if self.plot.x_min != None and self.plot.x_max != None: x_min = self.plot.x_min x_max = self.plot.x_max if self.plot.curve_start == "left": curve_x_offset = 0 else: curve_x_offset = round((self.plot.history_length_x - (x_max - x_min)) * factor_x) transform = QTransform() transform.translate( curve_x_offset, height - 1 + self.plot.curve_y_offset ) # -1 to accommodate the 1px width of the curve transform.scale(factor_x, -factor_y) transform.translate(-x_min, -y_min_scale) if self.plot.curve_motion_granularity > 1: self.plot.partial_update_width = math.ceil(transform.map(QLineF(0, 0, 1.5, 0)).length()) inverted_event_rect = transform.inverted()[0].mapRect(QRectF(event.rect())) painter.save() painter.setTransform(transform) for c in range(len(self.plot.curves_x)): if not self.plot.curves_visible[c]: continue curve_x = self.plot.curves_x[c] curve_y = self.plot.curves_y[c] path = QPainterPath() lineTo = path.lineTo if self.plot.curve_motion_granularity > 1: start = max(min(bisect.bisect_left(curve_x, inverted_event_rect.left()), len(curve_x) - 1) - 1, 0) else: start = 0 path.moveTo(curve_x[start], curve_y[start]) for i in xrange(start + 1, len(curve_x)): lineTo(curve_x[i], curve_y[i]) painter.setPen(self.plot.configs[c][1]) painter.drawPath(path) painter.restore()
class QTerminalWidget(QWidget): # color scheme: normal_foreground, normal_background, inverse_foreground, inverse_background, cursor_color color_scheme_names = { "white" : 0, "amber" : 1, "green": 2 } color_schemes= [ [ QColor("#000"),QColor("#fff"), QColor(0xff,0xff, 0xff,0xc0) ], [ QColor("#000"), QColor("#ffbe00"), QColor(0xff, 0xbe, 0x00,0xc0) ], [ QColor("#000"), QColor("#18f018"), QColor(0x00,0xff,0x00,0xc0) ], ] # # Keymap keycodes # keymap = { Qt.Key_Backspace: chr(127), Qt.Key_Escape: chr(27), Qt.Key_AsciiTilde: "~~", Qt.Key_Up: "~A", Qt.Key_Down: "~B", Qt.Key_Left: "~D", Qt.Key_Right: "~C", Qt.Key_PageUp: "~1", Qt.Key_PageDown: "~2", Qt.Key_Home: "~H", Qt.Key_End: "~F", Qt.Key_Insert: "~3", Qt.Key_Delete: "~4", Qt.Key_F1: "~a", Qt.Key_F2: "~b", Qt.Key_F3: "~c", Qt.Key_F4: "~d", Qt.Key_F5: "~e", Qt.Key_F6: "~f", Qt.Key_F7: "~g", Qt.Key_F8: "~h", Qt.Key_F9: "~i", Qt.Key_F10: "~j", Qt.Key_F11: "~k", Qt.Key_F12: "~l", } def __init__(self,parent, font_name, font_size, font_height, w,h, colorscheme): super().__init__(parent) self.setFocusPolicy(Qt.WheelFocus) self.setAutoFillBackground(False) self.setAttribute(Qt.WA_OpaquePaintEvent, True) self.setCursor(Qt.IBeamCursor) font = QFont(font_name) font.setPixelSize(font_size) self.setFont(font) self._screen = [] self._text = [] self._transform= QTransform() self._cursor_col = 0 self._cursor_row = 0 self._dirty = False self._kbdfunc= None self._w=w self._h=h self._alt_sequence= False self._alt_seq_length=0 self._alt_seq_value=0 self._cursortype= CURSOR_OFF self._color_scheme=self.color_schemes[self.color_scheme_names[colorscheme]] self._cursor_color=self._color_scheme[2] self._cursor_char= 0x20 self._cursor_attr=-1 self._cursor_update=True self._blink= True self._blink_counter=0 self._cursor_rect = QRect(0, 0, self._char_width, self._char_height) self._cursor_polygon=QPolygon([QPoint(0,0+(self._char_height/2)), QPoint(0+(self._char_width*0.8),0+self._char_height), QPoint(0+(self._char_width*0.8),0+(self._char_height*0.67)), QPoint(0+self._char_width,0+(self._char_height*0.67)), QPoint(0+self._char_width,0+(self._char_height*0.33)), QPoint(0+(self._char_width*0.8),0+(self._char_height*0.33)), QPoint(0+(self._char_width*0.8),0), QPoint(0,0+(self._char_height/2))]) # # overwrite standard methods # def sizeHint(self): return QSize(self._w,self._h) def minimumSizeHint(self): return QSize(self._w,self._h) def resizeEvent(self, event): self.resize(self._w, self._h) def setkbdfunc(self,func): self._kbdfunc= func def setFont(self, font): super().setFont(font) self._update_metrics() # # overwrite standard events # # # Paint event, this event repaints the screen if the screen memory was changed or # paints the cursor # This event is fired if # - the terminal window becomes visible again # - after processing a new key in the termianl output queue # def paintEvent(self, event): painter = QPainter(self) if self._dirty: self._dirty = False self._paint_screen(painter) else: self._blink_counter+=1 if self._blink_counter > CURSOR_BLINK: self._blink_counter=0 self._paint_cursor(painter) event.accept() # # keyboard pressed event, process keys and put them into the keyboard input buffer # def keyPressEvent(self, event): text = event.text() key = event.key() modifiers = event.modifiers() alt = modifiers == Qt.AltModifier if (event.isAutoRepeat() and text) or self._kbdfunc == None: event.accept() return if alt: if not self._alt_sequence: self._alt_sequence= True self._alt_seq_length=0 self._alt_seq_value=0 if self._alt_seq_length==0: if key== Qt.Key_5: self._kbdfunc(ord("["),False) self._alt_sequence=False elif key== Qt.Key_6: self._kbdfunc(ord("]"),False) self._alt_sequence=False elif key== Qt.Key_7: self._kbdfunc(124,False) self._alt_sequence=False elif key== Qt.Key_8: self._kbdfunc(ord("{"),False) self._alt_sequence=False elif key== Qt.Key_9: self._kbdfunc(ord("}"),False) self._alt_sequence=False elif key== Qt.Key_L: self._kbdfunc(ord("@"),False) self._alt_sequence=False elif key== Qt.Key_I: self._kbdfunc(72,True) self._alt_sequence=False elif key== Qt.Key_1 or key == Qt.Key_0 : self._alt_seq_value+= key - Qt.Key_0 self._alt_seq_length+=1 else: self._alt_sequence=False else: if key >= Qt.Key_0 and key <= Qt.Key_9: self._alt_seq_value*=10 self._alt_seq_value+= key - Qt.Key_0 self._alt_seq_length+=1 if self._alt_seq_length == 3: if self._alt_seq_value <= 127: self._kbdfunc(self._alt_seq_value,False) self._alt_sequence= False else: self._alt_sequence= False elif text: t=ord(text) if t== 13: # lf -> Endline self._kbdfunc(82, True) elif t== 8: # BACK ESC Q self._kbdfunc(81, True) elif t== 127: # -CHAR ESC G self._kbdfunc(71, True) else: if t < 128: # > 127 generates BASIC KEYWORDS! self._kbdfunc(t, False) else: s = self.keymap.get(key) if s: if s == "~A": # cursor up ESC A self._kbdfunc(65,True) elif s == "~B": # cursor down ESC D self._kbdfunc(68, True) elif s == "~C": # cursor right ESC C self._kbdfunc(67,True) elif s == "~D": # cursor left ESC B self._kbdfunc(66, True) elif s == "~3": # I/R ESC H self._kbdfunc(72, True) elif s == "~4": # -CHAR ESC G self._kbdfunc(71,True) elif s == "~1": # Page Up ESC J self._kbdfunc(74,True) elif s == "~2": # Page Down ESC K self._kbdfunc(75, True) elif s == "~H": # Begin of line ESC E self._kbdfunc(69,True) elif s == "~F": # End of line ESC F self._kbdfunc(70, True) elif s == "~a": # F1 -> Attn ESC L self._kbdfunc(76, True) elif s == "~b": # F2 -> Run ESC M self._kbdfunc(77, True) elif s == "~c": # F3 -> Cmds ESC N self._kbdfunc(78, True) elif s == "~d": # F4 -> SST ESC P self._kbdfunc(80, True) elif s == "~e": # F5 -> -Line ESC I self._kbdfunc(73, True) elif s == "~f": # F6 -> LC ESC O self._kbdfunc(79, True) # elif s == "~g": # F7 -> Ctrl ESC S # self._kbdfunc(83, True) else: pass if (event.isAutoRepeat() and not text) : time.sleep(0.05) event.accept() # # internal methods # def _update_metrics(self): fm = self.fontMetrics() self._char_height = fm.height() self._char_width = fm.width("W") # # update cursor position # def _update_cursor_rect(self): if self._cursortype== CURSOR_OFF or (self._cursor_col== -1 and self._cursor_row==-1): return cx, cy = self._pos2pixel(self._cursor_col, self._cursor_row) self._transform.reset() self._transform.translate(cx,cy) self._cursor_update=True self._blink=True # # determine pixel position from rowl, column # def _pos2pixel(self, col, row): x = (col * self._char_width) y = row * self._char_height return x, y # # paint cursor # def _paint_cursor(self, painter): if self._cursortype== CURSOR_OFF or (self._cursor_col== -1 and self._cursor_row==-1): return # # cursor position was updated initialize some variables # if self._cursor_update: self._cursor_update= False self._blink_brush=QBrush(self._cursor_color) self._blink_pen=QPen(self._cursor_color) self._blink_pen.setStyle(0) if self._cursor_attr: self._noblink_background_color = self._color_scheme[1] self._noblink_foreground_color = self._color_scheme[0] else: self._noblink_background_color = self._color_scheme[0] self._noblink_foreground_color = self._color_scheme[1] self._noblink_brush = QBrush(self._noblink_background_color) # # blink on: draw cursor # if self._blink: painter.setPen(self._blink_pen) painter.setBrush(self._blink_brush) painter.setTransform(self._transform) if self._cursortype== CURSOR_OVERWRITE: painter.drawRect(self._cursor_rect) else: painter.drawPolygon(self._cursor_polygon) self._blink= not self._blink # # blink off: draw character # else: painter.setBrush(self._noblink_brush) painter.setTransform(self._transform) painter.setPen(QPen(self._noblink_background_color)) painter.drawRect(self._cursor_rect) painter.fillRect(self._cursor_rect, self._noblink_brush) painter.setPen(QPen(self._noblink_foreground_color)) painter.drawText(self._cursor_rect,Qt.AlignTop | Qt.AlignLeft,chr(self._cursor_char)) self._blink= not self._blink # # paint screen from screen memory # def _paint_screen(self, painter): # Speed hacks: local name lookups are faster vars().update(QColor=QColor, QBrush=QBrush, QPen=QPen, QRect=QRect) char_width = self._char_width char_height = self._char_height painter_drawText = painter.drawText painter_fillRect = painter.fillRect painter_setPen = painter.setPen align = Qt.AlignTop | Qt.AlignLeft color_scheme= self._color_scheme # set defaults background_color = color_scheme[1] foreground_color = color_scheme[0] brush = QBrush(background_color) painter_fillRect(self.rect(), brush) pen = QPen(foreground_color) painter_setPen(pen) y = 0 text = [] text_append = text.append for row, line in enumerate(self._screen): col = 0 text_line = "" for item in line: if isinstance(item, str): x = col * char_width length = len(item) rect = QRect( x, y, x + char_width * length, y + char_height) painter_fillRect(rect, brush) painter_drawText(rect, align, item) col += length text_line += item else: invers_flag = item if invers_flag: background_color = color_scheme[1] foreground_color = color_scheme[0] else: background_color = color_scheme[0] foreground_color = color_scheme[1] pen = QPen(foreground_color) brush = QBrush(background_color) painter_setPen(pen) painter.setBrush(brush) y += char_height text_append(text_line) self._text = text # # external interface # # set cursor type (insert, replace, off) # def setCursorType(self,t): self._cursortype=t #: # get terminal memory and cursor information # def update_term(self,dump): (self._cursor_col, self._cursor_row, self._cursor_char, self._cursor_attr), self._screen = dump() self._update_cursor_rect() self._dirty = True def setDirty(self): self._dirty= True