Skip to content

Commit

Permalink
append python tab for run python code
Browse files Browse the repository at this point in the history
  • Loading branch information
ibarbech committed Nov 19, 2018
1 parent 6a7947d commit 17097e5
Show file tree
Hide file tree
Showing 11 changed files with 479 additions and 130 deletions.
2 changes: 1 addition & 1 deletion learnbot_dsl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
import os, sys

path = os.path.dirname(os.path.realpath(__file__))
__version__ = '0.2.31'
__version__ = '0.2.36'
8 changes: 4 additions & 4 deletions learnbot_dsl/blocksConfig/Control.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@
"name": "if",
"img": ["block6"],
"languages": { "ES": "si", "EN": "if"},
"tooltip": { "ES": "Se trata de una estructura de control que permite redirigir un curso de accion segun la evaluacion de una condicion, sea falsa o verdadera. Debe debajo de un bloque si", "EN": ""}
"tooltip": { "ES": "Se trata de una estructura de control que permite redirigir un curso de acción segun la evaluación de una condición, sea falsa o verdadera. Debe debajo de un bloque si", "EN": ""}
},

{
"type": "control",
"name": "elif",
"img": ["block6"],
"languages": { "ES": "sino si", "EN": "else if"},
"tooltip": { "ES": "Se trata de una estructura de control que permite redirigir un curso de accion segun la evaluacion de una condicion, sea falsa o verdadera. Debe debajo de un bloque si o un bloque sino si", "EN": ""}
"tooltip": { "ES": "Se trata de una estructura de control que permite redirigir un curso de acción segun la evaluación de una condición, sea falsa o verdadera. Debe debajo de un bloque si o un bloque sino si", "EN": ""}
},

{
"type": "control",
"name": "else",
"img": ["block5"],
"languages": { "ES": "sino", "EN": "else"},
"tooltip": { "ES": "Se trata de una estructura de control que permite redirigir un curso de accion segun la evaluacion de una condicion, sea falsa o verdadera. Debe debajo de un bloque si o un bloque sino si", "EN": ""}
"tooltip": { "ES": "Se trata de una estructura de control que permite redirigir un curso de acción segun la evaluación de una condición, sea falsa o verdadera. Debe debajo de un bloque si o un bloque sino si", "EN": ""}
},

{
"type": "control",
"name": "while",
"img": ["block6"],
"languages": { "ES": "mientras", "EN": "while"},
"tooltip": { "ES": "Se repetira la secuencia de codigo contenida en el bloque hasta que la condicion no se cumpla.", "EN": ""}
"tooltip": { "ES": "Se repetira la secuencia de codigo contenida en el bloque hasta que la condición no se cumpla.", "EN": ""}
},

{
Expand Down
30 changes: 24 additions & 6 deletions learnbot_dsl/blocksConfig/Operators.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
"type" : "operador",
"name" : "*",
"img" : ["block3"],
"tooltip" : {"ES": "Realiza la operación multiplicacion de los bloques conectados", "EN": ""}
"tooltip" : {"ES": "Realiza la operación multiplicación de los bloques conectados", "EN": ""}
},

{
"type" : "operador",
"name" : "/",
"img" : ["block3"],
"tooltip" : {"ES": "Realiza la operación division de los bloques conectados", "EN": ""}
"tooltip" : {"ES": "Realiza la operación división de los bloques conectados", "EN": ""}
},

{
Expand All @@ -43,7 +43,25 @@
"type" : "operador",
"name" : "+=",
"img" : ["block3"],
"tooltip" : {"ES": "Operador de adiccion a una variable, previamente inicializada", "EN": ""}
"tooltip" : {"ES": "Operador de adicción a una variable, previamente inicializada", "EN": ""}
},
{
"type" : "operador",
"name" : "-=",
"img" : ["block3"],
"tooltip" : {"ES": "Operador de resta a una variable, previamente inicializada", "EN": ""}
},
{
"type" : "operador",
"name" : "/=",
"img" : ["block3"],
"tooltip" : {"ES": "Operador de división a una variable, previamente inicializada", "EN": ""}
},
{
"type" : "operador",
"name" : "*=",
"img" : ["block3"],
"tooltip" : {"ES": "Operador de multiplicación a una variable, previamente inicializada", "EN": ""}
},
{
"type" : "operador",
Expand Down Expand Up @@ -80,23 +98,23 @@
"name" : "and",
"img" : ["block3"],
"languages" : {"ES": "Y", "EN": "and"},
"tooltip" : {"ES": "Concatena operaciones con la operacion logica Y", "EN": ""}
"tooltip" : {"ES": "Concatena operaciones con la operación lógica Y", "EN": ""}
},

{
"type" : "operador",
"name" : "or",
"img" : ["block3"],
"languages" : {"ES": "O", "EN": "or"},
"tooltip" : {"ES": "Concatena operaciones con la operacion logica O", "EN": ""}
"tooltip" : {"ES": "Concatena operaciones con la operación lógica O", "EN": ""}
},

{
"type" : "operador",
"name" : "not",
"img" : ["block3"],
"languages" : {"ES": "No", "EN": "not"},
"tooltip" : {"ES": "Niega una comparacion", "EN": ""}
"tooltip" : {"ES": "Niega una comparación", "EN": ""}
},

{
Expand Down
4 changes: 2 additions & 2 deletions learnbot_dsl/blocksConfig/Perceptual.conf
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@
"type": "boolean",
"name": "left",
"default": "0",
"translate": {"ES": "frente", "EN": "left"}
"translate": {"ES": "izquierda", "EN": "left"}
},
{
"type": "boolean",
"name": "front",
"default": "1",
"translate": {"ES": "izquierda", "EN": "front"}
"translate": {"ES": "frente", "EN": "front"}
},
{
"type": "boolean",
Expand Down
62 changes: 58 additions & 4 deletions learnbot_dsl/guis/Learnblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Form implementation generated from reading ui file '/home/ivan/robocomp/components/learnbot/learnbot_dsl/guis/Learnblock.ui'
#
# Created: Tue Nov 6 20:01:53 2018
# Created: Mon Nov 19 11:57:17 2018
# by: pyside-uic 0.2.15 running on PySide 1.2.2
#
# WARNING! All changes made in this file will be lost!
Expand Down Expand Up @@ -64,6 +64,53 @@ def setupUi(self, MainWindow):
self.Tabwi.setTabPosition(QtGui.QTabWidget.North)
self.Tabwi.setTabShape(QtGui.QTabWidget.Rounded)
self.Tabwi.setObjectName("Tabwi")
self.tab = QtGui.QWidget()
self.tab.setObjectName("tab")
self.horizontalLayout_5 = QtGui.QHBoxLayout(self.tab)
self.horizontalLayout_5.setObjectName("horizontalLayout_5")
self.verticalLayout_18 = QtGui.QVBoxLayout()
self.verticalLayout_18.setObjectName("verticalLayout_18")
self.label_4 = QtGui.QLabel(self.tab)
self.label_4.setObjectName("label_4")
self.verticalLayout_18.addWidget(self.label_4)
self.pythonCode = QtGui.QTextEdit(self.tab)
self.pythonCode.setObjectName("pythonCode")
self.verticalLayout_18.addWidget(self.pythonCode)
self.horizontalLayout_5.addLayout(self.verticalLayout_18)
self.verticalLayout_20 = QtGui.QVBoxLayout()
self.verticalLayout_20.setObjectName("verticalLayout_20")
self.gridLayout_3 = QtGui.QGridLayout()
self.gridLayout_3.setObjectName("gridLayout_3")
self.spinBoxPythonSize = QtGui.QSpinBox(self.tab)
self.spinBoxPythonSize.setMaximumSize(QtCore.QSize(61, 29))
self.spinBoxPythonSize.setProperty("value", 12)
self.spinBoxPythonSize.setObjectName("spinBoxPythonSize")
self.gridLayout_3.addWidget(self.spinBoxPythonSize, 1, 1, 1, 1)
self.label_5 = QtGui.QLabel(self.tab)
self.label_5.setObjectName("label_5")
self.gridLayout_3.addWidget(self.label_5, 1, 2, 1, 1)
self.label_6 = QtGui.QLabel(self.tab)
self.label_6.setObjectName("label_6")
self.gridLayout_3.addWidget(self.label_6, 0, 1, 1, 1)
self.verticalLayout_20.addLayout(self.gridLayout_3)
spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.verticalLayout_20.addItem(spacerItem1)
self.verticalLayout_19 = QtGui.QVBoxLayout()
self.verticalLayout_19.setObjectName("verticalLayout_19")
self.stopPythonPushButton = QtGui.QPushButton(self.tab)
self.stopPythonPushButton.setEnabled(True)
self.stopPythonPushButton.setObjectName("stopPythonPushButton")
self.verticalLayout_19.addWidget(self.stopPythonPushButton)
self.startPRPythonPushButton = QtGui.QPushButton(self.tab)
self.startPRPythonPushButton.setObjectName("startPRPythonPushButton")
self.verticalLayout_19.addWidget(self.startPRPythonPushButton)
self.startSRPythonPushButton = QtGui.QPushButton(self.tab)
self.startSRPythonPushButton.setEnabled(True)
self.startSRPythonPushButton.setObjectName("startSRPythonPushButton")
self.verticalLayout_19.addWidget(self.startSRPythonPushButton)
self.verticalLayout_20.addLayout(self.verticalLayout_19)
self.horizontalLayout_5.addLayout(self.verticalLayout_20)
self.Tabwi.addTab(self.tab, "")
self.program_text = QtGui.QWidget()
self.program_text.setEnabled(True)
self.program_text.setObjectName("program_text")
Expand Down Expand Up @@ -111,8 +158,8 @@ def setupUi(self, MainWindow):
self.label_2.setObjectName("label_2")
self.gridLayout_2.addWidget(self.label_2, 0, 1, 1, 1)
self.verticalLayout_5.addLayout(self.gridLayout_2)
spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.verticalLayout_5.addItem(spacerItem1)
spacerItem2 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.verticalLayout_5.addItem(spacerItem2)
self.verticalLayout_17 = QtGui.QVBoxLayout()
self.verticalLayout_17.setObjectName("verticalLayout_17")
self.stoptextPushButton = QtGui.QPushButton(self.program_text)
Expand Down Expand Up @@ -459,7 +506,7 @@ def setupUi(self, MainWindow):
self.menubar.addAction(self.menuHelp.menuAction())

self.retranslateUi(MainWindow)
self.Tabwi.setCurrentIndex(1)
self.Tabwi.setCurrentIndex(2)
self.functions.setCurrentIndex(1)
QtCore.QMetaObject.connectSlotsByName(MainWindow)

Expand All @@ -477,6 +524,13 @@ def retranslateUi(self, MainWindow):
self.language.setItemText(1, QtGui.QApplication.translate("MainWindow", "EN", None, QtGui.QApplication.UnicodeUTF8))
self.updatepushButton.setText(QtGui.QApplication.translate("MainWindow", "Update", None, QtGui.QApplication.UnicodeUTF8))
self.Tabwi.setWhatsThis(QtGui.QApplication.translate("MainWindow", "<html><head/><body><p>H</p><p><br/></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
self.label_4.setText(QtGui.QApplication.translate("MainWindow", "Program", None, QtGui.QApplication.UnicodeUTF8))
self.label_5.setText(QtGui.QApplication.translate("MainWindow", "px", None, QtGui.QApplication.UnicodeUTF8))
self.label_6.setText(QtGui.QApplication.translate("MainWindow", "Size Leter", None, QtGui.QApplication.UnicodeUTF8))
self.stopPythonPushButton.setText(QtGui.QApplication.translate("MainWindow", "Stop", None, QtGui.QApplication.UnicodeUTF8))
self.startPRPythonPushButton.setText(QtGui.QApplication.translate("MainWindow", "Start (physical robot)", None, QtGui.QApplication.UnicodeUTF8))
self.startSRPythonPushButton.setText(QtGui.QApplication.translate("MainWindow", "Start (simulated robot)", None, QtGui.QApplication.UnicodeUTF8))
self.Tabwi.setTabText(self.Tabwi.indexOf(self.tab), QtGui.QApplication.translate("MainWindow", "Python", None, QtGui.QApplication.UnicodeUTF8))
self.label_3.setText(QtGui.QApplication.translate("MainWindow", "Program", None, QtGui.QApplication.UnicodeUTF8))
self.connectCameraRobotpushButton.setText(QtGui.QApplication.translate("MainWindow", "Connect Camera Robot", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("MainWindow", "px", None, QtGui.QApplication.UnicodeUTF8))
Expand Down
102 changes: 101 additions & 1 deletion learnbot_dsl/guis/Learnblock.ui
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,108 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Python</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QVBoxLayout" name="verticalLayout_18">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Program</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="pythonCode"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_20">
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="1">
<widget class="QSpinBox" name="spinBoxPythonSize">
<property name="maximumSize">
<size>
<width>61</width>
<height>29</height>
</size>
</property>
<property name="value">
<number>12</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>px</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Size Leter</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_19">
<item>
<widget class="QPushButton" name="stopPythonPushButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Stop</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="startPRPythonPushButton">
<property name="text">
<string>Start (physical robot)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="startSRPythonPushButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Start (simulated robot)</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="program_text">
<property name="enabled">
<bool>true</bool>
Expand Down
9 changes: 6 additions & 3 deletions learnbot_dsl/learnbotCode/Button.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ def loadImg(self):
im = cv2.merge((r, g, b, a))
var = []
for x in self.__vars:
if getLanguage() in x.translate:
var.append(x.translate[getLanguage()])
else:
try:
if getLanguage() in x.translate:
var.append(x.translate[getLanguage()])
else:
var.append(x.name)
except:
var.append(x.name)
img = generateBlock(im, 34, self.showtext, self.__blockType, self.__connections, var, self.__type)
cv2.imwrite(self.tmpFile, img, (cv2.IMWRITE_PNG_COMPRESSION, 9))
Expand Down
Loading

0 comments on commit 17097e5

Please sign in to comment.