Qt Example: Difference between revisions

From FreeCAD Documentation
m (add __Icon__ = "home/user/.FreeCAD" on code)
(upgrade little detail "reset the checkBox and the spinBox")
Line 116: Line 116:
# ********** is a connection ** references lines **********
# ********** is a connection ** references lines **********
#
#
# horizontalScrollBar lines 146 to 156, 386, 589
# horizontalScrollBar lines 147 to 157, 386, 387, 590
# def on_horizontal_scrolling(self, val_X): #connection lines 480 to 485
# def on_horizontal_scrolling(self, val_X): #connection lines 157, 481, 486
# verticalScrollBar lines 158 to 168, 387, 590
# verticalScrollBar lines 159 to 169, 348, 349, 387, 388, 591
# def on_vertical_scrolling(self, val_Y): #connection lines 168, 488 to 493
# def on_vertical_scrolling(self, val_Y): #connection lines 169, 489, 494
# horizontalSlider lines 170 to 176, 526, 528, 591
# horizontalSlider lines 171 to 177, 527, 529, 592
# def on_horizontal_slider(self, val_X): #connection lines 176, 496 to 504
# def on_horizontal_slider(self, val_X): #connection lines 177, 497, 505
# verticalSlider lines 178 to 183, 541, 543, 592
# verticalSlider lines 179 to 184, 542, 544, 593
# def on_vertical_slider(self, val_Y): #connection lines 183, 507 to 515
# def on_vertical_slider(self, val_Y): #connection lines 184, 508, 516
# progressBar
# progressBar
# progressBar_1 lines 186 to 192, 483, 502, 530
# progressBar_1 lines 187 to 193, 484, 503, 531
# progressBar_2 lines 196 to 203, 491, 513, 545
# progressBar_2 lines 197 to 204, 492, 514, 546
# lineEdit
# lineEdit
# lineEdit_1 lines 207 to 212, 219, 405, 481, 500, 520, 587
# lineEdit_1 lines 208 to 213, 406, 482, 501, 521, 588
# def on_lineEdit_1_Pressed(self): #connection lines 211, 212, 519
# def on_lineEdit_1_Pressed(self): #connection lines 212, 213, 520
# lineEdit_2 lines 215 to 220, 408, 489, 511, 535, 588
# lineEdit_2 lines 2216 to 221, 409, 490, 512, 536, 589
# def on_lineEdit_2_Pressed(self): #connection lines 219, 220, 534
# def on_lineEdit_2_Pressed(self): #connection lines 220, 221, 535
# doubleSpinBox
# doubleSpinBox
# doubleSpinBox_1 lines 223 to 229, 411, 412, 584
# doubleSpinBox_1 lines 224 to 230, 412, 413, 585
# def on_doubleSpinBox_1_valueChanged(self,echelle): #connection lines 229, 610
# def on_doubleSpinBox_1_valueChanged(self,echelle): #connection lines 230, 616
# doubleSpinBox_2 lines 231 to 239, 414, 415, 585
# doubleSpinBox_2 lines 232 to 238, 415, 416, 586
# def on_doubleSpinBox_2_valueChanged(self,angle): #connection lines 237, 617
# def on_doubleSpinBox_2_valueChanged(self,angle): #connection lines 238, 623
# doubleSpinBox_3 lines 239 to 245, 417, 418, 586
# doubleSpinBox_3 lines 240 to 246, 418, 419, 587
# def on_doubleSpinBox_3_valueChanged(self,epaisseur): #connection lines 245, 623
# def on_doubleSpinBox_3_valueChanged(self,epaisseur): #connection lines 246, 629
# pushButton
# pushButton
# pushButton_1 lines 248 to 251, 400, 401
# pushButton_1 lines 249 to 252, 401, 402
# def on_pushButton_1_clicked(self): #connection line 579
# def on_pushButton_1_clicked(self): #connection line 252, 580
# pushButton_2 lines 254 to 257, 402, 403
# pushButton_2 lines 255 to 258, 403, 404
# def on_pushButton_2_clicked(self): #connection lines 257, 571
# def on_pushButton_2_clicked(self): #connection lines 258, 572
# groupBox lines 261 to 264, 267, 278, 288, 298, 308, 391
# groupBox lines 260 to 263, 266, 277, 286, 297, 307, 390
# radioButton
# radioButton
# radioButton_1 lines 265 to 273, 390, 391, 432, 436, 437
# radioButton_1 lines 266 to 274, 391, 392, 437, 438, 595
# def on_radioButton_1_clicked(self): #connection lines 273, 432
# def on_radioButton_1_clicked(self): #connection lines 274, 433
# radioButton_2 lines 276 to 283, 392, 393, 444, 445
# radioButton_2 lines 277 to 284, 393, 394, 445, 446
# def on_radioButton_2_clicked(self): #connection lines 283, 440
# def on_radioButton_2_clicked(self): #connection lines 284, 441
# radioButton_3 lines 286 to 395, 451, 452
# radioButton_3 lines 287 to 294, 395, 396, 452, 453
# def on_radioButton_3_clicked(self): #connection lines 293, 448
# def on_radioButton_3_clicked(self): #connection lines 294, 449
# radioButton_4 lines 296 to 397, 459, 460
# radioButton_4 lines 297 to 304, 397, 398, 460, 461
# def on_radioButton_4_clicked(self): #connection lines 303, 455
# def on_radioButton_4_clicked(self): #connection lines 304, 456
# checkBox
# checkBox
# checkBox_1 lines 307 to 315, 399, 400, 555, 559, 560, 566, 567
# checkBox_1 lines 307 to 315, 399, 400, 555, 559, 560, 566, 567, 596, 599
# def on_checkBox_1_clicked(self): #connection lines 310, 550
# def on_checkBox_1_clicked(self): #connection lines 311, 551
# textEdit
# textEdit
# textEdit lines 341 to 349, 484, 492, 503, 514, 593, 631
# textEdit lines 342 to 350, 485, 493, 504, 515, 594, 637
# def on_textEdit_Changed(self): #connection lines 350, 631
# def on_textEdit_Changed(self): #connection lines 350, 636
# graphicsView lines 354 to 361, 602, 608
# graphicsView lines 352 to 361, 606, 612
#
#
#
#
#
#
#
#

__title__ = "Examples_QT "
__title__ = "Examples_QT "
__author__ = "mario52"
__author__ = "mario52"
__version__ = "00.01"
__version__ = "00.02"
__date__ = "23/08/2015"
__date__ = "15/10/2015"

__url__ = "http://www.freecadweb.org/index-fr.html"
__url__ = "http://www.freecadweb.org/index-fr.html"
__Comment__ = "Example make and use buttom and . . . ."
__Comment__ = "Example make and use buttom and . . . ."
__Communication__ = "http://www.freecadweb.org/wiki/index.php?title=User:Mario52"
__Communication__ = "http://www.freecadweb.org/wiki/index.php?title=User:Mario52"
__Icon__ = "home/user/.FreeCAD"
__Icon__ = "home/user/.FreeCAD"
__IconW__ = "C:\Users\UserName\AppData\Roaming\FreeCAD"
__IconW__ = "C:/Users/UserName/AppData/Roaming/FreeCAD"

import PySide
import PySide
from PySide import QtCore, QtGui
from PySide import QtCore, QtGui
#from PySide.QtGui import qApp, QApplication, QGridLayout, QLineEdit, QPushButton, QTextBrowser, QWidget, QProgressBar
#from PySide.QtGui import qApp, QApplication, QGridLayout, QLineEdit, QPushButton, QTextBrowser, QWidget, QProgressBar

global switch ; switch = 0
global switch ; switch = 0

global path
global path
#path = your_directory_path # your directory path
#path = your_directory_path # your directory path
#path = FreeCAD.ConfigGet("AppHomePath") # path FreeCAD installation
#path = FreeCAD.ConfigGet("AppHomePath") # path FreeCAD installation
path = FreeCAD.ConfigGet("UserAppData") # path FreeCAD User data
path = FreeCAD.ConfigGet("UserAppData") # path FreeCAD User data

try:
try:
_fromUtf8 = QtCore.QString.fromUtf8
_fromUtf8 = QtCore.QString.fromUtf8
Line 193: Line 193:
def _fromUtf8(s):
def _fromUtf8(s):
return s
return s

try:
try:
_encoding = QtGui.QApplication.UnicodeUTF8
_encoding = QtGui.QApplication.UnicodeUTF8
Line 201: Line 201:
def _translate(context, text, disambig):
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
return QtGui.QApplication.translate(context, text, disambig)

class Ui_MainWindow(object):
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
def setupUi(self, MainWindow):
self.window = MainWindow
self.window = MainWindow
global switch
global switch

MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(400, 328)
MainWindow.resize(400, 328)
Line 213: Line 213:
self.widget = QtGui.QWidget(MainWindow)
self.widget = QtGui.QWidget(MainWindow)
self.widget.setObjectName(_fromUtf8("widget"))
self.widget.setObjectName(_fromUtf8("widget"))

## section horizontalScrollBar (same Slider)
## section horizontalScrollBar (same Slider)
# self.horizontalScrollBar = QtGui.QScrollBar(self.widget) # create horizontalScrollBar
# self.horizontalScrollBar = QtGui.QScrollBar(self.widget) # create horizontalScrollBar
Line 237: Line 237:
# self.verticalScrollBar.setObjectName(_fromUtf8("verticalScrollBar")) # object Name
# self.verticalScrollBar.setObjectName(_fromUtf8("verticalScrollBar")) # object Name
# self.verticalScrollBar.valueChanged.connect(self.on_vertical_scrolling) # connect on "def on_vertical_scrolling:" for execute action
# self.verticalScrollBar.valueChanged.connect(self.on_vertical_scrolling) # connect on "def on_vertical_scrolling:" for execute action

# section horizontalSlider
# section horizontalSlider
self.horizontalSlider = QtGui.QSlider(self.widget) # create horizontalSlider
self.horizontalSlider = QtGui.QSlider(self.widget) # create horizontalSlider
Line 245: Line 245:
self.horizontalSlider.setObjectName(_fromUtf8("horizontalSlider")) # object Name
self.horizontalSlider.setObjectName(_fromUtf8("horizontalSlider")) # object Name
self.horizontalSlider.valueChanged.connect(self.on_horizontal_slider) # connect on "def on_horizontal_slider:" for execute action
self.horizontalSlider.valueChanged.connect(self.on_horizontal_slider) # connect on "def on_horizontal_slider:" for execute action

# section verticalSlider
# section verticalSlider
self.verticalSlider = QtGui.QSlider(self.widget) # create verticalSlider
self.verticalSlider = QtGui.QSlider(self.widget) # create verticalSlider
Line 252: Line 252:
self.verticalSlider.setObjectName(_fromUtf8("verticalSlider")) # object Name
self.verticalSlider.setObjectName(_fromUtf8("verticalSlider")) # object Name
self.verticalSlider.valueChanged.connect(self.on_vertical_slider) # connect on "def on_vertical_slider:" for execute action
self.verticalSlider.valueChanged.connect(self.on_vertical_slider) # connect on "def on_vertical_slider:" for execute action

# section progressBar 1
# section progressBar 1
self.progressBar_1 = QtGui.QProgressBar(self.widget) # create object progressBar_1
self.progressBar_1 = QtGui.QProgressBar(self.widget) # create object progressBar_1
Line 262: Line 262:
self.progressBar_1.setToolTip(_translate("MainWindow", "progressBar_1 for lineEdit 1 and horizontal ScrollBar", None)) # tooltip for explanation
self.progressBar_1.setToolTip(_translate("MainWindow", "progressBar_1 for lineEdit 1 and horizontal ScrollBar", None)) # tooltip for explanation
# a tooltip can be set to all objects
# a tooltip can be set to all objects

# section progressBar 2
# section progressBar 2
self.progressBar_2 = QtGui.QProgressBar(self.widget) # create object progressBar_2
self.progressBar_2 = QtGui.QProgressBar(self.widget) # create object progressBar_2
Line 273: Line 273:
self.progressBar_2.setToolTip(_translate("MainWindow", "progressBar_2 for lineEdit 2 and vertical ScrollBar", None)) # tooltip for explanation
self.progressBar_2.setToolTip(_translate("MainWindow", "progressBar_2 for lineEdit 2 and vertical ScrollBar", None)) # tooltip for explanation
# a tooltip can be set to all objects
# a tooltip can be set to all objects

# section lineEdit 1
# section lineEdit 1
self.lineEdit_1 = QtGui.QLineEdit(self.widget) # create object lineEdit_1
self.lineEdit_1 = QtGui.QLineEdit(self.widget) # create object lineEdit_1
Line 289: Line 289:
# self.lineEdit_2.returnPressed.connect(self.on_lineEdit_2_Pressed) # connect on def "on_lineEdit_2_Pressed" for execute actionn # for validate the data with press on return touch
# self.lineEdit_2.returnPressed.connect(self.on_lineEdit_2_Pressed) # connect on def "on_lineEdit_2_Pressed" for execute actionn # for validate the data with press on return touch
self.lineEdit_2.textChanged.connect(self.on_lineEdit_2_Pressed) # connect on def "on_lineEdit_2_Pressed" for execute actionn # with tips key char by char
self.lineEdit_2.textChanged.connect(self.on_lineEdit_2_Pressed) # connect on def "on_lineEdit_2_Pressed" for execute actionn # with tips key char by char

# accelerated minimum maximum singleStep prefix suffix
# accelerated minimum maximum singleStep prefix suffix
self.doubleSpinBox_1 = QtGui.QDoubleSpinBox(self.widget) # create object doubleSpinBox_1
self.doubleSpinBox_1 = QtGui.QDoubleSpinBox(self.widget) # create object doubleSpinBox_1
Line 298: Line 298:
self.doubleSpinBox_1.setObjectName(_fromUtf8("doubleSpinBox_1")) # name of object
self.doubleSpinBox_1.setObjectName(_fromUtf8("doubleSpinBox_1")) # name of object
self.doubleSpinBox_1.valueChanged.connect(self.on_doubleSpinBox_1_valueChanged) #connect on def "on_doubleSpinBox_1_valueChanged"
self.doubleSpinBox_1.valueChanged.connect(self.on_doubleSpinBox_1_valueChanged) #connect on def "on_doubleSpinBox_1_valueChanged"

self.doubleSpinBox_2 = QtGui.QDoubleSpinBox(self.widget) # create object doubleSpinBox_2
self.doubleSpinBox_2 = QtGui.QDoubleSpinBox(self.widget) # create object doubleSpinBox_2
self.doubleSpinBox_2.setGeometry(QtCore.QRect(70, 140, 62, 22)) # coordinates position
self.doubleSpinBox_2.setGeometry(QtCore.QRect(70, 140, 62, 22)) # coordinates position
Line 306: Line 306:
self.doubleSpinBox_2.setObjectName(_fromUtf8("doubleSpinBox_2")) # name of object
self.doubleSpinBox_2.setObjectName(_fromUtf8("doubleSpinBox_2")) # name of object
self.doubleSpinBox_2.valueChanged.connect(self.on_doubleSpinBox_2_valueChanged) # connect on def "on_doubleSpinBox_2_valueChanged"
self.doubleSpinBox_2.valueChanged.connect(self.on_doubleSpinBox_2_valueChanged) # connect on def "on_doubleSpinBox_2_valueChanged"

self.doubleSpinBox_3 = QtGui.QDoubleSpinBox(self.widget) # create object doubleSpinBox_3
self.doubleSpinBox_3 = QtGui.QDoubleSpinBox(self.widget) # create object doubleSpinBox_3
self.doubleSpinBox_3.setGeometry(QtCore.QRect(70, 170, 62, 22)) # coordinates position
self.doubleSpinBox_3.setGeometry(QtCore.QRect(70, 170, 62, 22)) # coordinates position
Line 314: Line 314:
self.doubleSpinBox_3.setObjectName(_fromUtf8("doubleSpinBox_3")) # name of object
self.doubleSpinBox_3.setObjectName(_fromUtf8("doubleSpinBox_3")) # name of object
self.doubleSpinBox_3.valueChanged.connect(self.on_doubleSpinBox_3_valueChanged) # connect on def "on_doubleSpinBox_3_valueChanged"
self.doubleSpinBox_3.valueChanged.connect(self.on_doubleSpinBox_3_valueChanged) # connect on def "on_doubleSpinBox_3_valueChanged"

# section pushButton 1
# section pushButton 1
self.pushButton_1 = QtGui.QPushButton(self.widget) # create object PushButton_1
self.pushButton_1 = QtGui.QPushButton(self.widget) # create object PushButton_1
Line 320: Line 320:
self.pushButton_1.setObjectName(_fromUtf8("pushButton_1")) # name of object
self.pushButton_1.setObjectName(_fromUtf8("pushButton_1")) # name of object
self.pushButton_1.clicked.connect(self.on_pushButton_1_clicked) # connect on def "on_pushButton_1_clicked"
self.pushButton_1.clicked.connect(self.on_pushButton_1_clicked) # connect on def "on_pushButton_1_clicked"

# section pushButton 2
# section pushButton 2
self.pushButton_2 = QtGui.QPushButton(self.widget) # create object pushButton_2
self.pushButton_2 = QtGui.QPushButton(self.widget) # create object pushButton_2
Line 326: Line 326:
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) # name of object
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) # name of object
self.pushButton_2.clicked.connect(self.on_pushButton_2_clicked) # connect on def "on_pushButton_2_clicked"
self.pushButton_2.clicked.connect(self.on_pushButton_2_clicked) # connect on def "on_pushButton_2_clicked"

# section groupBox for the four radioButton
# section groupBox for the four radioButton
self.groupBox = QtGui.QGroupBox(self.widget) # this is the group for associate the four radioButton
self.groupBox = QtGui.QGroupBox(self.widget) # this is the group for associate the four radioButton
self.groupBox.setGeometry(QtCore.QRect(250, 45, 125, 181)) # coordinates position
self.groupBox.setGeometry(QtCore.QRect(250, 45, 125, 181)) # coordinates position
self.groupBox.setObjectName(_fromUtf8("groupBox")) # name of window groupBox
self.groupBox.setObjectName(_fromUtf8("groupBox")) # name of window groupBox

# section radioButton 1
# section radioButton 1
self.radioButton_1 = QtGui.QRadioButton(self.groupBox) # create object QRadioButton in groupBox
self.radioButton_1 = QtGui.QRadioButton(self.groupBox) # create object QRadioButton in groupBox
Line 342: Line 342:
self.radioButton_1.setIcon(icon01) # associate button and image
self.radioButton_1.setIcon(icon01) # associate button and image
self.radioButton_1.clicked.connect(self.on_radioButton_1_clicked) # connect radioButton_1 on "def on_radioButton_1_clicked:"
self.radioButton_1.clicked.connect(self.on_radioButton_1_clicked) # connect radioButton_1 on "def on_radioButton_1_clicked:"

# section radioButton 2
# section radioButton 2
self.radioButton_2 = QtGui.QRadioButton(self.groupBox) # create object QRadioButton in groupBox
self.radioButton_2 = QtGui.QRadioButton(self.groupBox) # create object QRadioButton in groupBox
Line 352: Line 352:
self.radioButton_2.setIcon(icon02) # associate button and image
self.radioButton_2.setIcon(icon02) # associate button and image
self.radioButton_2.clicked.connect(self.on_radioButton_2_clicked) # connect radioButton_2 on "def on_radioButton_2_clicked:"
self.radioButton_2.clicked.connect(self.on_radioButton_2_clicked) # connect radioButton_2 on "def on_radioButton_2_clicked:"

# section radioButton 3
# section radioButton 3
self.radioButton_3 = QtGui.QRadioButton(self.groupBox) # create object QRadioButton in groupBox
self.radioButton_3 = QtGui.QRadioButton(self.groupBox) # create object QRadioButton in groupBox
Line 362: Line 362:
self.radioButton_3.setIcon(icon03) # associate button and image
self.radioButton_3.setIcon(icon03) # associate button and image
self.radioButton_3.clicked.connect(self.on_radioButton_3_clicked) # connect radioButton_3 on "def on_radioButton_3_clicked:"
self.radioButton_3.clicked.connect(self.on_radioButton_3_clicked) # connect radioButton_3 on "def on_radioButton_3_clicked:"

# section radioButton 4
# section radioButton 4
self.radioButton_4 = QtGui.QRadioButton(self.groupBox) # create object QRadioButton in groupBox
self.radioButton_4 = QtGui.QRadioButton(self.groupBox) # create object QRadioButton in groupBox
Line 372: Line 372:
self.radioButton_4.setIcon(icon04) # associate button and image
self.radioButton_4.setIcon(icon04) # associate button and image
self.radioButton_4.clicked.connect(self.on_radioButton_4_clicked) # connect radioButton_4 on "def on_radioButton_4_clicked:"
self.radioButton_4.clicked.connect(self.on_radioButton_4_clicked) # connect radioButton_4 on "def on_radioButton_4_clicked:"

# section checkBox 1
# section checkBox 1
self.checkBox_1 = QtGui.QCheckBox(self.groupBox) # create object QRadioButton in groupBox
self.checkBox_1 = QtGui.QCheckBox(self.groupBox) # create object QRadioButton in groupBox
Line 383: Line 383:
icon1.addPixmap(QtGui.QPixmap(self.image_1),QtGui.QIcon.Normal, QtGui.QIcon.Off) #
icon1.addPixmap(QtGui.QPixmap(self.image_1),QtGui.QIcon.Normal, QtGui.QIcon.Off) #
self.checkBox_1.setIcon(icon1) # associate button and image
self.checkBox_1.setIcon(icon1) # associate button and image


self.label_1 = QtGui.QLabel(self.widget) # labels displayed on widget
self.label_1 = QtGui.QLabel(self.widget) # labels displayed on widget
self.label_1.setGeometry(QtCore.QRect(140, 50, 110, 16)) # label coordinates
self.label_1.setGeometry(QtCore.QRect(140, 50, 110, 16)) # label coordinates
self.label_1.setObjectName(_fromUtf8("label_1")) # label name
self.label_1.setObjectName(_fromUtf8("label_1")) # label name

self.label_2 = QtGui.QLabel(self.widget)
self.label_2 = QtGui.QLabel(self.widget)
self.label_2.setGeometry(QtCore.QRect(140, 80, 110, 16))
self.label_2.setGeometry(QtCore.QRect(140, 80, 110, 16))
self.label_2.setObjectName(_fromUtf8("label_2"))
self.label_2.setObjectName(_fromUtf8("label_2"))

self.label_3 = QtGui.QLabel(self.widget)
self.label_3 = QtGui.QLabel(self.widget)
self.label_3.setGeometry(QtCore.QRect(140, 110, 100, 16))
self.label_3.setGeometry(QtCore.QRect(140, 110, 100, 16))
self.label_3.setObjectName(_fromUtf8("label_3"))
self.label_3.setObjectName(_fromUtf8("label_3"))

self.label_4 = QtGui.QLabel(self.widget)
self.label_4 = QtGui.QLabel(self.widget)
self.label_4.setGeometry(QtCore.QRect(140, 140, 100, 16))
self.label_4.setGeometry(QtCore.QRect(140, 140, 100, 16))
self.label_4.setObjectName(_fromUtf8("label_4"))
self.label_4.setObjectName(_fromUtf8("label_4"))

self.label_5 = QtGui.QLabel(self.widget)
self.label_5 = QtGui.QLabel(self.widget)
self.label_5.setGeometry(QtCore.QRect(140, 170, 100, 16))
self.label_5.setGeometry(QtCore.QRect(140, 170, 100, 16))
self.label_5.setObjectName(_fromUtf8("label_5"))
self.label_5.setObjectName(_fromUtf8("label_5"))

self.label_6 = QtGui.QLabel(self.widget)
self.label_6 = QtGui.QLabel(self.widget)
self.label_6.setGeometry(QtCore.QRect(70, 215, 159, 25))
self.label_6.setGeometry(QtCore.QRect(70, 215, 159, 25))
self.label_6.setObjectName(_fromUtf8("label_6"))
self.label_6.setObjectName(_fromUtf8("label_6"))

self.textEdit = QtGui.QTextEdit(self.widget)
self.textEdit = QtGui.QTextEdit(self.widget)
self.textEdit.setGeometry(QtCore.QRect(251, 235, 124, 58))
self.textEdit.setGeometry(QtCore.QRect(251, 235, 124, 58))
Line 418: Line 418:
#self.textEdit.verticalScrollBar().setSliderPosition(0) # Slider Position
#self.textEdit.verticalScrollBar().setSliderPosition(0) # Slider Position
self.textEdit.textChanged.connect(self.on_textEdit_Changed) #connection on_textEdit_Changed
self.textEdit.textChanged.connect(self.on_textEdit_Changed) #connection on_textEdit_Changed

### ---graphicsView---
### ---graphicsView---
self.graphicsView = QtGui.QGraphicsView(self.widget) # graphic view declaration
self.graphicsView = QtGui.QGraphicsView(self.widget) # graphic view declaration
Line 429: Line 429:
self.graphicsView.setScene(ui.scene) # display image in the graphicView
self.graphicsView.setScene(ui.scene) # display image in the graphicView
### ---graphicsView---
### ---graphicsView---

MainWindow.setCentralWidget(self.widget)
MainWindow.setCentralWidget(self.widget)
self.menuBar = QtGui.QMenuBar(MainWindow)
self.menuBar = QtGui.QMenuBar(MainWindow)
Line 444: Line 444:
self.statusbar.setObjectName(_fromUtf8("statusbar"))
self.statusbar.setObjectName(_fromUtf8("statusbar"))
MainWindow.setStatusBar(self.statusbar)
MainWindow.setStatusBar(self.statusbar)

self.retranslateUi(MainWindow)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)

def retranslateUi(self, MainWindow):
def retranslateUi(self, MainWindow):
MainWindow.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # this function turns the front window (stay to hint)
MainWindow.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # this function turns the front window (stay to hint)
MainWindow.setWindowTitle(_translate("MainWindow", "Qt_Example", None)) # title main window
MainWindow.setWindowTitle(_translate("MainWindow", "Qt_Example", None)) # title main window
MainWindow.setWindowIcon(QtGui.QIcon(path+'MEPlan.png')) # change the icon of the main window
MainWindow.setWindowIcon(QtGui.QIcon(path+'MEPlan.png')) # change the icon of the main window

# for horizontalScrollBar
# for horizontalScrollBar
# self.horizontalScrollBar.setToolTip(_translate("MainWindow", "horizontalScrollBar", None))
# self.horizontalScrollBar.setToolTip(_translate("MainWindow", "horizontalScrollBar", None))
# self.verticalScrollBar.setToolTip(_translate("MainWindow", "verticalScrollBar", None))
# self.verticalScrollBar.setToolTip(_translate("MainWindow", "verticalScrollBar", None))

self.groupBox.setTitle(_translate("MainWindow", "View", None))
self.groupBox.setTitle(_translate("MainWindow", "View", None))
self.radioButton_1.setToolTip(_translate("MainWindow", "radioButton_1", None))
self.radioButton_1.setToolTip(_translate("MainWindow", "radioButton_1", None))
Line 472: Line 472:
self.pushButton_2.setToolTip(_translate("MainWindow", "pushButton_2", None))
self.pushButton_2.setToolTip(_translate("MainWindow", "pushButton_2", None))
self.pushButton_2.setText(_translate("MainWindow", "Quit", None))
self.pushButton_2.setText(_translate("MainWindow", "Quit", None))

self.lineEdit_1.setToolTip(_translate("MainWindow", "LineEdit 1", None))
self.lineEdit_1.setToolTip(_translate("MainWindow", "LineEdit 1", None))
self.label_1.setText(_translate("MainWindow", "LineEdit 1", None))
self.label_1.setText(_translate("MainWindow", "LineEdit 1", None))

self.lineEdit_2.setToolTip(_translate("MainWindow", "LineEdit_2", None))
self.lineEdit_2.setToolTip(_translate("MainWindow", "LineEdit_2", None))
self.label_2.setText(_translate("MainWindow", "LineEdit 2", None))
self.label_2.setText(_translate("MainWindow", "LineEdit 2", None))

self.label_3.setText(_translate("MainWindow", "doubleSpinBox_1", None))
self.label_3.setText(_translate("MainWindow", "doubleSpinBox_1", None))
self.doubleSpinBox_1.setToolTip(_translate("MainWindow", "doubleSpinBox_1", None))
self.doubleSpinBox_1.setToolTip(_translate("MainWindow", "doubleSpinBox_1", None))

self.label_4.setText(_translate("MainWindow", "doubleSpinBox_2", None))
self.label_4.setText(_translate("MainWindow", "doubleSpinBox_2", None))
self.doubleSpinBox_2.setToolTip(_translate("MainWindow", "doubleSpinBox_2", None))
self.doubleSpinBox_2.setToolTip(_translate("MainWindow", "doubleSpinBox_2", None))

self.label_5.setText(_translate("MainWindow", "doubleSpinBox_3", None))
self.label_5.setText(_translate("MainWindow", "doubleSpinBox_3", None))
self.doubleSpinBox_3.setToolTip(_translate("MainWindow", "doubleSpinBox_3", None))
self.doubleSpinBox_3.setToolTip(_translate("MainWindow", "doubleSpinBox_3", None))

font = QtGui.QFont() # see http://doc.qt.io/qt-4.8/qfont.html # label text displayed and colored in red
font = QtGui.QFont() # see http://doc.qt.io/qt-4.8/qfont.html # label text displayed and colored in red
font.setFamily("Times New Roman") # font used (Windows)
font.setFamily("Times New Roman") # font used (Windows)
Line 497: Line 497:
self.label_6.setStyleSheet("color : #ff0000") # Color text
self.label_6.setStyleSheet("color : #ff0000") # Color text
self.label_6.setText(_translate("MainWindow", "Hello world", None)) # same resultt with "<b>Hello world</b>"
self.label_6.setText(_translate("MainWindow", "Hello world", None)) # same resultt with "<b>Hello world</b>"

########### section connections on def #############################
########### section connections on def #############################
# radioboutons
# radioboutons
Line 507: Line 507:
print "radioButton_1"
print "radioButton_1"
#
#
def on_radioButton_2_clicked(self): # connection on_radioButton_2_clicked
def on_radioButton_2_clicked(self): # connection on_radioButton_2_clicked
#
#
Line 515: Line 515:
print "radioButton_2"
print "radioButton_2"
#
#

def on_radioButton_3_clicked(self): # connection on_radioButton_3_clicked
def on_radioButton_3_clicked(self): # connection on_radioButton_3_clicked
#
#
Line 522: Line 522:
print "radioButton_3"
print "radioButton_3"
#
#

def on_radioButton_4_clicked(self): # connection on_radioButton_4_clicked
def on_radioButton_4_clicked(self): # connection on_radioButton_4_clicked
#
#
Line 530: Line 530:
print "radioButton_4"
print "radioButton_4"
#
#

def affectation_X (self,val_X0): # connection affectation_X
def affectation_X (self,val_X0): # connection affectation_X
#val_X = float(val_X0) # extract the value and transform it in float
#val_X = float(val_X0) # extract the value and transform it in float
Line 538: Line 538:
print val_X0
print val_X0
#
#

def affectation_Y (self,val_Y0): # connection affectation_Y
def affectation_Y (self,val_Y0): # connection affectation_Y
#val_Y = float(val_Y0) # extract the value and transform it in float
#val_Y = float(val_Y0) # extract the value and transform it in float
Line 546: Line 546:
print val_Y0
print val_Y0
#
#

# # scroll bar barres coulissantes
# # scroll bar barres coulissantes
# def on_horizontal_scrolling(self, val_X): # connection on_horizontal_scrolling
# def on_horizontal_scrolling(self, val_X): # connection on_horizontal_scrolling
Line 562: Line 562:
# self.textEdit.setText(str(val_Y))
# self.textEdit.setText(str(val_Y))
# print "on_vertical_scrolling"
# print "on_vertical_scrolling"

# slider barres coulissantes
# slider barres coulissantes
def on_horizontal_slider(self, val_X): # connection on_horizontal_slider
def on_horizontal_slider(self, val_X): # connection on_horizontal_slider
Line 574: Line 574:
print "on_horizontal_slider" # displayed on View repport
print "on_horizontal_slider" # displayed on View repport
#
#

def on_vertical_slider(self, val_Y): # connection on_vertical_slider
def on_vertical_slider(self, val_Y): # connection on_vertical_slider
#
#
Line 585: Line 585:
print "on_vertical_slider" # displayed on View repport
print "on_vertical_slider" # displayed on View repport
#
#

# lineEdit
# lineEdit
def on_lineEdit_1_Pressed(self): # connection on_lineEdit_1_Pressed
def on_lineEdit_1_Pressed(self): # connection on_lineEdit_1_Pressed
Line 601: Line 601:
print val_X
print val_X
#
#
def on_lineEdit_2_Pressed(self): # connection on_lineEdit_2_Pressed
def on_lineEdit_2_Pressed(self): # connection on_lineEdit_2_Pressed
val_Y = self.lineEdit_2.text() # extract the string in the lineEdit
val_Y = self.lineEdit_2.text() # extract the string in the lineEdit
Line 616: Line 616:
print val_Y
print val_Y
#
#
# checkbox_01
# checkbox_01
def on_checkBox_1_clicked(self): # connection on_checkBox_1_clicked
def on_checkBox_1_clicked(self): # connection on_checkBox_1_clicked
Line 637: Line 637:
print "Mode free" # diplayed on View Repport
print "Mode free" # diplayed on View Repport
#
#

# Buttons
# Buttons
def on_pushButton_2_clicked(self): # Button Quit # connection on_pushButton_2_clicked
def on_pushButton_2_clicked(self): # Button Quit # connection on_pushButton_2_clicked
Line 646: Line 646:
self.window.hide() # hide the window and close the macro
self.window.hide() # hide the window and close the macro
#
#

def on_pushButton_1_clicked(self): # Button Reset # connection on_pushButton_1_clicked
def on_pushButton_1_clicked(self): # Button Reset # connection on_pushButton_1_clicked
#
#
Line 662: Line 662:
self.verticalSlider.setValue(0) # gives the value "0" to the verticalSlider
self.verticalSlider.setValue(0) # gives the value "0" to the verticalSlider
self.textEdit.clear() # cleans the textEdit
self.textEdit.clear() # cleans the textEdit
self.radioButton_1.setChecked(True) # by default True or False (one in the group))

self.checkBox_1.setChecked(True) # Check by default True or False
icon1 = QtGui.QIcon() # create image name
icon1.addPixmap(QtGui.QPixmap(self.image_1),QtGui.QIcon.Normal, QtGui.QIcon.Off) #
self.checkBox_1.setIcon(icon1) # associate button and image
if switch == 0: # switch for image in the graphic view Py or FC
if switch == 0: # switch for image in the graphic view Py or FC
switch = 1
switch = 1
Line 677: Line 682:
print "Reset"
print "Reset"
#
#

def on_doubleSpinBox_1_valueChanged(self,echelle): # connection on_doubleSpinBox_1_valueChanged
def on_doubleSpinBox_1_valueChanged(self,echelle): # connection on_doubleSpinBox_1_valueChanged
#
#
Line 684: Line 689:
print "SpinBox 1 ", echelle
print "SpinBox 1 ", echelle
#
#
def on_doubleSpinBox_2_valueChanged(self,angle): # connection on_doubleSpinBox_2_valueChanged
def on_doubleSpinBox_2_valueChanged(self,angle): # connection on_doubleSpinBox_2_valueChanged
#
#
Line 690: Line 695:
#
#
print "SpinBox 2 ", angle
print "SpinBox 2 ", angle

def on_doubleSpinBox_3_valueChanged(self,epaisseur): # connection on_doubleSpinBox_3_valueChanged
def on_doubleSpinBox_3_valueChanged(self,epaisseur): # connection on_doubleSpinBox_3_valueChanged
#
#
Line 697: Line 702:
print "SpinBox 3 ", epaisseur
print "SpinBox 3 ", epaisseur
#
#

def on_textEdit_Changed(self): # conection on_textEdit_Changed
def on_textEdit_Changed(self): # conection on_textEdit_Changed
texte = unicode(self.textEdit.toPlainText()) # extract the string of textEdit
texte = unicode(self.textEdit.toPlainText()) # extract the string of textEdit
Line 705: Line 710:
print texte
print texte
#
#

#######################################
#######################################

MainWindow = QtGui.QMainWindow()
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui = Ui_MainWindow()

Revision as of 09:18, 15 October 2015

File:MEPlan Macro Qt Example

Description
It describes Qt commands.

Author: Mario52
Author
Mario52
Download
None
Links
Macro Version
1.0
Date last modified
None
FreeCAD Version(s)
None
Default shortcut
None
See also
None

This macro is an example of using Qt commands their connections, extraction and data assignment.

Are treated :

  1. icon for window : The icon displayed on main window
  2. horizontalSlider : horizontal slider its connection and data extraction / assignment
  3. progressBar horizontal : progress bar horizontal its connection and data extraction / assignment
  4. verticalSlider : vertical slider its connection and data extraction / assignment
  5. progressBar vertical : progress bar vertical its connection and data extraction / assignment
  6. lineEdit : line edit its connection and data extraction / assignment
  7. lineEdit : line edit its connection and data extraction / assignment
  8. doubleSpinBox : double spinbox its connection and data extraction / assignment
  9. doubleSpinBox :
  10. doubleSpinBox :
  11. buttom : buttom its connection
  12. buttom :
  13. radioButtom : radio button with icons its connection and checked
  14. checkBox : checkbox with icon its connection checked and unchecked
  15. textEdit : text edit its connection and data extraction / assignment
  16. graphicsView : graphic view with 2 graphs and method used for change image

The tools used are : python-2.7.8

PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x32

The icons used

You must copy and paste the images in the same directory as the macro, here :

path = FreeCAD.ConfigGet("UserAppData")    # path FreeCAD User data

Linux : "home/user/.FreeCAD"

Windows : "C:\Users\UserName\AppData\Roaming\FreeCAD"

Script

Qt_Example.FCMacro

# -*- coding: utf-8 -*-
"""
***************************************************************************
*   Copyright (c) 2015 <mario52>                                          *
*                                                                         *
*   This file is a supplement to the FreeCAD CAx development system.      *
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU Lesser General Public License (LGPL)    *
*   as published by the Free Software Foundation; either version 2 of     *
*   the License, or (at your option) any later version.                   *
*   for detail see the LICENCE text file.                                 *
*                                                                         *
*   This software is distributed in the hope that it will be useful,      *
*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
*   GNU Library General Public License for more details.                  *
*                                                                         *
*   You should have received a copy of the GNU Library General Public     *
*   License along with this macro; if not, write to the Free Software     *
*   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
*   USA                                                                   *
***************************************************************************
*           WARNING! All changes in this file will be lost and            *  
*                  may cause malfunction of the program                   *
***************************************************************************
"""
# this macro is made with Python 2.7 and Qt 4.8.7
# 
# the modules used hare :
# python-2.7.8.msi                            #    https://www.python.org/downloads/
# PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x32.exe      #    https://riverbankcomputing.com/software/pyqt/download
#
# FreeCAD
##OS: Windows 8
##Word size of OS: 64-bit
##Word size of FreeCAD: 64-bit
##Version: 0.15.4671 (Git)
##"Branch: releases/FreeCAD-0-15
##Hash: 244b3aef360841646cbfe80a1b225c8b39c8380c
##Python version: 2.7.8
##Qt version: 4.8.6
##Coin version: 4.0.0a
##OCC version: 6.8.0.oce-0.17
#
# this macro is an example of use some buttons and connection :
#                                                    ********** is a connection  ** references lines **********
# 
# horizontalScrollBar                                                               lines 147 to 157, 386, 387, 590
#    def on_horizontal_scrolling(self, val_X):                  #connection         lines 157, 481, 486
# verticalScrollBar                                                                 lines 159 to 169, 348, 349, 387, 388, 591 
#    def on_vertical_scrolling(self, val_Y):                    #connection         lines 169, 489, 494
# horizontalSlider                                                                  lines 171 to 177, 527, 529, 592
#    def on_horizontal_slider(self, val_X):                     #connection         lines 177, 497, 505
# verticalSlider                                                                    lines 179 to 184, 542, 544, 593
#    def on_vertical_slider(self, val_Y):                       #connection         lines 184, 508, 516
# progressBar
#     progressBar_1                                                                 lines 187 to 193, 484, 503, 531
#     progressBar_2                                                                 lines 197 to 204, 492, 514, 546
# lineEdit
#     lineEdit_1                                                                    lines 208 to 213, 406, 482, 501, 521, 588
#        def on_lineEdit_1_Pressed(self):                       #connection         lines 212, 213, 520
#     lineEdit_2                                                                    lines 2216 to 221, 409, 490, 512, 536, 589
#        def on_lineEdit_2_Pressed(self):                       #connection         lines 220, 221, 535
# doubleSpinBox
#     doubleSpinBox_1                                                               lines 224 to 230, 412, 413, 585
#        def on_doubleSpinBox_1_valueChanged(self,echelle):     #connection         lines 230, 616
#     doubleSpinBox_2                                                               lines 232 to 238, 415, 416, 586
#        def on_doubleSpinBox_2_valueChanged(self,angle):       #connection         lines 238, 623
#     doubleSpinBox_3                                                               lines 240 to 246, 418, 419, 587 
#        def on_doubleSpinBox_3_valueChanged(self,epaisseur):   #connection         lines 246, 629
# pushButton
#     pushButton_1                                                                  lines 249 to 252, 401, 402
#        def on_pushButton_1_clicked(self):                     #connection         line 252, 580
#     pushButton_2                                                                  lines 255 to 258, 403, 404
#        def on_pushButton_2_clicked(self):                     #connection         lines 258, 572
# groupBox                                                                          lines 260 to 263, 266, 277, 286, 297, 307, 390
#     radioButton
#         radioButton_1                                                             lines 266 to 274, 391, 392, 437, 438, 595
#            def on_radioButton_1_clicked(self):                #connection         lines 274, 433
#         radioButton_2                                                             lines 277 to 284, 393, 394, 445, 446
#            def on_radioButton_2_clicked(self):                #connection         lines 284, 441
#         radioButton_3                                                             lines 287 to 294, 395, 396, 452, 453
#            def on_radioButton_3_clicked(self):                #connection         lines 294, 449
#         radioButton_4                                                             lines 297 to 304, 397, 398, 460, 461
#            def on_radioButton_4_clicked(self):                #connection         lines 304, 456
# checkBox
#        checkBox_1                                                                 lines 307 to 315, 399, 400, 555, 559, 560, 566, 567, 596, 599
#        def on_checkBox_1_clicked(self):                       #connection         lines 311, 551
# textEdit
#        textEdit                                                                   lines 342 to 350, 485, 493, 504, 515, 594, 637
#        def on_textEdit_Changed(self):                         #connection         lines 350, 636
# graphicsView                                                                      lines 352 to 361, 606, 612
# 
# 
# 
# 
 
__title__   = "Examples_QT "
__author__  = "mario52"
__version__ = "00.02"
__date__    = "15/10/2015"
 
__url__     = "http://www.freecadweb.org/index-fr.html"
__Comment__ = "Example make and use buttom and . . . ."
__Communication__ = "http://www.freecadweb.org/wiki/index.php?title=User:Mario52"
__Icon__  = "home/user/.FreeCAD"
__IconW__  = "C:/Users/UserName/AppData/Roaming/FreeCAD"
 
import PySide
from PySide import QtCore, QtGui
#from PySide.QtGui import qApp, QApplication, QGridLayout, QLineEdit, QPushButton, QTextBrowser, QWidget, QProgressBar
 
global switch ; switch = 0
 
global path
#path = your_directory_path                # your directory path
#path = FreeCAD.ConfigGet("AppHomePath")   # path FreeCAD installation
path = FreeCAD.ConfigGet("UserAppData")    # path FreeCAD User data
 
try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s
 
try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)
 
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        self.window = MainWindow
        global switch
 
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(400, 328)
        MainWindow.setMinimumSize(QtCore.QSize(400, 328))
        MainWindow.setMaximumSize(QtCore.QSize(400, 328))
        self.widget = QtGui.QWidget(MainWindow)
        self.widget.setObjectName(_fromUtf8("widget"))
 
##        section horizontalScrollBar                                                        (same Slider)
#        self.horizontalScrollBar = QtGui.QScrollBar(self.widget)                           # create horizontalScrollBar
#        self.horizontalScrollBar.setGeometry(QtCore.QRect(64, 5, 302, 16))                 # coordinates position
#        #self.horizontalScrollBar.setMinimum(-100)                                         # minimum value
#        self.horizontalScrollBar.setMaximum(100)                                           # maximum value
#        #self.horizontalScrollBar.setSingleStep(3)                                         # here step 3 ..
#        self.horizontalScrollBar.setValue( 5)                                              # value by default
#        self.horizontalScrollBar.setOrientation(QtCore.Qt.Horizontal)                      # orientation Horizontal
#        #self.horizontalScrollBar.setInvertedAppearance(True)                              # displacement rigth to left or left to rigth value "True" or "False"
#        self.horizontalScrollBar.setObjectName(_fromUtf8("horizontalScrollBar"))           # object Name
#        self.horizontalScrollBar.valueChanged.connect(self.on_horizontal_scrolling)        # connect on "def on_horizontal_scrolling:" for execute action
#
##        section verticalScrollBar
#        self.verticalScrollBar = QtGui.QScrollBar(self.widget)                             # create verticalScrollBar
#        self.verticalScrollBar.setGeometry(QtCore.QRect(20, 44, 20, 250))                  # coordinates position
#        #self.verticalScrollBar.setMinimum(-100)                                           # minimum value
#        self.verticalScrollBar.setMaximum(100)                                             # maximum value
#        #self.verticalScrollBar.setSingleStep(3)                                           # here step 3 .. degault 1
#        self.verticalScrollBar.setValue(5)                                                 # value by default
#        self.verticalScrollBar.setOrientation(QtCore.Qt.Vertical)                          # orientation Vertical
#        self.verticalScrollBar.setInvertedAppearance(True)                                 # displacement top to bottom or botton to top value "True" or "False" 
#        self.verticalScrollBar.setObjectName(_fromUtf8("verticalScrollBar"))               # object Name
#        self.verticalScrollBar.valueChanged.connect(self.on_vertical_scrolling)            # connect on "def on_vertical_scrolling:" for execute action
 
#        section horizontalSlider 
        self.horizontalSlider = QtGui.QSlider(self.widget)                                  # create horizontalSlider
        self.horizontalSlider.setGeometry(QtCore.QRect(64, 5, 302, 16))                     # coordinates position
        self.horizontalSlider.setOrientation(QtCore.Qt.Horizontal)                          # orientation Horizontal
        self.horizontalSlider.setInvertedAppearance(False)                                  # displacement rigth to left or left to rigth value "True" or "False"
        self.horizontalSlider.setObjectName(_fromUtf8("horizontalSlider"))                  # object Name
        self.horizontalSlider.valueChanged.connect(self.on_horizontal_slider)               # connect on "def on_horizontal_slider:" for execute action
 
#        section verticalSlider 
        self.verticalSlider = QtGui.QSlider(self.widget)                                   # create verticalSlider
        self.verticalSlider.setGeometry(QtCore.QRect(20, 44, 20, 250))                     # coordinates position
        self.verticalSlider.setOrientation(QtCore.Qt.Vertical)                             # orientation Vertical
        self.verticalSlider.setObjectName(_fromUtf8("verticalSlider"))                     # object Name
        self.verticalSlider.valueChanged.connect(self.on_vertical_slider)                  # connect on "def on_vertical_slider:" for execute action
 
#        section progressBar 1
        self.progressBar_1 = QtGui.QProgressBar(self.widget)                               # create object progressBar_1
        self.progressBar_1.setGeometry(QtCore.QRect(60, 21, 315, 23))                      # coordinates position
        self.progressBar_1.setValue(0)                                                     # value by default
        self.progressBar_1.setOrientation(QtCore.Qt.Horizontal)                            # orientation Horizontal
        self.progressBar_1.setAlignment(QtCore.Qt.AlignCenter)                             # align text center
        self.progressBar_1.setObjectName(_fromUtf8("progressBar_1"))                        # object Name
        self.progressBar_1.setToolTip(_translate("MainWindow", "progressBar_1 for lineEdit 1 and horizontal ScrollBar", None)) # tooltip for explanation
                                                                                            # a tooltip can be set to all objects
 
#        section progressBar 2
        self.progressBar_2 = QtGui.QProgressBar(self.widget)                                # create object progressBar_2
        self.progressBar_2.setGeometry(QtCore.QRect(40, 44, 20, 250))                       # coordinates position
        self.progressBar_2.setValue(0)                                                      # value by default
        self.progressBar_2.setOrientation(QtCore.Qt.Vertical)                               # position Vertical
        self.progressBar_2.setAlignment(QtCore.Qt.AlignCenter)                              # align text center (not text displayed ?)
        self.progressBar_2.setOrientation(QtCore.Qt.Vertical)                               # orientation Vertical
        self.progressBar_2.setObjectName(_fromUtf8("progressBar_2"))                        # progressBar 2 Y Vertical
        self.progressBar_2.setToolTip(_translate("MainWindow", "progressBar_2 for lineEdit 2 and vertical ScrollBar", None)) # tooltip for explanation
                                                                                            # a tooltip can be set to all objects
 
#        section lineEdit 1
        self.lineEdit_1 = QtGui.QLineEdit(self.widget)                                      # create object lineEdit_1
        self.lineEdit_1.setGeometry(QtCore.QRect(70, 50, 60, 22))                           # coordinates position
        self.lineEdit_1.setObjectName(_fromUtf8("lineEdit_1"))                              # name of object
        self.lineEdit_1.setText(QtGui.QApplication.translate("Form", "0", None, QtGui.QApplication.UnicodeUTF8))              # text by default
        #self.lineEdit_1.returnPressed.connect(self.on_lineEdit_1_Pressed)                  # connect on def "on_lineEdit_1_Pressed" for execute actionn   # for validate the data with press on return touch
        self.lineEdit_1.textChanged.connect(self.on_lineEdit_1_Pressed)                     # connect on def "on_lineEdit_1_Pressed" for execute actionn   # with tips key char by char
                                                                                            # a tooltip can be set to all objects
#        section lineEdit 2
        self.lineEdit_2 = QtGui.QLineEdit(self.widget)                                      # create object lineEdit_2
        self.lineEdit_2.setGeometry(QtCore.QRect(70, 80, 60, 22))                           # coordinates position
        self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2"))                              # name of object
        self.lineEdit_2.setText(QtGui.QApplication.translate("Form", "0", None, QtGui.QApplication.UnicodeUTF8)) # text by default
#        self.lineEdit_2.returnPressed.connect(self.on_lineEdit_2_Pressed)                  # connect on def "on_lineEdit_2_Pressed" for execute actionn   # for validate the data with press on return touch
        self.lineEdit_2.textChanged.connect(self.on_lineEdit_2_Pressed)                     # connect on def "on_lineEdit_2_Pressed" for execute actionn   # with tips key char by char
 
        # accelerated minimum maximum singleStep prefix suffix
        self.doubleSpinBox_1 = QtGui.QDoubleSpinBox(self.widget)                            # create object doubleSpinBox_1
        self.doubleSpinBox_1.setGeometry(QtCore.QRect(70, 110, 62, 22))                     # coordinates position
        self.doubleSpinBox_1.setMinimum(-10000.0)                                           # minimum value
        self.doubleSpinBox_1.setMaximum(10000.0)                                            # maximum value
        self.doubleSpinBox_1.setSingleStep(0.1)                                             # step for increase or decrease value here 0.1
        self.doubleSpinBox_1.setObjectName(_fromUtf8("doubleSpinBox_1"))                    # name of object
        self.doubleSpinBox_1.valueChanged.connect(self.on_doubleSpinBox_1_valueChanged)     #connect on def "on_doubleSpinBox_1_valueChanged"
 
        self.doubleSpinBox_2 = QtGui.QDoubleSpinBox(self.widget)                            # create object doubleSpinBox_2
        self.doubleSpinBox_2.setGeometry(QtCore.QRect(70, 140, 62, 22))                     # coordinates position
        self.doubleSpinBox_2.setMinimum(-361.0)                                             # minimum value
        self.doubleSpinBox_2.setMaximum(361.0)                                              # maximum value
        self.doubleSpinBox_2.setSingleStep(1)                                               # step for increase or decrease value here 1
        self.doubleSpinBox_2.setObjectName(_fromUtf8("doubleSpinBox_2"))                    # name of object
        self.doubleSpinBox_2.valueChanged.connect(self.on_doubleSpinBox_2_valueChanged)     # connect on def "on_doubleSpinBox_2_valueChanged"
 
        self.doubleSpinBox_3 = QtGui.QDoubleSpinBox(self.widget)                            # create object doubleSpinBox_3
        self.doubleSpinBox_3.setGeometry(QtCore.QRect(70, 170, 62, 22))                     # coordinates position
        self.doubleSpinBox_3.setMinimum(0)                                                  # minimum value
        self.doubleSpinBox_3.setMaximum(100.0)                                              # maximum value
        self.doubleSpinBox_3.setSingleStep(0.05)                                            # step for increase or decrease value here 0.05
        self.doubleSpinBox_3.setObjectName(_fromUtf8("doubleSpinBox_3"))                    # name of object
        self.doubleSpinBox_3.valueChanged.connect(self.on_doubleSpinBox_3_valueChanged)     # connect on def "on_doubleSpinBox_3_valueChanged"
 
#        section pushButton 1
        self.pushButton_1 = QtGui.QPushButton(self.widget)                                  # create object PushButton_1
        self.pushButton_1.setGeometry(QtCore.QRect(70, 198, 65, 20))                        # coordinates position
        self.pushButton_1.setObjectName(_fromUtf8("pushButton_1"))                          # name of object
        self.pushButton_1.clicked.connect(self.on_pushButton_1_clicked)                     # connect on def "on_pushButton_1_clicked"
 
#        section pushButton 2
        self.pushButton_2 = QtGui.QPushButton(self.widget)                                  # create object pushButton_2
        self.pushButton_2.setGeometry(QtCore.QRect(150, 198, 65, 20))                       # coordinates position
        self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))                          # name of object
        self.pushButton_2.clicked.connect(self.on_pushButton_2_clicked)                     # connect on def "on_pushButton_2_clicked"
 
#        section groupBox for the four radioButton
        self.groupBox = QtGui.QGroupBox(self.widget)                                        # this is the group for associate the four radioButton
        self.groupBox.setGeometry(QtCore.QRect(250, 45, 125, 181))                          # coordinates position
        self.groupBox.setObjectName(_fromUtf8("groupBox"))                                  # name of window groupBox
 
#        section radioButton 1
        self.radioButton_1 = QtGui.QRadioButton(self.groupBox)                              # create object QRadioButton in groupBox
        self.radioButton_1.setGeometry(QtCore.QRect(10, 30, 110, 20))                       # coordinates position
        self.radioButton_1.setObjectName(_fromUtf8("radioButton_1"))                        # name of object
        self.radioButton_1.setChecked(True)                                                 # by default True or False (one in the group))
        self.image_01 = path+"MEPlanT.png"                                                  # image dedicate of the button
        icon01 = QtGui.QIcon()                                                              # create image name
        icon01.addPixmap(QtGui.QPixmap(self.image_01),QtGui.QIcon.Normal, QtGui.QIcon.Off)  #
        self.radioButton_1.setIcon(icon01)                                                  # associate button and image
        self.radioButton_1.clicked.connect(self.on_radioButton_1_clicked)                   # connect radioButton_1 on "def on_radioButton_1_clicked:"
 
#        section radioButton 2
        self.radioButton_2 = QtGui.QRadioButton(self.groupBox)                              # create object QRadioButton in groupBox
        self.radioButton_2.setGeometry(QtCore.QRect(10, 60, 110, 20))                       # coordinates position
        self.radioButton_2.setObjectName(_fromUtf8("radioButton_2"))                        # name of object
        self.image_02 = path+"MEPlanF.png"                                                  # image dedicate of the button
        icon02 = QtGui.QIcon()                                                              # create image name
        icon02.addPixmap(QtGui.QPixmap(self.image_02),QtGui.QIcon.Normal, QtGui.QIcon.Off)  #
        self.radioButton_2.setIcon(icon02)                                                  # associate button and image
        self.radioButton_2.clicked.connect(self.on_radioButton_2_clicked)                   # connect radioButton_2 on "def on_radioButton_2_clicked:"
 
#        section radioButton 3
        self.radioButton_3 = QtGui.QRadioButton(self.groupBox)                              # create object QRadioButton in groupBox
        self.radioButton_3.setGeometry(QtCore.QRect(10, 90, 110, 20))                       # coordinates position
        self.radioButton_3.setObjectName(_fromUtf8("radioButton_3"))                        # name of object
        self.image_03 = path+"MEPlanD.png"                                                  # image dedicate of the button
        icon03 = QtGui.QIcon()                                                              # create image name
        icon03.addPixmap(QtGui.QPixmap(self.image_03),QtGui.QIcon.Normal, QtGui.QIcon.Off)  #
        self.radioButton_3.setIcon(icon03)                                                  # associate button and image
        self.radioButton_3.clicked.connect(self.on_radioButton_3_clicked)                   # connect radioButton_3 on "def on_radioButton_3_clicked:"
 
#        section radioButton 4
        self.radioButton_4 = QtGui.QRadioButton(self.groupBox)                              # create object QRadioButton in groupBox
        self.radioButton_4.setGeometry(QtCore.QRect(10, 150, 110, 20))                      # coordinates position
        self.radioButton_4.setObjectName(_fromUtf8("radioButton_4"))                        # name of object
        self.image_04 = path+"MEPlanI.png"                                                  # image dedicate of the button
        icon04 = QtGui.QIcon()                                                              # create image name
        icon04.addPixmap(QtGui.QPixmap(self.image_04),QtGui.QIcon.Normal, QtGui.QIcon.Off)  #
        self.radioButton_4.setIcon(icon04)                                                  # associate button and image
        self.radioButton_4.clicked.connect(self.on_radioButton_4_clicked)                   # connect radioButton_4 on "def on_radioButton_4_clicked:"
 
#        section checkBox 1
        self.checkBox_1 = QtGui.QCheckBox(self.groupBox)                                    # create object QRadioButton in groupBox
        self.checkBox_1.setGeometry(QtCore.QRect(20, 120, 110, 20))                         # coordinates position
        self.checkBox_1.setObjectName(_fromUtf8("checkBox_1"))                              # name of object
        self.checkBox_1.setChecked(True)                                                    # Check by default True or False
        self.checkBox_1.clicked.connect(self.on_checkBox_1_clicked)                         # connect on def "on_checkBox_1_clicked"
        self.image_1 = path+"MEpipe01.png"                                                  # image dedicate of the button
        icon1 = QtGui.QIcon()                                                               # create image name
        icon1.addPixmap(QtGui.QPixmap(self.image_1),QtGui.QIcon.Normal, QtGui.QIcon.Off)    # 
        self.checkBox_1.setIcon(icon1)                                                      # associate button and image
 
 
        self.label_1 = QtGui.QLabel(self.widget)                                            # labels displayed on widget
        self.label_1.setGeometry(QtCore.QRect(140, 50, 110, 16))                            # label coordinates 
        self.label_1.setObjectName(_fromUtf8("label_1"))                                    # label name
 
        self.label_2 = QtGui.QLabel(self.widget)
        self.label_2.setGeometry(QtCore.QRect(140, 80, 110, 16))
        self.label_2.setObjectName(_fromUtf8("label_2"))
 
        self.label_3 = QtGui.QLabel(self.widget)
        self.label_3.setGeometry(QtCore.QRect(140, 110, 100, 16))
        self.label_3.setObjectName(_fromUtf8("label_3"))
 
        self.label_4 = QtGui.QLabel(self.widget)
        self.label_4.setGeometry(QtCore.QRect(140, 140, 100, 16))
        self.label_4.setObjectName(_fromUtf8("label_4"))
 
        self.label_5 = QtGui.QLabel(self.widget)
        self.label_5.setGeometry(QtCore.QRect(140, 170, 100, 16))
        self.label_5.setObjectName(_fromUtf8("label_5"))
 
        self.label_6 = QtGui.QLabel(self.widget)
        self.label_6.setGeometry(QtCore.QRect(70, 215, 159, 25))
        self.label_6.setObjectName(_fromUtf8("label_6"))
 
        self.textEdit = QtGui.QTextEdit(self.widget)
        self.textEdit.setGeometry(QtCore.QRect(251, 235, 124, 58))
        self.textEdit.setObjectName(_fromUtf8("textEdit"))
        #self.textEdit.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)            #
        self.textEdit.setText("TexEdit ")
        self.textEdit.setToolTip(_translate("MainWindow", "textEdit", None))
        #self.textEdit.verticalScrollBar().setValue(0)                                      # verticalScrollBar Position
        #self.textEdit.verticalScrollBar().setSliderPosition(0)                             # Slider Position
        self.textEdit.textChanged.connect(self.on_textEdit_Changed)                         #connection on_textEdit_Changed
 
        ### ---graphicsView---
        self.graphicsView = QtGui.QGraphicsView(self.widget)                                # graphic view declaration
        self.graphicsView.setGeometry(QtCore.QRect(70, 235, 168, 60))                       # coordinates position
        self.graphicsView.setFrameShape(QtGui.QFrame.StyledPanel)                           # Frame for the gaphic view
        self.graphicsView.setObjectName(_fromUtf8("graphicsView"))                          # name gaphicView
        pic = QtGui.QPixmap(path+"MEPlanFC.png")                                            # image displayed in the graphicView
        self.scene = QtGui.QGraphicsScene()                                                 #
        self.scene.addPixmap(QtGui.QPixmap(pic))                                            # adding image in the graphicView
        self.graphicsView.setScene(ui.scene)                                                # display image in the graphicView
        ### ---graphicsView---
 
        MainWindow.setCentralWidget(self.widget)
        self.menuBar = QtGui.QMenuBar(MainWindow)
        self.menuBar.setGeometry(QtCore.QRect(0, 0, 400, 26))
        self.menuBar.setObjectName(_fromUtf8("menuBar"))
        MainWindow.setMenuBar(self.menuBar)
        self.mainToolBar = QtGui.QToolBar(MainWindow)
        self.mainToolBar.setObjectName(_fromUtf8("mainToolBar"))
        MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.mainToolBar)
        self.statusBar = QtGui.QStatusBar(MainWindow)
        self.statusBar.setObjectName(_fromUtf8("statusBar"))
        MainWindow.setStatusBar(self.statusBar)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        MainWindow.setStatusBar(self.statusbar)
 
        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
 
    def retranslateUi(self, MainWindow):
        MainWindow.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint)                   # this function turns the front window (stay to hint)
        MainWindow.setWindowTitle(_translate("MainWindow", "Qt_Example", None))            # title main window
        MainWindow.setWindowIcon(QtGui.QIcon(path+'MEPlan.png'))                           # change the icon of the main window
 
#        for horizontalScrollBar
#        self.horizontalScrollBar.setToolTip(_translate("MainWindow", "horizontalScrollBar", None))
#        self.verticalScrollBar.setToolTip(_translate("MainWindow", "verticalScrollBar", None))
 
        self.groupBox.setTitle(_translate("MainWindow", "View", None))
        self.radioButton_1.setToolTip(_translate("MainWindow", "radioButton_1", None))
        self.radioButton_1.setText(_translate("MainWindow", "radioButton_1", None))
        self.radioButton_2.setToolTip(_translate("MainWindow", "radioButton_2", None))
        self.radioButton_2.setText(_translate("MainWindow", "radioButton_2", None))
        self.radioButton_3.setToolTip(_translate("MainWindow", "radioButton_3" , None))
        self.radioButton_3.setText(_translate("MainWindow", "radioButton_3", None))
        self.radioButton_4.setToolTip(_translate("MainWindow", "radioButton_4", None))
        self.radioButton_4.setText(_translate("MainWindow", "radioButton_4", None))
        self.checkBox_1.setToolTip(_translate("MainWindow", "checkBox_1", None))
        self.checkBox_1.setText(_translate("MainWindow", "checkBox_1", None))
        self.pushButton_1.setToolTip(_translate("MainWindow", "pushButton_1", None))
        self.pushButton_1.setText(_translate("MainWindow", "Reset", None))
        self.pushButton_2.setToolTip(_translate("MainWindow", "pushButton_2", None))
        self.pushButton_2.setText(_translate("MainWindow", "Quit", None))
 
        self.lineEdit_1.setToolTip(_translate("MainWindow", "LineEdit 1", None))
        self.label_1.setText(_translate("MainWindow", "LineEdit 1", None))
 
        self.lineEdit_2.setToolTip(_translate("MainWindow", "LineEdit_2", None))
        self.label_2.setText(_translate("MainWindow", "LineEdit 2", None))
 
        self.label_3.setText(_translate("MainWindow", "doubleSpinBox_1", None))
        self.doubleSpinBox_1.setToolTip(_translate("MainWindow", "doubleSpinBox_1", None))
 
        self.label_4.setText(_translate("MainWindow", "doubleSpinBox_2", None))
        self.doubleSpinBox_2.setToolTip(_translate("MainWindow", "doubleSpinBox_2", None))
 
        self.label_5.setText(_translate("MainWindow", "doubleSpinBox_3", None))
        self.doubleSpinBox_3.setToolTip(_translate("MainWindow", "doubleSpinBox_3", None))
 
        font = QtGui.QFont()          # see http://doc.qt.io/qt-4.8/qfont.html              # label text displayed and colored in red
        font.setFamily("Times New Roman")                                                   # font used (Windows)
        font.setPointSize(10)                                                               # font PointSize
        font.setWeight(10)                                                                  # font Weight
        font.setBold(True)                                                                  # Bolt True or False 
        self.label_6.setFont(font)                                                          # associate label_6 and font
        self.label_6.setObjectName("label_6")                                               # name of object
        self.label_6.setStyleSheet("color : #ff0000")                                       # Color text
        self.label_6.setText(_translate("MainWindow", "Hello world", None))                 # same resultt with "<b>Hello world</b>"
 
    ########### section connections on def #############################
    # radioboutons
    def on_radioButton_1_clicked(self):                                                     # connection on_radioButton_1_clicked
        #
        #here your code
        #
        self.label_6.setText(_translate("MainWindow", "radioButton_1          ", None))     # display in the label_6 (red)
        print "radioButton_1"
        #
 
    def on_radioButton_2_clicked(self):                                                     # connection on_radioButton_2_clicked
        #
        #here your code
        #
        self.label_6.setText(_translate("MainWindow", "radioButton_2          ", None))     # display in the label_6 (red)
        print "radioButton_2"
        #
 
    def on_radioButton_3_clicked(self):                                                     # connection on_radioButton_3_clicked
        #
        #here your code
        self.label_6.setText(_translate("MainWindow", "radioButton_3          ", None))     # display in the label_6 (red)
        print "radioButton_3"
        #
 
    def on_radioButton_4_clicked(self):                                                     # connection on_radioButton_4_clicked
        #
        #here your code
        #
        self.label_6.setText(_translate("MainWindow", "radioButton_4         ", None))      # display in the label_6 (red)
        print "radioButton_4"
        #
 
    def affectation_X (self,val_X0):                                                        # connection affectation_X
        #val_X = float(val_X0)                                                              # extract the value and transform it in float
        #
        #here your code
        #
        print val_X0
        #
 
    def affectation_Y (self,val_Y0):                                                        # connection affectation_Y
        #val_Y = float(val_Y0)                                                              # extract the value and transform it in float
        #
        #here your code
        #
        print val_Y0
        #
 
#    # scroll bar barres coulissantes
#    def on_horizontal_scrolling(self, val_X):                                              # connection on_horizontal_scrolling
#        self.lineEdit_1.setText(str(val_X))
#        self.affectation_X(val_X)
#        self.progressBar_1.setValue(val_X)
#        self.textEdit.setText(str(val_X))
#        print "on_horizontal_scrolling"
#
#
#    def on_vertical_scrolling(self, val_Y):                                                # connection on_vertical_scrolling
#        self.lineEdit_2.setText(str(val_Y))
#        self.affectation_Y(val_Y)
#        self.progressBar_2.setValue(val_Y)
#        self.textEdit.setText(str(val_Y))
#        print "on_vertical_scrolling"
 
    # slider barres coulissantes
    def on_horizontal_slider(self, val_X):                                                  # connection on_horizontal_slider
        #
        #here your code
        #
        self.lineEdit_1.setText(str(val_X))                                                 # affect the value "val_X" and displayed in lineEdit_1
        self.affectation_X(val_X)
        self.progressBar_1.setValue(val_X)                                                  # affect the value "val_X" in progressbar_1
        self.textEdit.setText(str(val_X))                                                   # affect the value "val_X" in textEdit 
        print "on_horizontal_slider"                                                        # displayed on View repport
        #
 
    def on_vertical_slider(self, val_Y):                                                    # connection on_vertical_slider
        #
        #here your code
        #
        self.lineEdit_2.setText(str(val_Y))                                                 # affect the value "val_Y" and displayed in lineEdit_2
        self.affectation_Y(val_Y)
        self.progressBar_2.setValue(val_Y)                                                  # affect the value "val_Y" in progressbar_2
        self.textEdit.setText(str(val_Y))                                                   # affect the value "val_Y" in textEdit 
        print "on_vertical_slider"                                                          # displayed on View repport
        #
 
    # lineEdit
    def on_lineEdit_1_Pressed(self):                                                        # connection on_lineEdit_1_Pressed
        val_X = self.lineEdit_1.text()                                                      # extract the string in the lineEdit
        #
        #here your code
        #
        self.affectation_X(val_X)
        try:
            self.horizontalSlider.setValue(int(val_X))                                      # affect the value "val_X" on horizontalSlider and modify this
        except Exception:                                                                   # if error
            self.horizontalSlider.setValue(int(0))                                          # affect the value "0" on horizontalSlider and modify this
            val_X = "0"
        self.progressBar_1.setValue(int(val_X))                                             # affect the value "val_X" on progressBar_1 and modify this
        print val_X
        #
 
    def on_lineEdit_2_Pressed(self):                                                        # connection on_lineEdit_2_Pressed
        val_Y = self.lineEdit_2.text()                                                      # extract the string in the lineEdit
        #
        #here your code
        #
        self.affectation_Y(val_Y)
        try:
            self.verticalSlider.setValue(int(val_Y))                                        # affect the value "val_Y" on verticalSlider and modify this
        except Exception:                                                                   # if error
            self.verticalSlider.setValue(int(0))                                            # affect the value "0" on verticalSlider and modify this
            val_Y = "0"
        self.progressBar_2.setValue(int(val_Y))                                             # affect the value "val_Y" on progressBar_2 and modify this
        print val_Y
        #
 
    #  checkbox_01
    def on_checkBox_1_clicked(self):                                                        # connection on_checkBox_1_clicked
        #
        #here your code
        #
        if self.checkBox_1.isChecked():                                                     # if checkbox_01 is checked then ....
            self.image_1 = path+"MEpipe01.png"                                              # configure image_1
            icon1 = QtGui.QIcon()
            icon1.addPixmap(QtGui.QPixmap(self.image_1),QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.checkBox_1.setIcon(icon1)                                                  # affect image_1 to checkBox_1
            self.checkBox_1.setText(_translate("MainWindow", "Attached", None))             # text for checkBox_1
            print "Mode attached"                                                           # diplayed on View Repport
        else:                                                                               # if checkbox_01 is not checked then ....
            self.image_2 = path+"MEpipe02.png"                                              # configure image_2
            icon2 = QtGui.QIcon() 
            icon2.addPixmap(QtGui.QPixmap(self.image_2),QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.checkBox_1.setIcon(icon2)                                                  # affect image_2 to checkBox_1
            self.checkBox_1.setText(_translate("MainWindow", "Free", None))                 # text for checkBox_1
            print "Mode free"                                                               # diplayed on View Repport
        #
 
    # Buttons
    def on_pushButton_2_clicked(self):    # Button Quit                                     # connection on_pushButton_2_clicked
        #
        #here your code
        #
        App.Console.PrintMessage("End\r\n")
        self.window.hide()                                                                  # hide the window and close the macro
        #
 
    def on_pushButton_1_clicked(self):    # Button Reset                                    # connection on_pushButton_1_clicked
        #
        #here your code
        #
        global switch
        self.doubleSpinBox_1.setValue(0)                                                    # gives the value "0" to the doubleSpinBox_1
        self.doubleSpinBox_2.setValue(0)                                                    # gives the value "0" to the doubleSpinBox_2
        self.doubleSpinBox_3.setValue(0)                                                    # gives the value "0" to the doubleSpinBox_3
        self.lineEdit_1.setText(QtGui.QApplication.translate("Form", "0", None, QtGui.QApplication.UnicodeUTF8)) # gives the value "0" to the lineEdit_1
        self.lineEdit_2.setText(QtGui.QApplication.translate("Form", "0", None, QtGui.QApplication.UnicodeUTF8)) # gives the value "0" to the lineEdit_2
        #self.horizontalScrollBar.setValue(0)                                               # gives the value "0" to the horizontalScrollBar
        #self.verticalScrollBar.setValue(0)                                                 # gives the value "0" to the verticalScrollBar
        self.horizontalSlider.setValue(0)                                                   # gives the value "0" to the horizontalSlider
        self.verticalSlider.setValue(0)                                                     # gives the value "0" to the verticalSlider
        self.textEdit.clear()                                                               # cleans the textEdit
        self.radioButton_1.setChecked(True)                                                 # by default True or False (one in the group))
        self.checkBox_1.setChecked(True)                                                    # Check by default True or False
        icon1 = QtGui.QIcon()                                                               # create image name
        icon1.addPixmap(QtGui.QPixmap(self.image_1),QtGui.QIcon.Normal, QtGui.QIcon.Off)    # 
        self.checkBox_1.setIcon(icon1)                                                      # associate button and image
 
        if switch == 0:                                                                     # switch for image in the graphic view Py or FC
            switch = 1
            pic = QtGui.QPixmap(path+"MEPlanPY.png")                                        # image (Python)
            self.scene = QtGui.QGraphicsScene()                                             # name of image
            self.scene.addPixmap(QtGui.QPixmap(pic))                                        # add image "pic" (MEPlanPY.png)
            self.graphicsView.setScene(ui.scene)                                            # display the image in graphicview
        else:
            switch = 0
            pic = QtGui.QPixmap(path+"MEPlanFC.png")                                        # image (FreeCAD)
            self.scene = QtGui.QGraphicsScene()                                             # name of image
            self.scene.addPixmap(QtGui.QPixmap(pic))                                        # add image "pic" (MEPlanFC.png)
            self.graphicsView.setScene(ui.scene)                                            # display the image in graphicview
        print "Reset"
        #
 
    def on_doubleSpinBox_1_valueChanged(self,echelle):                                      # connection on_doubleSpinBox_1_valueChanged
        #
        #here your code
        #
        print "SpinBox 1 ", echelle
        #
 
    def on_doubleSpinBox_2_valueChanged(self,angle):                                        # connection on_doubleSpinBox_2_valueChanged
        #
        #here your code
        #
        print "SpinBox 2 ", angle
 
    def on_doubleSpinBox_3_valueChanged(self,epaisseur):                                    # connection on_doubleSpinBox_3_valueChanged
        #
        #here your code
        #
        print "SpinBox 3 ", epaisseur
        #
 
    def on_textEdit_Changed(self):                                                          # conection on_textEdit_Changed
        texte = unicode(self.textEdit.toPlainText())                                        # extract the string of textEdit
        #
        #here your code
        #
        print texte
        #
 
#######################################
 
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()

Enjoy

Other languages: