def test_qslider_intervention(self): parent = QHBoxLayout() slider = QSlider() # Don't specify orientation. ChildAdder.add(slider, 'fred', parent) # We promise to give it horizontal (the non-default) orientation. orient = slider.orientation() self.assertEqual(orient, Qt.Orientation.Horizontal)
def getParameterWidget(self): """ Returns a widget with sliders / fields with which properties of this volume property can be adjusted. :rtype: QWidget """ layout = QGridLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setAlignment(Qt.AlignTop) self.sliders = [] for index in range(7): slider = QSlider(Qt.Horizontal) slider.setMinimum(0) slider.setMaximum(1000) slider.setValue( int( math.pow(self.sectionsOpacity[index], 1.0 / 3.0) * slider.maximum())) slider.valueChanged.connect(self.valueChanged) self.sliders.append(slider) label = QLabel(self.sectionNames[index]) label.setAlignment(Qt.AlignRight | Qt.AlignVCenter) layout.addWidget(label, index, 0) layout.addWidget(slider, index, 1) try: from ColumnResizer import ColumnResizer columnResizer = ColumnResizer() columnResizer.addWidgetsFromLayout(layout, 0) except Exception, e: print e
def __init__(self, callback=None): self.callback = callback self.app = QApplication(sys.argv) self.vlayout = QVBoxLayout() self.button = QPushButton('light') self.button.pressed.connect(self._button_callback) self.button.setCheckable(True) self.button.setChecked(True) self.button.setStyleSheet('background-color: white') self.vlayout.addWidget(self.button) self.slider = QSlider() self.slider.setOrientation(Qt.Horizontal) self.vlayout.addWidget(self.slider) self.dial = QDial() self.dial.setNotchesVisible(True) self.dial.setWrapping(True) self.vlayout.addWidget(self.dial) self.quit = QPushButton('Quit') self.quit.clicked.connect(self.app.quit) self.vlayout.addWidget(self.quit) self.group = QGroupBox('Fake Actuator') self.group.setLayout(self.vlayout)
def set_dip_count(self, number): for i in range(number): dip = QSlider(self) dip.setMinimum(0) dip.setMaximum(1) dip.valueChanged.connect(self.__on_changed) self._layout.addWidget(dip) self._dips.append(dip)
def getParameterWidget(self): self.labelFixedOpacity = QLabel("Fixed:") self.labelFixedOpacity.setAlignment(Qt.AlignRight) self.labelMovingOpacity = QLabel("Moving:") self.labelMovingOpacity.setAlignment(Qt.AlignRight) self.sliderFixedOpacity = QSlider(Qt.Horizontal) self.sliderFixedOpacity.setValue( pow(self.fixedOpacity, 1.0 / 3.0) * 100.0) self.sliderMovingOpacity = QSlider(Qt.Horizontal) self.sliderMovingOpacity.setValue( pow(self.movingOpacity, 1.0 / 3.0) * 100.0) self.blendTypeComboBox = QComboBox() self.blendTypeComboBox.addItem("Default additive blend") self.blendTypeComboBox.addItem("Difference blend") self.blendTypeComboBox.currentIndexChanged.connect(self.valueChanged) # Be sure to connect after the values are set... self.sliderFixedOpacity.valueChanged.connect(self.valueChanged) self.sliderMovingOpacity.valueChanged.connect(self.valueChanged) groupLayout = QGridLayout() groupLayout.setAlignment(Qt.AlignTop) groupLayout.addWidget(self.labelFixedOpacity, 0, 0) groupLayout.addWidget(self.sliderFixedOpacity, 0, 1) groupLayout.addWidget(self.labelMovingOpacity, 1, 0) groupLayout.addWidget(self.sliderMovingOpacity, 1, 1) groupBox = QGroupBox() groupBox.setTitle("Opacity:") groupBox.setLayout(groupLayout) layout = QGridLayout() layout.setAlignment(Qt.AlignTop) layout.addWidget(groupBox) widget = QWidget() widget.setLayout(layout) return widget
def getParameterWidget(self): self.hueSlider = QSlider(Qt.Horizontal) self.hueSlider.setMaximum(360) self.hueSlider.setValue(self.fixedHue) self.hueSlider.valueChanged.connect(self.valueChanged) layout = QGridLayout() layout.setAlignment(Qt.AlignTop) layout.addWidget(QLabel("Base hue"), 0, 0) layout.addWidget(self.hueSlider, 0, 1) widget = QWidget() widget.setLayout(layout) return widget
def createRotableGroupBox(self): self.rotableGroupBox = QGroupBox("Rotable Widgets") self.rotableWidgets.append(QSpinBox()) self.rotableWidgets.append(QSlider()) self.rotableWidgets.append(QDial()) self.rotableWidgets.append(QProgressBar()) count = len(self.rotableWidgets) for i in range(count): self.rotableWidgets[i].valueChanged[int].\ connect(self.rotableWidgets[(i+1) % count].setValue) self.rotableLayout = QGridLayout() self.rotableGroupBox.setLayout(self.rotableLayout) self.rotateWidgets()
def __init__(self, parent=None): super(NumericBox, self).__init__(parent) self.slider = QSlider(Qt.Horizontal) self.spinner = self.spinner() self.spinner.setSingleStep(self.step) self.slider.setTickInterval(self.step * 100) self.slider.setSingleStep(self.step * 100) self.slider.sliderMoved.connect( lambda x: self.spinner.setValue(x / 100)) self.spinner.valueChanged.connect(self.applyValue) self.setLayout(line(self.slider, self.spinner)) self.layout().setStretch(1, 0)
def right_dock_create(self): self.btnonoff = QPushButton("Reset") self.slidvol = QSlider(Qt.Vertical) self.slidvol.setMinimum(0) self.slidvol.setMaximum(100) self.slidvol.setValue(50) self.labspeaker = QLabel() self.labspeaker.setPixmap( QPixmap(os.path.join(script_path, "../assets/speaker.png"))) self.sndvolumelabel = QLabel() self.rightlayout = QVBoxLayout() self.rightlayout.addWidget(self.btnonoff) self.rightlayout.addWidget(self.slidvol) self.rightlayout.addWidget(self.sndvolumelabel) self.rightlayout.addWidget(self.labspeaker)
def __init__(self, parent, North="Up", East="Right", South="Down", West="Left", BoxLabel='Power', valueName='Position'): QWidget.__init__(self) self.North = North self.East = East self.South = South self.West = West self.boxLabel = BoxLabel buttonLayout = QGridLayout(self) northButton = QPushButton(self.North, self) # northbutton.click(actionscript) eastButton = QPushButton(self.East, self) southButton = QPushButton(self.South, self) westButton = QPushButton(self.West, self) speedSlider = QSlider() speedSlider.setTickPosition(QSlider.TicksRight) speedSlider.setTickInterval(10) speedSlider.TicksRight sliderPosition = QSpinBox() sliderPosition.setRange(0, 101) sliderLabel = QLabel(self.boxLabel) speedSlider.valueChanged.connect(sliderPosition.setValue) sliderPosition.valueChanged.connect(speedSlider.setValue) SliderValue = speedSlider.value() speedSlider.valueChanged.connect(self.printValue) #Needs work to fix the layout issues...... buttonLayout.addWidget(northButton, 1, 1) buttonLayout.addWidget(eastButton, 2, 2) buttonLayout.addWidget(westButton, 2, 0) buttonLayout.addWidget(southButton, 3, 1) buttonLayout.addWidget(sliderPosition, 1, 3) buttonLayout.addWidget(sliderLabel, 0, 3) buttonLayout.addWidget(speedSlider, 2, 3, 3, 3) self.setLayout(buttonLayout)
def __init__(self): super(SliderWidget, self).__init__() self.label = QLabel() self.slider = QSlider(Qt.Horizontal) self.spinbox = QSpinBox() self.slider.valueChanged.connect(self.changedValue) self.spinbox.valueChanged.connect(self.changedValue) layout = QGridLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setVerticalSpacing(0) layout.addWidget(self.label, 0, 0) layout.addWidget(self.slider, 0, 1) layout.addWidget(self.spinbox, 0, 2) self.setLayout(layout)
def __init__(self): super(SliderFloatWidget, self).__init__() self.label = QLabel() self.slider = QSlider(Qt.Horizontal) self.spinbox = QDoubleSpinBox() self.slider.valueChanged.connect(self.changedValueFromSlider) self.spinbox.valueChanged.connect(self.changedValueFromSpinBox) # Keep track of whether one of the values was changed # By setting the value of the slider and the spinbox, valueChanged # events are fired. These events have to be ignored self._changed = False layout = QGridLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setVerticalSpacing(0) layout.addWidget(self.label, 0, 0) layout.addWidget(self.slider, 0, 1) layout.addWidget(self.spinbox, 0, 2) self.setLayout(layout)
def __init__(self, text, minValue, maxValue, defaultValue): QWidget.__init__(self) validator = QDoubleValidator(minValue, maxValue, 2, self) mainLayout = QHBoxLayout(self) checkBox = QCheckBox() checkBox.setFixedWidth(115) checkBox.setText(text) lineEdit = QLineEdit() lineEdit.setValidator(validator) lineEdit.setText(str(defaultValue)) slider = QSlider(QtCore.Qt.Horizontal) slider.setMinimum(minValue * 100) slider.setMaximum(maxValue * 100) slider.setValue(defaultValue) mainLayout.addWidget(checkBox) mainLayout.addWidget(lineEdit) mainLayout.addWidget(slider) QtCore.QObject.connect(slider, QtCore.SIGNAL('valueChanged(int)'), self.syncWidthLineEdit) QtCore.QObject.connect(lineEdit, QtCore.SIGNAL('textChanged(QString)'), self.syncWidthSlider) QtCore.QObject.connect(checkBox, QtCore.SIGNAL("clicked()"), self.updateEnabled) self.checkBox = checkBox self.slider = slider self.lineEdit = lineEdit self.updateEnabled()
def __init__(self, *args, **kwargs): self.minimum = 1 self.maximum = 100 self.lineEditMaximum = 10000 QMainWindow.__init__(self, *args, **kwargs) self.installEventFilter(self) #self.setWindowFlags( QtCore.Qt.Drawer ) self.setWindowTitle(Window_global.title) widgetMain = QWidget() layoutVertical = QVBoxLayout(widgetMain) self.setCentralWidget(widgetMain) layoutSlider = QHBoxLayout() lineEdit = QLineEdit() lineEdit.setFixedWidth(100) lineEdit.setText(str(1)) validator = QIntValidator(self.minimum, self.lineEditMaximum, self) lineEdit.setValidator(validator) slider = QSlider() slider.setOrientation(QtCore.Qt.Horizontal) slider.setMinimum(self.minimum) slider.setMaximum(self.maximum) layoutSlider.addWidget(lineEdit) layoutSlider.addWidget(slider) layoutAngle = QVBoxLayout() checkBox = QCheckBox('Connect Angle By Tangent') layoutVector = QHBoxLayout() leVx = QLineEdit() leVx.setText(str(1.000)) leVx.setEnabled(False) leVx.setValidator(QDoubleValidator(-100, 100, 5, self)) leVy = QLineEdit() leVy.setText(str(0.000)) leVy.setEnabled(False) leVy.setValidator(QDoubleValidator(-100, 100, 5, self)) leVz = QLineEdit() leVz.setText(str(0.000)) leVz.setEnabled(False) leVz.setValidator(QDoubleValidator(-100, 100, 5, self)) layoutAngle.addWidget(checkBox) layoutAngle.addLayout(layoutVector) layoutVector.addWidget(leVx) layoutVector.addWidget(leVy) layoutVector.addWidget(leVz) button = QPushButton('Create') layoutVertical.addLayout(layoutSlider) layoutVertical.addLayout(layoutAngle) layoutVertical.addWidget(button) QtCore.QObject.connect(slider, QtCore.SIGNAL('valueChanged(int)'), self.sliderValueChanged) QtCore.QObject.connect(lineEdit, QtCore.SIGNAL('textEdited(QString)'), self.lineEditValueChanged) QtCore.QObject.connect(button, QtCore.SIGNAL('clicked()'), Functions.createPointOnCurve) QtCore.QObject.connect(checkBox, QtCore.SIGNAL('clicked()'), Functions.setAngleEnabled) self.slider = slider self.lineEdit = lineEdit Window_global.slider = slider Window_global.button = button Window_global.checkBox = checkBox Window_global.leVx = leVx Window_global.leVy = leVy Window_global.leVz = leVz
def __init__(self): super(DataInspector, self).__init__() self.slider_width = +300 self.main_widget = QWidget(self) self.setCentralWidget(self.main_widget) self.render_widget = RenderWidget() # Create interface actions self.action_load_data = QAction('Load data set', self, shortcut='Ctrl+O') self.action_load_data.setIcon(QIcon("images/AddButton.png")) self.action_load_data.triggered.connect(self.load_file) self.action_show_simple = QAction('Switch to simple rendering', self, shortcut='Ctrl+1') self.action_show_simple.setText("Simple") self.action_show_simple.triggered.connect(self.switch_to_simple) self.action_show_ct = QAction('Switch to CT rendering', self, shortcut='Ctrl+2') self.action_show_ct.setText("CT") self.action_show_ct.triggered.connect(self.switch_to_ct) self.action_show_mip = QAction('Switch to MIP rendering', self, shortcut='Ctrl+3') self.action_show_mip.setText("MIP") self.action_show_mip.triggered.connect(self.switch_to_mip) # Align the dock buttons to the right with a spacer widget spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) # Add buttons to container on top self.toolbar = self.addToolBar('Main tools') self.toolbar.addAction(self.action_show_simple) self.toolbar.addAction(self.action_show_ct) self.toolbar.addAction(self.action_show_mip) self.toolbar.addWidget(spacer) self.toolbar.addAction(self.action_load_data) self.setUnifiedTitleAndToolBarOnMac(True) # Slider for simple visualization self.sliders_simple_widget = QSlider(Qt.Horizontal) self.sliders_simple_widget.setMinimumWidth(self.slider_width) self.sliders_simple_widget.setMaximumWidth(self.slider_width) self.sliders_simple_widget.setMinimum(0) self.sliders_simple_widget.setMaximum(1000) self.sliders_simple_widget.valueChanged.connect( self.simple_slider_value_changed) self.sliders_simple_widget.setHidden(True) # Create sliders for CT transfer function sliders_layout = QVBoxLayout() sliders_layout.setContentsMargins(0, 0, 0, 0) sliders_layout.setSpacing(0) self.sliders = [] for _ in range(0, 7): slider = QSlider(Qt.Horizontal) slider.setMinimum(0) slider.setMaximum(1000) slider.valueChanged.connect(self.ct_slider_value_changed) self.sliders.append(slider) sliders_layout.addWidget(slider) self.sliders_ct_widget = QWidget() self.sliders_ct_widget.setMinimumWidth(self.slider_width) self.sliders_ct_widget.setMaximumWidth(self.slider_width) self.sliders_ct_widget.setLayout(sliders_layout) self.sliders_ct_widget.setHidden(True) self.min_slider = QSlider(Qt.Horizontal) self.min_slider.setMinimum(0) self.min_slider.setMaximum(1000) self.min_slider.valueChanged.connect(self.mip_slider_value_changed) self.max_slider = QSlider(Qt.Horizontal) self.max_slider.setMinimum(0) self.max_slider.setMaximum(1000) self.max_slider.setValue(1000) self.max_slider.valueChanged.connect(self.mip_slider_value_changed) layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addWidget(self.min_slider) layout.addWidget(self.max_slider) self.sliders_mip_widget = QWidget() self.sliders_mip_widget.setMinimumWidth(self.slider_width) self.sliders_mip_widget.setMaximumWidth(self.slider_width) self.sliders_mip_widget.setLayout(layout) self.sliders_mip_widget.setHidden(True) layout = QHBoxLayout(self.main_widget) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.render_widget) layout.addWidget(self.sliders_mip_widget) layout.addWidget(self.sliders_ct_widget) layout.addWidget(self.sliders_simple_widget) self.main_widget.setLayout(layout) self.resize(800, 500)
def getParameterWidget(self): """ Returns a widget with sliders / fields with which properties of this volume property can be adjusted. :rtype: QWidget """ self.brightnessSlider = QSlider(Qt.Horizontal) self.brightnessSlider.setMinimum(0) self.brightnessSlider.setMaximum(500) self.brightnessSlider.setValue(int(self.brightness)) self.brightnessSlider.valueChanged.connect(self.valueChanged) self.brightnessLabel = QLabel(str(self.brightness / 100.0)) self.windowSlider = QSlider(Qt.Horizontal) self.windowSlider.setMinimum(0) self.windowSlider.setMaximum(int(abs(self.maximum - self.minimum))) self.windowSlider.setValue(int(self.window)) self.windowSlider.valueChanged.connect(self.valueChanged) self.windowLabel = QLabel(str(self.window)) self.levelSlider = QSlider(Qt.Horizontal) self.levelSlider.setMinimum(int(self.minimum)) self.levelSlider.setMaximum(int(self.maximum)) self.levelSlider.setValue(int(self.level)) self.levelSlider.valueChanged.connect(self.valueChanged) self.levelLabel = QLabel(str(self.level)) self.lowerBoundSlider = QSlider(Qt.Horizontal) self.lowerBoundSlider.setMinimum(int(self.minimum)) self.lowerBoundSlider.setMaximum(int(self.maximum)) self.lowerBoundSlider.setValue(int(self.lowerBound)) self.lowerBoundSlider.valueChanged.connect(self.valueChanged) self.lowerBoundLabel = QLabel(str(self.lowerBound)) self.upperBoundSlider = QSlider(Qt.Horizontal) self.upperBoundSlider.setMinimum(int(self.minimum)) self.upperBoundSlider.setMaximum(int(self.maximum)) self.upperBoundSlider.setValue(int(self.upperBound)) self.upperBoundSlider.valueChanged.connect(self.valueChanged) self.upperBoundLabel = QLabel(str(self.upperBound)) layout = QGridLayout() layout.setAlignment(Qt.AlignTop) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(QLabel("Window"), 0, 0) layout.addWidget(self.windowSlider, 0, 1) layout.addWidget(self.windowLabel, 0, 2) layout.addWidget(QLabel("Level"), 1, 0) layout.addWidget(self.levelSlider, 1, 1) layout.addWidget(self.levelLabel, 1, 2) layout.addWidget(QLabel("Brightness"), 2, 0) layout.addWidget(self.brightnessSlider, 2, 1) layout.addWidget(self.brightnessLabel, 2, 2) layout.addWidget(QLabel("Lower threshold"), 3, 0) layout.addWidget(self.lowerBoundSlider, 3, 1) layout.addWidget(self.lowerBoundLabel, 3, 2) layout.addWidget(QLabel("Upper threshold"), 4, 0) layout.addWidget(self.upperBoundSlider, 4, 1) layout.addWidget(self.upperBoundLabel, 4, 2) widget = QWidget() widget.setLayout(layout) return widget
def initUI(self): QToolTip.setFont(QFont('SansSerif', 10)) self.setGeometry(300, 200, 810, 430) self.setWindowTitle('Transformation on Human Face') #Method choose combobox self.comboAffineLabel = QLabel(self) self.comboAffineLabel.setText('Transformation Method:') self.comboAffineLabel.setGeometry(60, 270, 230, 30) self.comboAffine = QComboBox(self) self.comboAffine.addItem("Local Affine Transformation") self.comboAffine.addItem("Moving Least Squares") self.comboAffine.addItem("Morphing") self.comboAffine.setGeometry(22, 290, 225, 30) self.comboAffine.activated[str].connect(self.affineChoiceChange) #The button to choose the original figure self.oriBtn = QPushButton('Choose Original Picture', self) self.oriBtn.setToolTip('Choose Original Picture') self.oriBtn.setGeometry(20, 330, 230, 30) self.oriBtn.clicked.connect(self.showOriDialog) #The button to choose the proto figure self.protoBtn = QPushButton('Choose Proto Picture', self) self.protoBtn.setToolTip('Choose Proto Picture') self.protoBtn.setGeometry(20, 365, 230, 30) self.protoBtn.clicked.connect(self.showProtoDialog) #The distance function choose combobox self.comboLabel = QLabel(self) self.comboLabel.setText('Distance Fun:') self.comboLabel.setGeometry(310, 280, 200, 30) self.comboDis = QComboBox(self) self.comboDis.addItem("L2") self.comboDis.addItem("L1") self.comboDis.setGeometry(410, 280, 80, 30) self.comboDis.activated[str].connect(self.distanceChoiceChange) #E choose slider self.eLabel = QLabel(self) self.eLabel.setText('E Value:0.00') self.eLabel.setGeometry(310, 320, 200, 30) self.eSld = QSlider(Qt.Horizontal, self) self.eSld.setRange(0, 10**5) self.eSld.setFocusPolicy(Qt.NoFocus) self.eSld.setGeometry(390, 320, 120, 30) self.eSld.valueChanged[int].connect(self.changeEValue) #alpha choose slider self.aLabel = QLabel(self) self.aLabel.setText('Alpha Value:0.00') self.aLabel.setGeometry(310, 360, 200, 30) self.aSld = QSlider(Qt.Horizontal, self) self.aSld.setRange(0, 10**5) self.aSld.setFocusPolicy(Qt.NoFocus) self.aSld.setGeometry(410, 360, 100, 30) self.aSld.valueChanged[int].connect(self.changeAlphaValue) # Picture show self.oriTextLabel = QLabel(self) self.protoTextLabel = QLabel(self) self.transTextLabel = QLabel(self) self.oriTextLabel.setText('The Orginal Picture') self.protoTextLabel.setText('The Proto Picture') self.transTextLabel.setText('The Picture after Transformation') self.oriTextLabel.move(70, 5) self.protoTextLabel.move(350, 5) self.transTextLabel.move(580, 5) self.oriLabel = QLabel(self) self.protoLabel = QLabel(self) self.transLabel = QLabel(self) pixmap = QPixmap(self.oriPath) pixmap2 = QPixmap(self.protoPath) self.oriLabel.setPixmap(pixmap) self.protoLabel.setPixmap(pixmap2) self.transLabel.setPixmap(pixmap) #Position setting self.oriLabel.setGeometry(20, 20, 230, 230) self.protoLabel.setGeometry(290, 20, 230, 230) self.transLabel.setGeometry(560, 20, 230, 230) self.oriLabel.setScaledContents(True) self.protoLabel.setScaledContents(True) self.transLabel.setScaledContents(True) #Load button self.loadOriBtn = QPushButton('Load Ori Points', self) self.loadOriBtn.setToolTip('Load Control Points From Txt File') self.loadOriBtn.setGeometry(550, 280, 130, 30) self.loadOriBtn.clicked.connect(self.showLoadOriDialog) self.loadProtoBtn = QPushButton('Load Proto Points', self) self.loadProtoBtn.setToolTip('Load Control Points From Txt File') self.loadProtoBtn.setGeometry(680, 280, 130, 30) self.loadProtoBtn.clicked.connect(self.showLoadProtoDialog) #Face ++ button self.faceBtn = QPushButton('Face++ Keypoint', self) self.faceBtn.setToolTip('Save the Face++ Keypoints') self.faceBtn.setGeometry(550, 315, 130, 30) self.faceBtn.clicked.connect(self.detectKeyPoints) #Load region Button self.loadRegionBtn = QPushButton('Load Regions', self) self.loadRegionBtn.setToolTip('Load Regions From Txt File') self.loadRegionBtn.setGeometry(680, 315, 130, 30) self.loadRegionBtn.clicked.connect(self.showLoadRegionDialog) #Save Button setting self.saveBtn = QPushButton('Save', self) self.saveBtn.setToolTip( 'Transform this picture to the shape of Baboon') self.saveBtn.setGeometry(560, 350, 110, 40) self.saveBtn.clicked.connect(self.saveImg) #Transform action button self.confirmBtn = QPushButton('Generate', self) self.confirmBtn.setToolTip('Generate') self.confirmBtn.setGeometry(680, 350, 110, 40) self.confirmBtn.clicked.connect(self.transformAction) self.show()
def __init__(self, U, plot, length=1, title=None): super().__init__() layout = QVBoxLayout() if title: title = QLabel('<b>' + title + '</b>') title.setAlignment(Qt.AlignHCenter) layout.addWidget(title) layout.addWidget(plot) plot.set(U, 0) if length > 1: hlayout = QHBoxLayout() self.slider = QSlider(Qt.Horizontal) self.slider.setMinimum(0) self.slider.setMaximum(length - 1) self.slider.setTickPosition(QSlider.TicksBelow) hlayout.addWidget(self.slider) lcd = QLCDNumber(m.ceil(m.log10(length))) lcd.setDecMode() lcd.setSegmentStyle(QLCDNumber.Flat) hlayout.addWidget(lcd) layout.addLayout(hlayout) hlayout = QHBoxLayout() toolbar = QToolBar() self.a_play = QAction( self.style().standardIcon(QStyle.SP_MediaPlay), 'Play', self) self.a_play.setCheckable(True) self.a_rewind = QAction( self.style().standardIcon(QStyle.SP_MediaSeekBackward), 'Rewind', self) self.a_toend = QAction( self.style().standardIcon(QStyle.SP_MediaSeekForward), 'End', self) self.a_step_backward = QAction( self.style().standardIcon(QStyle.SP_MediaSkipBackward), 'Step Back', self) self.a_step_forward = QAction( self.style().standardIcon(QStyle.SP_MediaSkipForward), 'Step', self) self.a_loop = QAction( self.style().standardIcon(QStyle.SP_BrowserReload), 'Loop', self) self.a_loop.setCheckable(True) toolbar.addAction(self.a_play) toolbar.addAction(self.a_rewind) toolbar.addAction(self.a_toend) toolbar.addAction(self.a_step_backward) toolbar.addAction(self.a_step_forward) toolbar.addAction(self.a_loop) if hasattr(self, 'save'): self.a_save = QAction( self.style().standardIcon(QStyle.SP_DialogSaveButton), 'Save', self) toolbar.addAction(self.a_save) self.a_save.triggered.connect(self.save) hlayout.addWidget(toolbar) self.speed = QSlider(Qt.Horizontal) self.speed.setMinimum(0) self.speed.setMaximum(100) hlayout.addWidget(QLabel('Speed:')) hlayout.addWidget(self.speed) layout.addLayout(hlayout) self.timer = QTimer() self.timer.timeout.connect(self.update_solution) self.slider.valueChanged.connect(self.slider_changed) self.slider.valueChanged.connect(lcd.display) self.speed.valueChanged.connect(self.speed_changed) self.a_play.toggled.connect(self.toggle_play) self.a_rewind.triggered.connect(self.rewind) self.a_toend.triggered.connect(self.to_end) self.a_step_forward.triggered.connect(self.step_forward) self.a_step_backward.triggered.connect(self.step_backward) self.speed.setValue(50) elif hasattr(self, 'save'): hlayout = QHBoxLayout() toolbar = QToolBar() self.a_save = QAction( self.style().standardIcon(QStyle.SP_DialogSaveButton), 'Save', self) toolbar.addAction(self.a_save) hlayout.addWidget(toolbar) layout.addLayout(hlayout) self.a_save.triggered.connect(self.save) self.setLayout(layout) self.plot = plot self.U = U self.length = length
def initUI(self): self.setWindowTitle(self.title) self.setGeometry(self.left, self.top, self.width, self.height) # Select analysis file button button = QPushButton('Select analysis file', self) button.setToolTip('*.inp CalculiX analysis file.') button.move(10, 10) button.clicked.connect(self.on_click) # Text box - file path and name self.textbox_file_name = QLineEdit(self) self.textbox_file_name.move(120, 15) self.textbox_file_name.resize(420, 20) self.textbox_file_name.setText("None analysis file selected") self.textbox_file_name.setToolTip('Analysis file.') # Update button button1 = QPushButton('Update domains', self) button1.setToolTip( 'Update naming inputs and material data from FreeCAD.') button1.move(10, 50) button1.clicked.connect(self.on_click1) # Domains definition # Label above domains definition label21 = QLabel('Domain 0', self) label21.setStyleSheet("font-weight: bold") label21.move(120, 50) label21 = QLabel('Domain 1', self) label21.setStyleSheet("font-weight: bold") label21.move(260, 50) label21 = QLabel('Domain 2', self) label21.setStyleSheet("font-weight: bold") label21.move(400, 50) label24 = QLabel('Material object', self) label24.move(20, 80) label25 = QLabel('Thickness object', self) label25.move(20, 110) label26 = QLabel('As design domain', self) label26.move(20, 140) label27 = QLabel('Stress limit [MPa]', self) label27.move(20, 170) # Combo box - select domain by material object self.combo = QComboBox(self) self.combo.setToolTip('Material object to define the domain.') self.combo.move(120, 80) self.combo.resize(140, 30) self.combo.currentIndexChanged.connect(self.on_change) self.combo1 = QComboBox(self) self.combo1.setToolTip('Material object to define the domain.') self.combo1.move(260, 80) self.combo1.resize(140, 30) self.combo1.currentIndexChanged.connect(self.on_change1) self.combo2 = QComboBox(self) self.combo2.setToolTip('Material object to define the domain.') self.combo2.move(400, 80) self.combo2.resize(140, 30) self.combo2.currentIndexChanged.connect(self.on_change2) # Combo box - select thickness object self.combo0t = QComboBox(self) self.combo0t.setToolTip( 'Thickness object to specify if domain is for shells.') self.combo0t.move(120, 110) self.combo0t.resize(140, 30) self.combo1t = QComboBox(self) self.combo1t.setToolTip( 'Thickness object to specify if domain is for shells.') self.combo1t.move(260, 110) self.combo1t.resize(140, 30) self.combo2t = QComboBox(self) self.combo2t.setToolTip( 'Thickness object to specify if domain is for shells.') self.combo2t.move(400, 110) self.combo2t.resize(140, 30) self.textbox3 = QLineEdit(self) self.textbox3.move(120, 170) self.textbox3.resize(40, 20) # self.textbox3.setText("") self.textbox3.setToolTip( 'Thickness [mm] of shell elements in the domain.\n' 'This value overwrites thickness defined in FreeCAD') self.textbox4 = QLineEdit(self) self.textbox4.move(260, 170) self.textbox4.resize(40, 20) # self.textbox4.setText("") self.textbox4.setToolTip( 'Thickness [mm] of shell elements in the domain.\n' 'This value overwrites thickness defined in FreeCAD') self.textbox5 = QLineEdit(self) self.textbox5.move(400, 170) self.textbox5.resize(40, 20) # self.textbox5.setText("") self.textbox5.setToolTip( 'Thickness [mm] of shell elements in the domain.\n' 'This value overwrites thickness defined in FreeCAD') # Check box - design or nondesign self.checkbox = QCheckBox('', self) self.checkbox.setChecked(True) self.checkbox.setToolTip('Check to be the design domain.') self.checkbox.move(120, 140) self.checkbox1 = QCheckBox('', self) self.checkbox1.setChecked(True) self.checkbox1.setToolTip('Check to be the design domain.') self.checkbox1.move(260, 140) self.checkbox2 = QCheckBox('', self) self.checkbox2.setChecked(True) self.checkbox2.setToolTip('Check to be the design domain.') self.checkbox2.move(400, 140) # Text box - stress limit self.textbox = QLineEdit(self) self.textbox.move(120, 170) self.textbox.resize(40, 20) # self.textbox.setText("") self.textbox.setToolTip( 'Von Mises stress [MPa] limit, when reached, material removing will stop.' ) self.textbox1 = QLineEdit(self) self.textbox1.move(260, 170) self.textbox1.resize(40, 20) # self.textbox1.setText("") self.textbox1.setToolTip( 'Von Mises stress [MPa] limit, when reached, material removing will stop.' ) self.textbox2 = QLineEdit(self) self.textbox2.move(400, 170) self.textbox2.resize(40, 20) # self.textbox2.setText("") self.textbox2.setToolTip( 'Von Mises stress [MPa] limit, when reached, material removing will stop.' ) # Filters # Label above filter definition label31 = QLabel('Filter 0', self) label31.setStyleSheet("font-weight: bold") label31.move(120, 210) label32 = QLabel('Filter 1', self) label32.setStyleSheet("font-weight: bold") label32.move(260, 210) label33 = QLabel('Filter 2', self) label33.setStyleSheet("font-weight: bold") label33.move(400, 210) label34 = QLabel('Type', self) label34.move(20, 240) label35 = QLabel('Range [mm]', self) label35.move(20, 270) label36 = QLabel('Direction vector', self) label36.move(20, 300) label37 = QLabel('Apply to', self) label37.move(20, 330) # Combo box - select filter type self.combo6 = QComboBox(self) self.combo6.setToolTip( 'Filters:\n' '"simple" to suppress checkerboard effect,\n' '"casting" to prescribe casting direction (opposite to milling direction)\n' 'Recommendation: for casting use as first "casting" and as second "simple"' ) self.combo6.addItem("None") self.combo6.addItem("simple") self.combo6.addItem("casting") self.combo6.setCurrentIndex(1) self.combo6.move(120, 240) self.combo6.currentIndexChanged.connect(self.on_change6) self.combo7 = QComboBox(self) self.combo7.setToolTip( 'Filters:\n' '"simple" to suppress checkerboard effect,\n' '"casting" to prescribe casting direction (opposite to milling direction)\n' 'Recommendation: for casting use as first "casting" and as second "simple"' ) self.combo7.addItem("None") self.combo7.addItem("simple") self.combo7.addItem("casting") self.combo7.move(260, 240) self.combo7.currentIndexChanged.connect(self.on_change7) self.combo8 = QComboBox(self) self.combo8.setToolTip( 'Filters:\n' '"simple" to suppress checkerboard effect,\n' '"casting" to prescribe casting direction (opposite to milling direction)\n' 'Recommendation: for casting use as first "casting" and as second "simple"' ) self.combo8.addItem("None") self.combo8.addItem("simple") self.combo8.addItem("casting") self.combo8.move(400, 240) self.combo8.currentIndexChanged.connect(self.on_change8) # Text box - filter range self.textbox6 = QLineEdit(self) self.textbox6.move(120, 270) self.textbox6.resize(50, 20) # self.textbox6.setText("") self.textbox6.setToolTip( 'Filter range [mm], recommended two times mesh size.') self.textbox7 = QLineEdit(self) self.textbox7.move(260, 270) self.textbox7.resize(50, 20) # self.textbox7.setText("") self.textbox7.setToolTip( 'Filter range [mm], recommended two times mesh size.') self.textbox7.setEnabled(False) self.textbox8 = QLineEdit(self) self.textbox8.move(400, 270) self.textbox8.resize(50, 20) # self.textbox8.setText("") self.textbox8.setToolTip( 'Filter range [mm], recommended two times mesh size.') self.textbox8.setEnabled(False) # Text box - casting direction self.textbox9 = QLineEdit(self) self.textbox9.move(120, 300) self.textbox9.resize(80, 20) self.textbox9.setText("0, 0, 1") self.textbox9.setEnabled(False) self.textbox9.setToolTip( 'Casting direction vector, e.g. direction in z axis:\n' '0, 0, 1\n\n' 'solid void\n' 'XXXXXX.................\n' 'XXX........................\n' 'XX........................... --> z axis\n' 'XXXXX....................\n' 'XXXXXXXXXXX......') self.textbox10 = QLineEdit(self) self.textbox10.move(260, 300) self.textbox10.resize(80, 20) self.textbox10.resize(80, 20) self.textbox10.setText("0, 0, 1") self.textbox10.setEnabled(False) self.textbox10.setToolTip( 'Casting direction vector, e.g. direction in z axis:\n' '0, 0, 1\n\n' 'solid void\n' 'XXXXXX.................\n' 'XXX........................\n' 'XX........................... --> z axis\n' 'XXXXX....................\n' 'XXXXXXXXXXX......') self.textbox11 = QLineEdit(self) self.textbox11.move(400, 300) self.textbox11.resize(80, 20) self.textbox11.setText("0, 0, 1") self.textbox11.setEnabled(False) self.textbox11.setToolTip( 'Casting direction vector, e.g. direction in z axis:\n' '0, 0, 1\n\n' 'solid void\n' 'XXXXXX.................\n' 'XXX........................\n' 'XX........................... --> z axis\n' 'XXXXX....................\n' 'XXXXXXXXXXX......') # list widget - select domains self.widget = QListWidget(self) self.widget.setToolTip( 'Domains affected by the filter.\n' 'Select only from domains which you defined above.') self.widget.move(120, 330) self.widget.resize(140, 120) self.widget.setSelectionMode(QAbstractItemView.MultiSelection) self.widget1 = QListWidget(self) self.widget1.setToolTip( 'Domains affected by the filter.\n' 'Select only from domains which you defined above.') self.widget1.move(260, 330) self.widget1.resize(140, 120) self.widget1.setSelectionMode(QAbstractItemView.MultiSelection) self.widget1.setEnabled(False) self.widget2 = QListWidget(self) self.widget2.setToolTip( 'Domains affected by the filter.\n' 'Select only from domains which you defined above.') self.widget2.move(400, 330) self.widget2.resize(140, 120) self.widget2.setSelectionMode(QAbstractItemView.MultiSelection) self.widget2.setEnabled(False) # Other settings label40 = QLabel('Other settings', self) label40.setStyleSheet("font-weight: bold") label40.move(10, 470) # AR, RR slider label41 = QLabel('Change per iteration: low', self) label41.setFixedWidth(150) label41.move(10, 500) label42 = QLabel('high', self) label42.move(240, 500) self.slider = QSlider(Qt.Horizontal, self) self.slider.setRange(1, 3) self.slider.setSingleStep(1) self.slider.setValue(2) self.slider.move(150, 500) self.slider.resize(80, 30) self.slider.setToolTip( 'Sets mass change per iteration, which is controlled as\n' 'slow: mass_addition_ratio=0.01, mass_removal_ratio=0.02\n' 'middle: mass_addition_ratio=0.015, mass_removal_ratio=0.03\n' 'fast: mass_addition_ratio=0.03, mass_removal_ratio=0.06') # optimization base combobox label51 = QLabel('Optimization base', self) label51.move(10, 530) self.combo51 = QComboBox(self) self.combo51.setToolTip( 'Basic principle to determine if element should remain or be removed:\n' '"stiffness" to maximize stiffness (minimize compliance),\n' '"heat" to maximize heat flow.') self.combo51.addItem("stiffness") self.combo51.addItem("heat") self.combo51.move(120, 530) # mass goal ratio label52 = QLabel('Mass goal ratio', self) label52.move(10, 560) self.textbox52 = QLineEdit(self) self.textbox52.move(120, 560) self.textbox52.resize(50, 20) self.textbox52.setText("0.4") self.textbox52.setToolTip( 'Fraction of all design domains masses to be achieved;\n' 'between 0 and 1.') # generate conf. file button button21 = QPushButton('Generate conf. file', self) button21.setToolTip( 'Writes configuration file with optimization parameters.') button21.move(10, 600) button21.clicked.connect(self.on_click21) # edit conf. file button button22 = QPushButton('Edit conf. file', self) button22.setToolTip('Opens configuration file for hand modifications.') button22.move(10, 630) button22.clicked.connect(self.on_click22) # run optimization button button23 = QPushButton('Run optimization', self) button23.setToolTip('Writes configuration file and runs optimization.') button23.move(10, 660) button23.clicked.connect(self.on_click23) # generate conf file and run optimization button button24 = QPushButton('Generate conf.\nfile and run\noptimization', self) button24.setToolTip('Writes configuration file and runs optimization.') button24.move(120, 600) button24.resize(100, 90) button24.clicked.connect(self.on_click24) # help buttons label41 = QLabel('Help', self) label41.move(440, 560) button31 = QPushButton('Example', self) button31.setToolTip( 'https://github.com/fandaL/beso/wiki/Example-4:-GUI-in-FreeCAD') button31.move(440, 590) # button31.resize(80, 50) button31.clicked.connect(self.on_click31) button32 = QPushButton('Conf. comments', self) button32.setToolTip( 'https://github.com/fandaL/beso/blob/master/beso_conf.py') button32.move(440, 620) # button32.resize(80, 50) button32.clicked.connect(self.on_click32) button33 = QPushButton('Close', self) button33.move(440, 690) # button33.resize(80, 50) button33.clicked.connect(self.on_click33) # open log file button40 = QPushButton('Open log file', self) button40.setToolTip('Opens log file in your text editor.\n' '(Does not refresh automatically.)') button40.move(10, 690) button40.clicked.connect(self.on_click40) self.on_click1() # first update self.show()
def setupUi(self): scene = QGraphicsScene(self) self.view = QGraphicsView(scene, self) self.view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.view.setVisible(True) self.view.setInteractive(True) self.createPixmapIcon() self.mapWidget = MapWidget(self.mapManager) scene.addItem(self.mapWidget) self.mapWidget.setCenter(QGeoCoordinate(-8.1, -34.95)) self.mapWidget.setZoomLevel(5) #... self.slider = QSlider(Qt.Vertical, self) self.slider.setTickInterval(1) self.slider.setTickPosition(QSlider.TicksBothSides) self.slider.setMaximum(self.mapManager.maximumZoomLevel()) self.slider.setMinimum(self.mapManager.minimumZoomLevel()) self.slider.valueChanged[int].connect(self.sliderValueChanged) self.mapWidget.zoomLevelChanged[float].connect(self.mapZoomLevelChanged) mapControlLayout = QVBoxLayout() self.mapWidget.mapTypeChanged.connect(self.mapTypeChanged) for mapType in self.mapWidget.supportedMapTypes(): radio = QRadioButton(self) if mapType == QGraphicsGeoMap.StreetMap: radio.setText('Street') elif mapType == QGraphicsGeoMap.SatelliteMapDay: radio.setText('Sattelite') elif mapType == QGraphicsGeoMap.SatelliteMapNight: radio.setText('Sattelite - Night') elif mapType == QGraphicsGeoMap.TerrainMap: radio.setText('Terrain') if mapType == self.mapWidget.mapType(): radio.setChecked(True) radio.toggled[bool].connect(self.mapTypeToggled) self.mapControlButtons.append(radio) self.mapControlTypes.append(mapType) mapControlLayout.addWidget(radio) self.latitudeEdit = QLineEdit() self.longitudeEdit = QLineEdit() formLayout = QFormLayout() formLayout.addRow('Latitude', self.latitudeEdit) formLayout.addRow('Longitude', self.longitudeEdit) self.captureCoordsButton = QToolButton() self.captureCoordsButton.setText('Capture coordinates') self.captureCoordsButton.setCheckable(True) self.captureCoordsButton.toggled[bool].connect( self.mapWidget.setMouseClickCoordQuery) self.mapWidget.coordQueryResult.connect(self.updateCoords) self.setCoordsButton = QPushButton() self.setCoordsButton.setText('Set coordinates') self.setCoordsButton.clicked.connect(self.setCoordsClicked) buttonLayout = QHBoxLayout() buttonLayout.addWidget(self.captureCoordsButton) buttonLayout.addWidget(self.setCoordsButton) coordControlLayout = QVBoxLayout() coordControlLayout.addLayout(formLayout) coordControlLayout.addLayout(buttonLayout) widget = QWidget(self) layout = QGridLayout() layout.setRowStretch(0, 1) layout.setRowStretch(1, 0) topLayout = QGridLayout() bottomLayout = QGridLayout() topLayout.setColumnStretch(0, 0) topLayout.setColumnStretch(1, 1) bottomLayout.setColumnStretch(0, 0) bottomLayout.setColumnStretch(1, 1) topLayout.addWidget(self.slider, 0, 0) topLayout.addWidget(self.view, 0, 1) bottomLayout.addLayout(mapControlLayout, 0, 0) bottomLayout.addLayout(coordControlLayout, 0, 1) layout.addLayout(topLayout, 0, 0) layout.addLayout(bottomLayout, 1, 0) self.layout = layout widget.setLayout(layout) self.setCentralWidget(widget) self.view.setContextMenuPolicy(Qt.CustomContextMenu) self.view.customContextMenuRequested.connect(self.customContextMenuRequest)
def initUI(self): #Set Window QToolTip.setFont(QFont('Serif', 10)) self.setGeometry(280, 210, 800, 450) self.setWindowTitle('Image Registration Based on Control Points') #Set Algorithm self.comboAffineLabel = QLabel(self) self.comboAffineLabel.setText('Algorithm:') self.comboAffineLabel.setGeometry(60, 270, 230, 30) self.comboAffine = QComboBox(self) self.comboAffine.addItem("Morphing") self.comboAffine.addItem("Local Affine Transformation") self.comboAffine.addItem("Moving Least Squares") self.comboAffine.setGeometry(22, 290, 225, 30) self.comboAffine.activated[str].connect(self.affineChoiceChange) #Choose Human Face Image self.oriBtn = QPushButton('Human Face Image', self) self.oriBtn.setToolTip('Human Face Image') self.oriBtn.setGeometry(20, 330, 230, 30) self.oriBtn.clicked.connect(self.showOriDialog) #Choose Ape or another Human image self.protoBtn = QPushButton('Ape or Human image', self) self.protoBtn.setToolTip('Ape or Human image') self.protoBtn.setGeometry(310, 330, 230, 30) self.protoBtn.clicked.connect(self.showProtoDialog) #parameter e self.eLabel = QLabel(self) self.eLabel.setText('E Value:0.00') self.eLabel.setGeometry(550, 300, 200, 30) self.eSld = QSlider(Qt.Horizontal, self) self.eSld.setRange(0, 10**5) self.eSld.setFocusPolicy(Qt.NoFocus) self.eSld.setGeometry(550, 330, 120, 30) self.eSld.valueChanged[int].connect(self.changeEValue) #parameter alpha self.aLabel = QLabel(self) self.aLabel.setText('Alpha Value:0.00') self.aLabel.setGeometry(680, 300, 200, 30) self.aSld = QSlider(Qt.Horizontal, self) self.aSld.setRange(0, 10**5) self.aSld.setFocusPolicy(Qt.NoFocus) self.aSld.setGeometry(680, 330, 100, 30) self.aSld.valueChanged[int].connect(self.changeAlphaValue) # The Image self.oriTextLabel = QLabel(self) self.protoTextLabel = QLabel(self) self.transTextLabel = QLabel(self) self.oriTextLabel.setText('The Human Image') self.protoTextLabel.setText('The Ape or another Human Image') self.transTextLabel.setText('Deformation Image') self.oriTextLabel.move(70, 5) self.protoTextLabel.move(350, 5) self.transTextLabel.move(580, 5) self.oriLabel = QLabel(self) self.protoLabel = QLabel(self) self.transLabel = QLabel(self) pixmap = QPixmap(self.oriPath) pixmap2 = QPixmap(self.protoPath) self.oriLabel.setPixmap(pixmap) self.protoLabel.setPixmap(pixmap2) self.transLabel.setPixmap(pixmap) #Set Position self.oriLabel.setGeometry(20, 20, 230, 230) self.protoLabel.setGeometry(290, 20, 230, 230) self.transLabel.setGeometry(560, 20, 230, 230) self.oriLabel.setScaledContents(True) self.protoLabel.setScaledContents(True) self.transLabel.setScaledContents(True) #import points self.loadOriBtn = QPushButton('Deformed Points', self) self.loadOriBtn.setToolTip('Load Control Points From Txt File') self.loadOriBtn.setGeometry(20, 365, 230, 30) self.loadOriBtn.clicked.connect(self.showLoadOriDialog) self.loadProtoBtn = QPushButton('Control Points', self) self.loadProtoBtn.setToolTip('Load Control Points From Txt File') self.loadProtoBtn.setGeometry(310, 365, 230, 30) self.loadProtoBtn.clicked.connect(self.showLoadProtoDialog) #Deformed self.confirmBtn = QPushButton('Deformed', self) self.confirmBtn.setToolTip('Deformed') self.confirmBtn.setGeometry(580, 365, 150, 30) self.confirmBtn.clicked.connect(self.transformAction) self.show()