Exemplo n.º 1
0
class HistoryWidget(QWidget):
    def __init__(self, parent=None):
        super(HistoryWidget, self).__init__(parent=parent)
        self.historyView = QTreeView(self)
        self.proxyModel = HistorySortModel(self)
        self.sourceModel = QStandardItemModel()
        self.initUI()

    def initUI(self):
        self.historyView.setRootIsDecorated(False)
        self.historyView.setAlternatingRowColors(True)
        self.historyView.setModel(self.proxyModel)
        self.historyView.setSortingEnabled(True)
        self.historyView.sortByColumn(1, Qt.AscendingOrder)

        self.historyView.setFixedWidth(750)

        self.sourceModel = QStandardItemModel(0, 6, self)
        self.sourceModel.setHeaderData(0, Qt.Horizontal, "Model Name")
        self.sourceModel.setHeaderData(1, Qt.Horizontal, "Algorithm")
        self.sourceModel.setHeaderData(2, Qt.Horizontal, "Score")
        self.sourceModel.setHeaderData(3, Qt.Horizontal, "TrainSet")
        self.sourceModel.setHeaderData(4, Qt.Horizontal, "Running Time")
        self.sourceModel.setHeaderData(5, Qt.Horizontal, "Param")
        self.proxyModel.setSourceModel(self.sourceModel)
        self.historyView.setModel(self.sourceModel)

    def addItem(self, result: modelResult):
        self.sourceModel.insertRow(self.sourceModel.rowCount())

        self.sourceModel.setData(self.sourceModel.index(0, 0),
                                 result.modelName)  # string
        self.sourceModel.setData(self.sourceModel.index(0, 1),
                                 result.algorithm)  # string
        self.sourceModel.setData(self.sourceModel.index(0, 2),
                                 result.score)  # float
        self.sourceModel.setData(self.sourceModel.index(0, 3),
                                 result.trainSet)  # string
        self.sourceModel.setData(self.sourceModel.index(0, 4),
                                 result.runTime)  # second
        self.sourceModel.setData(self.sourceModel.index(0, 5),
                                 result.param)  # dict
Exemplo n.º 2
0
    def create_tree_view(self, start_path="/home", callback=None):
        """ Display the tree view to choose a folder """
        file_manager = QTreeView()

        self.callback_func = callback

        self.model = QFileSystemModel()
        self.model.setRootPath(start_path)

        # for ViewType in (QColumnView, QTreeView):
        file_manager.setModel(self.model)

        # hide all columns except the filename
        for i in range(1, self.model.columnCount()):
            file_manager.hideColumn(i)
        file_manager.setRootIndex(self.model.index(start_path))
        file_manager.setFixedWidth(self.width)
        file_manager.setWordWrap(True)

        file_manager.clicked.connect(self.item_clicked)
        return {"file_manager": file_manager, "file_model": self.model}
Exemplo n.º 3
0
class mainWindow(QMainWindow):#											||
	def __init__(self):#												||
		QMainWindow.__init__(self)#										||
		pxcfg = here+'/gui.yaml'
		self.config = monk.stone(pxcfg).
		self.setAttribute(Qt.WA_DeleteOnClose)#							||
		self.setWindowTitle("Pyffice 0.0.0.0.0.0")#						||
		self.setStyleSheet(open(qss, "r").read())#						||
		self.setAutoFillBackground(True)#								||
		self.loadMenu()#												||
		self.setLayout()#												||
		self.loadApp()#													||
	def buildMenu():
		pass
	def desktopMenu(self, application, cfg=None):
		#dynamically build menu from config file
		dtmcfg = self.config['menu']
		for item in cfg.keys():
			self.menu = QMenu(dtmcfg[item]['name'], application)
	def loadMenu(self):#												||
		menu = self.desktopMenu(self)# this sends the desktop object (self) to the menu object
		for mu in menu.__dir__():#										||dynamically add
			obj = getattr(menu, mu)#									||menu items to the
			if isinstance(obj, QMenu):#									||layout
				self.menuBar().addMenu(obj)#							||
	def setLayout(self):#												||
		self.main_widget = QWidget(self)
		self.l = QHBoxLayout(self.main_widget)
#		tbar = docAddBar()
#		l.addWidget(tbar.toolbar)
	def loadApp(self):#													||
		''
		app = alpr.App()
		self.formulaBar()
		self.createLayout()
		self.l.addWidget(app)
		self.main_widget.setFocus()
		self.setCentralWidget(self.main_widget)
		windowLayout = QBoxLayout(QBoxLayout.LeftToRight)
		self.treeview.setFixedWidth=200
		windowLayout.addWidget(self.treeview)
		windowLayout.addWidget(self.tabwidget)
		self.setLayout(windowLayout)
		self.show()
		return self
		self.functionBar = QToolBar()
		self.addToolBar(self.functionBar)
		self.functionInput = QLineEdit()
		self.functionBar.addWidget(self.functionInput)
		self.formulaBar = QToolBar()
		self.addToolBar(self.formulaBar)
		self.formulaInput = QLineEdit()
		self.formulaBar.addWidget(self.formulaInput)
		self.statusBar().showMessage('Pyffice is about to Live')
	def fileQuit(self):
		self.close()
	def closeEvent(self, ce):
		self.fileQuit()

	def treeView(self,):
		self.treeview = QTreeView()
		self.treeview.setModel(model)

		self.treeview.setRootIndex(model.index(QDir.homePath()))

		self.treeview.setColumnWidth(0,50)
		self.treeview.setColumnHidden(1, True)
		self.treeview.setColumnHidden(2, True)
		self.treeview.setColumnHidden(3, True)
		self.treeview.setFixedWidth(200)
		self.treeview.setAnimated(False)
		self.treeview.setIndentation(20)
		self.treeview.setSortingEnabled(True)
		return self
	def setupContextMenu(self):
		'I believe this should setup the right click menu'
		self.addAction(self.cell_addAction)
		self.addAction(self.cell_subAction)
		self.addAction(self.cell_mulAction)
		self.addAction(self.cell_divAction)
		self.addAction(self.cell_sumAction)
		self.addAction(self.firstSeparator)
		self.addAction(self.colorAction)
		self.addAction(self.fontAction)
		self.addAction(self.secondSeparator)
		self.addAction(self.clearAction)
		self.setContextMenuPolicy(Qt.ActionsContextMenu)
		return self
	def formulaBar(self):
		return self
	def functionBar(self):
		return self