Пример #1
0
    def run_arduino_make(self):
        self.emit(QtCore.SIGNAL("compile_log"), "start_compile",
                  "%s" % self.file_to_compile)

        process = QtCore.QProcess(self)
        self.set_process_env(process)

        ## construct the command "sh /app_path/etc/arduino_make.sh compile" and execute in project_dir dir
        command = QtCore.QString("sh ")
        script_full_path = settings.app_path().absoluteFilePath(
            "etc/arduino_make.sh compile")
        command.append(script_full_path)
        #print "command=", command
        self.emit(QtCore.SIGNAL("compile_log"), "command",
                  QtCore.QString(command))

        process.start(command)
        if process.waitForStarted():
            process.waitForFinished()
            result = process.readAllStandardOutput()
            #print type(result), result
            error = process.readAllStandardError()
            #print type(error), error
            if error:
                self.emit(QtCore.SIGNAL("compile_log"), "error",
                          QtCore.QString(error))
            else:
                self.emit(QtCore.SIGNAL("compile_log"), "result",
                          QtCore.QString(result))
Пример #2
0
	def load_website_menu(self):
		self.menuWebSites.clear()
		web_sites_file = settings.app_path().absoluteFilePath("etc/websites.yaml")
		groups_sites = app.utils.load_yaml(web_sites_file)
		for grp in groups_sites:
			grpMenu = self.menuWebSites.addMenu(grp)
			for site in groups_sites[grp]:
				act = grpMenu.addAction(site['title'])
				act.setProperty("url", site['url'])
				self.actionGroupWebsites.addAction(act)
				

		self.menuWebSites.addSeparator()
		self.actionEditWebsites = self.menuWebSites.addAction( "Edit Sites", self.on_websites_dialog )
Пример #3
0
    def run_arduino_upload(self):
        self.emit(QtCore.SIGNAL("compile_log"), "start_upload",
                  "%s" % self.file_to_compile)
        process = QtCore.QProcess(self)

        #arduino_path = settings.arduino_path()
        #if not arduino_path:
        #	self.set_error("Arduino root path not found", "..nothing to do ..")
        #TOD self.emit(
        #	return
        #print arduino_path.path()
        ## ENV - Set Envoironment variables
        #env = QtCore.QStringList()
        #env << QtCore.QString("ARDUINO_DIR=").append(arduino_path.path())
        #env << QtCore.QString("ARDUINO_BOARD=").append(self.board)
        #env << QtCore.QString("ARDUINO_sPORT=").append(self.serial_port)
        #process.setEnvironment(env)
        #self.emit(QtCore.SIGNAL("compile_log"), "env", env.join(" "))
        #print "----------------------------------------"
        self.set_process_env(process)

        ## Set "process path" to working dir Project Directory
        #project_dir = QtCore.QFileInfo(self.file_to_compile).absolutePath()
        #process.setWorkingDirectory(project_dir)
        #self.emit(QtCore.SIGNAL("compile_log"), "env", "cwd=" % project_dir)

        ## construct the command "sh /app_path/etc/arduino_make.sh compile" and execute in project_dir dir
        command = QtCore.QString("sh ")
        #args = QtCore.QStringList()
        script_full_path = settings.app_path().absoluteFilePath(
            "etc/arduino_make.sh compile upload")
        command.append(script_full_path)
        #print "command=", command
        self.emit(QtCore.SIGNAL("compile_log"), "command",
                  QtCore.QString(command))

        process.start(command)
        if process.waitForStarted():
            process.waitForFinished()
            result = process.readAllStandardOutput()
            #print type(result), result
            error = process.readAllStandardError()
            #print type(error), error
            if error:
                self.emit(QtCore.SIGNAL("compile_log"), "error",
                          QtCore.QString(error))
            else:
                self.emit(QtCore.SIGNAL("compile_log"), "result",
                          QtCore.QString(result))
Пример #4
0
    def load_website_menu(self):
        self.menuWebSites.clear()
        web_sites_file = settings.app_path().absoluteFilePath(
            "etc/websites.yaml")
        groups_sites = app.utils.load_yaml(web_sites_file)
        for grp in groups_sites:
            grpMenu = self.menuWebSites.addMenu(grp)
            for site in groups_sites[grp]:
                act = grpMenu.addAction(site['title'])
                act.setProperty("url", site['url'])
                self.actionGroupWebsites.addAction(act)

        self.menuWebSites.addSeparator()
        self.actionEditWebsites = self.menuWebSites.addAction(
            "Edit Sites", self.on_websites_dialog)
Пример #5
0
	def run_arduino_upload(self):
		self.emit(QtCore.SIGNAL("compile_log"), "start_upload", "%s" % self.file_to_compile)
		process = QtCore.QProcess(self)

		#arduino_path = settings.arduino_path()
		#if not arduino_path:
		#	self.set_error("Arduino root path not found", "..nothing to do ..")
			#TOD self.emit(
		#	return
		#print arduino_path.path()
		## ENV - Set Envoironment variables
		#env = QtCore.QStringList()
		#env << QtCore.QString("ARDUINO_DIR=").append(arduino_path.path())
		#env << QtCore.QString("ARDUINO_BOARD=").append(self.board)
		#env << QtCore.QString("ARDUINO_sPORT=").append(self.serial_port)
		#process.setEnvironment(env)
		#self.emit(QtCore.SIGNAL("compile_log"), "env", env.join(" "))
		#print "----------------------------------------"
		self.set_process_env(process)

		## Set "process path" to working dir Project Directory
		#project_dir = QtCore.QFileInfo(self.file_to_compile).absolutePath()
		#process.setWorkingDirectory(project_dir)
		#self.emit(QtCore.SIGNAL("compile_log"), "env", "cwd=" % project_dir)

		## construct the command "sh /app_path/etc/arduino_make.sh compile" and execute in project_dir dir
		command = QtCore.QString("sh ")
		#args = QtCore.QStringList()
		script_full_path = settings.app_path().absoluteFilePath("etc/arduino_make.sh compile upload")
		command.append(script_full_path)
		#print "command=", command
		self.emit(QtCore.SIGNAL("compile_log"), "command", QtCore.QString(command))

		process.start(command)
		if process.waitForStarted(): 
			process.waitForFinished()
			result =  process.readAllStandardOutput()
			#print type(result), result
			error = process.readAllStandardError()
			#print type(error), error
			if error:
				self.emit(QtCore.SIGNAL("compile_log"), "error", QtCore.QString(error))
			else:
				self.emit(QtCore.SIGNAL("compile_log"), "result", QtCore.QString(result))
Пример #6
0
	def run_arduino_make(self):
		self.emit(QtCore.SIGNAL("compile_log"), "start_compile", "%s" % self.file_to_compile)

		process = QtCore.QProcess(self)
		self.set_process_env(process)

		## construct the command "sh /app_path/etc/arduino_make.sh compile" and execute in project_dir dir
		command = QtCore.QString("sh ")
		script_full_path = settings.app_path().absoluteFilePath("etc/arduino_make.sh compile")
		command.append(script_full_path)
		#print "command=", command
		self.emit(QtCore.SIGNAL("compile_log"), "command", QtCore.QString(command))

		process.start(command)
		if process.waitForStarted(): 
			process.waitForFinished()
			result =  process.readAllStandardOutput()
			#print type(result), result
			error = process.readAllStandardError()
			#print type(error), error
			if error:
				self.emit(QtCore.SIGNAL("compile_log"), "error", QtCore.QString(error))
			else:
				self.emit(QtCore.SIGNAL("compile_log"), "result", QtCore.QString(result))
Пример #7
0
	def ard_make(self, file_to_compile, board, port):
		
		self.file_to_compile = file_to_compile
		self.board = board
		self.port = port
		self.emit(QtCore.SIGNAL("compile_log"), "start_compile", "%s" % self.file_to_compile)
		process = QtCore.QProcess(self)

		arduino_path = settings.arduino_path()
		if not arduino_path:
			self.set_error("Arduino root path not found", "..nothing to do ..")
			#TOD self.emit(
			return
		#print arduino_path.path()
		## ENV - Set Envoironment variables
		env = QtCore.QStringList()
		env << QtCore.QString("ARDUINO_DIR=").append(arduino_path.path())
		env << QtCore.QString("ARDUINO_BOARD=").append(board)
		env << QtCore.QString("ARDUINO_sPORT=").append(port)
		process.setEnvironment(env)
		self.emit(QtCore.SIGNAL("compile_log"), "env", env.join(" "))
		#print "----------------------------------------"

		## Set "process path" to working dir Project Directory
		project_dir = QtCore.QFileInfo(self.file_to_compile).absolutePath()
		process.setWorkingDirectory(project_dir)
		self.emit(QtCore.SIGNAL("compile_log"), "env", "cwd=" % project_dir)

		## construct the command "sh /app_path/etc/arduino_make.sh compile" and execute in project_dir dir
		command = QtCore.QString("sh ")
		#args = QtCore.QStringList()
		script_full_path = settings.app_path().absoluteFilePath("etc/arduino_make.sh compile ")
		command.append(script_full_path)
		#print "command=", command
		self.emit(QtCore.SIGNAL("compile_log"), "command", QtCore.QString(command))
		## Execute process
		process.start(command)
		if process.waitForStarted(): 
			process.waitForFinished()
			result =  process.readAllStandardOutput()
			#print type(result), result
			error = process.readAllStandardError()
			#print type(error), error
			if error:
				#print "is error", error
				#self.actionIcon.setIcon(Icon(Ico.CompileError))
				#self.statusLabel.setText("Error")
				#self.textWidget.setPlainText(QtCore.QString(error))
				#self.emit(QtCore.SIGNAL("compile_error"), QtCore.QString(error))
				self.emit(QtCore.SIGNAL("compile_log"), "error", QtCore.QString(error))
			else:
				#print "is ok", result
				#self.emit(QtCore.SIGNAL("compile_result"), QtCore.QString(result))
				self.emit(QtCore.SIGNAL("compile_log"), "result", QtCore.QString(result))

				#self.statusLabel.setText("OK")
				#self.actionIcon.setIcon(Icon(Ico.CompileOk))
				#self.textWidget.setPlainText(QtCore.QString(result))


		### >>>> DEAD
		#self.progress.hide()
		return
		command = QtCore.QString()
		## Create command sh arduinp_make.sh 
		command.append("pwd") # sh ").append(self.main.settings.app_path()).append("/etc/arduino_make.sh compile")
		#args = QtCore.QStringList()
		#command.append(self.main.settings.app_path()).append("/etc/arduino_make.sh compile ")
		#command.append(QtCore.QFileInfo(self.current_file_path).dir().path())
		print "command=", command
		process = QtCore.QProcess(self)
		process.start(command)
		if process.waitForStarted(): 
			process.waitForFinished();
			result =  process.readAllStandardOutput()
			#print type(result), result
			error = process.readAllStandardError()
			#print type(error), error
			if error:
			
				self.textWidget.setPlainText(QtCore.QString(error))
			else:
				self.textWidget.setPlainText(QtCore.QString(result))
Пример #8
0
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self)

        # TODO - User customisable style
        QtGui.QApplication.setStyle(QtGui.QStyleFactory.create("Cleanlooks"))

        ## Set the title text format
        self.title_text = "Dawn"

        ## Sets up the settings and other global classes
        self.api = app.API.API()
        self.ut = None

        ## Set Window Properties
        self.setWindowTitle(self.title_text)
        self.setWindowIcon(Icon(Ico.Arduino))
        self.setMinimumWidth(800)
        self.setMinimumHeight(600)

        self.setDockNestingEnabled(True)
        self.setDockOptions(QtGui.QMainWindow.ForceTabbedDocks | QtGui.QMainWindow.VerticalTabs)

        self.topToolBar = QtGui.QToolBar()
        self.topToolBar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
        self.addToolBar(self.topToolBar)

        ##############################################################
        ## File Menu
        ##############################################################
        menuFile = self.menuBar().addMenu("File")
        menuSettings = menuFile.addAction(Icon(Ico.Settings), "Settings", self.on_settings_dialog)
        menuFile.addSeparator()
        # TODO: Connect this to something
        menuExit = menuFile.addAction(Icon(Ico.Exit), "Exit", self.on_exit)
        # self.topToolBar.addAction(menuSettings)

        ##############################################################
        ## View Menu
        ##############################################################
        menuView = self.menuBar().addMenu("View")
        self.groupViewActions = QtGui.QActionGroup(self)
        self.connect(self.groupViewActions, QtCore.SIGNAL("triggered (QAction *)"), self.on_action_view)

        views = []
        views.append(["projects", Ico.Projects, "Projects"])
        views.append(["api_browser", Ico.Function, "API Browser"])
        views.append(["help", Ico.Help, "Help"])
        views.append(["file_system_browser", Ico.FileSystemBrowser, "Files Browser"])

        for ki, ico, caption in views:
            act = menuView.addAction(Icon(ico), caption)
            act.setProperty("ki", ki)
            self.topToolBar.addAction(act)
            self.groupViewActions.addAction(act)
        self.topToolBar.addSeparator()
        menuView.addAction("View Help in dock - TODO")
        menuView.addAction("View something else in dock")

        ##############################################################
        ## Projects Menu
        ##############################################################
        menuProjects = self.menuBar().addMenu("Projects")
        ## TODO populate this menu

        ##############################################################
        ## Hardware Menu
        ##############################################################
        menuHardware = self.menuBar().addMenu("Hardware")

        ## Boards
        self.actionGroupBoards = QtGui.QActionGroup(self)
        self.actionGroupBoards.setExclusive(True)
        self.connect(self.actionGroupBoards, QtCore.SIGNAL("triggered(QAction *)"), self.on_action_select_board)
        self.menuBoards = menuHardware.addMenu(Icon(Ico.Board), "-- No Board Selected --")  # populates later
        act = menuHardware.addAction(Icon(Ico.Boards), "Boards", self.on_action_boards)
        self.topToolBar.addAction(act)
        menuHardware.addSeparator()

        ## Bootloaders
        self.actionGroupBootLoaders = QtGui.QActionGroup(self)
        self.actionGroupBootLoaders.setExclusive(True)
        self.connect(self.actionGroupBootLoaders, QtCore.SIGNAL("triggered(QAction *)"), self.on_action_bootloader_burn)
        self.menuBootLoaders = menuHardware.addMenu(Icon(Ico.BootLoaderBurn), "Burn Bootloader")  # populates later
        act = menuHardware.addAction(Icon(Ico.BootLoaders), "Bootloaders", self.on_action_bootloaders)
        self.topToolBar.addAction(act)
        self.topToolBar.addSeparator()

        ##############################################################
        ## Websites Menu
        ##############################################################
        self.menuWebSites = self.menuBar().addMenu("Websites")

        self.menuWebSites.addSeparator()
        self.actionEditWebsites = self.menuWebSites.addAction("Edit Sites", self.on_websites_dialog)

        ##############################################################
        ## Help Menu
        menuHelp = self.menuBar().addMenu("Help")
        menuHelp.addAction("About This Project", self.on_about)
        menuHelp.addAction("About Qt", self.on_about_qt)

        ####################################
        ## Dock Widgets
        ####################################
        helpDockWidget = HelpDock("Help", self, self)
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, helpDockWidget)

        ##########################################################
        ## Central Widget
        ##########################################################

        self.mainTabWidget = QtGui.QTabWidget(self)
        self.mainTabWidget.setTabsClosable(True)
        self.mainTabWidget.setMovable(True)
        self.setCentralWidget(self.mainTabWidget)
        self.connect(self.mainTabWidget, QtCore.SIGNAL("tabCloseRequested (int)"), self.on_close_tab_requested)
        self.connect(self.mainTabWidget, QtCore.SIGNAL("currentChanged (int)"), self.on_tab_change)

        ## Load Projects and Welcome
        self.on_open_project(settings.app_path().absoluteFilePath("etc/example_project/example.pde"))
        self.on_action_view(QtCore.QString("welcome"))
        self.on_action_view(QtCore.QString("projects"))
        self.mainTabWidget.setCurrentIndex(0)
        ##########################################################
        ## Status Bar
        ##########################################################
        self.statusBar().addPermanentWidget(QtGui.QLabel("Board:"))
        self.lblBoard = QtGui.QLabel("-- none --")
        self.statusBar().addPermanentWidget(self.lblBoard)

        ##########################################################
        ## Globally Shared Widgets
        ##########################################################

        ## Borads
        self.boards = app.Boards.Boards(self)
        self.connect(self.boards, QtCore.SIGNAL("board_selected"), self.on_board_selected)
        self.boards.load_current()  ## THIS actually sets current as event above is not fired in constructor

        ## API

        if not settings.value("virginity"):
            self.on_settings_dialog()

        settings.restore_window("main_window", self)
        self.on_refresh_settings()
Пример #9
0
	def compile(self, file_path):

		self.current_file_path = file_path
		self.progress.show()

		arduino_path = settings.arduino_path()
		if not arduino_path:
			self.set_error("Arduino root path not found", "..nothing to do ..")
			return
		## Set Envoironment
		env = QtCore.QStringList()
		env << QtCore.QString("ARDUINO_DIR=").append(settings.arduino_path().absolutePath())
		env << QtCore.QString("ARDUINO_BOARD=").append("atmega328")
		env << QtCore.QString("ARDUINO_sPORT=").append("s/ssdev/ttyUSB0")
		self.process.setEnvironment(env)

		print "----------------------------------------"

		## Set working dir
		sketch_dir = QtCore.QFileInfo(self.current_file_path).absolutePath()
		
		self.process.setWorkingDirectory(sketch_dir)

		command = QtCore.QString("sh ")
		## Create command sh arduinp_make.sh 
		#command.append("pwd  ") #.append(QtCore.QFileInfo(self.current_file_path).dir().path())
		#args = QtCore.QStringList()
		command.append(settings.app_path().absoluteFilePath("etc/arduino_make.sh").append(" compile"))
		#command.append(QtCore.QFileInfo(self.current_file_path).dir().path())
		print "command=", command
		self.process.start(command)
		if self.process.waitForStarted(): 
			self.process.waitForFinished()
			result =  self.process.readAllStandardOutput()
			#print type(result), result
			error = self.process.readAllStandardError()
			#print type(error), error
			if error:
				print "is error"
				self.actionIcon.setIcon(Icon(Ico.CompileError))
				self.statusLabel.setText("Error")
				self.terminalTextWidget.setPlainText(QtCore.QString(error))
			else:
				print "is ok"
				self.statusLabel.setText("OK")
				self.actionIcon.setIcon(Icon(Ico.CompileOk))
				self.terminalTextWidget.setPlainText(QtCore.QString(result))



		self.progress.hide()
		return
		command = QtCore.QString()
		## Create command sh arduinp_make.sh 
		command.append("pwd") # sh ").append(self.main.settings.app_path()).append("/etc/arduino_make.sh compile")
		#args = QtCore.QStringList()
		#command.append(self.main.settings.app_path()).append("/etc/arduino_make.sh compile ")
		#command.append(QtCore.QFileInfo(self.current_file_path).dir().path())
		print "command=", command
		process = QtCore.QProcess(self)
		process.start(command)
		if process.waitForStarted(): 
			process.waitForFinished();
			result =  process.readAllStandardOutput()
			#print type(result), result
			error = process.readAllStandardError()
			#print type(error), error
			if error:
			
				self.terminalTextWidget.setPlainText(QtCore.QString(error))
			else:
				self.terminalTextWidget.setPlainText(QtCore.QString(result))
Пример #10
0
    def __init__(self, parent, main):
        QtGui.QDialog.__init__(self, parent)
        self.main = main

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

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

        ###############################
        ## Add Website Group
        ###############################
        grp = QtGui.QGroupBox("Add Website")
        mainLayout.addWidget(grp)
        grid = QtGui.QGridLayout()
        grp.setLayout(grid)

        row = 0
        grid.addWidget(QtGui.QLabel("Group"), row, 0, 1, 1,
                       QtCore.Qt.AlignRight)
        self.comboGroup = QtGui.QComboBox()
        self.comboGroup.addItem("Arduino")
        self.comboGroup.addItem("arduino-pyqt")
        self.comboGroup.addItem("Other")
        self.comboGroup.setFixedWidth(400)  ## WTF why this not expand
        grid.addWidget(self.comboGroup, row, 1, 1, 1, QtCore.Qt.AlignLeft)

        buttAddGroup = QtGui.QToolButton()
        buttAddGroup.setIcon(Icon(Ico.Add))
        buttAddGroup.setText("New Group")
        self.connect(buttAddGroup, QtCore.SIGNAL("clicked()"),
                     self.on_add_group)
        grid.addWidget(buttAddGroup, row, 2, 1, 1, QtCore.Qt.AlignLeft)

        row += 1
        grid.addWidget(QtGui.QLabel("Title"), row, 0, 1, 1,
                       QtCore.Qt.AlignRight)
        self.txtTitle = QtGui.QLineEdit("")
        self.txtTitle.setFixedWidth(400)  ## WTF why this not expand
        grid.addWidget(self.txtTitle, row, 1, 1, 1, QtCore.Qt.AlignLeft)

        row += 1
        grid.addWidget(QtGui.QLabel("Url"), row, 0, 1, 1, QtCore.Qt.AlignRight)
        self.txtUrl = QtGui.QLineEdit("")
        self.txtUrl.setFixedWidth(700)  ## WTF why this not expand
        grid.addWidget(self.txtUrl, row, 1, 1, 2, QtCore.Qt.AlignLeft)

        row += 1
        butt = QtGui.QPushButton()
        butt.setText("Add")
        butt.setIcon(Icon(Ico.Save))
        self.connect(butt, QtCore.SIGNAL("clicked()"), self.on_add_site)
        grid.addWidget(butt, row, 2, 1, 2, QtCore.Qt.AlignRight)

        grid.setColumnStretch(0, 1)
        grid.setColumnStretch(1, 2)
        grid.setColumnStretch(2, 4)

        ##############################################
        ### Toolbar
        ##############################################

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

        self.actionDelete = toolbar.addAction(Icon(Ico.Help), "Delete Site",
                                              self.on_delete_site)
        self.actionDelete.setDisabled(True)
        toolbar.addSeparator()

        ##############################################
        ### Tree
        ##############################################
        self.tree = QtGui.QTreeWidget()
        mainLayout.addWidget(self.tree)
        self.tree.headerItem().setText(self.COLS.group, "Group")
        self.tree.headerItem().setText(self.COLS.title, "Title")
        self.tree.headerItem().setText(self.COLS.url, "Address")
        self.tree.setRootIsDecorated(True)
        self.connect(self.tree, QtCore.SIGNAL("itemSelectionChanged()"),
                     self.on_tree_selection_changed)
        self.connect(self.tree,
                     QtCore.SIGNAL("itemClicked(QTreeWidgetItem *,int)"),
                     self.on_tree_item_clicked)
        self.connect(self.tree,
                     QtCore.SIGNAL("itemChanged (QTreeWidgetItem *,int)"),
                     self.save_sites)

        ############################
        ### Storage
        self.websites_file = settings.app_path().absoluteFilePath(
            "etc/websites.yaml")
        self.sites = None  # list of sites
        self.load_sites()
Пример #11
0
	def __init__(self, parent, main):
		QtGui.QDialog.__init__(self, parent)
		self.main = main

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

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

		###############################
		## Add Website Group
		###############################
		grp = QtGui.QGroupBox("Add Website")
		mainLayout.addWidget(grp)
		grid = QtGui.QGridLayout()
		grp.setLayout(grid)
	
		row = 0
		grid.addWidget(QtGui.QLabel("Group"), row, 0, 1, 1, QtCore.Qt.AlignRight)
		self.comboGroup = QtGui.QComboBox()
		self.comboGroup.addItem("Arduino")
		self.comboGroup.addItem("arduino-pyqt")
		self.comboGroup.addItem("Other")
		self.comboGroup.setFixedWidth(400) ## WTF why this not expand
		grid.addWidget(self.comboGroup, row,  1, 1, 1, QtCore.Qt.AlignLeft)

		buttAddGroup = QtGui.QToolButton()
		buttAddGroup.setIcon(Icon(Ico.Add))
		buttAddGroup.setText("New Group")
		self.connect(buttAddGroup, QtCore.SIGNAL("clicked()"), self.on_add_group)
		grid.addWidget(buttAddGroup, row,  2, 1, 1, QtCore.Qt.AlignLeft)
	
		row += 1
		grid.addWidget(QtGui.QLabel("Title"), row, 0, 1, 1, QtCore.Qt.AlignRight)
		self.txtTitle = QtGui.QLineEdit("")
		self.txtTitle.setFixedWidth(400) ## WTF why this not expand
		grid.addWidget(self.txtTitle, row,  1, 1, 1, QtCore.Qt.AlignLeft)

		row += 1
		grid.addWidget(QtGui.QLabel("Url"), row, 0, 1, 1, QtCore.Qt.AlignRight)
		self.txtUrl = QtGui.QLineEdit("")
		self.txtUrl.setFixedWidth(700) ## WTF why this not expand
		grid.addWidget(self.txtUrl, row, 1, 1, 2, QtCore.Qt.AlignLeft)

		row += 1
		butt = QtGui.QPushButton()
		butt.setText("Add")
		butt.setIcon(Icon(Ico.Save))
		self.connect(butt, QtCore.SIGNAL("clicked()"), self.on_add_site)
		grid.addWidget(butt, row, 2, 1, 2, QtCore.Qt.AlignRight)

		grid.setColumnStretch(0, 1)
		grid.setColumnStretch(1, 2)
		grid.setColumnStretch(2, 4)

		##############################################
		### Toolbar
		##############################################

		toolbar = QtGui.QToolBar(self)
		toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
		mainLayout.addWidget( toolbar )
	
		self.actionDelete = toolbar.addAction(Icon(Ico.Help), "Delete Site", self.on_delete_site)
		self.actionDelete.setDisabled(True)
		toolbar.addSeparator()

		##############################################
		### Tree
		##############################################
		self.tree = QtGui.QTreeWidget()
		mainLayout.addWidget(self.tree)
		self.tree.headerItem().setText(self.COLS.group, "Group")
		self.tree.headerItem().setText(self.COLS.title, "Title")
		self.tree.headerItem().setText(self.COLS.url, "Address")
		self.tree.setRootIsDecorated(True)
		self.connect( self.tree, QtCore.SIGNAL("itemSelectionChanged()"), self.on_tree_selection_changed)
		self.connect( self.tree, QtCore.SIGNAL("itemClicked(QTreeWidgetItem *,int)"), self.on_tree_item_clicked)
		self.connect( self.tree, QtCore.SIGNAL("itemChanged (QTreeWidgetItem *,int)"), self.save_sites)
		

		############################
		### Storage
		self.websites_file = settings.app_path().absoluteFilePath("etc/websites.yaml")
		self.sites = None # list of sites
		self.load_sites()
Пример #12
0
    def compile(self, file_path):

        self.current_file_path = file_path
        self.progress.show()

        arduino_path = settings.arduino_path()
        if not arduino_path:
            self.set_error("Arduino root path not found", "..nothing to do ..")
            return
        ## Set Envoironment
        env = QtCore.QStringList()
        env << QtCore.QString("ARDUINO_DIR=").append(
            settings.arduino_path().absolutePath())
        env << QtCore.QString("ARDUINO_BOARD=").append("atmega328")
        env << QtCore.QString("ARDUINO_sPORT=").append("s/ssdev/ttyUSB0")
        self.process.setEnvironment(env)

        print "----------------------------------------"

        ## Set working dir
        sketch_dir = QtCore.QFileInfo(self.current_file_path).absolutePath()

        self.process.setWorkingDirectory(sketch_dir)

        command = QtCore.QString("sh ")
        ## Create command sh arduinp_make.sh
        #command.append("pwd  ") #.append(QtCore.QFileInfo(self.current_file_path).dir().path())
        #args = QtCore.QStringList()
        command.append(settings.app_path().absoluteFilePath(
            "etc/arduino_make.sh").append(" compile"))
        #command.append(QtCore.QFileInfo(self.current_file_path).dir().path())
        print "command=", command
        self.process.start(command)
        if self.process.waitForStarted():
            self.process.waitForFinished()
            result = self.process.readAllStandardOutput()
            #print type(result), result
            error = self.process.readAllStandardError()
            #print type(error), error
            if error:
                print "is error"
                self.actionIcon.setIcon(Icon(Ico.CompileError))
                self.statusLabel.setText("Error")
                self.terminalTextWidget.setPlainText(QtCore.QString(error))
            else:
                print "is ok"
                self.statusLabel.setText("OK")
                self.actionIcon.setIcon(Icon(Ico.CompileOk))
                self.terminalTextWidget.setPlainText(QtCore.QString(result))

        self.progress.hide()
        return
        command = QtCore.QString()
        ## Create command sh arduinp_make.sh
        command.append(
            "pwd"
        )  # sh ").append(self.main.settings.app_path()).append("/etc/arduino_make.sh compile")
        #args = QtCore.QStringList()
        #command.append(self.main.settings.app_path()).append("/etc/arduino_make.sh compile ")
        #command.append(QtCore.QFileInfo(self.current_file_path).dir().path())
        print "command=", command
        process = QtCore.QProcess(self)
        process.start(command)
        if process.waitForStarted():
            process.waitForFinished()
            result = process.readAllStandardOutput()
            #print type(result), result
            error = process.readAllStandardError()
            #print type(error), error
            if error:

                self.terminalTextWidget.setPlainText(QtCore.QString(error))
            else:
                self.terminalTextWidget.setPlainText(QtCore.QString(result))