Beispiel #1
0
    def __init__(self, parent, main, function_name=None):
        QtGui.QWidget.__init__(self, parent)

        self.main = main
        self.function_name = function_name

        mainLayout = QtGui.QVBoxLayout()
        self.setLayout(mainLayout)

        gridLayout = QtGui.QGridLayout()
        mainLayout.addLayout(gridLayout)
        row = 0

        ## Function
        gridLayout.addWidget(QtGui.QLabel("Function:"), row, 0,
                             QtCore.Qt.AlignRight)
        self.txtFunction = QtGui.QLineEdit()
        gridLayout.addWidget(self.txtFunction, row, 1)
        gridLayout.addWidget(QtGui.QLabel("Name eg digitialFilter()"), row, 2)

        ## Lib
        row += 1
        gridLayout.addWidget(QtGui.QLabel("Lib:"), row, 0,
                             QtCore.Qt.AlignRight)
        self.txtLib = QtGui.QLineEdit()
        #self.cmbLib.addItem("arduino")
        #self.cmbLib.addItem("servo")
        #self.cmbLib.addItem("stepper")
        gridLayout.addWidget(self.txtLib, row, 1)
        gridLayout.addWidget(QtGui.QLabel("Lib eg arduino"), row, 2)

        ## Section
        row += 1
        gridLayout.addWidget(QtGui.QLabel("Section:"), row, 0,
                             QtCore.Qt.AlignRight)
        self.txtSection = QtGui.QLineEdit()
        gridLayout.addWidget(self.txtSection, row, 1)
        gridLayout.addWidget(
            QtGui.QLabel("Nav section eg math or digtital IO"), row, 2)

        ## Syntax
        row += 1
        gridLayout.addWidget(QtGui.QLabel("Syntax:"), row, 0,
                             QtCore.Qt.AlignRight)
        self.txtSyntax = QtGui.QLineEdit()
        gridLayout.addWidget(self.txtSyntax, row, 1)
        gridLayout.addWidget(QtGui.QLabel("eg digitalWrite(pin, value)"), row,
                             2)

        ## Tooltip
        row += 1
        gridLayout.addWidget(QtGui.QLabel("Summary:"), row, 0,
                             QtCore.Qt.AlignRight)
        self.txtSummary = QtGui.QLineEdit()
        gridLayout.addWidget(self.txtSummary, row, 1)
        gridLayout.addWidget(QtGui.QLabel("Brief popup description"), row, 2)

        ## Parameters Widgets tree
        row += 1
        grpBox = QtGui.QGroupBox("Parameters")
        gridLayout.addWidget(grpBox, row, 0, 1, 3)
        grpLayout = QtGui.QVBoxLayout()
        grpLayout.setSpacing(0)
        grpBox.setLayout(grpLayout)

        toolbar = QtGui.QToolBar()
        toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
        grpLayout.addWidget(toolbar)
        toolbar.addAction(Icon(Ico.Add), "Add", self.on_add_parameter)
        toolbar.addAction(Icon(Ico.Remove), "Remove", self.on_remove_parameter)
        toolbar.addSeparator()
        toolbar.addAction(Icon(Ico.Up), "Up", self.on_move_up)
        toolbar.addAction(Icon(Ico.Down), "Down", self.on_move_down)

        self.tree = QtGui.QTreeWidget()
        self.tree.setRootIsDecorated(False)
        self.tree.headerItem().setText(0, "Parameter")
        self.tree.headerItem().setText(1, "Description")
        grpLayout.addWidget(self.tree)

        ## Description
        row += 1
        grpBox = QtGui.QGroupBox("Description")
        gridLayout.addWidget(grpBox, row, 0, 1, 3)
        grpLayout = QtGui.QVBoxLayout()
        grpBox.setLayout(grpLayout)
        self.txtDescription = QtGui.QPlainTextEdit()
        grpLayout.addWidget(self.txtDescription)

        ## Example
        #row  += 1
        grpBox = QtGui.QGroupBox("Example")
        gridLayout.addWidget(grpBox, 0, 3, 7, 1)
        grpLayout = QtGui.QVBoxLayout()
        grpBox.setLayout(grpLayout)
        self.txtExample = QtGui.QPlainTextEdit()
        grpLayout.addWidget(self.txtExample)

        gridLayout.setColumnStretch(0, 0)
        gridLayout.setColumnStretch(1, 2)
        gridLayout.setColumnStretch(2, 0)
        gridLayout.setColumnStretch(3, 3)

        ############################################
        ## Bottom Buttons
        bbox = QtGui.QHBoxLayout()
        mainLayout.addLayout(bbox)
        bbox.addStretch(20)
        cancelButton = GenericWidgets.CancelButton(self, "Cancel")
        bbox.addWidget(cancelButton, 1)
        self.saveButton = GenericWidgets.SaveButton(self)
        bbox.addWidget(self.saveButton, 1)

        if self.function_name:
            self.load_file()
Beispiel #2
0
	def __init__(self, parent, main, function_file, path, paths):
		QtGui.QDialog.__init__(self, parent)

		self.main = main
		self.function_file = function_file
		self.path = path
		self.paths = paths
		self.dic = None
		#print function_file, path, paths

		self.setMinimumWidth(1100)
		self.setMinimumHeight(800)

		mainLayout = QtGui.QVBoxLayout()
		self.setLayout(mainLayout)


		gridLayout = QtGui.QGridLayout()
		mainLayout.addLayout(gridLayout)
		row = 0

		## Function
		gridLayout.addWidget(QtGui.QLabel("Function:"), row, 0, QtCore.Qt.AlignRight)
		self.txtFunction = QtGui.QLineEdit()
		gridLayout.addWidget(self.txtFunction, row, 1)
		gridLayout.addWidget(QtGui.QLabel("Name eg digitialFilter (no brackets)"), row, 2)
		self.connect(self.txtFunction, QtCore.SIGNAL("textChanged(const QString&)"), self.on_function_text_changed)


		## Lib
		row  += 1
		gridLayout.addWidget(QtGui.QLabel("Lib:"), row, 0, QtCore.Qt.AlignRight)
		self.comboLib = QtGui.QComboBox()
		for pth in paths:
			newIdx = self.comboLib.count()
			self.comboLib.insertItem(newIdx, pth)
			print pth, self.path
			if pth == self.path:
				self.comboLib.setCurrentIndex(newIdx)
		gridLayout.addWidget(self.comboLib, row, 1)
		gridLayout.addWidget(QtGui.QLabel("Lib eg arduino"), row, 2)


		## Section
		row  += 1
		gridLayout.addWidget(QtGui.QLabel("Section:"), row, 0, QtCore.Qt.AlignRight)
		self.txtSection = QtGui.QLineEdit()
		gridLayout.addWidget(self.txtSection, row, 1)
		gridLayout.addWidget(QtGui.QLabel("Nav section eg math or digtital IO"), row, 2)


		## Syntax
		"""
		row  += 1
		gridLayout.addWidget(QtGui.QLabel("Syntax:"), row, 0, QtCore.Qt.AlignRight)
		self.txtSyntax = QtGui.QLineEdit()
		self.txtSyntax.setReadOnly(True)
		gridLayout.addWidget(self.txtSyntax, row, 1)
		gridLayout.addWidget(QtGui.QLabel(""), row, 2)
		"""

		## Summary
		row  += 1
		gridLayout.addWidget(QtGui.QLabel("Summary:"), row, 0, QtCore.Qt.AlignRight)
		self.txtSummary = QtGui.QLineEdit()
		gridLayout.addWidget(self.txtSummary, row, 1, 1, 2)
		#gridLayout.addWidget(QtGui.QLabel("Brief popup description"), row, 2)

		## Parameters Widgets tree
		row  += 1
		grpBox = QtGui.QGroupBox("Parameters")
		gridLayout.addWidget(grpBox, row, 0, 1, 3)
		grpLayout = QtGui.QVBoxLayout()
		grpLayout.setSpacing(0)
		grpBox.setLayout(grpLayout)

		toolbar = QtGui.QToolBar()
		toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
		grpLayout.addWidget(toolbar)

		
		self.radioFixed = QtGui.QRadioButton("Fixed params", self)
		toolbar.addWidget(self.radioFixed)
		self.radioFixed.hide()
		self.radioVariable = QtGui.QRadioButton("Variable params", self)
		self.radioVariable.hide()
		toolbar.addWidget(self.radioVariable)
		toolbar.addSeparator()
		

		toolbar.addAction(Icon(Ico.Add), "Add Syntax", self.on_add_syntax)
		toolbar.addAction(Icon(Ico.Remove), "Remove", self.on_remove_parameter)
		toolbar.addSeparator()
		toolbar.addAction(Icon(Ico.Up), "Up", self.on_move_up)
		toolbar.addAction(Icon(Ico.Down), "Down", self.on_move_down)

		self.tree = QtGui.QTreeWidget()
		self.tree.setRootIsDecorated(False)
		self.tree.headerItem().setText(0, "Parameter")
		self.tree.headerItem().setText(1, "Description")
		grpLayout.addWidget(self.tree)
		self.connect(self.tree, QtCore.SIGNAL("itemChanged(QTreeWidgetItem *,int)"), self.on_tree_changed)

		## Returns
		row  += 1
		self.chkReturn = QtGui.QCheckBox("Return")
		self.connect(self.chkReturn, QtCore.SIGNAL("toggled(bool)"), self.on_chk_return)
		gridLayout.addWidget(self.chkReturn, row, 0, QtCore.Qt.AlignRight)
		self.txtReturn = QtGui.QLineEdit()
		gridLayout.addWidget(self.txtReturn, row, 1, 1, 2)
		#gridLayout.addWidget(QtGui.QLabel("eg milliseconds elapsed"), row, 2)

		## Description
		row  += 1
		grpBox = QtGui.QGroupBox("Description")
		gridLayout.addWidget(grpBox, row, 0, 1, 3)
		grpLayout = QtGui.QVBoxLayout()
		grpBox.setLayout(grpLayout)
		self.txtDescription = QtGui.QPlainTextEdit()
		grpLayout.addWidget(self.txtDescription)

		## Example
		#row  += 1
		grpBox = QtGui.QGroupBox("Example")
		gridLayout.addWidget(grpBox, 0, 3, 7, 1)
		grpLayout = QtGui.QVBoxLayout()
		grpBox.setLayout(grpLayout)
		self.txtExample = QtGui.QPlainTextEdit()
		grpLayout.addWidget(self.txtExample)

		gridLayout.setColumnStretch(0, 0)
		gridLayout.setColumnStretch(1, 2)
		gridLayout.setColumnStretch(2, 0)
		gridLayout.setColumnStretch(3, 3)

		############################################
		## Bottom Buttons
		bbox = QtGui.QHBoxLayout()
		mainLayout.addLayout(bbox)
		bbox.addStretch(20)
		cancelButton = GenericWidgets.CancelButton(self, "Cancel")
		bbox.addWidget(cancelButton, 1)
		self.saveButton = GenericWidgets.SaveButton(self)
		bbox.addWidget(self.saveButton, 1)

		self.statusBar = QtGui.QStatusBar(self)
		mainLayout.addWidget(self.statusBar)

		if self.function_file:
			self.load_file()
Beispiel #3
0
	def __init__(self, parent, main):
		QtGui.QDialog.__init__(self, parent)
		self.main = main

		self.setWindowTitle("Settings")
		self.setWindowIcon(Icon(Ico.Settings))
		self.setMinimumWidth(700)
		self.setMinimumHeight(500)

		mainLayout = QtGui.QVBoxLayout()
		self.setLayout(mainLayout)

		self.path_keys = []
		self.path_keys.append( ['path/arduino_path','Arduino Path', 'Directory of arduino installation'] )
		self.path_keys.append( ['path/sketchbooks_path', 'Sketchbooks',	'Directory to sketchbooks'] )
		self.path_keys.append( ['path/arduino_svn_path', 'Arduino Svn', 'Path to svn trunk/'] )

		vBox = QtGui.QVBoxLayout()
		vBox.setSpacing(20)
		mainLayout.addLayout(vBox)


		promptButtonGroup = QtGui.QButtonGroup(self)
		self.connect(promptButtonGroup, QtCore.SIGNAL("buttonClicked(QAbstractButton *)"), self.on_prompt_button)

		browseButtonGroup = QtGui.QButtonGroup(self)
		self.connect(browseButtonGroup, QtCore.SIGNAL("buttonClicked(QAbstractButton *)"), self.on_browse_button)

		self.txt = {}
		self.lbl = {}
		#butt = {}
		#buttP = {}
		for fKey, title, description in self.path_keys:

			grp = QtGui.QGroupBox( "%s" % (title) )
			vBox.addWidget(grp)
			vb = QtGui.QVBoxLayout()
			grp.setLayout(vb)
			
			lbl = QtGui.QLabel( description )
			vb.addWidget(lbl)

			pth = self.main.settings.value(fKey)
			self.txt[fKey] = QtGui.QLineEdit(pth) #setval.toString())
			self.txt[fKey].setReadOnly(True)
			vb.addWidget(self.txt[fKey])

			hBox = QtGui.QHBoxLayout()
			vb.addLayout(hBox)

			self.lbl[fKey] = QtGui.QLabel("-")
			hBox.addWidget(self.lbl[fKey])
			self.check_file(fKey)

			buttP = QtGui.QToolButton(self)
			#buttP[fKey].setIcon(dIcon(dIco.Green))
			buttP.setText("Prompt")
			buttP.setProperty("ki", QtCore.QVariant(fKey) )
			buttP.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
			hBox.addWidget(buttP)
			buttP.setVisible(False)
			promptButtonGroup.addButton(buttP)

			buttB = QtGui.QToolButton(self)
			#butt[fKey].setIcon(dIcon(dIco.Green))
			buttB.setText("Browse")
			buttB.setProperty("ki", QtCore.QVariant(fKey) )
			buttB.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
			hBox.addWidget(buttB)
			browseButtonGroup.addButton(buttB)	

		vBox.addStretch(10)

		#########################################
		## Save Cancel Buttons
		buttonBox = QtGui.QHBoxLayout()
		mainLayout.addLayout(buttonBox)
		buttonBox.addStretch(20)

		cancelButton = GenericWidgets.CancelButton(self, "Cancel")
		buttonBox.addWidget(cancelButton)

		saveButton = GenericWidgets.SaveButton(self)
		buttonBox.addWidget(saveButton)