def __init__(self): super(TransformationHistoryWidget, self).__init__() self.actionContainer = ButtonContainer() self.transformationModel = TransformationModel() self.transformationView = TransformationListView() self.transformationView.setRootIsDecorated(False) self.transformationView.setModel(self.transformationModel) self.transformationView.setAttribute(Qt.WA_MacShowFocusRect, False) self.transformationView.clicked.connect(self.clickedTransformation) self._transformCount = 0 layout = QVBoxLayout() layout.setSpacing(0) layout.setAlignment(Qt.AlignTop) layout.addWidget(self.transformationView) layout.addWidget(self.actionContainer) self.setLayout(layout) removeButton = QPushButton() removeButton.setIcon(QIcon(AppVars.imagePath() + "RemoveButton.png")) removeButton.clicked.connect(self.removeButtonClicked) removeButton.setToolTip("Remove the last transformation") self.actionContainer.addButton(removeButton)
def __init__(self, renderController, parent=None): super(RenderPropWidget, self).__init__(parent=parent) # Three tabs: Visualization, data info and slices self.visParamTabWidget = RenderParameterWidget(renderController) self.dataInfoTabWidget = RenderInfoWidget() self.slicesTabWidget = RenderSlicerParamWidget(renderController) # Create the load dataset widget self.loadDataWidget = QWidget() self.loadDataButton = QPushButton() self.loadDataButton.setText("Load a dataset") layout = QVBoxLayout() layout.setAlignment(Qt.AlignTop) layout.addWidget(self.loadDataButton) self.loadDataWidget.setLayout(layout) # Create the tab widget self.tabWidget = QTabWidget() self.tabWidget.addTab(self.visParamTabWidget, "Visualization") self.tabWidget.addTab(self.dataInfoTabWidget, "Data info") self.tabWidget.addTab(self.slicesTabWidget, "Slices") layout = QVBoxLayout() layout.addWidget(self.loadDataWidget) self.setLayout(layout)
def __init__(self, renderController, parent=None): super(RenderPropWidget, self).__init__(parent=parent) # Three tabs: Visualization, data info and slices self.visParamTabWidget = RenderParameterWidget(renderController) self.dataInfoTabWidget = RenderInfoWidget() self.slicesTabWidget = RenderSlicerParamWidget(renderController) # Create the load dataset widget self.loadDataWidget = QWidget() self.loadDataButton = QPushButton() self.loadDataButton.setText("Load a dataset") layout = QVBoxLayout() layout.setAlignment(Qt.AlignTop) layout.addWidget(self.loadDataButton) self.loadDataWidget.setLayout(layout) # Create the tab widget self.tabWidget = QTabWidget() self.tabWidget.addTab(self.visParamTabWidget, "Visualization") self.tabWidget.addTab(self.slicesTabWidget, "Slices") self.tabWidget.addTab(self.dataInfoTabWidget, "Data info") self.currentTabIndex = 0 self.extraTabWidget = None self.tabWidget.currentChanged.connect(self.tabIndexChanged) layout = QVBoxLayout() layout.addWidget(self.loadDataWidget) self.setLayout(layout)
class TooltipPositioningWithArrow(TooltipPositioning): ARROW_MARGIN = 7 ARROW_SIZE = 11 ARROW_ODD_SIZE = 15 def _getTopOrBottomArrow(self, alignment, tooltip, main_window): arrow_alignment = TooltipAlignment.mapToMainWindow(tooltip.hoveredWidget(), main_window).x() - alignment + \ tooltip.hoveredWidget().width() / 2 - self.ARROW_ODD_SIZE / 2 if arrow_alignment > tooltip.widget().width(): arrow_alignment = tooltip.widget().width() - self.ARROW_ODD_SIZE self._arrow = QWidget() self._arrow.setLayout(self._getTopOrBottomArrowLayout(arrow_alignment)) self._label_arrow = QLabel() self._label_arrow.setStyleSheet( self._getArrowStylesheet(tooltip.color())) self._label_arrow.setFixedWidth(self.ARROW_ODD_SIZE) self._label_arrow.setFixedHeight(self.ARROW_SIZE) self._arrow.layout().addWidget(self._label_arrow) return self._arrow def _getTopOrBottomArrowLayout(self, arrow_alignment): self._arrow_layout = QHBoxLayout() self._arrow_layout.setAlignment(Qt.AlignLeft) self._arrow_layout.setContentsMargins(arrow_alignment, 0, 0, 0) return self._arrow_layout def _getLeftOrRightArrow(self, alignment, tooltip, main_window): arrow_alignment = TooltipAlignment.mapToMainWindow(tooltip.hoveredWidget(), main_window).y() \ - alignment + tooltip.hoveredWidget().height() / 2 - self.ARROW_ODD_SIZE / 2 if arrow_alignment > tooltip.widget().height(): arrow_alignment = tooltip.widget().height() - self.ARROW_ODD_SIZE self._arrow = QWidget() self._arrow.setLayout(self._getLeftOrRightArrowLayout(arrow_alignment)) self._label_arrow = QLabel() self._label_arrow.setStyleSheet( self._getArrowStylesheet(tooltip.color())) self._label_arrow.setFixedWidth(self.ARROW_SIZE) self._label_arrow.setFixedHeight(self.ARROW_ODD_SIZE) self._arrow.layout().addWidget(self._label_arrow) return self._arrow def _getLeftOrRightArrowLayout(self, arrow_alignment): self._arrow_layout = QVBoxLayout() self._arrow_layout.setAlignment(Qt.AlignTop) self._arrow_layout.setContentsMargins(0, arrow_alignment, 0, 0) return self._arrow_layout def _getArrowStylesheet(self, color="rgb(255, 255, 255)"): raise NotImplementedError("Subclass responsibility") def showTooltip(self, tooltip, align, main_window): raise NotImplementedError("Subclass responsibility")
def __init__(self, ID, parent=None): super(OutputButton, self).__init__(ID, parent) self.inputDisplay = QLabel() self.inputDisplay.setText("-") layout = QVBoxLayout() layout.addWidget(self.inputDisplay) layout.setAlignment(Qt.AlignBottom | Qt.AlignHCenter) self.setLayout(layout)
def init(self, parent): """ """ rad = self.factory.radius if not rad: rad = 20 if self.control is None: ctrl = qtLED() layout = QVBoxLayout() layout.addWidget(ctrl) scene = QGraphicsScene() # ctrl.setStyleSheet("qtLED { border-style: none; }"); # ctrl.setAutoFillBackground(True) # system background color scene.setBackgroundBrush(QBrush(QColor(237, 237, 237))) ctrl.setStyleSheet("border: 0px") ctrl.setMaximumWidth(rad + 15) ctrl.setMaximumHeight(rad + 15) x, y = 10, 10 cx = x + rad / 1.75 cy = y + rad / 1.75 brush = self.get_color(self.value.state, cx, cy, rad / 2) pen = QPen() pen.setWidth(0) self.led = scene.addEllipse(x, y, rad, rad, pen=pen, brush=brush) if self.factory.label: txt = QLabel(self.factory.label) layout.addWidget(txt) layout.setAlignment(txt, Qt.AlignHCenter) # txt = scene.addText(self.factory.label, QFont('arial 6')) # txt.setPos(cx, 10) ctrl.setScene(scene) layout.setAlignment(ctrl, Qt.AlignHCenter) self.value.on_trait_change(self.update_object, 'state') self.control = QWidget() self.control.setLayout(layout)
def init_ui(self): """handle layout""" ly_main = QHBoxLayout() ly_right = QVBoxLayout() ly_right.addWidget(self.lb_title) ly_right.addWidget(self.lb_subtitle) ly_right.addWidget(self.lb_subtitle1) ly_right.setAlignment(Qt.AlignVCenter) ly_main.addWidget(self.lb_icon) ly_main.addLayout(ly_right) ly_main.addWidget(self.lb_icon1) self.setLayout(ly_main) self.resize(90, 60)
def setupTopGroup(self): topGroup = QGroupBox("Simulation Results") self.resultsPathLineEdit = SimpleOption('resultsPath','Results Path','/home/thomas/Dropbox/Keio/research/results/') topGroupLayout = QVBoxLayout() topGroupLayout.setSpacing(0) topGroupLayout.setAlignment(Qt.AlignTop) topGroupLayout.addWidget(self.resultsPathLineEdit) self.loadResultsLabel = QLabel() self.loadResultsLabel.setAlignment(Qt.AlignHCenter) topGroupLayout.addWidget(self.loadResultsLabel) self.loadResultsButton = QPushButton("Load the results") self.loadResultsButton.clicked.connect(self.loadResults) topGroupLayout.addWidget(self.loadResultsButton) topGroup.setLayout(topGroupLayout) self.topLeftLayout.addWidget(topGroup)
def _buildControlPanel(self): ''' Create all buttons, labels, etc for the application control elements ''' layout = QVBoxLayout() layout.addWidget(self._buildSetupPanel()) layout.addWidget(self._buildSpeedPanel()) layout.addWidget(self._buildResultsPanel()) layout.addWidget(self._buildRenderingOptions()) layout.setAlignment(Qt.AlignLeft | Qt.AlignTop) ctrlWidget = QWidget(self._window) ctrlWidget.setLayout(layout) ctrlWidget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) return ctrlWidget
def __init__(self, record_id, parent=None): super(BookEditForm, self).__init__(parent) self.setupUi(self) # had to subclass this spinbox to support return grabbing self.edYear = ReturnKeySpinBox(self) self.edYearHolder.addWidget(self.edYear) # configuring id's for radio group self.radioAvailability.setId(self.rdSell,0) self.radioAvailability.setId(self.rdRent,1) self.radioAvailability.setId(self.rdInactive,2) # overlaying a clean button over the image (couldn't do it in designer) self.btnCleanImage = QPushButton() self.btnCleanImage.setIcon(QIcon(":icons/clean.png")) self.btnCleanImage.setFixedWidth(35) self.btnCleanImage.clicked.connect(self.clear_image) self.btnCleanImage.setVisible(False) clean_img_layout = QVBoxLayout(self.edImage) clean_img_layout.addWidget(self.btnCleanImage) clean_img_layout.setAlignment(Qt.AlignTop | Qt.AlignLeft) clean_img_layout.setContentsMargins(2,2,0,0) self._access = statics.access_level # for currency formatting self._locale = QLocale() self._record_id = record_id # had to hardcode these, wouldn't work otherwise: self.contentsLayout.setAlignment(self.groupBox, QtCore.Qt.AlignTop) self.contentsLayout.setAlignment(self.groupBox_2, QtCore.Qt.AlignTop) self.log = logging.getLogger('BookEditForm') self._subject_list = [] self._removed_subjects = [] self._added_subjects = [] self.setup_model() self.fill_form() self.setup_fields() self._old_data = self.extract_input(text_only=True) # flag to indicate whether there were changes to the fields self._dirty = False # user did input an image self._image_set = False # image changed during edit self._image_changed = False
def add_command_tab(self, command_list, tab_name = "Commands"): outer_widget = QWidget() outer_layout = QVBoxLayout() outer_widget.setLayout(outer_layout) outer_layout.setContentsMargins(2, 2, 2, 2) outer_layout.setSpacing(1) for c in command_list: new_command = qButtonWithArgumentsClass(c[1], c[0], c[2], self.help_instance, max_field_size = 100) outer_layout.addWidget(new_command) outer_layout.setAlignment(new_command,QtCore.Qt.AlignTop ) outer_layout.addStretch() scroller = QScrollArea() scroller.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # scroller.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) scroller.setWidget(outer_widget) scroller.setWidgetResizable(True) self.addTab(scroller, tab_name)
def setupFilterGroup(self): filterGroup = QGroupBox('Filter the results') filterGroupLayout = QVBoxLayout() filterGroupLayout.setSpacing(0) filterGroupLayout.setAlignment(Qt.AlignTop) # Distribution Model self.filterDistribution = SimpleComboboxOption('dis','Speed Distribution Model',3, True, 'Uniform','Exponential','Normal','Log Normal') filterGroupLayout.addWidget(self.filterDistribution) self.filterDistribution.setVisible(False) # Number of results per point self.filterNb = SimpleSpinOption('simuNbMin', 'Minimum results for a given setting', 10, integer=True, checkable=True) self.filterNb.checkBox.setChecked(True) filterGroupLayout.addWidget(self.filterNb) # Filter the date dateWidget = QWidget() dateWidget.setLayout(QHBoxLayout()) self.filterDate = QCheckBox('After') self.filterDate.setChecked(QSettings().value('filterDate','0')=='1') dateWidget.layout().addWidget(self.filterDate) self.filterDateYear = QComboBox() for m in xrange(2010,2012): self.filterDateYear.addItem(str(m)) self.filterDateYear.setCurrentIndex(int(QSettings().value('dateYear', 1))) dateWidget.layout().addWidget(self.filterDateYear) dateWidget.layout().addWidget(QLabel('Year')) self.filterDateMonth = QComboBox() for m in xrange(1,13): self.filterDateMonth.addItem(str(m)) self.filterDateMonth.setCurrentIndex(int(QSettings().value('dateMonth', 4))) dateWidget.layout().addWidget(self.filterDateMonth) dateWidget.layout().addWidget(QLabel('Month')) self.filterDateDay = QComboBox() for d in xrange(1,32): self.filterDateDay.addItem(str(d)) self.filterDateDay.setCurrentIndex(int(QSettings().value('dateDay', 0))) dateWidget.layout().addWidget(self.filterDateDay) dateWidget.layout().addWidget(QLabel('Day')) filterGroupLayout.addWidget(dateWidget) filterGroup.setLayout(filterGroupLayout) self.topLeftLayout.addWidget(filterGroup) # Filter the scenario self.filterScenar = SimpleComboboxOption('scenar','Scenario',1, True, 'vanet-highway-test-thomas','vanet-highway-scenario2') filterGroupLayout.addWidget(self.filterScenar) # Filter gap self.filterGap = SimpleSpinOption('avgdistanalyze','Average Distance (m)',100, checkable=True) filterGroupLayout.addWidget(self.filterGap)
def createGUI(self): self.series = QSpinBox() self.series.setMinimum(1) self.repetitions = QSpinBox() self.repetitions.setMaximum(512) self.avgHeartRateToggle = QCheckBox() self.avgHeartRateToggle.toggled.connect(self._toggleHeartRateSpinBox) self.avgHeartRate = QSpinBox() self.avgHeartRate.setMinimum(30) self.avgHeartRate.setMaximum(250) self.avgHeartRate.setValue(120) self.avgHeartRate.setDisabled(True) self.dateSelector_widget = QCalendarWidget() self.dateSelector_widget.setMaximumDate(QDate.currentDate()) self.addButton = QPushButton("Add pushup") self.addButton.setMaximumWidth(90) self.addButton.clicked.connect(self._createPushup) self.cancelButton = QPushButton("Cancel") self.cancelButton.setMaximumWidth(90) self.cancelButton.clicked.connect(self.reject) self.pushupForm.addRow("Series", self.series) self.pushupForm.addRow("Repetitions", self.repetitions) self.pushupForm.addRow("Store average heart rate ? ", self.avgHeartRateToggle) self.pushupForm.addRow("Average Heart Rate", self.avgHeartRate) self.pushupForm.addRow("Exercise Date", self.dateSelector_widget) btnsLayout = QVBoxLayout() btnsLayout.addWidget(self.addButton) btnsLayout.addWidget(self.cancelButton) btnsLayout.setAlignment(Qt.AlignRight) layoutWrapper = QVBoxLayout() layoutWrapper.addLayout(self.pushupForm) layoutWrapper.addLayout(btnsLayout) self.setLayout(layoutWrapper)
def create_box_layout(self, is_vertical=True, align=""): """ Returns a new GUI toolkit neutral 'box' layout manager. """ if is_vertical: layout = QVBoxLayout() alignment = Qt.AlignTop if align == "bottom": alignment = Qt.AlignBottom layout.setAlignment(alignment) else: layout = QHBoxLayout() alignment = Qt.AlignLeft if align == "right": alignment = Qt.AlignRight layout.setAlignment(alignment) layout.setSpacing(0) ### PYSIDE: layout.setMargin( 0 ) return layout_adapter(layout, is_vertical)
def __init__(self, parent, widget): """Construct an OverlayDialog with the given Qt GUI parent and displaying the given widget. """ super(OverlayDialog, self).__init__(parent, Qt.SplashScreen) self.setAcceptDrops(True) self.setAttribute(Qt.WA_TranslucentBackground) bgcolor = self.palette().color(QPalette.Background) self.setPalette(QColor(bgcolor.red(), bgcolor.green(), bgcolor.blue(), 0)) # alpha self.setModal(True) layout = QVBoxLayout(self) layout.setAlignment(Qt.AlignCenter) layout.addWidget(widget) self.setLayout(layout) self.resize(0.8 * parent.size().width(), 0.8 * parent.size().height()) widget.resize(self.width(), self.height())
def __init__(self): super(TransformationHistoryWidget, self).__init__() self.actionContainer = ButtonContainer() self.transformationModel = TransformationModel() self.transformationView = TransformationListView() self.transformationView.setRootIsDecorated(False) self.transformationView.setModel(self.transformationModel) layout = QVBoxLayout() layout.setSpacing(0) layout.setAlignment(Qt.AlignTop) layout.addWidget(self.transformationView) layout.addWidget(self.actionContainer) self.setLayout(layout) removeButton = QPushButton() removeButton.setIcon(QIcon(AppVars.imagePath() + "RemoveButton.png")) removeButton.clicked.connect(self.removeButtonClicked) self.actionContainer.addButton(removeButton)
def __init__(self): super(HighwayAnalyzeWidget,self).__init__() self.averageSimulationTime = 325.0 mainLayout = QVBoxLayout() mainLayout.setAlignment(Qt.AlignTop|Qt.AlignHCenter) mainLayout.setSpacing(0) self.setLayout(mainLayout) topWidget = QWidget() self.topLayout = QHBoxLayout() self.topLayout.setSpacing(0) topWidget.setLayout(self.topLayout) topLeftWidget = QWidget() self.topLeftLayout = QVBoxLayout() topLeftWidget.setLayout(self.topLeftLayout) self.setupTopGroup() self.setupFilterGroup() self.topLayout.addWidget(topLeftWidget) self.layout().addWidget(topWidget) # Button and log buttonAndLogWidget = QWidget() buttonAndLogWidget.setLayout(QVBoxLayout()) # Analyze the results BUTTON self.analyzeResultsButton = QPushButton('Analyze the results') self.analyzeResultsButton.clicked.connect(self.analyzeResults) self.analyzeResultsButton.setEnabled(False) buttonAndLogWidget.layout().addWidget(self.analyzeResultsButton) # LOG self.logText = QTextBrowser() self.logText.setFont(QFont('Century Gothic', 7)) self.logText.setWordWrapMode(QTextOption.NoWrap) buttonAndLogWidget.layout().addWidget(self.logText) self.topLayout.addWidget(buttonAndLogWidget) self.results = [] self.logFile = os.path.join(self.resultsPath(), 'analyze_'+os.uname()[1]+'.log') # Image self.picLabel = QLabel() self.picLabel.setAlignment(Qt.AlignHCenter) #self.picLabel.resize(800,600) self.picLabel.setMinimumSize(800,600) self.layout().addWidget(self.picLabel)
def __init__(self, parent, widget): """Construct an OverlayDialog with the given Qt GUI parent and displaying the given widget. """ super(OverlayDialog, self).__init__(parent, Qt.SplashScreen) self.setAcceptDrops(True) self.setAttribute(Qt.WA_TranslucentBackground) bgcolor = self.palette().color(QPalette.Background) self.setPalette( QColor(bgcolor.red(), bgcolor.green(), bgcolor.blue(), 0)) # alpha self.setModal(True) layout = QVBoxLayout(self) layout.setAlignment(Qt.AlignCenter) layout.addWidget(widget) self.setLayout(layout) self.resize(0.8 * parent.size().width(), 0.8 * parent.size().height()) widget.resize(self.width(), self.height())
def __init__(self, res): QWidget.__init__(self) self.res = res layout = QVBoxLayout() self.setLayout(layout) preview = QLabel() if 'image' in res.mime: pixmap = QPixmap(res.file_path).scaledToWidth(32) else: info = QFileInfo(res.file_path) pixmap = QFileIconProvider().icon(info).pixmap(32, 32) preview.setPixmap(pixmap) preview.setMask(pixmap.mask()) preview.setMaximumHeight(32) label = QLabel() label.setText(res.file_name) layout.addWidget(preview) layout.addWidget(label) layout.setAlignment(Qt.AlignHCenter) self.setFixedWidth(64) self.setFixedHeight(64)
def create_icon_box(self, name, text): style = "width:48px;height:48px;background-color:white;border-radius:5px;border:1px solid rgb(50,50,50);" icon_label = QtGui.QLabel() icon_label.setStyleSheet(style) icon_label.setMaximumWidth(48) icon_label.setMinimumWidth(48) icon_label.setMaximumHeight(48) icon_label.setMinimumHeight(48) setattr(self, name, icon_label) icon_text = QtGui.QLabel(text) icon_text.setStyleSheet("font-size:10px;") icon_text.setAlignment(QtCore.Qt.AlignCenter) vbox = QVBoxLayout() vbox.setAlignment(QtCore.Qt.AlignCenter) vbox.addWidget(icon_label) vbox.addWidget(icon_text) vbox.setContentsMargins(0, 0, 0, 0) w = QtGui.QWidget() w.setLayout(vbox) w.setMaximumWidth(70) return w
def create_icon_box(self, name, text): style = 'width:48px;height:48px;background-color:white;border-radius:5px;border:1px solid rgb(50,50,50);' icon_label = QtGui.QLabel() icon_label.setStyleSheet(style) icon_label.setMaximumWidth(48) icon_label.setMinimumWidth(48) icon_label.setMaximumHeight(48) icon_label.setMinimumHeight(48) setattr(self, name, icon_label) icon_text = QtGui.QLabel(text) icon_text.setStyleSheet('font-size:10px;') icon_text.setAlignment(QtCore.Qt.AlignCenter) vbox = QVBoxLayout() vbox.setAlignment(QtCore.Qt.AlignCenter) vbox.addWidget(icon_label) vbox.addWidget(icon_text) vbox.setContentsMargins(0, 0, 0, 0) w = QtGui.QWidget() w.setLayout(vbox) w.setMaximumWidth(70) return w
class SceneTab(QWidget): # FIXME I'm Ugly. """This widget is for changing the Scene propagation policies of the module. """ def __init__(self, parent, agent): """Construct the SceneTab with the given parent (TabDialog) and ModuleAgent. """ super(SceneTab, self).__init__(parent) self.agent = agent self.layout = QVBoxLayout() self.layout.setAlignment(Qt.AlignCenter) self.layout.addWidget(self.buildHighlightGroupBox()) self.layout.addItem(QSpacerItem(5, 5)) self.layout.addWidget(self.buildModuleGroupBox()) self.layout.addItem(QSpacerItem(5, 5)) self.layout.addWidget(self.buildAttributeGroupBox()) self.setLayout(self.layout) def buildHighlightGroupBox(self): """Layout/construct the highlight UI for this tab.""" groupBox = QGroupBox("Highlight Policy") layout = QVBoxLayout() # agent.propagate_highlights self.highlights_propagate = QCheckBox("Propagate highlights to " + "other modules.") self.highlights_propagate.setChecked(self.agent.propagate_highlights) self.highlights_propagate.stateChanged.connect(self.highlightsPropagateChanged) # We only allow this change if the parent does not propagate if self.agent.parent().propagate_highlights: self.highlights_propagate.setDisabled(True) # agent.apply_highlights self.applyHighlights = QCheckBox("Apply highlights from " + "other modules.") self.applyHighlights.setChecked(self.agent.apply_highlights) self.applyHighlights.stateChanged.connect(self.applyHighlightsChanged) layout.addWidget(self.applyHighlights) layout.addItem(QSpacerItem(5, 5)) layout.addWidget(self.highlights_propagate) groupBox.setLayout(layout) return groupBox def highlightsPropagateChanged(self): """Called when highlight propagtion is changed to update the Agent. """ self.agent.propagate_highlights = self.highlights_propagate.isChecked() def applyHighlightsChanged(self): """Called when highlight application is changed to update the Agent. """ self.agent.apply_highlights = self.applyHighlights.isChecked() def buildModuleGroupBox(self): """Layout/construct the ModuleScene UI for this tab.""" groupBox = QGroupBox("Module Policy") layout = QVBoxLayout() # agent.propagate_module_scenes self.module_propagate = QCheckBox("Propagate module scene information " + "to other modules.") self.module_propagate.setChecked(self.agent.propagate_module_scenes) self.module_propagate.stateChanged.connect(self.modulePropagateChanged) # We only allow this change if the parent does not propagate if self.agent.parent().propagate_module_scenes: self.module_propagate.setDisabled(True) # agent.apply_module_scenes self.module_applyScene = QCheckBox("Apply module scene information " + "from other modules.") self.module_applyScene.setChecked(self.agent.apply_module_scenes) self.module_applyScene.stateChanged.connect(self.moduleApplyChanged) layout.addWidget(self.module_applyScene) layout.addItem(QSpacerItem(5, 5)) layout.addWidget(self.module_propagate) groupBox.setLayout(layout) return groupBox def modulePropagateChanged(self): """Called when ModuleScene propagtion is changed to update the Agent. """ self.agent.propagate_module_scenes = self.module_propagate.isChecked() def moduleApplyChanged(self): """Called when ModuleScene application is changed to update the Agent. """ self.agent.apply_module_scenes = self.module_applyScene.isChecked() def buildAttributeGroupBox(self): """Layout/construct the AttributeScene UI for this tab.""" groupBox = QGroupBox("Attribute Policy (Colors)") layout = QVBoxLayout() # agent.propagate_attribute_scenes self.attr_propagate = QCheckBox( "Propagate attribute scene " + "information (e.g. color maps) to other modules." ) self.attr_propagate.setChecked(self.agent.propagate_attribute_scenes) self.attr_propagate.stateChanged.connect(self.attrPropagateChanged) # We only allow this change if the parent does not propagate if self.agent.parent().propagate_attribute_scenes: self.attr_propagate.setDisabled(True) # agent.apply_attribute_scenes self.attr_applyScene = QCheckBox("Apply attribute scene information " + "from other modules.") self.attr_applyScene.setChecked(self.agent.apply_attribute_scenes) self.attr_applyScene.stateChanged.connect(self.attrApplyChanged) layout.addWidget(self.attr_applyScene) layout.addItem(QSpacerItem(5, 5)) layout.addWidget(self.attr_propagate) groupBox.setLayout(layout) return groupBox def attrPropagateChanged(self): """Called when AttributeScene propagtion is changed to update the Agent. """ self.agent.propagate_attribute_scenes = self.attr_propagate.isChecked() def attrApplyChanged(self): """Called when AttributeScene application is changed to update the Agent. """ self.agent.apply_attribute_scenes = self.attr_applyScene.isChecked()
def __init__(self, parent=None): super(MassAttribute_UI, self).__init__(parent) # Abstract self.applier = self.Applikator(self) self.selection = [] self.callback = None self.ctx = None # storing found attributes' types to avoid double check self.solved = {} self.setLocale(QLocale.C) self.setAttribute(Qt.WA_DeleteOnClose) self.setAttribute(Qt.WA_QuitOnClose) self.setFixedWidth(300) self.setWindowTitle('Massive Attribute Modifier') # UI L_main = QVBoxLayout() self.WV_title = QLabel('') self.WV_title.setVisible(False) self.WV_title.setFont(QFont('Verdana', 10)) self.WV_title.setContentsMargins(0, 0, 0, 7) self.WB_select = QPushButton('Select') self.WB_select.setVisible(False) self.WB_select.setFixedWidth(50) self.WB_select.clicked.connect(lambda: cmds.select(self.selection)) self.WB_update = QPushButton('Update') self.WB_update.setFixedWidth(50) self.WB_update.clicked.connect( lambda: self.update_attributes(cmds.ls(sl=True))) self.WV_search = Filter() self.WV_search.textChanged.connect(self.filter) self.WC_cases = QCheckBox('Case sensitive') self.WC_cases.stateChanged.connect(self.filter) self.WC_types = QCheckBox('Type filtering') self.WL_attrtype = QComboBox() self.WL_attrtype.setEnabled(False) for i, ctx in enumerate(sorted(self.ctx_wide)): self.WL_attrtype.addItem(ctx.title()) self.WL_attrtype.setItemIcon(i, self.ctx_icons[ctx]) L_attrtype = line(self.WC_types, self.WL_attrtype) self.WC_types.stateChanged.connect( partial(self.update_attributes, self.selection)) self.WC_types.stateChanged.connect(self.WL_attrtype.setEnabled) self.WL_attrtype.currentIndexChanged.connect(self.filter) self.WC_liveu = QCheckBox('Live') self.WC_liveu.stateChanged.connect(self.WB_update.setDisabled) self.WC_liveu.stateChanged.connect(self.set_callback) self.WC_histo = QCheckBox('Load history') self.WC_histo.setChecked(True) self.WC_histo.stateChanged.connect( partial(self.update_attributes, self.selection)) self.WC_child = QCheckBox('Children') self.WC_child.stateChanged.connect( partial(self.update_attributes, self.selection)) options = group( 'Options', line(self.WC_cases, L_attrtype), line(self.WC_child, self.WC_histo, self.WC_liveu, self.WB_update)) options.layout().setSpacing(2) self.WL_attributes = QTreeWidget() self.WL_attributes.setStyleSheet( 'QTreeView {alternate-background-color: #1b1b1b;}') self.WL_attributes.setAlternatingRowColors(True) self.WL_attributes.setHeaderHidden(True) self.WL_attributes.setRootIsDecorated(False) self.objs_attr = set() self.shps_attr = set() self.W_EDI_float = FloatBox() self.W_EDI_int = IntBox() self.W_EDI_enum = QComboBox() self.W_EDI_bool = QCheckBox() self.W_EDI_str = QLineEdit() self.W_EDI_d3 = Double3() self.W_EDI_d4 = Double4() self.W_EDI_color = ColorPicker() # Final layout L_title = line(self.WV_title, self.WB_select) L_title.setStretch(0, 1) L_main.addLayout(L_title) L_main.setAlignment(Qt.AlignLeft) L_main.addWidget(self.WV_search) L_main.addWidget(options) L_main.addWidget(self.WL_attributes) L_edits = col(self.W_EDI_bool, self.W_EDI_int, self.W_EDI_float, self.W_EDI_enum, self.W_EDI_str, self.W_EDI_d3, self.W_EDI_d4, self.W_EDI_color) L_edits.setContentsMargins(0, 8, 0, 0) L_main.addLayout(L_edits) L_main.setStretch(3, 1) L_main.setSpacing(2) self.appliers = { 'float': self.applier.apply_float, 'enum': self.applier.apply_enum, 'bool': self.applier.apply_bool, 'time': self.applier.apply_float, 'byte': self.applier.apply_int, 'angle': self.applier.apply_float, 'string': self.applier.apply_str, 'float3': self.applier.apply_d3, 'float4': self.applier.apply_d4, 'color': self.applier.apply_color } self.setLayout(L_main) # final settings self.WL_attributes.itemSelectionChanged.connect(self.update_setter) self.applier.unset_editors()
class DeviceList(QScrollArea): def __init__(self, programming_handler, info_handler, reset_handler): super(DeviceList, self).__init__() self.deviceWidgets = [] self.programming_handler = programming_handler self.info_handler = info_handler self.reset_handler = reset_handler self.updateCounter = 0 self.initUI() def initUI(self): self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.listWidget = QWidget() self.layout = QVBoxLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.listWidget.setLayout(self.layout) self.setWidgetResizable(True) self.setWidget(self.listWidget) self.updateList() def updateList(self): self.updateCounter += 1 deviceInfoList = list( filter(is_supported_device, easyhid.Enumeration().find())) deleteList = [] deviceIds = [dev.path for dev in deviceInfoList] oldDevices = [] newDevices = [] # look at the list of connected devices and find out which devices are # no longer connected and remove them i = 0 while i < self.layout.count(): devItem = self.layout.itemAt(i).widget() if hasattr(devItem, "device") and (devItem.device.path in deviceIds): oldDevices.append(devItem.device) i += 1 else: self.layout.takeAt(i).widget().deleteLater() # Now find the list of new devices oldDeviceIds = [dev.path for dev in oldDevices] for dev in deviceInfoList: if dev.path in oldDeviceIds: continue else: newDevices.append(dev) for devInfo in newDevices: devWidget = DeviceWidget(devInfo) if devWidget.label: self.deviceWidgets.append(devWidget) self.layout.addWidget(devWidget) devWidget.program.connect(self.programming_handler) devWidget.show_info.connect(self.info_handler) devWidget.reset.connect(self.reset_handler) # if len(self.deviceWidgets) == 0: if len(oldDevices) == 0 and len(newDevices) == 0: n = self.updateCounter % 4 label = QLabel("Scanning for devices" + "." * n + " " * (4 - n)) self.layout.setAlignment(Qt.AlignCenter) self.layout.addWidget(label) self.deviceWidgets = [] else: self.layout.setAlignment(Qt.AlignTop) self.updateCounter = 0
toolButtonLeft1 = CreateFlatButton(QAction(icon, "Left", mainWindow)) toolButtonLeft2 = CreateFlatButton(QAction(icon, "2nd left", mainWindow)) toolButtonRight = CreateFlatButton(QAction(icon, "Right", mainWindow)) toolButtonCenter = QPushButton() toolButtonCenter.setIcon(QIcon(basePath + "LandmarkTransformButton.png")) toolButtonCenter.setText("Center") toolButtonCenter.setMinimumWidth(200) barWidget = ToolbarWidget() barWidget.addLeftItem(toolButtonLeft1) barWidget.addLeftItem(toolButtonLeft2) barWidget.addCenterItem(toolButtonCenter) barWidget.addRightItem(toolButtonRight) toolbar.addWidget(barWidget) layout = QVBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.setAlignment(Qt.AlignVCenter | Qt.AlignHCenter) layout.addWidget(QLabel("Test toolbar widget")) widget = QWidget() widget.setLayout(layout) mainWindow.setCentralWidget(widget) mainWindow.setGeometry(100, 100, 500, 300) mainWindow.show() app.exec_()
def __init__(self, parent=None): super(MassAttribute_UI, self).__init__(parent) # Abstract self.applier = self.Applikator(self) self.selection = [] self.callback = None self.ctx = None # storing found attributes' types to avoid double check self.solved = {} self.setLocale(QLocale.C) self.setAttribute(Qt.WA_DeleteOnClose) self.setAttribute(Qt.WA_QuitOnClose) self.setFixedWidth(300) self.setWindowTitle('Massive Attribute Modifier') # UI L_main = QVBoxLayout() self.WV_title = QLabel('') self.WV_title.setVisible(False) self.WV_title.setFont(QFont('Verdana', 10)) self.WV_title.setContentsMargins(0, 0, 0, 7) self.WB_select = QPushButton('Select') self.WB_select.setVisible(False) self.WB_select.setFixedWidth(50) self.WB_select.clicked.connect(lambda: cmds.select(self.selection)) self.WB_update = QPushButton('Update') self.WB_update.setFixedWidth(50) self.WB_update.clicked.connect(lambda:self.update_attributes(cmds.ls(sl=True))) self.WV_search = Filter() self.WV_search.textChanged.connect(self.filter) self.WC_cases = QCheckBox('Case sensitive') self.WC_cases.stateChanged.connect(self.filter) self.WC_types = QCheckBox('Type filtering') self.WL_attrtype = QComboBox() self.WL_attrtype.setEnabled(False) for i, ctx in enumerate(sorted(self.ctx_wide)): self.WL_attrtype.addItem(ctx.title()) self.WL_attrtype.setItemIcon(i, self.ctx_icons[ctx]) L_attrtype = line(self.WC_types, self.WL_attrtype) self.WC_types.stateChanged.connect(partial(self.update_attributes, self.selection)) self.WC_types.stateChanged.connect(self.WL_attrtype.setEnabled) self.WL_attrtype.currentIndexChanged.connect(self.filter) self.WC_liveu = QCheckBox('Live') self.WC_liveu.stateChanged.connect(self.WB_update.setDisabled) self.WC_liveu.stateChanged.connect(self.set_callback) self.WC_histo = QCheckBox('Load history') self.WC_histo.setChecked(True) self.WC_histo.stateChanged.connect(partial(self.update_attributes, self.selection)) self.WC_child = QCheckBox('Children') self.WC_child.stateChanged.connect(partial(self.update_attributes, self.selection)) options = group('Options', line(self.WC_cases, L_attrtype), line(self.WC_child, self.WC_histo, self.WC_liveu, self.WB_update)) options.layout().setSpacing(2) self.WL_attributes = QTreeWidget() self.WL_attributes.setStyleSheet('QTreeView {alternate-background-color: #1b1b1b;}') self.WL_attributes.setAlternatingRowColors(True) self.WL_attributes.setHeaderHidden(True) self.WL_attributes.setRootIsDecorated(False) self.objs_attr = set() self.shps_attr = set() self.W_EDI_float = FloatBox() self.W_EDI_int = IntBox() self.W_EDI_enum = QComboBox() self.W_EDI_bool = QCheckBox() self.W_EDI_str = QLineEdit() self.W_EDI_d3 = Double3() self.W_EDI_d4 = Double4() self.W_EDI_color = ColorPicker() # Final layout L_title = line(self.WV_title, self.WB_select) L_title.setStretch(0, 1) L_main.addLayout(L_title) L_main.setAlignment(Qt.AlignLeft) L_main.addWidget(self.WV_search) L_main.addWidget(options) L_main.addWidget(self.WL_attributes) L_edits = col(self.W_EDI_bool, self.W_EDI_int, self.W_EDI_float, self.W_EDI_enum, self.W_EDI_str, self.W_EDI_d3, self.W_EDI_d4, self.W_EDI_color) L_edits.setContentsMargins(0, 8, 0, 0) L_main.addLayout(L_edits) L_main.setStretch(3, 1) L_main.setSpacing(2) self.appliers = {'float': self.applier.apply_float, 'enum': self.applier.apply_enum, 'bool': self.applier.apply_bool, 'time': self.applier.apply_float, 'byte': self.applier.apply_int, 'angle': self.applier.apply_float, 'string': self.applier.apply_str, 'float3': self.applier.apply_d3, 'float4': self.applier.apply_d4, 'color': self.applier.apply_color} self.setLayout(L_main) # final settings self.WL_attributes.itemSelectionChanged.connect(self.update_setter) self.applier.unset_editors()
class SceneTab(QWidget): #FIXME I'm Ugly. """This widget is for changing the Scene propagation policies of the module. """ def __init__(self, parent, agent): """Construct the SceneTab with the given parent (TabDialog) and ModuleAgent. """ super(SceneTab, self).__init__(parent) self.agent = agent self.layout = QVBoxLayout() self.layout.setAlignment(Qt.AlignCenter) self.layout.addWidget(self.buildHighlightGroupBox()) self.layout.addItem(QSpacerItem(5, 5)) self.layout.addWidget(self.buildModuleGroupBox()) self.layout.addItem(QSpacerItem(5, 5)) self.layout.addWidget(self.buildAttributeGroupBox()) self.setLayout(self.layout) def buildHighlightGroupBox(self): """Layout/construct the highlight UI for this tab.""" groupBox = QGroupBox("Highlight Policy") layout = QVBoxLayout() # agent.propagate_highlights self.highlights_propagate = QCheckBox("Propagate highlights to " + "other modules.") self.highlights_propagate.setChecked(self.agent.propagate_highlights) self.highlights_propagate.stateChanged.connect( self.highlightsPropagateChanged) # We only allow this change if the parent does not propagate if self.agent.parent().propagate_highlights: self.highlights_propagate.setDisabled(True) # agent.apply_highlights self.applyHighlights = QCheckBox("Apply highlights from " + "other modules.") self.applyHighlights.setChecked(self.agent.apply_highlights) self.applyHighlights.stateChanged.connect(self.applyHighlightsChanged) layout.addWidget(self.applyHighlights) layout.addItem(QSpacerItem(5, 5)) layout.addWidget(self.highlights_propagate) groupBox.setLayout(layout) return groupBox def highlightsPropagateChanged(self): """Called when highlight propagtion is changed to update the Agent. """ self.agent.propagate_highlights = self.highlights_propagate.isChecked() def applyHighlightsChanged(self): """Called when highlight application is changed to update the Agent. """ self.agent.apply_highlights = self.applyHighlights.isChecked() def buildModuleGroupBox(self): """Layout/construct the ModuleScene UI for this tab.""" groupBox = QGroupBox("Module Policy") layout = QVBoxLayout() # agent.propagate_module_scenes self.module_propagate = QCheckBox( "Propagate module scene information " + "to other modules.") self.module_propagate.setChecked(self.agent.propagate_module_scenes) self.module_propagate.stateChanged.connect(self.modulePropagateChanged) # We only allow this change if the parent does not propagate if self.agent.parent().propagate_module_scenes: self.module_propagate.setDisabled(True) # agent.apply_module_scenes self.module_applyScene = QCheckBox("Apply module scene information " + "from other modules.") self.module_applyScene.setChecked(self.agent.apply_module_scenes) self.module_applyScene.stateChanged.connect(self.moduleApplyChanged) layout.addWidget(self.module_applyScene) layout.addItem(QSpacerItem(5, 5)) layout.addWidget(self.module_propagate) groupBox.setLayout(layout) return groupBox def modulePropagateChanged(self): """Called when ModuleScene propagtion is changed to update the Agent. """ self.agent.propagate_module_scenes = self.module_propagate.isChecked() def moduleApplyChanged(self): """Called when ModuleScene application is changed to update the Agent. """ self.agent.apply_module_scenes = self.module_applyScene.isChecked() def buildAttributeGroupBox(self): """Layout/construct the AttributeScene UI for this tab.""" groupBox = QGroupBox("Attribute Policy (Colors)") layout = QVBoxLayout() # agent.propagate_attribute_scenes self.attr_propagate = QCheckBox( "Propagate attribute scene " + "information (e.g. color maps) to other modules.") self.attr_propagate.setChecked(self.agent.propagate_attribute_scenes) self.attr_propagate.stateChanged.connect(self.attrPropagateChanged) # We only allow this change if the parent does not propagate if self.agent.parent().propagate_attribute_scenes: self.attr_propagate.setDisabled(True) # agent.apply_attribute_scenes self.attr_applyScene = QCheckBox("Apply attribute scene information " + "from other modules.") self.attr_applyScene.setChecked(self.agent.apply_attribute_scenes) self.attr_applyScene.stateChanged.connect(self.attrApplyChanged) layout.addWidget(self.attr_applyScene) layout.addItem(QSpacerItem(5, 5)) layout.addWidget(self.attr_propagate) groupBox.setLayout(layout) return groupBox def attrPropagateChanged(self): """Called when AttributeScene propagtion is changed to update the Agent. """ self.agent.propagate_attribute_scenes = self.attr_propagate.isChecked() def attrApplyChanged(self): """Called when AttributeScene application is changed to update the Agent. """ self.agent.apply_attribute_scenes = self.attr_applyScene.isChecked()
def setupUI(self): layout = QVBoxLayout() layout.setAlignment(Qt.AlignHCenter) self.setContentsMargins(20, 10, 20, 5) banner = QHBoxLayout() banner.addWidget(self.logo) bannerText = QVBoxLayout() text = QLabel("Salary Management System") text.setStyleSheet("font-size: 30px;") bannerText.addWidget(text) bannerText.setAlignment(text, Qt.AlignBottom) text2 = QLabel("Indian Institute of Information Technology Kalyani") text2.setStyleSheet("font-size: 20px;") bannerText.addWidget(text2) bannerText.setAlignment(text2, Qt.AlignTop) banner.addLayout(bannerText) banner.addStretch() layout.addLayout(banner) layout.addSpacing(30) bttnList = [ self.bttnAddDesignation, self.bttnDelDesg, self.bttnEditDesg, self.bttnShowDesg, self.bttnShowEmp, self.bttnEditEmp, self.bttnAddEmployee, self.bttnDelEmp, self.bttnSettings, self.bttnCalcSalary ] for bttn in bttnList: bttn.setObjectName("HomeBttn") bttn.setIconSize(QSize(55, 55)) employeeGroup = QGroupBox("Employee") employeeGroupLayout = QVBoxLayout() employeeGroupLayout.addWidget(self.bttnAddEmployee) employeeGroupLayout.addWidget(self.bttnEditEmp) employeeGroupLayout.addWidget(self.bttnDelEmp) employeeGroupLayout.addWidget(self.bttnShowEmp) employeeGroup.setLayout(employeeGroupLayout) designationGroup = QGroupBox("Designation") designationGroupLayout = QVBoxLayout() designationGroupLayout.addWidget(self.bttnAddDesignation) designationGroupLayout.addWidget(self.bttnEditDesg) designationGroupLayout.addWidget(self.bttnDelDesg) designationGroupLayout.addWidget(self.bttnShowDesg) designationGroup.setLayout(designationGroupLayout) groups = QHBoxLayout() groups.addWidget(employeeGroup) groups.addWidget(designationGroup) otherBttns = QGroupBox() otherBttnsLayout = QVBoxLayout() otherBttnsLayout.addWidget(self.bttnCalcSalary) otherBttnsLayout.addWidget(self.bttnSettings) otherBttnsLayout.addStretch() otherBttns.setLayout(otherBttnsLayout) groups.addWidget(otherBttns) groups.addStretch() layout.addLayout(groups) layout.addStretch() version = QLabel(version_text) layout.addWidget(version) centerLayout = QHBoxLayout() centerLayout.addStretch() centerLayout.addLayout(layout) centerLayout.addStretch() self.setLayout(centerLayout)
class Ui_MainView(QMainWindow): gui_methods_sig = Signal(int, ) def __init__(self, ): super(Ui_MainView, self).__init__() self.output_folder = os.getcwd() self.usr = '' self.psw = '' self.save_username_checked = False self.right_base_layout_v = QtGui.QVBoxLayout() self.msgBox = QtGui.QMessageBox() self.validations = validate_inputs.validate_controls( self ) # instance for input validations and we are passing self to validate class for model updations def gifUI(self, gui_slate): self.gui = gui_slate self.gif_widget = QWidget() self.gif_layout = QVBoxLayout() self.movie_screen = QLabel() self.movie_screen.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.movie_screen.setAlignment(QtCore.Qt.AlignCenter) self.gif_layout.addWidget(self.movie_screen) ag_file = "GIF-180704_103026.gif" self.movie = QtGui.QMovie(ag_file, QtCore.QByteArray(), self.gif_widget) self.movie.setCacheMode(QtGui.QMovie.CacheAll) self.movie.setSpeed(75) self.movie_screen.setMovie(self.movie) # self.movie_screen.setFixedWidth(500) self.gif_widget.setLayout(self.gif_layout) self.gui.setCentralWidget(self.gif_widget) # self.gui.addDockWidget(self.gif_widget) self.movie.start() # self.movie.setPaused(True) self.gif_widget.show() # time.sleep(2) # self.movie.stop() def setupUi(self, gui_slate): self.gui = gui_slate self.gui.get_option_selected = False self.gui.push_option_selected = False self.gui.extract_opt_selected = False self.gui.compare_opt_selected = False #Outer most Main Layout self.widget = QWidget() self.widget.setMinimumSize(850, 600) self.main_layout_h = QHBoxLayout() self.main_layout_h.setAlignment(QtCore.Qt.AlignTop) self.widget.setLayout(self.main_layout_h) self.gui.setCentralWidget(self.widget) self.left_base_widget = QWidget() # self.left_base_widget.setMaximumWidth(600) # self.left_base_widget.setMinimumWidth(450) # self.left_base_widget.setMaximumHeight(700) self.right_base_widget = QWidget() #3 Sub main Layouts self.left_base_layout_v = QVBoxLayout() # self.right_base_layout_v = QVBoxLayout() self.corner_logo_layout_v = QVBoxLayout() self.left_base_layout_v.setAlignment(QtCore.Qt.AlignTop) self.right_base_layout_v.setAlignment(QtCore.Qt.AlignTop) #Added Widgets and layouts to the outermost layout self.main_layout_h.addWidget(self.left_base_widget) self.main_layout_h.addWidget(self.right_base_widget) self.main_layout_h.addLayout(self.corner_logo_layout_v) # , QtGui.QFont.Normal self.grp_heading_font = QtGui.QFont("Verdana", 10) self.grp_heading_font.setItalic(True) #Radio buttons layout self.radio_groupBox = QtGui.QGroupBox() self.radio_option_layout_lb_h = QHBoxLayout() self.radio_groupBox.setLayout(self.radio_option_layout_lb_h) self.radio_groupBox.setMinimumWidth(450) self.left_base_layout_v.addWidget(self.radio_groupBox) #Credentials layouts self.credentials_groupbox = QtGui.QGroupBox("GTAC Credentials") self.credentials_groupbox.setFont(self.grp_heading_font) self.credentials_layout_lb_v = QVBoxLayout() self.username_layout_lb_h = QHBoxLayout() self.password_layout_lb_h = QHBoxLayout() self.cr_layout_lb_h = QHBoxLayout() self.password_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft) self.credentials_layout_lb_v.addLayout(self.username_layout_lb_h) self.credentials_layout_lb_v.addLayout(self.password_layout_lb_h) self.credentials_layout_lb_v.addLayout(self.cr_layout_lb_h) self.credentials_groupbox.setLayout(self.credentials_layout_lb_v) self.left_base_layout_v.addWidget(self.credentials_groupbox) self.credentials_groupbox.setAlignment(QtCore.Qt.AlignLeft) self.credentials_groupbox.hide() #IP group box layouts self.IP_groupBox = QtGui.QGroupBox("IP Inputs") self.IP_groupBox.setFont(self.grp_heading_font) self.ip_file_layout_lb_v = QVBoxLayout() self.ip_file_select_layout_lb_h = QHBoxLayout() self.ip_file_select_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft) self.ip_file_layout_lb_v.addLayout(self.ip_file_select_layout_lb_h) self.IP_groupBox.setMaximumHeight(135) self.IP_groupBox.setLayout(self.ip_file_layout_lb_v) self.left_base_layout_v.addWidget(self.IP_groupBox) self.IP_groupBox.hide() # Commands group box selection self.Commands_groupBox = QtGui.QGroupBox("Commands Inputs") self.Commands_groupBox.setFont(self.grp_heading_font) self.commands_label_layout_lb_v = QVBoxLayout() self.default_chkbx_layout_lb_h = QHBoxLayout() self.commands_file_layout_lb_h = QHBoxLayout() self.commands_file_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft) self.commands_custom_box_layout_lb_h = QHBoxLayout() self.none_radio_btn_layout_lb_h = QHBoxLayout() self.commands_label_layout_lb_v.addLayout( self.default_chkbx_layout_lb_h) self.commands_label_layout_lb_v.addLayout( self.commands_file_layout_lb_h) self.commands_label_layout_lb_v.addLayout( self.commands_custom_box_layout_lb_h) self.commands_label_layout_lb_v.addLayout( self.none_radio_btn_layout_lb_h) self.Commands_groupBox.setMaximumHeight(225) self.Commands_groupBox.setAlignment(QtCore.Qt.AlignLeft) self.Commands_groupBox.setLayout(self.commands_label_layout_lb_v) self.left_base_layout_v.addWidget(self.Commands_groupBox) self.Commands_groupBox.hide() # results group box self.results_groupBox = QtGui.QGroupBox("Results") self.results_groupBox.setFont(self.grp_heading_font) self.results_layout_lb_v = QVBoxLayout() self.output_layout_lb_h = QHBoxLayout() self.output_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft) self.results_layout_lb_v.addLayout(self.output_layout_lb_h) self.results_groupBox.setLayout(self.results_layout_lb_v) self.left_base_layout_v.addWidget(self.results_groupBox) self.results_groupBox.hide() # Go Button self.go_btn_layout_lb_h = QHBoxLayout() self.left_base_layout_v.addLayout(self.go_btn_layout_lb_h) # Right and Left Widget on individual layouts self.left_base_widget.setLayout(self.left_base_layout_v) self.right_base_widget.setLayout(self.right_base_layout_v) #### just to see right base layout self.right_base = QtGui.QTextEdit(self.gui) self.right_base.setStyleSheet( """QToolTip { background-color: #00bfff; color: black; border: black solid 2px }""" ) self.right_base.setObjectName("IP_Address") self.right_base_layout_v.addWidget(self.right_base) # self.right_base.setMaximumHeight(500) self.right_base.hide() self.snap_gif = QtGui.QLabel(self.gui) self.snap_gif.setText("") self.snap_gif.setStyleSheet("background-color: None") self.snap_gif.setPixmap(QtGui.QPixmap("Capture.png")) self.snap_gif.setObjectName("logo_corner") self.right_base_layout_v.addWidget(self.snap_gif) ###### self.gui.setWindowTitle('SPEED + 3.0') self.gui.setWindowIcon(QtGui.QIcon(":/logo/Wind_icon.png")) self.gui.setAutoFillBackground(True) self.corner_logolabel = QtGui.QLabel(self.gui) self.corner_logolabel.setText("") self.corner_logolabel.setStyleSheet("background-color: None") self.corner_logolabel.setPixmap(QtGui.QPixmap(":/logo/ATT-LOGO-2.png")) self.corner_logolabel.setObjectName("logo_corner") # self.corner_logo_layout_v.setAlignment(QtCore.Qt.AlignTop) self.corner_logo_layout_v.setAlignment( int(QtCore.Qt.AlignTop | QtCore.Qt.AlignRight)) self.corner_logo_layout_v.addWidget(self.corner_logolabel) self.msgBox.setWindowIcon(QtGui.QIcon(":/logo/Wind_icon.png")) self.msgBox.setFont(QtGui.QFont("Verdana", 8, QtGui.QFont.Normal)) self.make_menu() ## gif at&t logo # self.movie_screen = QLabel() # self.movie_screen.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding) # self.movie_screen.setAlignment(QtCore.Qt.AlignCenter) # self.right_base_layout_v.addWidget(self.movie_screen) # # ag_file = "C:/Users/rg012f/eclipse-workspace/poojan_try/giphy.gif" # self.movie = QtGui.QMovie(ag_file, QtCore.QByteArray(), None) # self.movie.setCacheMode(QtGui.QMovie.CacheAll) # self.movie.setSpeed(75) # self.movie_screen.setMovie(self.movie) # # # self.movie.setPaused(True) # self.movie.start() # self.right_base_widget.show() # time.sleep(2) ######################### order of the below funtion calls is importnant change them wisely##################### self.check_save_username() self.create_views() self.left_radio_controls() self.connect_child_views() def make_menu(self): self.myMenu = self.gui.menuBar() self.file = self.myMenu.addMenu('&File') self.file.addAction("&Select Output Folder...", self.select_destination, "Ctrl+O") self.file.addAction("&Exit", self.closewindow, "Ctrl+X") self.file = self.myMenu.addMenu('&Help') self.file.addAction("&About...", self.about_tool, "Ctrl+H") def check_save_username(self): print("Yo reached save username") try: f = open('Username.txt', 'r') lines = f.readlines() if len(lines): self.save_username_checked = True else: self.save_username_checked = False except Exception as ex: print(ex) def select_destination(self, ): fld = QtGui.QFileDialog.getExistingDirectory(self.gui, 'Select Output Folder') self.output_folder = str(fld) def closewindow(self): self.gui.close() def about_tool(self): abouttool = "Speed + v3.0 \n\nThis tool is useful to fetch, push, extract, compare device configs \n" self.msgBox.setText(abouttool) self.msgBox.setWindowTitle("About Speed +") self.msgBox.show() def left_radio_controls(self): # ============================ main radio options selection : radio_font = QtGui.QFont("Verdana", 10, QtGui.QFont.Normal) self.get_radio_option = QtGui.QRadioButton(self.gui) self.get_radio_option.setFont(radio_font) self.get_radio_option.setText("Get") self.radio_option_layout_lb_h.addWidget(self.get_radio_option) self.push_radio_option = QtGui.QRadioButton(self.gui) self.push_radio_option.setFont(radio_font) self.push_radio_option.setText("Push") self.radio_option_layout_lb_h.addWidget(self.push_radio_option) self.extract_radio_option = QtGui.QRadioButton(self.gui) self.extract_radio_option.setFont(radio_font) self.extract_radio_option.setText("Extract") self.radio_option_layout_lb_h.addWidget(self.extract_radio_option) self.compare_radio_option = QtGui.QRadioButton(self.gui) self.compare_radio_option.setFont(radio_font) self.compare_radio_option.setText("Compare") self.radio_option_layout_lb_h.addWidget(self.compare_radio_option) def disp_get_options(self): self.snap_gif.show() self.push_view.hide_push() self.excel_view.userOptionextract.hide() self.compare_view.main_widget.hide() self.get_view.display_get() def disp_push_options(self): self.snap_gif.show() self.get_view.hide_get() self.excel_view.userOptionextract.hide() self.compare_view.main_widget.hide() self.push_view.display_push() self.validations.hide_right_common() def disp_ext_options(self): self.get_view.hide_get() self.push_view.hide_push() self.compare_view.main_widget.hide() self.excel_view.display_excel_portion() self.validations.hide_right_common() def disp_comp_options(self): self.get_view.hide_get() self.push_view.hide_push() self.excel_view.userOptionextract.hide() self.compare_view.display_comapre_portion() self.validations.hide_right_common() def connect_child_views(self): self.get_radio_option.clicked.connect(self.disp_get_options) self.push_radio_option.clicked.connect(self.disp_push_options) self.extract_radio_option.clicked.connect(self.disp_ext_options) self.compare_radio_option.clicked.connect(self.disp_comp_options) self.base_left.go_button.clicked.connect(self.connect_validate_option) def connect_validate_option(self): self.validations.validate_user_inputs( ) # passing self to validation class method , other end this self is last_parent def create_views(self): self.base_left = left_base( self ) # we are passing main GUI and also local self as 'last_parent' to left base view to update variables self.get_view = get_controls(self.gui, self.base_left) self.push_view = push_controls(self.gui, self.base_left) self.excel_view = extract_excel(self.gui, self.base_left) self.compare_view = compare_op_results(self) def show_gif_right_base(self, path, layout): print("ui parent view show_gif_right_base line 394") self.movie_screen = QLabel() self.movie_screen.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.movie_screen.setAlignment(QtCore.Qt.AlignCenter) layout.addWidget(self.movie_screen) ag_file = path self.movie = QtGui.QMovie(ag_file, QtCore.QByteArray(), None) self.movie.setCacheMode(QtGui.QMovie.CacheAll) self.movie.setSpeed(75) self.movie_screen.setMovie(self.movie) #"C:/Users/rg012f/eclipse-workspace/poojan_try/giphy.gif" self.movie.setPaused(True) self.movie.start() # self.right_base_widget.setLayout(layout) # self.right_base_widget.show() def hide_gif_right_base(self): self.movie_screen.hide()
def __init__(self): super(HighwaySimulatorGui, self).__init__() centralTab = QTabWidget() mainWidget = QWidget() self.resultsWidget = HighwayAnalyzeWidget() centralTab.addTab(mainWidget, 'Run') centralTab.addTab(self.resultsWidget, 'Analyze') self.setCentralWidget(centralTab) centralLayout = QVBoxLayout() #centralLayout.setSpacing(0) centralLayout.setAlignment(Qt.AlignTop) gridWidget = QWidget() gridLayout = QGridLayout() gridLayout.setSpacing(0) gridWidget.setLayout(gridLayout) mainWidget.setLayout(centralLayout) self.options = dict() # GENERAL generalGroup = QGroupBox('General Settings') generalGroup.setLayout(QVBoxLayout()) generalGroup.layout().setSpacing(0) self.pathOption = SimpleOption('path','Output Path','/home/thomas/Dropbox/Keio/research/results/') generalGroup.layout().addWidget(self.pathOption) self.scenarioOption = SimpleComboboxOption('scenario','Scenario',1, False, 'vanet-highway-test-thomas','vanet-highway-scenario2') self.scenarioOption.combo.currentIndexChanged[int].connect(self.scenarioChanged) generalGroup.layout().addWidget(self.scenarioOption) self.options['time'] = SimpleSpinOption('time','Simulation Time (sec.)',1500,True) self.options['time'].setRange(0,3000) self.options['mix'] = SimpleSpinOption('mix','Percentage of cars compare to trucks (%)',80,True) self.options['mix'].setRange(0,100) self.options['gap'] = SimpleSpinOption('gap','Average Gap (m.)',5) self.options['gap'].setRange(1,2000) self.options['lane'] = SimpleSpinOption('lane','Number of Lanes',2,True) self.options['lane'].setRange(2,4) self.options['spl'] = SimpleSpinOption('spl','Speed Limit (km/h)',130,True) self.options['spl'].setRange(1,200) for widget in ('time','mix','gap','lane','spl'): generalGroup.layout().addWidget(self.options[widget]) gridLayout.addWidget(generalGroup,0,0) # TRAFFIC trafficGroup = QGroupBox('Traffic Settings') trafficGroup.setLayout(QVBoxLayout()) trafficGroup.layout().setSpacing(0) # m/s = (km/h)*1000/3600 self.options['vel1'] = SimpleSpinOption('vel1','Average Speed (km/h)',105,True) self.options['vel1'].setRange(5,150) self.options['dis'] = SimpleComboboxOption('dis','Speed Distribution Model',3, False, 'Uniform','Exponential','Normal','Log Normal') self.options['spstd'] = SimpleSpinOption('spstd','Speed Distribution Variance',1.0) self.options['spstd'].setRange(0,50) self.options['flow1'] = SimpleSpinOption('flow1','Traffic Flow Mean (veh/s)',1.0) self.options['flow1'].setRange(0.1,50.0) self.options['std1'] = SimpleSpinOption('std1','Traffic Flow Variance',0.8) self.options['std1'].setRange(0.1,50.0) self.options['maxflow'] = SimpleSpinOption('maxflow','Traffic Maximum Flow (veh/s)',5) self.options['maxflow'].setRange(0.1,50.0) # Scenar 2 self.options['avgdist'] = SimpleSpinOption('avgdist','Average Distance (m)',100) self.options['avgdist'].setRange(1,10000) self.options['avgspeed'] = SimpleSpinOption('avgspeed','Average Speed (km/h)',105) self.options['avgspeed'].setRange(1,10000) self.options['despeed'] = SimpleSpinOption('despeed','Desired Speed (km/h)',130) self.options['despeed'].setRange(1,10000) self.options['ambumaxspeed'] = SimpleSpinOption('ambumaxspeed','Ambu Max Speed (km/h)',165) self.options['ambumaxspeed'].setRange(1,10000) self.options['ambuinitspeed'] = SimpleSpinOption('ambuinitspeed','Ambu Initial Speed (km/h)',130) self.options['ambuinitspeed'].setRange(1,10000) for widget in ('vel1','dis','spstd','flow1','std1','maxflow', 'avgdist', 'avgspeed', 'despeed', 'ambumaxspeed', 'ambuinitspeed'): trafficGroup.layout().addWidget(self.options[widget]) self.scenarioChanged(self.scenarioOption.combo.currentIndex()) gridLayout.addWidget(trafficGroup,0,1) # VANET vanetGroup = QGroupBox('VANET Settings') vanetGroup.setLayout(QVBoxLayout()) vanetGroup.layout().setSpacing(0) # self.options['prate'] = SimpleSpinOption('prate','Penetration Rate of VANET (%)',100,True) # self.options['prate'].setRange(0,100) self.options['prate'] = 0 # start with 0 self.options['pw'] = SimpleSpinOption('pw','Transmission Power (dBm)',21.5) self.options['pw'].setRange(10,50) #for widget in ('prate','pw'): for widget in ('pw',): vanetGroup.layout().addWidget(self.options[widget]) gridLayout.addWidget(vanetGroup,1,0) # BATCH SETTINGS batchGroup = QGroupBox("Batch Settings") batchGroup.setLayout(QVBoxLayout()) self.gapPrateOption = SimpleSpinOption('gapPrate', 'VANET percentage rate gap', 10, integer=True) self.sameSimuTimesOption = SimpleSpinOption('sameSimuTimes', 'How many times the same simulation', 100, integer=True) batchGroup.layout().setSpacing(0) batchGroup.layout().addWidget(self.gapPrateOption) batchGroup.layout().addWidget(self.sameSimuTimesOption) gridLayout.addWidget(batchGroup,1,1) # START SIMU centralLayout.addWidget(gridWidget) self.startButton = QPushButton('START') self.startButton.clicked.connect(self.startSimu) centralLayout.addWidget(self.startButton) self.progressBar = QProgressBar() centralLayout.addWidget(self.progressBar) self.shutdownWhenDone = QCheckBox('Shutdown when done') self.actionWhenDone = QComboBox() self.actionWhenDone.addItems(['When finished... do nothing', 'When finished... shutdown the computer', 'When finished... Re-run the simulations!']) self.actionWhenDone.setCurrentIndex(int(QSettings().value('actionWhenDone', 0))) centralLayout.addWidget(self.actionWhenDone) self.infoLabel = QLabel() centralLayout.addWidget(self.infoLabel) # LOG self.logText = QTextBrowser() self.logText.setFont(QFont('Century Gothic', 7)) centralLayout.addWidget(self.logText) self.setWindowTitle('Nishimura Lab | Highway Simulation') #self.resize(520,len(self.options)*60+100) #self.resultFile = open('/home/thomas/Dropbox/Keio/research/results/summary.txt', 'a') #self.resultFile = os.path.join(self.pathOption.getValue(), 'summary.txt') self.logFile = os.path.join(self.pathOption.getValue(), 'results_'+os.uname()[1]+'.log')