def setup(self, name="", path="", existing=True): self.name = name self.projPath = path projImg = "" frameWidget = QtWidgets.QWidget() pName = QtWidgets.QLabel(name) pName.setObjectName("projectLabel") pImg = QtWidgets.QLabel("") pImg.setObjectName("projectLabel") #pImg.setScaledContents(True) #projFile = open(path, "r") #print(projFile.read()) #print(projFile.read().split("\n")[3].split("=")[1]) #QtGui.QPixmap(projFile.read().split("\n")[3].split("=")[1]) if existing: frameWidget.setObjectName("carouselItemFrame") pImg.setPixmap( QtGui.QPixmap( "/home/jfk422/Projects/HitchTestProj/Resources/titleImg.png" ).scaled(256, 256, QtCore.Qt.KeepAspectRatio)) else: frameWidget.setObjectName("carouselItemFrameNonExisting") pImg.setPixmap( QtGui.QPixmap("./resources/projectImages/pImgO.png").scaled( 256, 256, QtCore.Qt.KeepAspectRatio)) mainLay = QtWidgets.QVBoxLayout() mainLay.setContentsMargins(QtCore.QMargins(0, 0, 0, 0)) mainLay.setSpacing(0) titleLay = QtWidgets.QVBoxLayout() titleLay.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignHCenter) titleLay.setContentsMargins(QtCore.QMargins(0, 10, 0, 10)) titleWidget = QtWidgets.QWidget() titleWidget.setLayout(titleLay) imgLay = QtWidgets.QVBoxLayout() imgLay.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignHCenter) imgLay.setContentsMargins(QtCore.QMargins(0, 0, 0, 20)) imgWidget = QtWidgets.QWidget() imgWidget.setLayout(imgLay) titleLay.addWidget(pName) imgLay.addWidget(pImg) mainLay.addWidget(titleWidget) mainLay.addWidget(imgWidget) frameWidget.setLayout(mainLay) backLay = QtWidgets.QHBoxLayout() backLay.setContentsMargins(QtCore.QMargins(0, 10, 0, 10)) backLay.addWidget(frameWidget) self.setLayout(backLay)
def setup(self, carouselWidgets, startPos=0, elemAsButtons=False): self.cWidgets = carouselWidgets self.pos = startPos globalPos = startPos print(len(carouselWidgets)) frameWidget = QtWidgets.QWidget() frameWidget.setObjectName("carouselFrame") left = qta.icon("fa.caret-left", color="#f9f9f9") right = qta.icon("fa.caret-right", color="#f9f9f9") goLeft = QtWidgets.QPushButton(left, "") goLeft.setObjectName("carouselSideButtons") goLeft.setIconSize(QtCore.QSize(64, 64)) goLeft.setMaximumWidth(70) goLeft.setSizePolicy( QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)) goLeft.clicked.connect(lambda: Carousel.prevItem(self)) goRight = QtWidgets.QPushButton(right, "") goRight.setObjectName("carouselSideButtons") goRight.setIconSize(QtCore.QSize(64, 64)) goRight.setMaximumWidth(70) goRight.setSizePolicy( QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)) goRight.clicked.connect(lambda: Carousel.nextItem(self)) backLay = QtWidgets.QHBoxLayout() backLay.setContentsMargins(QtCore.QMargins(0, 0, 0, 0)) backLay.addWidget(frameWidget) cLay = QtWidgets.QGridLayout() cLay.setContentsMargins(QtCore.QMargins(0, 0, 0, 0)) cLay.addWidget(goLeft, 0, 0) centerItem = QtWidgets.QWidget() Carousel.itemsLay = QtWidgets.QStackedLayout() Carousel.itemsLay.setContentsMargins(QtCore.QMargins(0, 0, 0, 0)) centerItem.setLayout(Carousel.itemsLay) cLay.addWidget(centerItem, 0, 1) for i in range(len(self.cWidgets)): if elemAsButtons: itmBtn = QtWidgets.QPushButton(self.cWidgets[i]) Carousel.itemsLay.addWidget(itmBtn) else: Carousel.itemsLay.addWidget(self.cWidgets[i]) cLay.addWidget(goRight, 0, 2) cLay.setSpacing(10) frameWidget.setLayout(cLay) self.setLayout(backLay)
def setupUi(self, Form, ds_type, selector_labels): """Sets up the general window This function coordinates the changing input from the signal slots and updates the attributes that are parsed to the plotting lib functions. update_plots() is either periodically called e.g. by the timer or once on startup. Args: self: Object of the Ui_Form class. Form: PlotWindow object that inherits the used calls here from the underlying QWidget class. ds_type: Integer selector_labels: String list with names of the datasets on all axis Returns: No return variable. The function operates on the given object. """ Form.setObjectName(_fromUtf8("Form")) Form.resize(750, 450) self.gridLayout_Top = QtGui.QGridLayout(Form) self.gridLayout_Top.setContentsMargins(0, 0, 0, 0) self.gridLayout_Top.setObjectName(_fromUtf8("gridLayout_Top")) # we push for a tight layout self.gridLayout_Top.setContentsMargins(0, 0, 0, 0) self.gridLayout_Top.setContentsMargins(QtCore.QMargins(0, 0, 0, 0)) self.gridLayout_Top.setSpacing(0) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setSizeConstraint(QtGui.QLayout.SetMinimumSize) self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.horizontalLayout.setContentsMargins(QtCore.QMargins(0, 0, 0, 0)) self.horizontalLayout.setSpacing(0) self.gridLayout_Top.addLayout(self.horizontalLayout, 0, 0, 1, 1) self.gridLayout = QtGui.QGridLayout() self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.gridLayout_Top.addLayout(self.gridLayout, 1, 0, 1, 1) Form.setWindowTitle(_translate("Form", "Form", None)) QtCore.QMetaObject.connectSlotsByName(Form) self.selector_labels = selector_labels if ds_type == ds_types['coordinate']: self.setupCoordinate(Form) if ds_type == ds_types['vector']: self.setupVector(Form) if ds_type == ds_types['matrix'] or ds_type == -1: self.setupMatrix(Form) if ds_type == ds_types['box']: self.setupBox(Form) if ds_type == ds_types['txt']: self.setupTxt(Form) if ds_type == ds_types['view']: self.setupView(Form)
def process_property(xmlprop, widget=widget): pname = xmlprop.get("name") if pname in translate_properties: pname = translate_properties[pname] setpname = "set" + pname[0].upper() + pname[1:] if pname == "layoutSpacing": set_fn = widget.layout.setSpacing elif pname == "margin": set_fn = widget.setContentsMargins elif pname in ("paletteBackgroundColor", "paletteForegroundColor"): set_fn = widget.setStyleSheet else: set_fn = getattr(widget, setpname, None) if set_fn is None: if Options.DEBUG_LEVEL > 50: print("qt3ui: Missing property", pname, " for %r" % widget.__class__) return # print "Found property", pname if pname == "contentsMargins" or pname == "layoutSpacing": try: value = int(xmlprop.get("stdset")) value /= 2 except Exception as e: value = 0 if pname == "contentsMargins": value = QtCore.QMargins(value, value, value, value) elif pname == "margin": try: value = loadVariant(xmlprop) except Exception: value = 0 value = QtCore.QMargins(value, value, value, value) elif pname == "paletteBackgroundColor": value = 'background-color:' + loadVariant(xmlprop).name() elif pname == "paletteForegroundColor": value = 'color:' + loadVariant(xmlprop).name() else: value = loadVariant(xmlprop) try: set_fn(value) except Exception as e: if Options.DEBUG_LEVEL > 50: print(e, repr(value)) if Options.DEBUG_LEVEL > 50: print(etree.ElementTree.tostring(xmlprop))
def setup(self): vMenu = QtWidgets.QVBoxLayout() vMenu.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) vMenu.setContentsMargins(QtCore.QMargins(20, 20, 20, 20)) hSettings = QtWidgets.QHBoxLayout() hSettings.setContentsMargins(QtCore.QMargins(0, 0, 0, 0)) self.scrollLay = QtWidgets.QVBoxLayout() self.scrollLay.setContentsMargins(QtCore.QMargins(10, 10, 10, 10)) self.scrollLay.setAlignment(QtCore.Qt.AlignTop) self.scrollLayWid = QtWidgets.QWidget() self.scrollLayWid.setObjectName("console") self.scrollLayWid.setLayout(self.scrollLay) wSettings = QtWidgets.QWidget() wSettings.setLayout(hSettings) fileText = QtWidgets.QLabel("Run File") fileText.setObjectName("menuTitle") vMenu.addWidget(fileText) vMenu.addWidget(wSettings) scroll = QtWidgets.QScrollArea() scroll.setWidget(self.scrollLayWid) scroll.setWidgetResizable(True) vMenu.addWidget(scroll) #Add icons later! chooser = QtWidgets.QComboBox() chooser.setMaximumHeight(40) chooser.addItem("Test") chooser.addItem("Test2") chooser.setObjectName("menuRunChooser") hSettings.addWidget(chooser) runBtn = QtWidgets.QPushButton("Run File") runBtn.setMaximumHeight(40) runBtn.setObjectName("scrollMenuItem") hSettings.addWidget(runBtn) for i in range(100): testText = QtWidgets.QLabel("Play of the Game: JFK422") testText.setObjectName("consoleText") self.scrollLay.addWidget(testText) self.setSizePolicy( QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)) self.setLayout(vMenu)
def __init__(self): super().__init__() self.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0))) self.setBackgroundRoundness(0) self.setMargins(QtCore.QMargins(0, 0, 0, 0)) self.layout().setContentsMargins(0, 0, 0, 0) self.legend().hide() chartFont = QtGui.QFont(self.font()) chartFont.setPixelSize(9) self.setFont(chartFont) self.IndicatorName = QtWidgets.QGraphicsSimpleTextItem(self) self.IndicatorName.setBrush(QtGui.QBrush(QtGui.QColor(255, 255, 255))) self.IndicatorName.setOpacity(1.0) self.IndicatorName.setPos(0, 0) indicatorView = QtChart.QChartView(self) indicatorView.setRenderHint(QtGui.QPainter.Antialiasing) indicatorLayout = QtWidgets.QVBoxLayout() indicatorLayout.setSpacing(0) indicatorLayout.setContentsMargins(0, 0, 0, 0) indicatorLayout.addWidget( DoubleLineSeparator(orientation='horizontal', linecolor=COLOR_SEPARATOR, spacecolor='rgb(0,0,0)', stroke=1, width=3)) indicatorLayout.addWidget(indicatorView) self.frame = QtWidgets.QFrame() self.frame.setLayout(indicatorLayout)
def setup(self, name, path, itemIndex, bcType=""): lay = QtWidgets.QHBoxLayout() Breadcrumb.bc = QtWidgets.QPushButton() self.path = path self.name = name self.index = itemIndex lay.setContentsMargins(QtCore.QMargins(0, 0, 0, 0)) if bcType == "start": icon = qta.icon("fa.caret-right", color="#f9f9f9") Breadcrumb.bc.setIcon(icon) Breadcrumb.bc.setIconSize(QtCore.QSize(32, 32)) else: Breadcrumb.bc.setText(name) Breadcrumb.bc.setMaximumHeight(51) Breadcrumb.bc.setMinimumWidth(160) Breadcrumb.bc.setObjectName("bcName") Breadcrumb.bc.setSizePolicy( QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)) #Breadcrumb.bc.clicked.connect(lambda:introductionWindow.Introduction.selectProject(self)) self.setLayout(lay) lay.addWidget(Breadcrumb.bc) self.setMaximumWidth(150)
def __init__(self): super().__init__() self.setObjectName('window') self.offsetField = MemViewerWindow._make_spin_box( 'offsetField', self.on_offset_changed) self.lengthField = MemViewerWindow._make_spin_box( 'lengthField', self.on_length_changed) self.spanField = MemViewerWindow._make_spin_box( 'spanField', self.on_span_changed) self.imageField = QAliasedPixmap() self.imageField.setObjectName('imageField') vbox = QtWidgets.QVBoxLayout() vbox.setAlignment(QtCore.Qt.AlignVCenter) vbox.setContentsMargins(20, 20, 20, 20) vbox.addWidget(QtWidgets.QLabel('Offset')) vbox.addWidget(self.offsetField) vbox.addWidget(QtWidgets.QLabel('Length')) vbox.addWidget(self.lengthField) vbox.addWidget(QtWidgets.QLabel('Span')) vbox.addWidget(self.spanField) hbox = QtWidgets.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins()) hbox.addLayout(vbox) hbox.addWidget(self.imageField) self.setLayout(hbox)
def setup(self, name, path, itemIndex, colour): lay = QtWidgets.QHBoxLayout() LastProjItem.projBtn = QtWidgets.QPushButton() self.path = path self.name = name self.index = itemIndex self.colour = colour lay.setContentsMargins(QtCore.QMargins(0, 0, 0, 0)) LastProjItem.projBtn.setText(name) LastProjItem.projBtn.setMaximumHeight(51) LastProjItem.projBtn.setMinimumWidth(160) if colour: LastProjItem.projBtn.setStyleSheet("background-color: #a51946;") LastProjItem.projBtn.clicked.connect( lambda: introductionWindow.Introduction.projNotFound( self, self.path)) else: LastProjItem.projBtn.setObjectName("projectName") LastProjItem.projBtn.clicked.connect( lambda: introductionWindow.Introduction.selectProject(self)) self.setLayout(lay) lay.addWidget(LastProjItem.projBtn) self.setMaximumWidth(150)
def __init__(self): super().__init__() self.setWindowTitle(self.title) self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) self.setWindowModality(QtCore.Qt.ApplicationModal) self.mainLayout = QtWidgets.QVBoxLayout() self.setLayout(self.mainLayout) self.mainLayout.setAlignment(QtCore.Qt.AlignHCenter) self.mainLayout.setSizeConstraint(QtWidgets.QLayout.SetFixedSize) self.mainLayout.setContentsMargins(QtCore.QMargins(self.hMargin, self.vMargin, self.hMargin, self.vMargin)) self.iconLabel = QtWidgets.QLabel() self.iconLabel.setPixmap(icons.main.pixmap(128, 128)) self.iconLabel.setAlignment(QtCore.Qt.AlignHCenter) self.mainLayout.addWidget(self.iconLabel, QtCore.Qt.AlignHCenter) self.titleLabel = QtWidgets.QLabel(f'<html><h1>{__app__} {__version__}</h1></html>') self.mainLayout.addWidget(self.titleLabel, QtCore.Qt.AlignHCenter) self.mainLayout.setAlignment(self.titleLabel, QtCore.Qt.AlignHCenter) self.blurbLabel = QtWidgets.QLabel(f'<html><h3>{__description__}</h3></html>') self.mainLayout.addWidget(self.blurbLabel, QtCore.Qt.AlignHCenter) self.mainLayout.setAlignment(self.blurbLabel, QtCore.Qt.AlignHCenter) self.authorLabel = QtWidgets.QLabel('<html><h4>made with ❤ by <a href="' 'https://discoverygc.com/forums/member.php?action=profile&uid=32907">' 'Biggles</a> (<a href="https://github.com/biqqles">biqqles</a>)' '</h4></html>') self.authorLabel.setOpenExternalLinks(True) self.mainLayout.addWidget(self.authorLabel, QtCore.Qt.AlignHCenter) self.mainLayout.setAlignment(self.authorLabel, QtCore.Qt.AlignHCenter) self.mainLayout.addStretch(40) self.licenceLabel = QtWidgets.QLabel('<html>This application is free software, released under the ' '<a href="https://gnu.org/licenses/gpl.html">GNU General Public License ' 'v3.0</a> as is and with absolutely no warranty whatsoever.</html>') self.licenceLabel.setWordWrap(True) self.licenceLabel.setOpenExternalLinks(True) self.mainLayout.setAlignment(self.licenceLabel, QtCore.Qt.AlignCenter) self.mainLayout.addWidget(self.licenceLabel, QtCore.Qt.AlignHCenter) self.thanksLabel = QtWidgets.QLabel( '<html><h4>With thanks to:</h4><ul>' '<li><a href="' 'https://discoverygc.com/forums/member.php?action=profile&uid=4734">Error</a> for the use of their ' '<a href="https://github.com/AudunVN/Navmap">Online Navmap</a></li>' '<li>Icons made by:<ul>' '<li><a href="https://www.flaticon.com/authors/freepik">Freepik</a> from ' '<a href="https://www.flaticon.com">www.flaticon.com</a></li>' '<li><a href="https://www.flaticon.com/authors/roundicons">Roundicons</a> from ' '<a href="https://www.flaticon.com">www.flaticon.com</a></li>' '<li><a href="https://www.flaticon.com/authors/neungstockr">neungstockr</a> from ' '<a href="https://www.flaticon.com">www.flaticon.com</a>.</li></ul></li>' '<li>See also the acknowledgements for <a href="https://github.com/biqqles/flair">flair</a> and ' '<a href="https://github.com/biqqles/flint">flint</a>.</li>' '</ul></html>') self.thanksLabel.setOpenExternalLinks(True) self.mainLayout.addWidget(self.thanksLabel, QtCore.Qt.AlignHCenter)
def addHWidget(self): Box = QtWidgets.QWidget() Layout = QtWidgets.QHBoxLayout() Box.setLayout(Layout) Box.setContentsMargins(QtCore.QMargins(0, 0, 0, 0)) Layout.layout().setContentsMargins(0, 0, 0, 0) return Box, Layout
def make_loss_at_center_input(self): box = QtWidgets.QHBoxLayout() box.addWidget(QtWidgets.QLabel("Loss at center frequency (dB): "), 1, QtCore.Qt.AlignRight) box.addWidget(self.loss_at_center_line_edit, 1, QtCore.Qt.AlignLeft) box.setContentsMargins(QtCore.QMargins(2, 40, 2, 0)) return box
def _addTraceSelectorIndicator(self, Form, sizePolicy, TraceSelector="", TraceIndicator="", prefix="Trace: "): self.TraceSelIndLayout = QtGui.QVBoxLayout() self.TraceSelIndLayout.setSizeConstraint(QtGui.QLayout.SetMinimumSize) self.TraceSelIndLayout.setObjectName(_fromUtf8("TraceSelIndLayout")) self.TraceSelIndLayout.setContentsMargins(0, 0, 0, 0) self.TraceSelIndLayout.setContentsMargins(QtCore.QMargins(0, 0, 0, 0)) self.TraceSelIndLayout.setSpacing(1) setattr(self, TraceSelector, QtGui.QSpinBox(Form)) temp_SelInd = getattr(self, TraceSelector) temp_SelInd.setSizePolicy(sizePolicy) temp_SelInd.setSuffix(_fromUtf8("")) temp_SelInd.setMinimum(-99999) temp_SelInd.setMaximum(99999) temp_SelInd.setProperty("value", -1) temp_SelInd.setObjectName(_fromUtf8(TraceSelector)) temp_SelInd.setPrefix(_translate("Form", prefix, None)) self.TraceSelIndLayout.addWidget(temp_SelInd) setattr(self, TraceIndicator, QtGui.QLineEdit(Form)) temp_SelInd = getattr(self, TraceIndicator) temp_SelInd.setSizePolicy(sizePolicy) temp_SelInd.setReadOnly(False) temp_SelInd.setObjectName(_fromUtf8("TraceValue")) self.TraceSelIndLayout.addWidget(temp_SelInd) self.horizontalLayout.addLayout(self.TraceSelIndLayout, stretch=-10)
def __init__(self, chartViewParent: QtChart.QChartView, *preset): super().__init__() self.__chart = QtChart.QChart() self.__chart.legend().hide() self.__chart.setMinimumHeight(180) self.__chart.setMargins(QtCore.QMargins(0, 0, 0, 0)) self.__series = QtChart.QPieSeries() self.__series.setHoleSize(0.58) self.__series.setPieSize(0.75) for i in range(8): ps = QtChart.QPieSlice(str(i), 1) ps.setExploded(True) ps.setExplodeDistanceFactor(RING_NORMAL) ps.clicked.connect(self.__slice_clicked) ps.hovered.connect(self.__slice_hovered) ps.doubleClicked.connect(self.__slice_dblclicked) self.__series.append(ps) self.__chart.addSeries(self.__series) chartViewParent.setRenderHint(QtGui.QPainter.Antialiasing, True) chartViewParent.setChart(self.__chart) self.__last_slice = self.__series.slices()[0]
def addChart(self, radius, profile, type="line"): series = QtChart.QLineSeries() self.currentRadius = [] self.currentProfile = [] for x, y in zip(radius, profile): series.append(x, y) self.currentRadius.append(x) self.currentProfile.append(y) self.profileChart = QtChart.QChart() self.profileChart.setTheme(self.theme) self.profileChart.setBackgroundRoundness(0) self.profileChart.setMargins(QtCore.QMargins(0, 0, 0, 0)) self.profileChart.removeAllSeries() self.profileChart.addSeries(series) axisX = QtChart.QValueAxis() axisX.setTickCount(10) if type == "line" or type == "rectangle": axisX.setTitleText("K (\u212B\u207B\u00B9)") elif type == "arc": axisX.setTitleText("\u03A7 (\u00BA)") axisY = QtChart.QValueAxis() axisY.setTickCount(10) axisY.setTitleText("Intensity (arb. units)") self.profileChart.addAxis(axisX, QtCore.Qt.AlignBottom) self.profileChart.addAxis(axisY, QtCore.Qt.AlignLeft) series.attachAxis(axisX) series.attachAxis(axisY) self.profileChart.legend().setVisible(False) self.setChart(self.profileChart) self.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
def __init__(self, config): super(BarChart, self).__init__() chartDefault = dict(config['chartDefault'].items()) if int(chartDefault['theme']) == 0: self.theme = QtChart.QChart.ChartThemeLight if int(chartDefault['theme']) == 1: self.theme = QtChart.QChart.ChartThemeBlueCerulean if int(chartDefault['theme']) == 2: self.theme = QtChart.QChart.ChartThemeDark if int(chartDefault['theme']) == 3: self.theme = QtChart.QChart.ChartThemeBrownSand if int(chartDefault['theme']) == 4: self.theme = QtChart.QChart.ChartThemeBlueNcs if int(chartDefault['theme']) == 5: self.theme = QtChart.QChart.ChartThemeHighContrast if int(chartDefault['theme']) == 6: self.theme = QtChart.QChart.ChartThemeBlueIcy if int(chartDefault['theme']) == 7: self.theme = QtChart.QChart.ChartThemeQt self.setRenderHint(QtGui.QPainter.Antialiasing) self.setContentsMargins(0, 0, 0, 0) self.barChart = QtChart.QChart() self.barChart.setBackgroundRoundness(0) self.barChart.setMargins(QtCore.QMargins(0, 0, 0, 0)) self.barChart.setTheme(self.theme) self.barChart.legend().setVisible(False) self.ncomp = 0 self.setChart(self.barChart)
def __init__(self, width, height, numberLabels=3, heading='', *args, **kwargs): super(LabeledDonatChart, self).__init__(*args, **kwargs) # widget properties self.setObjectName('LabeledDonatChart') self.setFrameShape(qtwidgets.QFrame.StyledPanel) self.setFixedWidth(width) self.setFixedHeight(height) self.setContentsMargins(0, 0, 0, 0) # donut chart self.series = qtchart.QPieSeries() self.series.setHoleSize(0.6) self.chart = qtchart.QChart() self.chart.setBackgroundVisible(False) self.chart.addSeries(self.series) self.chart.legend().hide() self.chart.setMargins(qtcore.QMargins(0, 0, 0, 0)) self.chart.setMinimumWidth(width) self.chart.setMinimumHeight(height) self.chartView = LabeledChartView(width, height, numberLabels, heading, self.chart, self) self.chartView.setRenderHint(qtgui.QPainter.Antialiasing) self.layout = qtwidgets.QHBoxLayout(self) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.addWidget(self.chartView)
def make_groupdelay_inband_input(self): box = QtWidgets.QVBoxLayout() box.addWidget(QtWidgets.QLabel("In band (ns): "), 1, QtCore.Qt.AlignBottom) self.groupdelay_inband_text_edit.setMinimumSize(200, 450) box.addWidget(self.groupdelay_inband_text_edit, 9, QtCore.Qt.AlignTop) box.setContentsMargins(QtCore.QMargins(10, 0, 5, 0)) return box
def make_insertionloss_outofband_input(self): box = QtWidgets.QVBoxLayout() box.addWidget(QtWidgets.QLabel("Out Of Band rejection (dB): "), 1, QtCore.Qt.AlignBottom) self.insertionloss_outofband_text_edit.setMinimumSize(200, 450) box.addWidget(self.insertionloss_outofband_text_edit, 9, QtCore.Qt.AlignTop) box.setContentsMargins(QtCore.QMargins(10, 0, 5, 0)) return box
def createUI(self): self.button = QtWidgets.QPushButton(self.buttonText, self) self.button.setCursor(QtCore.Qt.ArrowCursor) self.clicked = self.button.clicked self.layout.addWidget(self.button) self.layout.setAlignment(QtCore.Qt.AlignRight) self.layout.setContentsMargins(QtCore.QMargins(0, 0, 0, 0)) self.setLayout(self.layout)
def setup(self): vMenu = QtWidgets.QVBoxLayout() vMenu.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) vMenu.setContentsMargins(QtCore.QMargins(20, 20, 20, 20)) scrollLay = QtWidgets.QVBoxLayout() scrollLay.setContentsMargins(QtCore.QMargins(10, 10, 10, 10)) scrollLay.setAlignment(QtCore.Qt.AlignTop) scrollLayWid = QtWidgets.QWidget() scrollLayWid.setObjectName("scrollMenuLay") scrollLayWid.setLayout(scrollLay) fileText = QtWidgets.QLabel("Window") fileText.setObjectName("menuTitle") vMenu.addWidget(fileText) scroll = QtWidgets.QScrollArea() scroll.setWidget(scrollLayWid) scroll.setWidgetResizable(True) vMenu.addWidget(scroll) #Add icons later! Also further additions may needed fileExplorer = QtWidgets.QPushButton("File Explorer") fileExplorer.setMaximumHeight(50) fileExplorer.setObjectName("scrollMenuItem") scrollLay.addWidget(fileExplorer) closeAllEditors = QtWidgets.QPushButton("Close all Editors") closeAllEditors.setMaximumHeight(50) closeAllEditors.setObjectName("scrollMenuItem") scrollLay.addWidget(closeAllEditors) console = QtWidgets.QPushButton("Show Console") console.setMaximumHeight(50) console.setObjectName("scrollMenuItem") scrollLay.addWidget(console) self.setSizePolicy( QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)) self.setLayout(vMenu)
def setup(self): vMenu = QtWidgets.QVBoxLayout() vMenu.setContentsMargins(QtCore.QMargins(0,0,0,0)) wid = QtWidgets.QWidget() wid.setObjectName("seperator") wid.setMinimumHeight(3) vMenu.addWidget(wid) self.setLayout(vMenu)
def __init__(self, parent=None): super().__init__(parent) self.imageField1 = qttools.QAliasedPixmap(320 / 168, 3) self.imageField2 = qttools.QAliasedPixmap(320 / 168, 3) hbox = QtWidgets.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins()) hbox.addWidget(self.imageField1) hbox.addWidget(self.imageField2) self.setLayout(hbox)
def make_output_return_loss_tab(self): tab = QtWidgets.QGroupBox() tab_content = QtWidgets.QVBoxLayout() tab_content.addWidget(QtWidgets.QLabel("Rejection (dB): "), 1, QtCore.Qt.AlignBottom) self.outputreturnloss_text_edit.setMinimumSize(200, 450) tab_content.addWidget(self.outputreturnloss_text_edit, 9, QtCore.Qt.AlignTop) tab_content.setContentsMargins(QtCore.QMargins(30, 0, 30, 0)) tab.setLayout(tab_content) return tab
def setShadowWidth(self, width): self.shadowWidth = width self.shadowMargins = QtCore.QMargins(self.shadowWidth, self.shadowWidth, self.shadowWidth, self.shadowWidth) self.setContentsMargins(self.shadowMargins) _dropShadow = QtWidgets.QGraphicsDropShadowEffect(self) _dropShadow.setBlurRadius(self.shadowWidth) _dropShadow.setColor(Qt.black) _dropShadow.setOffset(0.0) self.setGraphicsEffect(_dropShadow) self.update(self.rect()) xutils.show_shadow(xutils.get_xwindow(int(self.winId())), str(width))
def setupUi(self, Form, ds_type): Form.setObjectName(_fromUtf8("Form")) Form.resize(750, 450) self.gridLayout_Top = QtGui.QGridLayout(Form) self.gridLayout_Top.setContentsMargins(0, 0, 0, 0) self.gridLayout_Top.setObjectName(_fromUtf8("gridLayout_Top")) # we push for a tight layout self.gridLayout_Top.setContentsMargins(0, 0, 0, 0) self.gridLayout_Top.setContentsMargins(QtCore.QMargins(0, 0, 0, 0)) self.gridLayout_Top.setSpacing(0) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setSizeConstraint(QtGui.QLayout.SetMinimumSize) self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.horizontalLayout.setContentsMargins(QtCore.QMargins(0, 0, 0, 0)) self.horizontalLayout.setSpacing(0) self.gridLayout_Top.addLayout(self.horizontalLayout, 0, 0, 1, 1) self.gridLayout = QtGui.QGridLayout() self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.gridLayout_Top.addLayout(self.gridLayout, 1, 0, 1, 1) Form.setWindowTitle(_translate("Form", "Form", None)) QtCore.QMetaObject.connectSlotsByName(Form) if ds_type == ds_types['coordinate']: self.setupCoordinate(Form) if ds_type == ds_types['vector']: self.setupVector(Form) if ds_type == ds_types['matrix'] or ds_type == -1: self.setupMatrix(Form) if ds_type == ds_types['box']: self.setupBox(Form) if ds_type == ds_types['txt']: self.setupTxt(Form) if ds_type == ds_types['view']: self.setupView(Form)
def __init__(self): super().__init__() self._chart = QtChart.QChart() self._chart.legend().hide() self._chart.layout().setContentsMargins(0, 0, 0, 0) self._chart.setBackgroundRoundness(0) self._chart.setBackgroundVisible(False) self._chart.setMargins(QtCore.QMargins(0, 0, 0, 0)) self._xAxis = QtChart.QValueAxis() self._xAxis.setTickCount(3) self._xAxis.setMinorTickCount(4) self._xAxis.setLabelFormat("%.3f mm") self._chart.addAxis(self._xAxis, QtCore.Qt.AlignBottom) self._yAxis = QtChart.QValueAxis() self._yAxis.setTickCount(2) self._yAxis.setMinorTickCount(3) self._yAxis.setLabelFormat("%.2g Ohm") self._chart.addAxis(self._yAxis, QtCore.Qt.AlignLeft) self._line = QtChart.QLineSeries() self._line.setColor(QtGui.QColor('magenta')) self._chart.addSeries(self._line) self._line.attachAxis(self._xAxis) self._line.attachAxis(self._yAxis) self._series = QtChart.QScatterSeries() self._series.setName("R") self._series.setMarkerSize(3) self._series.setBorderColor(QtGui.QColor('red')) self._series.setColor(QtGui.QColor('red')) self._chart.addSeries(self._series) self._series.attachAxis(self._xAxis) self._series.attachAxis(self._yAxis) self._marker = QtChart.QScatterSeries() self._marker.setMarkerSize(9) self._marker.setBorderColor(QtGui.QColor('red')) self._marker.setColor(QtGui.QColor('red')) self._chart.addSeries(self._marker) self._marker.attachAxis(self._xAxis) self._marker.attachAxis(self._yAxis) self.qt.setMinimumSize(160, 60) self._view = QtChart.QChartView(self._chart) self.qt.layout().setContentsMargins(0, 0, 0, 0) self.qt.layout().addWidget(self._view)
def sceneRectChanged(self): self.__scene_rect = QtCore.QRect() for node in self.__nodes: self.__scene_rect |= node.rect() size = max(self.__scene_rect.width(), self.__scene_rect.height()) if size < 1000: m = (1000 - size) / 2 self.__scene_rect += QtCore.QMargins(m, m, m, m) v_rect = self.__inv_transform.mapRect(self.viewport().rect()) self.__should_show_map = not v_rect.contains(self.__scene_rect) self.viewport().update(self.mapRect())
def __init__(self, project): super().__init__() self.ui = Ui_Prepare() self.ui.setupUi(self) self.project = project self.last_hotword_index = 0 self.main_dataset = DataSet() # Init hotword list self.hotwords = self.project.project_info['hotwords'] for hotword in self.hotwords: self.ui.current_hotword.addItem(hotword) self.sample_classes = [None] + self.hotwords # Init directory list self.folder_list_layout = QtWidgets.QVBoxLayout() self.folder_list = [[] for i in range(len(self.hotwords) + 1)] self.pie_slices = [QtChart.QPieSlice("non-hotword ()", 0)] self.pie_slices.extend([QtChart.QPieSlice("{} ()".format(name), 0) for name in self.hotwords]) self.display_selected_directories(0) # Pie chart self.pie_series = QtChart.QPieSeries() for pie_slice in self.pie_slices: self.pie_series.append(pie_slice) self.pie_series.setHoleSize(0) self.pie_view = QtChart.QChartView() self.pie_view.setRenderHint(QtGui.QPainter.Antialiasing) self.pie_view.chart().layout().setContentsMargins(0,0,0,0) self.pie_view.chart().setMargins(QtCore.QMargins(0,0,0,0)) self.pie_view.chart().legend().setAlignment(QtCore.Qt.AlignRight) self.pie_view.chart().addSeries(self.pie_series) layout = QtWidgets.QVBoxLayout() layout.addWidget(self.pie_view) self.ui.graph_placeholder.setLayout(layout) #Connects self.ui.current_hotword.currentIndexChanged.connect(self.display_selected_directories) self.ui.add_folder_button.clicked.connect(self.add_folder) self.ui.test_subset_CB.stateChanged.connect(self.ui.test_subset_percent.setEnabled) self.ui.val_on_test_set_CB.stateChanged.connect(self.disable_validation_set) self.ui.training_percent.valueChanged.connect(self.on_trainsample_update) self.ui.validation_percent.valueChanged.connect(self.on_valsample_update) self.ui.test_percent.valueChanged.connect(self.on_testsample_update) self.ui.done_button.clicked.connect(self.on_done_clicked) self.ui.add_set_PB.clicked.connect(self.add_set)
def __createHorizontalLayout(self): layout = QHBoxLayout() self.buttonLayout = QVBoxLayout() self.buttonLayout.setAlignment(Qt.AlignVCenter | Qt.AlignLeft) widget = self.__layoutToWidget(self.buttonLayout) widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) layout.addWidget(widget) self.imageLayout = QHBoxLayout() self.imageLayout.setContentsMargins(QtCore.QMargins()) layout.addWidget(self.__layoutToWidget(self.imageLayout)) return layout