示例#1
0
文件: qhistory.py 项目: epage/ejpi
	def __init__(self, errorReporter):
		super(QCalcHistory, self).__init__()
		self._prettyRenderer = operation.render_number()
		self._errorLog = errorReporter

		self._historyStore = QtGui.QStandardItemModel()
		self._historyStore.setHorizontalHeaderLabels(["", "Equation", "Result"])
		self._historyStore.itemChanged.connect(self._on_item_changed)

		self._historyView = QtGui.QTreeView()
		self._historyView.setModel(self._historyStore)
		self._historyView.setUniformRowHeights(True)
		self._historyView.setRootIsDecorated(False)
		self._historyView.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
		self._historyView.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
		self._historyView.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
		self._historyView.setHeaderHidden(True)
		self._historyView.activated.connect(self._on_row_activated)

		viewHeader = self._historyView.header()
		viewHeader.setSortIndicatorShown(True)
		viewHeader.setClickable(True)

		viewHeader.setResizeMode(self._CLOSE_COLUMN, QtGui.QHeaderView.ResizeToContents)
		viewHeader.setResizeMode(self._EQ_COLUMN, QtGui.QHeaderView.Stretch)
		viewHeader.setResizeMode(self._RESULT_COLUMN, QtGui.QHeaderView.ResizeToContents)
		viewHeader.setStretchLastSection(False)

		self._rowCount = 0
		self._programmaticUpdate = False
		self._closeIcon = qui_utils.get_theme_icon(("window-close", "general_close", "gtk-close"))
示例#2
0
文件: history.py 项目: epage/ejpi-gtk
	def __init__(self, history, entry, errorReporting, constants, operations):
		self.history = history
		self.__entry = weakref.ref(entry)

		self.__errorReporter = errorReporting
		self.__constants = constants
		self.__operations = operations

		self.__serialRenderer = operation.render_number()
示例#3
0
	def __init__(self, view):
		super(GtkCalcHistory, self).__init__()
		self.__prettyRenderer = operation.render_number()
		self._historyView = view

		# stock-id, display, value
		self.__historyStore = gtk.ListStore(
			gobject.TYPE_STRING, # stock id for pixbuf
			gobject.TYPE_STRING, # view of data
			gobject.TYPE_STRING, # view of result
			object, # data
			object, # result
		)
		self._historyView.set_model(self.__historyStore)

		# create the TreeViewColumns to display the data
		self.__closeColumn = gtk.TreeViewColumn('')
		self._historyView.append_column(self.__closeColumn)

		self.__historyColumn = gtk.TreeViewColumn('History')
		self.__historyColumn.set_sort_column_id(0)
		self.__historyColumn.set_expand(True)
		self._historyView.append_column(self.__historyColumn)

		self.__resultColumn = gtk.TreeViewColumn('')
		self.__resultColumn.set_sort_column_id(0)
		self._historyView.append_column(self.__resultColumn)

		# create a CellRenderers to render the data
		self.__closeCell = gtk.CellRendererPixbuf()
		hildonize.set_pix_cell_thumb_selectable(self.__closeCell)
		self.__closeColumn.pack_start(self.__closeCell, False)
		self.__closeColumn.set_attributes(self.__closeCell, stock_id=0)

		self.__expressionCell = gtk.CellRendererText()
		self.__expressionCell.set_property("ellipsize", pango.ELLIPSIZE_MIDDLE)
		self.__historyColumn.pack_start(self.__expressionCell, True)
		self.__historyColumn.set_attributes(self.__expressionCell, text=1)

		self.__valueCell = gtk.CellRendererText()
		self.__valueCell.set_property("ellipsize", pango.ELLIPSIZE_NONE)
		self.__resultColumn.pack_end(self.__valueCell, False)
		self.__resultColumn.set_attributes(self.__valueCell, text=2)

		self._historyView.set_reorderable(True)
		self._historyView.get_selection().set_mode(gtk.SELECTION_SINGLE)
		self._historyView.connect("row-activated", self._on_close_activated)