Пример #1
0
    def __init__(self):
        QWidget.__init__(self)
        self.setMinimumSize(800, 600)
        self.donuts = []
        self.chart_view = QtCharts.QChartView()
        self.chart_view.setRenderHint(QPainter.Antialiasing)
        self.chart = self.chart_view.chart()
        self.chart.legend().setVisible(False)
        self.chart.setTitle("Nested donuts demo")
        self.chart.setAnimationOptions(QtCharts.QChart.AllAnimations)

        self.min_size = 0.1
        self.max_size = 0.9
        self.donut_count = 5

        self.setup_donuts()

        # create main layout
        self.main_layout = QGridLayout(self)
        self.main_layout.addWidget(self.chart_view, 1, 1)
        self.setLayout(self.main_layout)

        self.update_timer = QTimer(self)
        self.update_timer.timeout.connect(self.update_rotation)
        self.update_timer.start(1250)
Пример #2
0
    def paintEvent(self, event):
        contents_y = self.edit.verticalScrollBar().value()
        page_bottom = contents_y + self.edit.viewport().height()
        font_metrics = self.fontMetrics()
        current_block = self.edit.document().findBlock(self.edit.textCursor().position())
        painter = QPainter(self)
        line_count = 0
        block = self.edit.document().begin()
        while block.isValid():
            line_count += 1
            position = self.edit.document().documentLayout().blockBoundingRect(block).topLeft()
            if position.y() > page_bottom:
                break
            bold = False
            if block == current_block:
                bold = True
                font = painter.font()
                font.setBold(True)
                painter.setFont(font)
                self.current = line_count
            painter.drawText(self.width() - font_metrics.width(str(line_count)) - 10,
                             round(position.y()) - contents_y + font_metrics.ascent(),
                             str(line_count))
            if bold:
                font = painter.font()
                font.setBold(False)
                painter.setFont(font)
            block = block.next()
        self.highest_line = line_count
        painter.end()

        QWidget.paintEvent(self, event)
Пример #3
0
class MainWindow(QMainWindow):
	def __init__(self, parent=None):
		super().__init__(parent)
		self.centralWidget = QWidget(self)
		self.layout = QHBoxLayout(self.centralWidget)

		self.centralWidget.setLayout(self.layout)
		self.setCentralWidget(self.centralWidget)
Пример #4
0
    def __init__(self, argv, parentQWidget = None):
        QWidget.__init__(self)

        const.mode_interactive = 1
        const.mode_file = 2
        const.mode_batch = 3
        const.mode_default = const.mode_batch

        arg_file = ''
        if '-i' in argv:
            mode = const.mode_interactive
        elif '-b' in argv:
            mode = const.mode_batch
        elif '-f' in argv:
            mode = const.mode_file
            idx = argv.index('-f')
            arg_file = argv[idx+1]

        src_path = None
        if '-s' in argv:
            idx = argv.index('-s')
            src_path = argv[idx+1]

        if '-c' in argv:
            idx = argv.index('-c')
            cfg_file = argv[idx+1]

        hbox = QHBoxLayout()
        vbox = QVBoxLayout()
        scrollView = ScrollArea()
        headerView = Header.Header(self)
        scrollView.connectHeaderView(headerView)
        headerView.connectMainView(scrollView.mainView.drawer)
        vbox.addWidget(headerView)
        vbox.addWidget(scrollView)

        toolBox = ToolBox.ToolBox(mode)

        hbox.addLayout(vbox)
        hbox.addLayout(toolBox)

        self.controller = Kitchen.Kitchen(mode,arg_file,cfg_file)
        self.controller.connectView(scrollView.mainView.drawer)
        self.controller.connectToolBox(toolBox)
        self.controller.start()

        srcViewer = SourceViewer.SourceViewer()
        srcViewer.createIndex(src_path)

        toolBox.connectMsgRcv(headerView)
        toolBox.connectMsgRcv(scrollView.mainView.drawer)
        toolBox.connectMsgRcv(self.controller)
        toolBox.connectDiagramView(scrollView.mainView.drawer)

        scrollView.mainView.drawer.setToolBox(toolBox)
        scrollView.mainView.drawer.connectSourceViewer(srcViewer)

        self.setLayout(hbox)
Пример #5
0
    def testMoveLayout(self):
        l = QHBoxLayout()
        self.assertEqual(getrefcount(self.widget1), 2)
        l.addWidget(self.widget1)
        self.assertEqual(getrefcount(self.widget1), 3)

        w = QWidget()
        w.setLayout(l)
        self.assertEqual(getrefcount(self.widget1), 3)
Пример #6
0
    def __init__(self):
        QWidget.__init__(self)

        self.model = CustomTableModel()

        self.table_view = QTableView()
        self.table_view.setModel(self.model)
        self.table_view.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
        self.table_view.verticalHeader().setSectionResizeMode(QHeaderView.Stretch)

        self.chart = QtCharts.QChart()
        self.chart.setAnimationOptions(QtCharts.QChart.AllAnimations)

        self.series = QtCharts.QLineSeries()
        self.series.setName("Line 1")
        self.mapper = QtCharts.QVXYModelMapper(self)
        self.mapper.setXColumn(0)
        self.mapper.setYColumn(1)
        self.mapper.setSeries(self.series)
        self.mapper.setModel(self.model)
        self.chart.addSeries(self.series)

        # for storing color hex from the series
        seriesColorHex = "#000000"

        # get the color of the series and use it for showing the mapped area
        seriesColorHex = "{}".format(self.series.pen().color().name())
        self.model.add_mapping(seriesColorHex, QRect(0, 0, 2, self.model.rowCount()))

        # series 2
        self.series = QtCharts.QLineSeries()
        self.series.setName("Line 2")

        self.mapper = QtCharts.QVXYModelMapper(self)
        self.mapper.setXColumn(2)
        self.mapper.setYColumn(3)
        self.mapper.setSeries(self.series)
        self.mapper.setModel(self.model)
        self.chart.addSeries(self.series)

        # get the color of the series and use it for showing the mapped area
        seriesColorHex = "{}".format(self.series.pen().color().name())
        self.model.add_mapping(seriesColorHex, QRect(2, 0, 2, self.model.rowCount()));

        self.chart.createDefaultAxes()
        self.chart_view = QtCharts.QChartView(self.chart)
        self.chart_view.setRenderHint(QPainter.Antialiasing)
        self.chart_view.setMinimumSize(640, 480)

        # create main layout
        self.main_layout = QGridLayout()
        self.main_layout.addWidget(self.table_view, 1, 0)
        self.main_layout.addWidget(self.chart_view, 1, 1)
        self.main_layout.setColumnStretch(1, 1)
        self.main_layout.setColumnStretch(0, 0)
        self.setLayout(self.main_layout)
Пример #7
0
    def testLoadFileUnicodeFilePath(self):
        filePath = str(os.path.join(os.path.dirname(__file__), 'test.ui'))
        loader = QUiLoader()
        parent = QWidget()
        w = loader.load(filePath, parent)
        self.assertNotEqual(w, None)

        self.assertEqual(len(parent.children()), 1)

        child = w.findChild(QWidget, "child_object")
        self.assertNotEqual(child, None)
        self.assertEqual(w.findChild(QWidget, "grandson_object"), child.findChild(QWidget, "grandson_object"))
Пример #8
0
    def __init__(self):
        QWidget.__init__(self)
 
        self.hello = ["Hallo welt!", "Ciao mondo!",
            "Hei maailma!", "Hola mundo!", "Hei verden!"]
 
        self.button = QPushButton("Click me!")
        self.text = QLabel("Hello World")
        self.text.setAlignment(Qt.AlignCenter)
 
        self.layout = QVBoxLayout()
        self.layout.addWidget(self.text)
        self.layout.addWidget(self.button)
        self.setLayout(self.layout)
 
        self.button.clicked.connect(self.magic)
Пример #9
0
 def testObjectDestructorOrder(self):
     w = QWidget()
     filt = MyFilter()
     filt.app = self.app
     w.installEventFilter(filt)
     w.show()
     w.close()
     w = None
     self.assert_(True)
Пример #10
0
    def testWindowButtonClickClose(self):
        button = QPushButton()
        window = QWidget()
        window.connect(button, SIGNAL('clicked()'), SLOT('close()'))

        window.show()
        self.assert_(window.isVisible())
        button.click()
        self.assert_(not window.isVisible())
Пример #11
0
    def test_setLayout(self):
        layout = QVBoxLayout()
        btn1 = QPushButton("button_v1")
        layout.addWidget(btn1)

        btn2 = QPushButton("button_v2")
        layout.addWidget(btn2)

        layout2 = QHBoxLayout()

        btn1 = QPushButton("button_h1")
        layout2.addWidget(btn1)

        btn2 = QPushButton("button_h2")
        layout2.addWidget(btn2)

        layout.addLayout(layout2)

        widget = QWidget()
        widget.setLayout(layout)
Пример #12
0
 def __init__(self):
     super(MainWindow, self).__init__()
     hBoxLayout = QHBoxLayout(self)
     self.plainTextEdit = QPlainTextEdit()
     self.plainTextEdit.setMinimumWidth(400)
     self.plainTextEdit.setReadOnly(True)
     hBoxLayout.addWidget(self.plainTextEdit)
     self.renderWindow = RenderWindow(QSurfaceFormat())
     container = QWidget.createWindowContainer(self.renderWindow)
     container.setMinimumSize(QSize(400, 400))
     hBoxLayout.addWidget(container)
Пример #13
0
    class WidgetPySignal(UsesQApplication):
        """Tests the connection of python signals to QWidget qt slots."""

        def setUp(self):
            super(WidgetPySignal, self).setUp()
            self.obj = Dummy()
            self.widget = QWidget()

        def tearDown(self):
            super(WidgetPySignal, self).tearDown()
            del self.obj
            del self.widget

        def testShow(self):
            """Emission of a python signal to QWidget slot show()"""
            self.widget.hide()

            QObject.connect(self.obj, SIGNAL("dummy()"), self.widget, SLOT("show()"))
            self.assert_(not self.widget.isVisible())

            self.obj.emit(SIGNAL("dummy()"))
            self.assert_(self.widget.isVisible())
Пример #14
0
    def __init__(self):
        super(MainWindow, self).__init__()

        self.setWindowTitle('Qt DataVisualization 3D Bars')

        self.bars = QtDataVisualization.Q3DBars()

        self.columnAxis = QtDataVisualization.QCategory3DAxis()
        self.columnAxis.setTitle('Columns')
        self.columnAxis.setTitleVisible(True)
        self.columnAxis.setLabels(['Column1', 'Column2'])
        self.columnAxis.setLabelAutoRotation(30)

        self.rowAxis = QtDataVisualization.QCategory3DAxis()
        self.rowAxis.setTitle('Rows')
        self.rowAxis.setTitleVisible(True)
        self.rowAxis.setLabels(['Row1', 'Row2'])
        self.rowAxis.setLabelAutoRotation(30)

        self.valueAxis = QtDataVisualization.QValue3DAxis()
        self.valueAxis.setTitle('Values')
        self.valueAxis.setTitleVisible(True)
        self.valueAxis.setRange(0, 5)

        self.bars.setRowAxis(self.rowAxis)
        self.bars.setColumnAxis(self.columnAxis)
        self.bars.setValueAxis(self.valueAxis)

        self.series = QtDataVisualization.QBar3DSeries()
        self.arrayData = [[1, 2], [3, 4]]
        self.series.dataProxy().addRows(dataToBarDataArray(self.arrayData))

        self.bars.setPrimarySeries(self.series)

        self.container = QWidget.createWindowContainer(self.bars)

        if not self.bars.hasContext():
            print("Couldn't initialize the OpenGL context.")
            sys.exit(-1)

        camera = self.bars.scene().activeCamera()
        camera.setYRotation(22.5)

        geometry = QGuiApplication.primaryScreen().geometry()
        size = geometry.height() * 3 / 4
        self.container.setMinimumSize(size, size)

        self.container.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.container.setFocusPolicy(Qt.StrongFocus)
        self.setCentralWidget(self.container)
Пример #15
0
    def testInternalRef(self):
        mw = QWidget()
        w = QWidget()
        ow = QWidget()

        topLayout = QGridLayout()

        # unique reference
        self.assertEqual(getrefcount(w), 2)
        self.assertEqual(getrefcount(ow), 2)

        topLayout.addWidget(w, 0, 0)
        topLayout.addWidget(ow, 1, 0)

        # layout keep the referemce
        self.assertEqual(getrefcount(w), 3)
        self.assertEqual(getrefcount(ow), 3)

        mainLayout = QGridLayout()

        mainLayout.addLayout(topLayout, 1, 0, 1, 4)

        # the same reference
        self.assertEqual(getrefcount(w), 3)
        self.assertEqual(getrefcount(ow), 3)

        mw.setLayout(mainLayout)

        # now trasfer the ownership to mw
        self.assertEqual(getrefcount(w), 3)
        self.assertEqual(getrefcount(ow), 3)

        del mw

        # remove the ref and invalidate the widget
        self.assertEqual(getrefcount(w), 2)
        self.assertEqual(getrefcount(ow), 2)
Пример #16
0
    def initializeWindow(self):
        layout = QVBoxLayout()

        self.m_deviceBox = QComboBox()
        self.m_deviceBox.activated[int].connect(self.deviceChanged)
        for deviceInfo in QAudioDeviceInfo.availableDevices(QAudio.AudioOutput):
            self.m_deviceBox.addItem(deviceInfo.deviceName(), deviceInfo)

        layout.addWidget(self.m_deviceBox)

        self.m_modeButton = QPushButton()
        self.m_modeButton.clicked.connect(self.toggleMode)
        self.m_modeButton.setText(self.PUSH_MODE_LABEL)

        layout.addWidget(self.m_modeButton)

        self.m_suspendResumeButton = QPushButton(
                clicked=self.toggleSuspendResume)
        self.m_suspendResumeButton.setText(self.SUSPEND_LABEL)

        layout.addWidget(self.m_suspendResumeButton)

        volumeBox = QHBoxLayout()
        volumeLabel = QLabel("Volume:")
        self.m_volumeSlider = QSlider(Qt.Horizontal, minimum=0, maximum=100,
                singleStep=10)
        self.m_volumeSlider.valueChanged.connect(self.volumeChanged)

        volumeBox.addWidget(volumeLabel)
        volumeBox.addWidget(self.m_volumeSlider)

        layout.addLayout(volumeBox)

        window = QWidget()
        window.setLayout(layout)

        self.setCentralWidget(window)
Пример #17
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.glWidget = GLWidget()

        self.xSlider = self.createSlider(SIGNAL("xRotationChanged(int)"),
                                         self.glWidget.setXRotation)
        self.ySlider = self.createSlider(SIGNAL("yRotationChanged(int)"),
                                         self.glWidget.setYRotation)
        self.zSlider = self.createSlider(SIGNAL("zRotationChanged(int)"),
                                         self.glWidget.setZRotation)

        mainLayout = QHBoxLayout()
        mainLayout.addWidget(self.glWidget)
        mainLayout.addWidget(self.xSlider)
        mainLayout.addWidget(self.ySlider)
        mainLayout.addWidget(self.zSlider)
        self.setLayout(mainLayout)

        self.xSlider.setValue(15 * 16)
        self.ySlider.setValue(345 * 16)
        self.zSlider.setValue(0 * 16)

        self.setWindowTitle(self.tr("Hello GL"))
Пример #18
0
from PySide2.QtWidgets import QApplication, QWidget, QLabel, QPlainTextEdit, QDoubleSpinBox, QPushButton, QMessageBox
from PySide2.QtGui import QIcon

import re
import numpy as np
import matplotlib.pyplot as plt

app = QApplication([])
window = QWidget()
window.setWindowTitle("Equation Plotter")
window.setGeometry(400, 400, 700, 600)
window.setMaximumWidth(700)
window.setMaximumHeight(600)

formatlabel = QLabel(window)
formatlabel.setText(
    "Please Enter the Polynomial in the following format: \n                        a*x^2-b/x-c "
)
formatlabel.move(220, 40)

equationlabel = QLabel(window)
equationlabel.setText("Enter Polynomial Equation:")
equationlabel.move(0, 105)

equationinput = QPlainTextEdit(window)
equationinput.setGeometry(170, 100, 400, 30)

# equationbutton = QPushButton("Set Equation",window)
# equationbutton.setGeometry(575,100,100,30)

#### Minimum #########
Пример #19
0
    def __init__(self):
        QWidget.__init__(self)

        m = QMenu(self)
        b = QPushButton("Hello", self)
        b.setMenu(m)
Пример #20
0
    def __init__(self):
        QWidget.__init__(self)

        m = QMenu(self)
        b = QPushButton("Hello", self)
        b.setMenu(m)
 def testQWidgetGetContentsMargins(self):
     obj = QWidget()
     values = (10, 20, 30, 40)
     obj.setContentsMargins(*values)
     self.assert_(self.compareTuples(obj.getContentsMargins(), values))
Пример #22
0
 def event(self, e):
     self._sequence.append(e.type())
     return QWidget.event(self, e)
Пример #23
0
 def __init__(self):
     QWidget.__init__(self)
    def __init__(self, *args, **kwargs):
        super(PreprocessingImageWindow, self).__init__(*args, **kwargs)
        self.file_path = None
        self.file_name = None
        self.dataset_path = None


        self.setObjectName("self")
        self.resize(1280, 720)
        self.setAutoFillBackground(True)
        self.setFixedSize(1280, 720)
    
        self.centralwidget = QWidget(self)
        self.centralwidget.setAutoFillBackground(True)
        self.centralwidget.setObjectName("centralwidget")



        self.gridLayout = QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.tabWidget = QTabWidget(self.centralwidget)
        self.tabWidget.setAutoFillBackground(True)
        self.tabWidget.setObjectName("tabWidget")


        ## INFO BOX:
        self.tab1 = QWidget()
        self.tab1.setAutoFillBackground(True)
        self.tab1.setObjectName("tab1")
        self.frame = QFrame(self.tab1)
        self.frame.setGeometry(QtCore.QRect(10, 60, 1000, 111))
        self.frame.setAutoFillBackground(True)
        self.frame.setFrameShape(QFrame.StyledPanel)
        self.frame.setFrameShadow(QFrame.Raised)
        self.frame.setObjectName("frame")
        self.label_2 = QLabel(self.frame)
        self.label_2.setGeometry(QtCore.QRect(11, 10, 184, 17))
        font = QtGui.QFont()
        font.setItalic(True)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.widget = QWidget(self.frame)
        self.widget.setGeometry(QtCore.QRect(100, 30, 301, 65))
        self.widget.setObjectName("widget")
        self.verticalLayout = QVBoxLayout(self.widget)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setObjectName("verticalLayout")
        self.label_instances = QLabel(self.widget)
        self.label_instances.setObjectName("label_instances")
        self.verticalLayout.addWidget(self.label_instances)
        self.label_classes = QLabel(self.widget)
        self.label_classes.setObjectName("label_classes")
        self.verticalLayout.addWidget(self.label_classes)
    
        ## Frame 2 PARAMETERS
        self.frame_2 = QFrame(self.tab1)
        self.frame_2.setGeometry(QtCore.QRect(1030, 60, 211, 261))
        self.frame_2.setAutoFillBackground(True)
        self.frame_2.setFrameShape(QFrame.StyledPanel)
        self.frame_2.setFrameShadow(QFrame.Raised)
        self.frame_2.setObjectName("frame_2")
    
        self.toolBox = QToolBox(self.frame_2)
        self.toolBox.setGeometry(QtCore.QRect(10, 40, 191, 151))
        self.toolBox.setObjectName("toolBox")
    
        self.page_resize = QWidget()
        self.page_resize.setGeometry(QtCore.QRect(100, 0, 191, 89))
        self.page_resize.setObjectName("page_resize")
    
        self.layoutWidget = QWidget(self.page_resize)
        self.layoutWidget.setGeometry(QtCore.QRect(0, 0, 188, 52))
        self.layoutWidget.setObjectName("layoutWidget")
    
        self.verticalLayout_2 = QVBoxLayout(self.layoutWidget)
        self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
    
        self.form = QFormLayout ()
    
        self.input_length = QLineEdit()
        self.input_length.setValidator (QtGui.QIntValidator())
        self.input_length.setObjectName("Choose_length")
        self.verticalLayout_2.addWidget(self.input_length)
        self.input_length.setEnabled (False)


        self.input_height = QLineEdit()
        self.input_height.setValidator (QtGui.QIntValidator())
        self.input_height.setObjectName("Choose_height")
        self.verticalLayout_2.addWidget(self.input_height)
        self.input_height.setEnabled (False)
    
        self.form.addRow ("Length :", self.input_length)
    
        self.start = QPushButton(self.frame_2)
        self.start.setObjectName("pushButton_start")
        self.verticalLayout_2.addWidget(self.start)
        self.page_resize.setLayout (self.form)
    
        self.form.addRow ("height :", self.input_height)
        self.form.addRow (self.start)


        self.input_length.setText ("40")
        self.input_height.setText ("40")



        self.toolBox.addItem(self.page_resize, "")
        self.label_3 = QLabel(self.frame_2)
        self.label_3.setGeometry(QtCore.QRect(10, 10, 181, 17))
        font = QtGui.QFont()
        font.setItalic(True)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")


        ## Frame 3 DISPLAY
        self.frame_3 = QFrame(self.tab1)
        self.frame_3.setGeometry(QtCore.QRect(10, 180, 1000, 450))
        self.frame_3.setAutoFillBackground(True)
        self.frame_3.setFrameShape(QFrame.StyledPanel)
        self.frame_3.setFrameShadow(QFrame.Raised)
        self.frame_3.setObjectName("frame_3")
    
        ## Display matrix
        self.tableWidget = QTableWidget(self.frame_3)
        self.tableWidget.setGeometry(QtCore.QRect(0, 0, 1000, 450))
        self.tableWidget.setAutoFillBackground(True)
        self.tableWidget.setObjectName("tableWidget")
        self.tableWidget.setColumnCount(0)
        self.tableWidget.setRowCount(0)


        ## Frame 4 VISUALIZATION
        self.frame_4 = QFrame(self.tab1)
        self.frame_4.setGeometry(QtCore.QRect(1030, 330, 211, 191))
        self.frame_4.setFrameShape(QFrame.StyledPanel)
        self.frame_4.setFrameShadow(QFrame.Raised)
        self.frame_4.setObjectName("frame_4")


        ## BUTTON FOR VISUALIZATION
        self.pushButton_previous= QPushButton(self.frame_4)
        self.pushButton_previous.setGeometry(QtCore.QRect(50, 40, 121, 41))
        self.pushButton_previous.setIconSize(QtCore.QSize(30, 30))
        self.pushButton_previous.setAutoDefault(False)
        self.pushButton_previous.setDefault(False)
        self.pushButton_previous.setFlat(False)
        self.pushButton_previous.setObjectName("pushButton_previous")
    
        self.pushButton_next = QPushButton(self.frame_4)
        self.pushButton_next.setGeometry(QtCore.QRect(50, 85, 121, 41))
        self.pushButton_next.setObjectName("pushButton_next")


        self.pushButton_table = QPushButton (self.frame_4)
        self.pushButton_table.setGeometry (QtCore.QRect (50, 130, 121, 41))
        self.pushButton_table.setObjectName ("pushButton_table")


        ## SAVE
        self.frame_5 = QFrame(self.tab1)
        self.frame_5.setGeometry(QtCore.QRect(1080, 550, 121, 41))
        self.frame_5.setFrameShape(QFrame.StyledPanel)
        self.frame_5.setFrameShadow(QFrame.Raised)
        self.frame_5.setObjectName("frame_5")
    
        self.pushButton_save = QPushButton (self.frame_5)
        self.pushButton_save.setGeometry (QtCore.QRect (0, 0, 121, 41))
        self.pushButton_save.setObjectName ("pushButton_save")


        ## RETURN BUTTON
        self.frame_6 = QFrame(self.tab1)
        self.frame_6.setGeometry(QtCore.QRect(1080, 10, 121, 41))
        self.frame_6.setFrameShape(QFrame.StyledPanel)
        self.frame_6.setFrameShadow(QFrame.Raised)
        self.frame_6.setObjectName("frame_6")
    
        self.pushButton_return = QPushButton (self.frame_6)
        self.pushButton_return.setGeometry (QtCore.QRect (0, 0, 121, 41))
        self.pushButton_return.setObjectName ("pushButton_return")



        self.label_4 = QLabel(self.frame_4)
        self.label_4.setGeometry(QtCore.QRect(10, 10, 111, 17))
        font = QtGui.QFont()
        font.setItalic(True)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.layoutWidget2 = QWidget(self.tab1)
        self.layoutWidget2.setGeometry(QtCore.QRect(10, 20, 611, 31))
        self.layoutWidget2.setObjectName("layoutWidget2")
        self.horizontalLayout = QHBoxLayout(self.layoutWidget2)
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.label = QLabel(self.layoutWidget2)
        font = QtGui.QFont()
        font.setItalic(True)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.horizontalLayout.addWidget(self.label)
        self.textEdit = QTextEdit(self.layoutWidget2)
        self.textEdit.setObjectName("textEdit")
        self.horizontalLayout.addWidget(self.textEdit)
        self.toolButton = QToolButton(self.layoutWidget2)
        self.toolButton.setObjectName("toolButton")
        self.horizontalLayout.addWidget(self.toolButton)
        self.valider = QPushButton(self.layoutWidget2)
        self.valider.setObjectName("valider")
        self.horizontalLayout.addWidget(self.valider)
        self.tabWidget.addTab(self.tab1, "")
        self.gridLayout.addWidget(self.tabWidget, 0, 1, 1, 1)
        self.setCentralWidget(self.centralwidget)


        self.lbl = QLabel(self.frame_3)
        self.lbl.setGeometry(QtCore.QRect(10, 180, 0, 381))


        ## ACTIVATED OR NOT
        self.tableWidget.setVisible(False)
        self.pushButton_next.setEnabled(False)
        self.pushButton_previous.setEnabled(False)
        self.valider.setEnabled(False)
        self.start.setEnabled(False)
        self.pushButton_table.setEnabled (False)
        self.pushButton_save.setEnabled (False)


        self.toolButton.clicked.connect(self.open_dataset)
        self.start.clicked.connect(self.preprocess)
        self.pushButton_previous.clicked.connect(self.previous_state)
        self.pushButton_next.clicked.connect(self.next_state)
        self.valider.clicked.connect (self.get_dataset_information)
        self.pushButton_table.clicked.connect (self.showTable)
        self.pushButton_save.clicked.connect (self.save)
    
        p = QtGui.QPalette()
        p.setColor(QtGui.QPalette.Window, QtGui.QColor(133,132,130))
        p.setColor(QtGui.QPalette.Button, QtGui.QColor(153,150,150))
        p.setColor(QtGui.QPalette.WindowText, QtGui.QColor(13,13,12))
        p.setColor(self.toolBox.backgroundRole(), QtGui.QColor(189,187,185))
        p.setColor(QtGui.QPalette.ButtonText, QtGui.QColor(13,13,12))
        self.setPalette(p)
    
        self.retranslateUi(self)
        self.tabWidget.setCurrentIndex(0)
        self.toolBox.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(self)
Пример #25
0
class DebugModulesWidget(QWidget, DockContextHandler):
	def __init__(self, parent, name, data):
		if not type(data) == binaryninja.binaryview.BinaryView:
			raise Exception('expected widget data to be a BinaryView')

		self.bv = data

		QWidget.__init__(self, parent)
		DockContextHandler.__init__(self, self, name)
		self.actionHandler = UIActionHandler()
		self.actionHandler.setupActionHandler(self)

		self.table = QTableView(self)
		self.model = DebugModulesListModel(self.table, data)
		self.table.setModel(self.model)

		self.item_delegate = DebugModulesItemDelegate(self)
		self.table.setItemDelegate(self.item_delegate)

		# self.table.setSortingEnabled(True)
		self.table.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
		self.table.setSelectionMode(QAbstractItemView.ExtendedSelection)

		self.table.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
		self.table.verticalHeader().setVisible(False)

		self.table.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel)
		self.table.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)

		self.table.resizeColumnsToContents()
		self.table.resizeRowsToContents()

		for i in range(len(self.model.columns)):
			self.table.setColumnWidth(i, self.item_delegate.sizeHint(self.table.viewOptions(), self.model.index(-1, i, QModelIndex())).width())

		update_layout = QHBoxLayout()
		update_layout.setContentsMargins(0, 0, 0, 0)

		update_label = QLabel("Data is Stale")
		update_button = QPushButton("Refresh")
		update_button.clicked.connect(lambda: self.refresh())

		update_layout.addWidget(update_label)
		update_layout.addStretch(1)
		update_layout.addWidget(update_button)

		self.update_box = QWidget()
		self.update_box.setLayout(update_layout)

		self.layout = QVBoxLayout()
		self.layout.setContentsMargins(0, 0, 0, 0)
		self.layout.setSpacing(0)
		self.layout.addWidget(self.table)
		self.setLayout(self.layout)

	def notifyOffsetChanged(self, offset):
		pass

	def refresh(self):
		debug_state = binjaplug.get_state(self.bv)
		debug_state.ui.update_modules()

	def notifyModulesChanged(self, new_modules):
		self.model.update_rows(new_modules)
		self.table.resizeColumnsToContents()
		self.layout.removeWidget(self.update_box)
		self.update_box.setVisible(False)

	def mark_dirty(self):
		self.layout.addWidget(self.update_box)
		self.update_box.setVisible(True)

	def contextMenuEvent(self, event):
		self.m_contextMenuManager.show(self.m_menu, self.actionHandler)

	def shouldBeVisible(self, view_frame):
		if view_frame is None:
			return False
		else:
			return True
Пример #26
0
    def __init__(self, parent, name, data):
        # Read the configuration
        settings = Settings()
        settings.register_group("ghinja", "Ghinja")
        settings.register_setting(
            "ghinja.ghidra_install_path", """
				{
					"title" : "Ghidra Installation Path",
					"type" : "string",
					"default" : "",
					"description" : "Path to analyzeHeadless file in Ghidra installation dir."
				}
				""")
        if not os.path.exists(
                settings.get_string("ghinja.ghidra_install_path")):
            show_message_box(
                "Path to Ghidra headless was not found!",
                "To allow the Ghinja plugin to work, you will be prompted to specify the path to the \"analyzeHeadless(.bat)\" file.",
                buttons=0,
                icon=2)
            settings.set_string(
                "ghinja.ghidra_install_path",
                get_open_filename_input(
                    "Provide Path to Ghidra \"analyzeHeadless(.bat)\" file (Usually: <GHIDRA_INSTALL>/support/analyzeHeadless)"
                ).decode("utf-8"))

        self.rename_settings = Settings()
        self.rename_settings.register_group("ghinja_rename", "Rename")
        self.rename_settings.register_setting(
            "ghinja_rename.ghinja_rename_struct", """
				{
					"title" : "Ghidra Rename Struct",
					"type" : "string",
					"default" : "{}",
					"description" : "Settings to hold renames for variables."
				}
				""")

        global instance_id
        self.binja_renames = {}  # {"function_name":[{"original":"new"})]}
        self.current_function = None
        self.current_offset = None
        self.decomp = None
        self.current_view = None
        self.function_output = None
        self.decompile_result_path = None
        self.decompile_offset_path = None
        self.decompiler_done = False
        self.function_args = []
        QWidget.__init__(self, parent)
        DockContextHandler.__init__(self, self, name)
        self.actionHandler = UIActionHandler()
        self.actionHandler.setupActionHandler(self)
        layout = QVBoxLayout()
        self.editor = QTextEdit(self)
        self.editor.setReadOnly(True)
        self.editor.installEventFilter(self)
        self.editor.setStyleSheet(
            "QTextEdit { background-color: #2a2a2a; font-family: Consolas }")
        self.editor.setPlainText(
            " Click anywhere in the dock to start decompiler")
        self.editor.selectionChanged.connect(self.onSelect)
        highlighter = Highlighter(self.editor.document(), "",
                                  self.function_args)
        layout.addWidget(self.editor)
        layout.setAlignment(QtCore.Qt.AlignLeft)
        self.setLayout(layout)
        instance_id += 1
        self.data = data
Пример #27
0
    def __init__(self):
        QWidget.__init__(self)
        self.items = 0

        # Example data
        self._data = {
            "Water": 24.5,
            "Electricity": 55.1,
            "Rent": 850.0,
            "Supermarket": 230.4,
            "Internet": 29.99,
            "Bars": 21.85,
            "Public transportation": 60.0,
            "Coffee": 22.45,
            "Restaurants": 120
        }

        # Left
        self.table = QTableWidget()
        self.table.setColumnCount(2)
        self.table.setHorizontalHeaderLabels(["Description", "Price"])
        self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)

        # Right
        self.description = QLineEdit()
        self.price = QLineEdit()
        self.add = QPushButton("Add")
        self.clear = QPushButton("Clear")
        self.quit = QPushButton("Quit")

        # Disabling 'Add' button
        self.add.setEnabled(False)

        self.right = QVBoxLayout()
        self.right.setMargin(10)
        self.right.addWidget(QLabel("Description"))
        self.right.addWidget(self.description)
        self.right.addWidget(QLabel("Price"))
        self.right.addWidget(self.price)
        self.right.addWidget(self.add)
        self.right.addStretch()
        self.right.addWidget(self.clear)
        self.right.addWidget(self.quit)

        # QWidget Layout
        self.layout = QHBoxLayout()

        #self.table_view.setSizePolicy(size)
        self.layout.addWidget(self.table)
        self.layout.addLayout(self.right)

        # Set the layout to the QWidget
        self.setLayout(self.layout)

        # Signals and Slots
        self.add.clicked.connect(self.add_element)
        self.quit.clicked.connect(self.quit_application)
        self.clear.clicked.connect(self.clear_table)
        self.description.textChanged[str].connect(self.check_disable)
        self.price.textChanged[str].connect(self.check_disable)

        # Fill example data
        self.fill_table()
Пример #28
0
    def __init__(self, app, parent=None):
        super(MainWindow, self).__init__(parent)
        self.imagesDir = app.dir + '/images/'
        self.setWindowIcon(QIcon(self.imagesDir + 'icon.png'))
        self.path = ''

        self.settings = QSettings()
        self.lastDir = self.settings.value('lastDir', '')

        self.setMinimumWidth(540)

        self.supportedFormats = []
        for f in QImageReader.supportedImageFormats():
            self.supportedFormats.append(str(f.data(), encoding="utf-8"))

        self.fileWatcher = QFileSystemWatcher()
        self.fileWatcher.fileChanged.connect(self.fileChanged)

        # widgets
        self.showPixmapWidget = None

        self.tileWidthSpinBox = QSpinBox()
        self.tileWidthSpinBox.setValue(16)
        self.tileWidthSpinBox.setFixedWidth(50)
        self.tileWidthSpinBox.setMinimum(1)

        self.tileHeightSpinBox = QSpinBox()
        self.tileHeightSpinBox.setValue(16)
        self.tileHeightSpinBox.setFixedWidth(50)
        self.tileHeightSpinBox.setMinimum(1)

        self.paddingSpinBox = QSpinBox()
        self.paddingSpinBox.setFixedWidth(50)
        self.paddingSpinBox.setMinimum(1)

        self.transparentCheckbox = QCheckBox("Transparent")
        self.transparentCheckbox.setChecked(True)
        self.transparentCheckbox.stateChanged.connect(self.transparentChanged)

        self.backgroundColorEdit = ColorEdit()
        self.backgroundColorEdit.setEnabled(False)
        self.backgroundColorLabel = QLabel("Background color:")
        self.backgroundColorLabel.setEnabled(False)

        self.forcePotCheckBox = QCheckBox("Force PoT")
        self.forcePotCheckBox.setChecked(True)
        self.forcePotCheckBox.stateChanged.connect(self.forcePotChanged)

        self.reorderTilesCheckBox = QCheckBox("Reorder tiles")

        self.generateAndExportButton = QPushButton("Generate and export")
        self.generateAndExportButton.setFixedHeight(32)
        self.generateAndExportButton.clicked.connect(self.generateAndExportClicked)
        self.generateAndExportButton.setEnabled(False)

        self.pixmapWidget = PixmapWidget()
        self.pixmapWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.pixmapWidget.setPixmap(self.createDropTextPixmap())
        self.pixmapWidget.dropSignal.connect(self.fileDropped)
        self.pixmapWidget.setMinimumHeight(300)

        # load settings
        self.tileWidthSpinBox.setValue(int(self.settings.value('tileWidth', 16)))
        self.tileHeightSpinBox.setValue(int(self.settings.value('tileHeight', 16)))
        self.paddingSpinBox.setValue(int(self.settings.value('padding', 1)))
        self.forcePotCheckBox.setChecked(True if self.settings.value('forcePot', 'true') == 'true' else False)
        self.reorderTilesCheckBox.setChecked(True if self.settings.value('reorderTiles', 'false') == 'true' else False)
        self.transparentCheckbox.setChecked(True if self.settings.value('transparent', 'false') == 'true' else False)
        self.backgroundColorEdit.setColorText(str(self.settings.value('backgroundColor', '#FF00FF')))
        self.restoreGeometry(QByteArray(self.settings.value('MainWindow/geometry')))
        self.restoreState(QByteArray(self.settings.value('MainWindow/windowState')))

        # layout
        hl1 = QHBoxLayout()
        hl1.setContentsMargins(5, 5, 5, 5)
        hl1.addWidget(QLabel("Tile width:"))
        hl1.addSpacing(5)
        hl1.addWidget(self.tileWidthSpinBox)
        hl1.addSpacing(15)
        hl1.addWidget(QLabel("Tile height:"))
        hl1.addSpacing(5)
        hl1.addWidget(self.tileHeightSpinBox)
        hl1.addSpacing(15)
        hl1.addWidget(QLabel("Padding:"))
        hl1.addSpacing(5)
        hl1.addWidget(self.paddingSpinBox)
        hl1.addSpacing(15)
        hl1.addWidget(self.forcePotCheckBox)
        hl1.addSpacing(15)
        hl1.addWidget(self.reorderTilesCheckBox)
        hl1.addStretch()

        hl2 = QHBoxLayout()
        hl2.setContentsMargins(5, 5, 5, 5)
        hl2.addWidget(self.transparentCheckbox)
        hl2.addSpacing(15)
        hl2.addWidget(self.backgroundColorLabel)
        hl2.addSpacing(5)
        hl2.addWidget(self.backgroundColorEdit)
        hl2.addStretch()

        hl3 = QHBoxLayout()
        hl3.setContentsMargins(5, 5, 5, 5)
        hl3.addWidget(self.generateAndExportButton)

        vl = QVBoxLayout()
        vl.setContentsMargins(0, 0, 0, 0)
        vl.setSpacing(0)
        vl.addLayout(hl1)
        vl.addLayout(hl2)
        vl.addWidget(self.pixmapWidget)
        vl.addLayout(hl3)

        w = QWidget()
        w.setLayout(vl)
        self.setCentralWidget(w)

        self.setTitle()
Пример #29
0
# PySide2 tutorial 3
# Widget使用

import sys
from PySide2.QtCore import Qt
from PySide2.QtGui import QFont
from PySide2.QtWidgets import QApplication, QWidget, QPushButton

app = QApplication(sys.argv)

window = QWidget()
window.resize(400, 300)

quit = QPushButton("Quit", window)  # 设置Button附着于window上
quit.setFont(QFont("Times", 18, QFont.Bold))
quit.setGeometry(10, 20, 150, 40)
quit.resize(300, 40)
# QtCore.QObject.connect(quit, QtCore.SIGNAL("clicked()"), app, QtCore.SLOT("quit()"))
quit.clicked.connect(app.quit)
window.show()
sys.exit(app.exec_())
class MainWidget(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.lyt = QVBoxLayout()
        self.setLayout(self.lyt)

        #list of host & services
        self.table_main = QWidget()
        self.table_main_lyt = QVBoxLayout(self.table_main)
        self.info_table = QWidget()
        self.table_main_lyt.addWidget(self.info_table)
        self.lyt.addWidget(self.table_main)

        self.init_refresh()

        self.refresh()

    def init_refresh(self):
        self.refrsh_opt = QWidget()
        self.refrsh_opt_lyt = QHBoxLayout()
        self.refrsh_opt.setLayout(self.refrsh_opt_lyt)

        self.refrsh_btn = QPushButton()
        self.refrsh_btn.setIcon(self.style().standardIcon(
            QStyle.SP_BrowserReload))
        self.refrsh_btn.clicked.connect(self.refresh)

        self.test1_btn = QPushButton()
        self.test1_btn.setIcon(self.style().standardIcon(
            QStyle.SP_BrowserReload))
        self.test1_btn.clicked.connect(self.test1)

        self.refrsh_opt_lyt.addWidget(self.refrsh_btn)
        self.refrsh_opt_lyt.addWidget(self.test1_btn)

        self.lyt.addWidget(self.refrsh_opt)

    def test1(self):
        print("test")

    def refresh(self):
        print("Signal: refresh")
        self.netinfo = get_host_summary()

        self.table_main_lyt.removeWidget(self.info_table)
        self.info_table = QWidget()
        self.info_table_lyt = QGridLayout(self.info_table)
        self.table_main_lyt.addWidget(self.info_table)

        row = 0
        col = 0
        for iHeadline in ("Interface", "Mac", "Ip", "Hostname"):
            self.info_table_lyt.addWidget(QLabel("<b>" + iHeadline + "</b>"),
                                          row, col)
            col += 1
        for iServiceName, iService in SERVICES.items():
            self.info_table_lyt.addWidget(
                QLabel("<b>" + iServiceName + "</b>"), row, col)
            col += 1

        row += 1
        col = 0
        for iHost in self.netinfo:
            self.info_table_lyt.addWidget(QLabel(str(iHost["dev"])), row, col)
            col += 1
            self.info_table_lyt.addWidget(QLabel(str(iHost["mac"])), row, col)
            col += 1
            self.info_table_lyt.addWidget(QLabel(str(iHost["ip"])), row, col)
            col += 1

            if "hostname" in iHost:
                self.info_table_lyt.addWidget(QLabel(str(iHost["hostname"])),
                                              row, col)
            else:
                self.info_table_lyt.addWidget(QLabel(""), row, col)

            for iServiceName, iService in SERVICES.items():
                col += 1
                service_info = iHost["services"][iServiceName]
                if len(service_info) < 1:
                    self.info_table_lyt.addWidget(QLabel("x"), row, col)
                    continue
                widget = iService["display"].display(service_info)
                self.info_table_lyt.addWidget(widget, row, col)

            row += 1
            col = 0
Пример #31
0
 def update(self, *args):
     #width=50
     #if self.width() != width:
         #self.setFixedWidth(width)
     QWidget.update(self, *args)
    def _init_widgets(self):
        main = QMainWindow()
        main.setWindowFlags(Qt.Widget)

        carttree = QProgramTree(self.workspace)
        self._carttree = carttree
        carttree_dock = QDockWidget("Cartprograph Tree", carttree)
        main.setCentralWidget(carttree_dock)
        carttree_dock.setWidget(carttree)

        # TODO: THIS NEEDS A REFACTOR.. BAD
        # BEGIN CONSOLE VIEW ASSEMBLY
        console_view = self.workspace.view_manager.first_view_in_category(
            "console")
        self.console_tabs = console_view.tab_widget = QTabWidget()
        console_view.tab_widget.setTabPosition(QTabWidget.South)
        console_view.ipython_tab = QWidget()
        console_view.ipython_tab.setLayout(
            QHBoxLayout(console_view.ipython_tab))
        console_view.tab_layout = QHBoxLayout()
        console_view.ipython_tab.layout().addWidget(
            console_view._ipython_widget)
        console_view.tab_widget.addTab(console_view.ipython_tab, "Console")
        console_view.tab_layout.addWidget(console_view.tab_widget)
        console_view.layout().setContentsMargins(0, 0, 0, 0)
        console_view.layout().addLayout(console_view.tab_layout)
        console_view.min_size = QSize(0, 125)
        console_view._ipython_widget.push_namespace(
            {"cartprograph": self.workspace.cartprograph})
        console_group = QtWidgets.QGroupBox()
        console_group.setLayout(QtWidgets.QVBoxLayout(console_group))

        self.console_output = QPlainTextEdit()
        self.console_output.setReadOnly(True)
        console_group.layout().addWidget(self.console_output)

        self.console_input = QLineEdit()
        console_group.layout().addWidget(self.console_input)
        self.console_input.returnPressed.connect(
            lambda: self.workspace.cartprograph.client.send_input(
                self.selected_item_id,
                self.console_input.text() + "\n"))
        self.workspace.view_manager.first_view_in_category(
            "console").tab_widget.addTab(console_group, "Cartprograph Console")
        # END CONSOLE VIEW ASSEMBLY

        # BEGIN TAB VIEW ASSEMBLY
        func_view = self.workspace.view_manager.first_view_in_category(
            "functions")
        self.func_tabs = func_view.tab_widget = QTabWidget()
        funcview_container = QWidget()
        funcview_container.setLayout(QVBoxLayout(funcview_container))
        func_tabs_layout = QHBoxLayout()
        funcview_container.layout().addWidget(func_view._function_table)
        funcview_container.layout().addWidget(func_view._status_label)
        func_view.tab_widget.addTab(funcview_container, "Functions")
        func_tabs_layout.addWidget(func_view.tab_widget)
        func_view.layout().setContentsMargins(0, 0, 0, 0)
        func_view.layout().addLayout(func_tabs_layout)

        table_tabs = QTabWidget()
        table_functab = QWidget()
        table_functab.setLayout(QVBoxLayout(table_functab))
        table_blocktab = QWidget()
        table_blocktab.setLayout(QVBoxLayout(table_blocktab))
        table_datapoint_tab = QWidget()
        table_datapoint_tab.setLayout(QVBoxLayout(table_datapoint_tab))
        table_watchertab = QWidget()
        table_watchertab.setLayout(QVBoxLayout(table_watchertab))

        self.functable = QTableWidget()
        self.functable.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.functable.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
        table_tabs.addTab(table_functab, "Syscalls")
        table_functab.layout().addWidget(self.functable)

        self.blocktable = QTableWidget()
        self.blocktable.setEditTriggers(QAbstractItemView.NoEditTriggers)
        table_tabs.addTab(table_blocktab, "Basic Blocks")
        table_blocktab.layout().addWidget(self.blocktable)
        self.blocktable.cellDoubleClicked.connect(self._handle_table_click)

        self.datapoint_table = QTableWidget()
        self.datapoint_table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        table_tabs.addTab(table_datapoint_tab, "Datapoints")
        table_datapoint_tab.layout().addWidget(self.datapoint_table)

        self.watcherlist = QListWidget()

        table_tabs.addTab(table_watchertab, "Watchers")
        table_watchertab.layout().addWidget(self.watcherlist)
        self.watcherRefreshButton = QPushButton("Refresh")
        table_watchertab.layout().addWidget(self.watcherRefreshButton)

        self.watcherlist.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.watcherlist.customContextMenuRequested.connect(
            self._watcher_context_menu)
        self.watcherlist.itemDoubleClicked.connect(self._handle_watcher_click)
        self.watcherlist.itemChanged.connect(self._handle_watcher_change)

        self.watcherRefreshButton.clicked.connect(self._fire_watcher_update)

        func_view.tab_widget.addTab(table_tabs, "Cartprograph")

        # END TAB VIEW ASSEMBLY

        main_layout = QVBoxLayout()

        main_layout.addWidget(main)
        self.setLayout(main_layout)
Пример #33
0
 def testQWidgetGetContentsMargins(self):
     obj = QWidget()
     values = (10, 20, 30, 40)
     obj.setContentsMargins(*values)
     self.assertTrue(self.compareTuples(obj.getContentsMargins(), values))
Пример #34
0
    def __init__(self, lamination=None):
        """Initialize the widget according to lamination

        Parameters
        ----------
        self : PWSlot11
            A PWSlot11 widget
        lamination : Lamination
            current lamination to edit
        """

        # Build the interface according to the .ui file
        QWidget.__init__(self)
        self.setupUi(self)
        self.lamination = lamination
        self.slot = lamination.slot

        # Set FloatEdit unit
        self.lf_W0.unit = "m"
        self.lf_W1.unit = "m"
        self.lf_W2.unit = "m"
        self.lf_H0.unit = "m"
        self.lf_H2.unit = "m"
        self.lf_R1.unit = "m"
        # Set unit name (m ou mm)
        wid_list = [
            self.unit_W0,
            self.unit_W1,
            self.unit_W2,
            self.unit_H0,
            self.unit_H2,
            self.unit_R1,
        ]
        for wid in wid_list:
            wid.setText(gui_option.unit.get_m_name())

        # Fill the fields with the lamination values (if they're filled)
        self.lf_W0.setValue(self.slot.W0)
        self.lf_W1.setValue(self.slot.W1)
        self.lf_W2.setValue(self.slot.W2)
        self.lf_H0.setValue(self.slot.H0)
        if self.slot.H1_is_rad is None:
            self.slot.H1_is_rad = False
        if self.slot.H1_is_rad:
            self.lf_H1.setValue(self.slot.H1)
        else:  # convert m unit
            self.lf_H1.setValue(gui_option.unit.get_m(self.slot.H1))
        self.lf_H2.setValue(self.slot.H2)
        self.lf_R1.setValue(self.slot.R1)

        # Update the unit combobox with the current m unit name
        self.c_H1_unit.clear()
        self.c_H1_unit.addItems([gui_option.unit.get_m_name(), "rad", "deg"])
        if self.slot.H1_is_rad:
            self.c_H1_unit.setCurrentIndex(1)  # Rad
        else:
            self.c_H1_unit.setCurrentIndex(0)  # m

        # Display the main output of the slot (surface, height...)
        self.w_out.comp_output()

        # Connect the signal/slot
        self.lf_W0.editingFinished.connect(self.set_W0)
        self.lf_W1.editingFinished.connect(self.set_W1)
        self.lf_W2.editingFinished.connect(self.set_W2)
        self.lf_H0.editingFinished.connect(self.set_H0)
        self.lf_H1.editingFinished.connect(self.set_H1)
        self.lf_H2.editingFinished.connect(self.set_H2)
        self.c_H1_unit.currentIndexChanged.connect(self.set_H1_unit)
        self.lf_R1.editingFinished.connect(self.set_R1)
Пример #35
0
 def onAbout(self):
     q = QWidget()
     icon = QtGui.QIcon(":/icon.ico")
     q.setWindowIcon(icon)
     QMessageBox.about(q, "About MyTerm", appInfo.aboutme)
Пример #36
0
    def __init__(self, path_to_rom=""):
        super(MainWindow, self).__init__()

        self.setWindowIcon(icon("foundry.ico"))
        self.setStyleSheet(SETTINGS["gui_style"])

        file_menu = QMenu("File")

        open_rom_action = file_menu.addAction("&Open ROM")
        open_rom_action.triggered.connect(self.on_open_rom)
        self.open_m3l_action = file_menu.addAction("&Open M3L")
        self.open_m3l_action.triggered.connect(self.on_open_m3l)

        file_menu.addSeparator()

        self.save_rom_action = file_menu.addAction("&Save ROM")
        self.save_rom_action.triggered.connect(self.on_save_rom)
        self.save_rom_as_action = file_menu.addAction("&Save ROM as ...")
        self.save_rom_as_action.triggered.connect(self.on_save_rom_as)
        """
        file_menu.AppendSeparator()
        """
        self.save_m3l_action = file_menu.addAction("&Save M3L")
        self.save_m3l_action.triggered.connect(self.on_save_m3l)
        """
        file_menu.Append(ID_SAVE_LEVEL_TO, "&Save Level to", "")
        file_menu.AppendSeparator()
        file_menu.Append(ID_APPLY_IPS_PATCH, "&Apply IPS Patch", "")
        file_menu.AppendSeparator()
        file_menu.Append(ID_ROM_PRESET, "&ROM Preset", "")
        """
        file_menu.addSeparator()
        settings_action = file_menu.addAction("&Settings")
        settings_action.triggered.connect(self._on_show_settings)
        file_menu.addSeparator()
        exit_action = file_menu.addAction("&Exit")
        exit_action.triggered.connect(lambda _: self.close())

        self.menuBar().addMenu(file_menu)
        """
        edit_menu = wx.Menu()

        edit_menu.Append(ID_EDIT_LEVEL, "&Edit Level", "")
        edit_menu.Append(ID_EDIT_OBJ_DEFS, "&Edit Object Definitions", "")
        edit_menu.Append(ID_EDIT_PALETTE, "&Edit Palette", "")
        edit_menu.Append(ID_EDIT_GRAPHICS, "&Edit Graphics", "")
        edit_menu.Append(ID_EDIT_MISC, "&Edit Miscellaneous", "")
        edit_menu.AppendSeparator()
        edit_menu.Append(ID_FREE_FORM_MODE, "&Free form Mode", "")
        edit_menu.Append(ID_LIMIT_SIZE, "&Limit Size", "")
        """

        self.level_menu = QMenu("Level")

        self.select_level_action = self.level_menu.addAction("&Select Level")
        self.select_level_action.triggered.connect(self.open_level_selector)

        self.reload_action = self.level_menu.addAction("&Reload Level")
        self.reload_action.triggered.connect(self.reload_level)
        self.level_menu.addSeparator()
        self.edit_header_action = self.level_menu.addAction("&Edit Header")
        self.edit_header_action.triggered.connect(self.on_header_editor)
        self.edit_autoscroll = self.level_menu.addAction("Edit Autoscrolling")
        self.edit_autoscroll.triggered.connect(self.on_edit_autoscroll)

        self.menuBar().addMenu(self.level_menu)

        self.object_menu = QMenu("Objects")

        view_blocks_action = self.object_menu.addAction("&View Blocks")
        view_blocks_action.triggered.connect(self.on_block_viewer)
        view_objects_action = self.object_menu.addAction("&View Objects")
        view_objects_action.triggered.connect(self.on_object_viewer)
        self.object_menu.addSeparator()
        view_palettes_action = self.object_menu.addAction(
            "View Object Palettes")
        view_palettes_action.triggered.connect(self.on_palette_viewer)

        self.menuBar().addMenu(self.object_menu)

        self.view_menu = QMenu("View")
        self.view_menu.triggered.connect(self.on_menu)

        action = self.view_menu.addAction("Mario")
        action.setProperty(ID_PROP, ID_MARIO)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_mario"])

        action = self.view_menu.addAction("&Jumps on objects")
        action.setProperty(ID_PROP, ID_JUMP_OBJECTS)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_jump_on_objects"])

        action = self.view_menu.addAction("Items in blocks")
        action.setProperty(ID_PROP, ID_ITEM_BLOCKS)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_items_in_blocks"])

        action = self.view_menu.addAction("Invisible items")
        action.setProperty(ID_PROP, ID_INVISIBLE_ITEMS)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_invisible_items"])

        action = self.view_menu.addAction("Autoscroll Path")
        action.setProperty(ID_PROP, ID_AUTOSCROLL)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_autoscroll"])

        self.view_menu.addSeparator()

        action = self.view_menu.addAction("Jump Zones")
        action.setProperty(ID_PROP, ID_JUMPS)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_jumps"])

        action = self.view_menu.addAction("&Grid lines")
        action.setProperty(ID_PROP, ID_GRID_LINES)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_grid"])

        action = self.view_menu.addAction("Resize Type")
        action.setProperty(ID_PROP, ID_RESIZE_TYPE)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_expansion"])

        self.view_menu.addSeparator()

        action = self.view_menu.addAction("&Block Transparency")
        action.setProperty(ID_PROP, ID_TRANSPARENCY)
        action.setCheckable(True)
        action.setChecked(SETTINGS["block_transparency"])

        self.view_menu.addSeparator()
        self.view_menu.addAction(
            "&Save Screenshot of Level").triggered.connect(self.on_screenshot)
        """
        self.view_menu.Append(ID_BACKGROUND_FLOOR, "&Background & Floor", "")
        self.view_menu.Append(ID_TOOLBAR, "&Toolbar", "")
        self.view_menu.AppendSeparator()
        self.view_menu.Append(ID_ZOOM, "&Zoom", "")
        self.view_menu.AppendSeparator()
        self.view_menu.Append(ID_USE_ROM_GRAPHICS, "&Use ROM Graphics", "")
        self.view_menu.Append(ID_PALETTE, "&Palette", "")
        self.view_menu.AppendSeparator()
        self.view_menu.Append(ID_MORE, "&More", "")
        """

        self.menuBar().addMenu(self.view_menu)

        help_menu = QMenu("Help")
        """
        help_menu.Append(ID_ENEMY_COMPATIBILITY, "&Enemy Compatibility", "")
        help_menu.Append(ID_TROUBLESHOOTING, "&Troubleshooting", "")
        help_menu.AppendSeparator()
        help_menu.Append(ID_PROGRAM_WEBSITE, "&Program Website", "")
        help_menu.Append(ID_MAKE_A_DONATION, "&Make a Donation", "")
        help_menu.AppendSeparator()
        """
        update_action = help_menu.addAction("Check for updates")
        update_action.triggered.connect(self.on_check_for_update)

        help_menu.addSeparator()

        video_action = help_menu.addAction("Feature Video on YouTube")
        video_action.triggered.connect(lambda: open_url(feature_video_link))

        github_action = help_menu.addAction("Github Repository")
        github_action.triggered.connect(lambda: open_url(github_link))

        discord_action = help_menu.addAction("SMB3 Rom Hacking Discord")
        discord_action.triggered.connect(lambda: open_url(discord_link))

        help_menu.addSeparator()

        enemy_compat_action = help_menu.addAction("Enemy Compatibility")
        enemy_compat_action.triggered.connect(
            lambda: open_url(enemy_compat_link))

        about_action = help_menu.addAction("&About")
        about_action.triggered.connect(self.on_about)

        self.menuBar().addMenu(help_menu)

        self.block_viewer = None
        self.object_viewer = None

        self.level_ref = LevelRef()
        self.level_ref.data_changed.connect(self._on_level_data_changed)

        self.context_menu = ContextMenu(self.level_ref)
        self.context_menu.triggered.connect(self.on_menu)

        self.level_view = LevelView(self, self.level_ref, self.context_menu)

        self.scroll_panel = QScrollArea()
        self.scroll_panel.setWidgetResizable(True)
        self.scroll_panel.setWidget(self.level_view)

        self.setCentralWidget(self.scroll_panel)

        self.spinner_panel = SpinnerPanel(self, self.level_ref)
        self.spinner_panel.zoom_in_triggered.connect(self.level_view.zoom_in)
        self.spinner_panel.zoom_out_triggered.connect(self.level_view.zoom_out)
        self.spinner_panel.object_change.connect(self.on_spin)

        self.object_list = ObjectList(self, self.level_ref, self.context_menu)

        self.object_dropdown = ObjectDropdown(self)
        self.object_dropdown.object_selected.connect(
            self._on_placeable_object_selected)

        self.level_size_bar = LevelSizeBar(self, self.level_ref)
        self.enemy_size_bar = EnemySizeBar(self, self.level_ref)

        self.jump_list = JumpList(self, self.level_ref)
        self.jump_list.add_jump.connect(self.on_jump_added)
        self.jump_list.edit_jump.connect(self.on_jump_edit)
        self.jump_list.remove_jump.connect(self.on_jump_removed)

        jump_buttons = QWidget()
        jump_buttons.setLayout(QHBoxLayout())
        jump_buttons.layout().setContentsMargins(0, 0, 0, 0)

        add_jump_button = QPushButton("Add Jump")
        add_jump_button.clicked.connect(self.on_jump_added)

        set_jump_destination_button = QPushButton("Set Jump Destination")
        set_jump_destination_button.clicked.connect(self._show_jump_dest)

        jump_buttons.layout().addWidget(add_jump_button)
        jump_buttons.layout().addWidget(set_jump_destination_button)

        splitter = QSplitter(self)
        splitter.setOrientation(Qt.Vertical)

        splitter.addWidget(self.object_list)
        splitter.setStretchFactor(0, 1)
        splitter.addWidget(self.jump_list)
        splitter.addWidget(jump_buttons)

        splitter.setChildrenCollapsible(False)

        level_toolbar = QToolBar("Level Info Toolbar", self)
        level_toolbar.setContextMenuPolicy(Qt.PreventContextMenu)
        level_toolbar.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        level_toolbar.setOrientation(Qt.Horizontal)
        level_toolbar.setFloatable(False)

        level_toolbar.addWidget(self.spinner_panel)
        level_toolbar.addWidget(self.object_dropdown)
        level_toolbar.addWidget(self.level_size_bar)
        level_toolbar.addWidget(self.enemy_size_bar)
        level_toolbar.addWidget(splitter)

        level_toolbar.setAllowedAreas(Qt.LeftToolBarArea | Qt.RightToolBarArea)

        self.addToolBar(Qt.RightToolBarArea, level_toolbar)

        self.object_toolbar = ObjectToolBar(self)
        self.object_toolbar.object_selected.connect(
            self._on_placeable_object_selected)

        object_toolbar = QToolBar("Object Toolbar", self)
        object_toolbar.setContextMenuPolicy(Qt.PreventContextMenu)
        object_toolbar.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        object_toolbar.setFloatable(False)

        object_toolbar.addWidget(self.object_toolbar)
        object_toolbar.setAllowedAreas(Qt.LeftToolBarArea
                                       | Qt.RightToolBarArea)

        self.addToolBar(Qt.LeftToolBarArea, object_toolbar)

        self.menu_toolbar = QToolBar("Menu Toolbar", self)
        self.menu_toolbar.setOrientation(Qt.Horizontal)
        self.menu_toolbar.setIconSize(QSize(20, 20))

        self.menu_toolbar.addAction(icon("settings.svg"),
                                    "Editor Settings").triggered.connect(
                                        self._on_show_settings)
        self.menu_toolbar.addSeparator()
        self.menu_toolbar.addAction(
            icon("folder.svg"), "Open ROM").triggered.connect(self.on_open_rom)
        self.menu_toolbar.addAction(
            icon("save.svg"), "Save Level").triggered.connect(self.on_save_rom)
        self.menu_toolbar.addSeparator()

        self.undo_action = self.menu_toolbar.addAction(icon("rotate-ccw.svg"),
                                                       "Undo Action")
        self.undo_action.triggered.connect(self.level_ref.undo)
        self.undo_action.setEnabled(False)
        self.redo_action = self.menu_toolbar.addAction(icon("rotate-cw.svg"),
                                                       "Redo Action")
        self.redo_action.triggered.connect(self.level_ref.redo)
        self.redo_action.setEnabled(False)

        self.menu_toolbar.addSeparator()
        play_action = self.menu_toolbar.addAction(icon("play-circle.svg"),
                                                  "Play Level")
        play_action.triggered.connect(self.on_play)
        play_action.setWhatsThis(
            "Opens an emulator with the current Level set to 1-1.\nSee Settings."
        )
        self.menu_toolbar.addSeparator()
        self.menu_toolbar.addAction(icon("zoom-out.svg"),
                                    "Zoom Out").triggered.connect(
                                        self.level_view.zoom_out)
        self.menu_toolbar.addAction(icon("zoom-in.svg"),
                                    "Zoom In").triggered.connect(
                                        self.level_view.zoom_in)
        self.menu_toolbar.addSeparator()
        header_action = self.menu_toolbar.addAction(icon("tool.svg"),
                                                    "Edit Level Header")
        header_action.triggered.connect(self.on_header_editor)
        header_action.setWhatsThis(
            "<b>Header Editor</b><br/>"
            "Many configurations regarding the level are done in its header, like the length of "
            "the timer, or where and how Mario enters the level.<br/>")

        self.jump_destination_action = self.menu_toolbar.addAction(
            icon("arrow-right-circle.svg"), "Go to Jump Destination")
        self.jump_destination_action.triggered.connect(
            self._go_to_jump_destination)
        self.jump_destination_action.setWhatsThis(
            "Opens the level, that can be reached from this one, e.g. by entering a pipe."
        )

        self.menu_toolbar.addSeparator()

        whats_this_action = QWhatsThis.createAction()
        whats_this_action.setWhatsThis(
            "Click on parts of the editor, to receive help information.")
        whats_this_action.setIcon(icon("help-circle.svg"))
        whats_this_action.setText("Starts 'What's this?' mode")
        self.menu_toolbar.addAction(whats_this_action)

        self.menu_toolbar.addSeparator()
        self.warning_list = WarningList(self, self.level_ref, self.level_view,
                                        self.object_list)

        warning_action = self.menu_toolbar.addAction(
            icon("alert-triangle.svg"), "Warning Panel")
        warning_action.setWhatsThis("Shows a list of warnings.")
        warning_action.triggered.connect(self.warning_list.show)
        warning_action.setDisabled(True)

        self.warning_list.warnings_updated.connect(warning_action.setEnabled)

        self.addToolBar(Qt.TopToolBarArea, self.menu_toolbar)

        self.status_bar = ObjectStatusBar(self, self.level_ref)
        self.setStatusBar(self.status_bar)

        self.delete_shortcut = QShortcut(QKeySequence(Qt.Key_Delete), self,
                                         self.remove_selected_objects)

        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_X), self, self._cut_objects)
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_C), self, self._copy_objects)
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_V), self, self._paste_objects)

        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Z), self, self.level_ref.undo)
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Y), self, self.level_ref.redo)
        QShortcut(QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_Z), self,
                  self.level_ref.redo)

        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Plus), self,
                  self.level_view.zoom_in)
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Minus), self,
                  self.level_view.zoom_out)

        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_A), self,
                  self.level_view.select_all)
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_L), self,
                  self.object_dropdown.setFocus)

        self.on_open_rom(path_to_rom)

        self.showMaximized()
Пример #37
0
    def __init__(self, Dashboard: QMainWindow):

        # Set Window parameters
        Dashboard.setWindowTitle("ASL Tools - Tableau de bord")
        Dashboard.setWindowFlag(Qt.Window)

        # Main frame
        frame = QWidget(Dashboard)
        self.h_layout = QHBoxLayout(frame)

        # Menubar
        menubar = Dashboard.menuBar()
        menu_file: QMenu = menubar.addMenu("Fichier")
        self.action_file_new = QAction("Nouveau", menubar)
        self.action_file_new.setIcon(QIcon(":/images/new-file.svg"))
        self.action_file_new.setShortcut("Ctrl+N")
        menu_file.addAction(self.action_file_new)
        self.action_file_open = QAction("Ouvrir", menubar)
        self.action_file_open.setIcon(QIcon(":/images/open-file.svg"))
        self.action_file_open.setShortcut("Ctrl+O")
        menu_file.addAction(self.action_file_open)
        self.action_file_save = QAction("Enregistrer", menubar)
        self.action_file_save.setIcon(QIcon(":/images/save.svg"))
        self.action_file_save.setShortcut("Ctrl+S")
        menu_file.addAction(self.action_file_save)
        self.action_file_saveas = QAction("Enregistrer sous", menubar)
        self.action_file_saveas.setIcon(QIcon(":/images/save-as.svg"))
        self.action_file_saveas.setShortcut("Ctrl+Shift+S")
        menu_file.addAction(self.action_file_saveas)
        menu_file.addSeparator()
        self.action_file_export = QAction("Exporter", menubar)
        self.action_file_export.setIcon(QIcon(":/images/export.svg"))
        menu_file.addAction(self.action_file_export)
        menu_file.addSeparator()
        self.action_file_quit = QAction("Quitter", menubar)
        self.action_file_quit.setIcon(QIcon(":/images/quit.svg"))
        menu_file.addAction(self.action_file_quit)
        menu_edit: QMenu = menubar.addMenu("Edition")
        self.action_edit_copy = QAction("Copier", menubar)
        self.action_edit_copy.setIcon(QIcon(":/images/copy.svg"))
        self.action_edit_copy.setShortcut("Alt+C")
        menu_edit.addAction(self.action_edit_copy)
        self.action_edit_paste = QAction("Coller", menubar)
        self.action_edit_paste.setIcon(QIcon(":/images/paste.svg"))
        self.action_edit_paste.setShortcut("Alt+V")
        menu_edit.addAction(self.action_edit_paste)
        self.h_layout.setMenuBar(menubar)

        # Spacer
        spacerItem = QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding,
                                 QtWidgets.QSizePolicy.Minimum)
        self.h_layout.addItem(spacerItem)
        self.gridLayout = QtWidgets.QGridLayout()
        self.list = QtWidgets.QListWidget(frame)
        self.list.setObjectName("list")
        self.gridLayout.addWidget(self.list, 2, 0, 1, 1)
        self.gridLayout_4 = QtWidgets.QGridLayout()
        self.gridLayout_4.setObjectName("gridLayout_4")
        self.label_e_pmus_hld = QtWidgets.QLabel(frame)
        self.label_e_pmus_hld.setMinimumSize(QtCore.QSize(0, 20))
        self.label_e_pmus_hld.setObjectName("label_e_pmus_hld")
        self.gridLayout_4.addWidget(self.label_e_pmus_hld, 14, 0, 1, 1)
        self.e_pmus_inc = QtWidgets.QSpinBox(frame)
        self.e_pmus_inc.setMaximum(100)
        self.e_pmus_inc.setObjectName("e_pmus_inc")
        self.gridLayout_4.addWidget(self.e_pmus_inc, 13, 1, 1, 1)
        self.resistance = QtWidgets.QSpinBox(frame)
        self.resistance.setMaximum(500)
        self.resistance.setObjectName("resistance")
        self.gridLayout_4.addWidget(self.resistance, 3, 1, 1, 1)
        self.label_e_pmus = QtWidgets.QLabel(frame)
        self.label_e_pmus.setMinimumSize(QtCore.QSize(0, 20))
        self.label_e_pmus.setObjectName("label_e_pmus")
        self.gridLayout_4.addWidget(self.label_e_pmus, 12, 0, 1, 1)
        self.respi_rate = QtWidgets.QSpinBox(frame)
        self.respi_rate.setMaximum(500)
        self.respi_rate.setObjectName("respi_rate")
        self.gridLayout_4.addWidget(self.respi_rate, 4, 1, 1, 1)
        self.e_pmus_rel = QtWidgets.QSpinBox(frame)
        self.e_pmus_rel.setMaximum(100)
        self.e_pmus_rel.setObjectName("e_pmus_rel")
        self.gridLayout_4.addWidget(self.e_pmus_rel, 15, 1, 1, 1)
        self.e_pmus = QtWidgets.QSpinBox(frame)
        self.e_pmus.setMaximum(100)
        self.e_pmus.setObjectName("e_pmus")
        self.gridLayout_4.addWidget(self.e_pmus, 12, 1, 1, 1)
        self.label_e_pmus_inc = QtWidgets.QLabel(frame)
        self.label_e_pmus_inc.setMinimumSize(QtCore.QSize(0, 20))
        self.label_e_pmus_inc.setObjectName("label_e_pmus_inc")
        self.gridLayout_4.addWidget(self.label_e_pmus_inc, 13, 0, 1, 1)
        self.e_pmus_hld = QtWidgets.QSpinBox(frame)
        self.e_pmus_hld.setMaximum(100)
        self.e_pmus_hld.setObjectName("e_pmus_hld")
        self.gridLayout_4.addWidget(self.e_pmus_hld, 14, 1, 1, 1)
        self.enabled = QtWidgets.QCheckBox(frame)
        self.enabled.setText("")
        self.enabled.setObjectName("enabled")
        self.gridLayout_4.addWidget(self.enabled, 0, 1, 1, 1)
        spacerItem1 = QSpacerItem(20, 30, QtWidgets.QSizePolicy.Minimum,
                                  QtWidgets.QSizePolicy.Minimum)
        self.gridLayout_4.addItem(spacerItem1, 16, 0, 1, 1)
        self.label_i_pmus_inc = QtWidgets.QLabel(frame)
        self.label_i_pmus_inc.setMinimumSize(QtCore.QSize(0, 20))
        self.label_i_pmus_inc.setObjectName("label_i_pmus_inc")
        self.gridLayout_4.addWidget(self.label_i_pmus_inc, 8, 0, 1, 1)
        self.label_i_pmus_hld = QtWidgets.QLabel(frame)
        self.label_i_pmus_hld.setMinimumSize(QtCore.QSize(0, 20))
        self.label_i_pmus_hld.setObjectName("label_i_pmus_hld")
        self.gridLayout_4.addWidget(self.label_i_pmus_hld, 9, 0, 1, 1)
        self.label_i_pmus = QtWidgets.QLabel(frame)
        self.label_i_pmus.setMinimumSize(QtCore.QSize(0, 20))
        self.label_i_pmus.setObjectName("label_i_pmus")
        self.gridLayout_4.addWidget(self.label_i_pmus, 7, 0, 1, 1)
        spacerItem2 = QSpacerItem(20, 30, QtWidgets.QSizePolicy.Minimum,
                                  QtWidgets.QSizePolicy.Minimum)
        self.gridLayout_4.addItem(spacerItem2, 6, 0, 1, 1)
        self.i_pmus_inc = QtWidgets.QSpinBox(frame)
        self.i_pmus_inc.setMaximum(100)
        self.i_pmus_inc.setObjectName("i_pmus_inc")
        self.gridLayout_4.addWidget(self.i_pmus_inc, 8, 1, 1, 1)
        spacerItem3 = QSpacerItem(20, 30, QtWidgets.QSizePolicy.Minimum,
                                  QtWidgets.QSizePolicy.Minimum)
        self.gridLayout_4.addItem(spacerItem3, 11, 0, 1, 1)
        self.i_pmus_rel = QtWidgets.QSpinBox(frame)
        self.i_pmus_rel.setMaximum(100)
        self.i_pmus_rel.setObjectName("i_pmus_rel")
        self.gridLayout_4.addWidget(self.i_pmus_rel, 10, 1, 1, 1)
        self.i_pmus = QtWidgets.QSpinBox(frame)
        self.i_pmus.setMaximum(100)
        self.i_pmus.setObjectName("i_pmus")
        self.gridLayout_4.addWidget(self.i_pmus, 7, 1, 1, 1)
        self.i_pmus_hld = QtWidgets.QSpinBox(frame)
        self.i_pmus_hld.setMaximum(100)
        self.i_pmus_hld.setObjectName("i_pmus_hld")
        self.gridLayout_4.addWidget(self.i_pmus_hld, 9, 1, 1, 1)
        self.compliance = QtWidgets.QSpinBox(frame)
        self.compliance.setMaximum(500)
        self.compliance.setObjectName("compliance")
        self.gridLayout_4.addWidget(self.compliance, 2, 1, 1, 1)
        self.label_enabled = QtWidgets.QLabel(frame)
        self.label_enabled.setMinimumSize(QtCore.QSize(0, 20))
        self.label_enabled.setObjectName("label_enabled")
        self.gridLayout_4.addWidget(self.label_enabled, 0, 0, 1, 1)
        self.label_crf = QtWidgets.QLabel(frame)
        self.label_crf.setMinimumSize(QtCore.QSize(0, 20))
        self.label_crf.setObjectName("label_crf")
        self.gridLayout_4.addWidget(self.label_crf, 17, 0, 1, 1)
        self.label_resistance = QtWidgets.QLabel(frame)
        self.label_resistance.setMinimumSize(QtCore.QSize(0, 20))
        self.label_resistance.setObjectName("label_resistance")
        self.gridLayout_4.addWidget(self.label_resistance, 3, 0, 1, 1)
        self.label_respi_rate = QtWidgets.QLabel(frame)
        self.label_respi_rate.setMinimumSize(QtCore.QSize(0, 20))
        self.label_respi_rate.setObjectName("label_respi_rate")
        self.gridLayout_4.addWidget(self.label_respi_rate, 4, 0, 1, 1)
        self.label_e_pmus_rel = QtWidgets.QLabel(frame)
        self.label_e_pmus_rel.setMinimumSize(QtCore.QSize(0, 20))
        self.label_e_pmus_rel.setObjectName("label_e_pmus_rel")
        self.gridLayout_4.addWidget(self.label_e_pmus_rel, 15, 0, 1, 1)
        self.label_i_pmus_rel = QtWidgets.QLabel(frame)
        self.label_i_pmus_rel.setMinimumSize(QtCore.QSize(0, 20))
        self.label_i_pmus_rel.setObjectName("label_i_pmus_rel")
        self.gridLayout_4.addWidget(self.label_i_pmus_rel, 10, 0, 1, 1)
        self.crf = QtWidgets.QDoubleSpinBox(frame)
        self.crf.setDecimals(1)
        self.crf.setSingleStep(0.1)
        self.crf.setObjectName("crf")
        self.gridLayout_4.addWidget(self.crf, 17, 1, 1, 1)
        self.label_compliance = QtWidgets.QLabel(frame)
        self.label_compliance.setMinimumSize(QtCore.QSize(0, 20))
        self.label_compliance.setObjectName("label_compliance")
        self.gridLayout_4.addWidget(self.label_compliance, 2, 0, 1, 1)
        spacerItem4 = QSpacerItem(20, 30, QtWidgets.QSizePolicy.Minimum,
                                  QtWidgets.QSizePolicy.Minimum)
        self.gridLayout_4.addItem(spacerItem4, 1, 0, 1, 1)
        spacerItem4 = QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum,
                                  QtWidgets.QSizePolicy.Expanding)
        self.gridLayout_4.addItem(spacerItem4, 18, 0, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_4, 2, 1, 1, 1)
        self.label_file = QtWidgets.QLabel(frame)
        self.label_file.setTextFormat(QtCore.Qt.PlainText)
        self.label_file.setAlignment(QtCore.Qt.AlignCenter)
        self.label_file.setObjectName("label_file")
        self.gridLayout.addWidget(self.label_file, 0, 0, 1, 3)
        self.verticalLayout_2 = QtWidgets.QVBoxLayout()
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.label = QtWidgets.QLabel(frame)
        self.label.setObjectName("label")
        self.verticalLayout_2.addWidget(self.label)
        self.comment = QtWidgets.QTextEdit(frame)
        self.comment.setObjectName("comment")
        self.verticalLayout_2.addWidget(self.comment)
        self.gridLayout.addLayout(self.verticalLayout_2, 2, 2, 1, 1)
        self.h_layout.addLayout(self.gridLayout)
        spacerItem5 = QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Minimum)
        self.h_layout.addItem(spacerItem5)

        # Set size and position
        w, h = self.h_layout.sizeHint().toTuple()
        w_s, h_s = QApplication.primaryScreen().size().toTuple()
        x = round(w_s / 2 - w / 2)
        y = round(h_s / 2 - h / 2)
        Dashboard.setCentralWidget(frame)
        Dashboard.resize(w, h)
        Dashboard.move(x, y)

        self.retranslateUi(Dashboard)
        QtCore.QMetaObject.connectSlotsByName(Dashboard)
        Dashboard.setTabOrder(self.list, self.enabled)
        Dashboard.setTabOrder(self.enabled, self.compliance)
        Dashboard.setTabOrder(self.compliance, self.resistance)
        Dashboard.setTabOrder(self.resistance, self.respi_rate)
        Dashboard.setTabOrder(self.respi_rate, self.i_pmus)
        Dashboard.setTabOrder(self.i_pmus, self.i_pmus_inc)
        Dashboard.setTabOrder(self.i_pmus_inc, self.i_pmus_hld)
        Dashboard.setTabOrder(self.i_pmus_hld, self.i_pmus_rel)
        Dashboard.setTabOrder(self.i_pmus_rel, self.e_pmus)
        Dashboard.setTabOrder(self.e_pmus, self.e_pmus_inc)
        Dashboard.setTabOrder(self.e_pmus_inc, self.e_pmus_hld)
        Dashboard.setTabOrder(self.e_pmus_hld, self.e_pmus_rel)
        Dashboard.setTabOrder(self.e_pmus_rel, self.crf)
Пример #38
0
    def init_ui(self):
        main_splitter = QSplitter(self, Qt.Horizontal)

        left_pane = QWidget(self)
        left_pane.setMaximumWidth(370)
        left_v_box = QVBoxLayout(self)
        left_pane.setLayout(left_v_box)

        right_pane = QWidget(self)
        right_v_box = QVBoxLayout(self)
        right_pane.setLayout(right_v_box)

        main_splitter.addWidget(left_pane)
        main_splitter.addWidget(right_pane)

        # ===== Details =====
        self.group_box_details = QuickyGui.create_group_box(self, "Details")

        nif_files_loaded = QuickyGui.create_label(self, ".nif files loaded")
        self.lcd_nif_files_loaded = QuickyGui.create_lcd(self)

        nif_files_ignored = QuickyGui.create_label(self, ".nif files ignored")
        self.lcd_nif_files_ignored = QuickyGui.create_lcd(self)

        self.nif_files_list_widget = NifList(self)
        self.ignored_nif_files_list_widget = NifList(self)
        self.update_nif_files()

        self.group_box_legends = QuickyGui.create_group_box(self, "Legends")
        instructions_4 = QuickyGui.create_label(
            self, "Green - File correctly processed\n")
        instructions_4.setStyleSheet(
            "QLabel { color : darkGreen; font-weight : bold }")
        instructions_5 = QuickyGui.create_label(self,
                                                "Blue - File is processing\n")
        instructions_5.setStyleSheet(
            "QLabel { color : darkBlue; font-weight : bold }")
        instructions_6 = QuickyGui.create_label(
            self, "Red - File ignored/with errors.")
        instructions_6.setStyleSheet(
            "QLabel { color : darkRed; font-weight : bold }")
        instructions_7 = QuickyGui.create_label(
            self, "Reasons : "
            "\n * Check log to see if there is an error concerning this file, or try to open it with NifSkope"
            "\n * Otherwise it couldn't find a NiTriShape block whose name is specified in provided keywords. It may be normal, if there is no body part. But if there is and you want this file to be processed by the tool, then you must add the corresponding NiTriShape block's name (use nikskope to find it) to the list of keywords, located in the .ini file, situated alongside the executable."
            " If you have Nikskope, you can open the file by double-clicking on in, in the list view, or from your explorer. Restart the tool to load the new .ini file."
        )
        instructions_7.setStyleSheet("QLabel { color : darkRed}")

        vbox = QVBoxLayout()
        vbox.setSpacing(5)
        vbox.addWidget(instructions_4)
        vbox.addWidget(instructions_5)
        vbox.addWidget(instructions_6)
        vbox.addWidget(instructions_7)

        self.group_box_legends.setLayout(vbox)

        vbox = QVBoxLayout(self)

        hbox = QHBoxLayout(self)
        hbox.addWidget(nif_files_loaded)
        hbox.addWidget(self.lcd_nif_files_loaded)

        vbox.addItem(hbox)
        vbox.addWidget(self.nif_files_list_widget)

        hbox = QHBoxLayout(self)
        hbox.addWidget(nif_files_ignored)
        hbox.addWidget(self.lcd_nif_files_ignored)
        vbox.addItem(hbox)

        vbox.addWidget(self.ignored_nif_files_list_widget)
        vbox.addWidget(self.group_box_legends)

        self.group_box_details.setLayout(vbox)
        right_v_box.addWidget(self.group_box_details)

        # ===== STEP 0 - Instructions =====
        self.group_box_instructions = QuickyGui.create_group_box(
            self, "Instructions")

        instructions_1 = QuickyGui.create_label(
            self,
            "I. By clicking on \"Scan Folder\", all .nif contained in this folder (subfolders and so on), will be added to the set of files to be processed. You can scan multiple folder, by clicking again. All files not already present will be added."
        )
        instructions_2 = QuickyGui.create_label(
            self,
            "II. Once your desired parameters are set, click on \"Apply\". Bewary, the process is quite slow (just opening the file is quite consuming somehow)"
        )

        vbox = QVBoxLayout()
        vbox.setSpacing(5)
        vbox.addWidget(instructions_1)
        vbox.addWidget(instructions_2)

        self.group_box_instructions.setLayout(vbox)
        left_v_box.addWidget(self.group_box_instructions)

        # ===== STEP I - Load Files =====
        self.group_box_load_files = QuickyGui.create_group_box(
            self, "STEP I - Load .nif files")

        button_load_files = QuickyGui.create_button(self, "Scan Folder",
                                                    self.action_load_files)
        button_clear_files = QuickyGui.create_button(self,
                                                     "Clear loaded files",
                                                     self.action_clear_files)

        hbox = QHBoxLayout()
        hbox.addWidget(button_load_files)
        hbox.addWidget(button_clear_files)

        self.group_box_load_files.setLayout(hbox)
        left_v_box.addWidget(self.group_box_load_files)

        # ===== STEP II - Set parameters =====
        self.group_box_parameters = QuickyGui.create_group_box(
            self, "STEP II - Set parameters")

        vbox = QVBoxLayout()

        # Glossiness
        label_glossiness = QuickyGui.create_label(self, "Glossiness")
        self.spin_box_glossiness = QDoubleSpinBox()
        self.spin_box_glossiness.setMinimum(0)
        self.spin_box_glossiness.setMaximum(1000)
        self.spin_box_glossiness.setValue(CONFIG.getfloat("NIF", "Glossiness"))
        log.info("Glossiness target : " +
                 str(self.spin_box_glossiness.value()))

        hbox = QHBoxLayout()
        hbox.addWidget(label_glossiness)
        hbox.addWidget(self.spin_box_glossiness)
        vbox.addItem(hbox)

        # Specular Strength
        label_specular_strength = QuickyGui.create_label(
            self, "Specular Strength")
        self.spin_box_specular_strength = QDoubleSpinBox()
        self.spin_box_specular_strength.setMinimum(0)
        self.spin_box_specular_strength.setMaximum(1000)
        self.spin_box_specular_strength.setValue(
            CONFIG.getfloat("NIF", "SpecularStrength"))
        log.info("Specular Strength target : " +
                 str(self.spin_box_specular_strength.value()))

        hbox = QHBoxLayout()
        hbox.addWidget(label_specular_strength)
        hbox.addWidget(self.spin_box_specular_strength)
        vbox.addItem(hbox)

        self.group_box_parameters.setLayout(vbox)
        left_v_box.addWidget(self.group_box_parameters)

        # ===== STEP III - Apply =====
        self.group_box_apply = QuickyGui.create_group_box(
            self, "STEP III - Apply")

        button_load_files = QuickyGui.create_button(self, "Apply",
                                                    self.action_apply)

        hbox = QHBoxLayout()
        hbox.addWidget(button_load_files)

        self.group_box_apply.setLayout(hbox)
        left_v_box.addWidget(self.group_box_apply)

        # ===== Finalizing =====
        self.progress_bar = QProgressBar(self)
        left_v_box.addWidget(self.progress_bar)

        left_v_box.setSpacing(10)
        self.mainLayout.addWidget(main_splitter)
Пример #39
0
 def __init__(self, parent = None):
     QWidget.__init__(self, parent)
     self._sequence = []
     self.setAttribute(Qt.WA_AcceptTouchEvents)
     QTimer.singleShot(200, self.generateEvent)
Пример #40
0
 def setUp(self):
     super(WidgetPySignal, self).setUp()
     self.obj = Dummy()
     self.widget = QWidget()
Пример #41
0
class Window(QMainWindow):
    """Contains code for  the window that the user initially sees"""
    def __init__(self, title: str = ''):
        super().__init__()
        self.setWindowTitle(title)

        self.menu = self.menuBar()
        self.file_menu = self.menu.addMenu("File")
        self.edit_menu = self.menu.addMenu("Edit")

        self.menu_entries = []
        self.setup_menus()
        for entry in self.menu_entries:
            m, n, t, sh = entry
            self.add_menu_entry(m, n, t, sh)

        self.widget = QWidget()

        self.left = QVBoxLayout()
        self.setup_left_column()
        self.center = QVBoxLayout()
        self.setup_center_column()
        self.right = QVBoxLayout()
        self.setup_right_column()

        self.columns = QHBoxLayout()
        self.columns.addLayout(self.left)
        self.columns.addLayout(self.center)
        self.columns.addLayout(self.right)

        self.widget.setLayout(self.columns)
        self.setCentralWidget(self.widget)

    def setup_left_column(self):
        self.left.addWidget(QLabel("This is the left column"))
        pass

    def setup_center_column(self):
        self.center.addWidget(QLabel("This is the center column"))
        pass

    def setup_right_column(self):
        self.right.addWidget(QLabel("This is the right column"))
        pass

    def setup_menus(self):
        self.menu_entries += [(self.file_menu, 'Exit', self.exit_app, 'Ctrl+Q')
                              ]

    def add_menu_entry(self,
                       menu: QMenuBar,
                       name: str,
                       trigger: Callable,
                       shortcut: str = ''):
        action = QAction(name, self)

        if len(shortcut) > 0:
            action.setShortcut(shortcut)

        action.triggered.connect(trigger)

        menu.addAction(action)

    @Slot()
    def exit_app(self, checked):
        QApplication.quit()
Пример #42
0
 def __init__(self):
     QWidget.__init__(self)
Пример #43
0
    def __init__(self, parent):
        super(LevelSelector, self).__init__(parent)

        self.setWindowTitle("Level Selector")
        self.setModal(True)

        self.level_name = ""

        self.object_set = 0
        self.object_data_offset = 0x0
        self.enemy_data_offset = 0x0

        self.world_label = QLabel(parent=self, text="World")
        self.world_list = QListWidget(parent=self)
        self.world_list.addItems(WORLD_ITEMS)

        self.world_list.itemDoubleClicked.connect(self.on_ok)
        self.world_list.itemSelectionChanged.connect(self.on_world_click)

        self.level_label = QLabel(parent=self, text="Level")
        self.level_list = QListWidget(parent=self)

        self.level_list.itemDoubleClicked.connect(self.on_ok)
        self.level_list.itemSelectionChanged.connect(self.on_level_click)

        self.enemy_data_label = QLabel(parent=self, text="Enemy Data")
        self.enemy_data_spinner = Spinner(parent=self)

        self.object_data_label = QLabel(parent=self, text="Object Data")
        self.object_data_spinner = Spinner(self)

        self.object_set_label = QLabel(parent=self, text="Object Set")
        self.object_set_dropdown = QComboBox(self)
        self.object_set_dropdown.addItems(OBJECT_SET_ITEMS)

        self.button_ok = QPushButton("Ok", self)
        self.button_ok.clicked.connect(self.on_ok)
        self.button_cancel = QPushButton("Cancel", self)
        self.button_cancel.clicked.connect(self.close)

        stock_level_widget = QWidget()
        stock_level_layout = QGridLayout(stock_level_widget)

        stock_level_layout.addWidget(self.world_label, 0, 0)
        stock_level_layout.addWidget(self.level_label, 0, 1)

        stock_level_layout.addWidget(self.world_list, 1, 0)
        stock_level_layout.addWidget(self.level_list, 1, 1)

        self.source_selector = QTabWidget()
        self.source_selector.addTab(stock_level_widget, "Stock Levels")

        for world_number in range(WORLD_COUNT):
            world_number += 1

            world_map_select = WorldMapLevelSelect(world_number)
            world_map_select.level_selected.connect(
                self._on_level_selected_via_world_map)

            self.source_selector.addTab(world_map_select,
                                        f"World {world_number}")

        data_layout = QGridLayout()

        data_layout.addWidget(self.enemy_data_label, 0, 0)
        data_layout.addWidget(self.object_data_label, 0, 1)
        data_layout.addWidget(self.enemy_data_spinner, 1, 0)
        data_layout.addWidget(self.object_data_spinner, 1, 1)

        data_layout.addWidget(self.object_set_label, 2, 0)
        data_layout.addWidget(self.object_set_dropdown, 2, 1)

        data_layout.addWidget(self.button_ok, 3, 0)
        data_layout.addWidget(self.button_cancel, 3, 1)

        main_layout = QVBoxLayout()
        main_layout.addWidget(self.source_selector)
        main_layout.addLayout(data_layout)

        self.setLayout(main_layout)

        self.world_list.setCurrentRow(1)  # select Level 1-1
        self.on_world_click()
Пример #44
0
    def __init__(self, test_name: str, reference_image: QPixmap,
                 generated_image: QPixmap):
        super(ApprovalDialog, self).__init__()

        self.setWindowTitle(test_name)

        main_layout = QVBoxLayout(self)

        ref_image = QLabel()
        ref_image.setPixmap(reference_image)

        gen_image = QLabel()
        gen_image.setPixmap(generated_image)

        scroll_area = QScrollArea()

        self.layout().addWidget(scroll_area)

        screen_width, screen_height = QGuiApplication.primaryScreen().size(
        ).toTuple()

        if reference_image.width() + gen_image.width() >= screen_width:
            self.image_layout = QVBoxLayout()
        else:
            self.image_layout = QHBoxLayout()

        self.image_layout.addStretch()
        self.image_layout.addWidget(ref_image)
        self.image_layout.addWidget(gen_image)
        self.image_layout.addStretch()

        scroll_area.setWidget(QWidget())
        scroll_area.setWidgetResizable(True)

        scroll_area.widget().setSizePolicy(QSizePolicy.MinimumExpanding,
                                           QSizePolicy.MinimumExpanding)
        scroll_area.setSizePolicy(QSizePolicy.MinimumExpanding,
                                  QSizePolicy.Maximum)

        scroll_area.widget().setLayout(self.image_layout)

        def _sizeHint():
            orig_size = scroll_area.widget().sizeHint()

            orig_size.setHeight(orig_size.height() + 20)
            orig_size.setWidth(orig_size.width() + 20)

            if orig_size.width() > screen_width - 20:
                orig_size.setWidth(screen_width - 20)

            if orig_size.height() > screen_height - 20:
                orig_size.setHeight(screen_height - 20)

            return orig_size

        scroll_area.sizeHint = _sizeHint

        button_box = QDialogButtonBox()

        button_box.addButton(
            "Reject", QDialogButtonBox.RejectRole).clicked.connect(self.reject)
        button_box.addButton(QDialogButtonBox.Ignore).clicked.connect(
            self._on_ignore)

        button_box.addButton("Accept as new Reference",
                             QDialogButtonBox.ApplyRole).clicked.connect(
                                 self._on_overwrite)

        main_layout.addWidget(scroll_area)
        main_layout.addWidget(button_box, alignment=Qt.AlignCenter)
Пример #45
0
 def __init__(self):
     QWidget.__init__(self)
     self.penFromEnum = None
     self.penFromInteger = None
Пример #46
0
    def __init__(self, machine, material_dict, is_stator=False):
        """Initialize the widget according to machine

        Parameters
        ----------
        self : SLamParam
            A SLamParam widget
        machine : Machine
            current machine to edit
        material_dict: dict
            Materials dictionary (library + machine)
        is_stator : bool
            To adapt the GUI to set either the stator or the rotor
        """

        # Build the interface according to the .ui file
        QWidget.__init__(self)
        self.setupUi(self)

        # Saving arguments
        self.machine = machine
        self.material_dict = material_dict
        self.is_stator = is_stator

        # Set FloatEdit unit
        self.lf_L1.unit = "m"
        self.lf_Wrvd.unit = "m"
        self.u = gui_option.unit
        self.unit_L1.setText(self.u.get_m_name())
        self.unit_Wrvd.setText(self.u.get_m_name())

        # Get the correct object to set
        if self.is_stator:
            self.obj = machine.stator
            if self.obj.Kf1 is None:
                self.obj.Kf1 = 0.95  # Defaut value
        else:
            self.obj = machine.rotor
            if self.obj.L1 is None:
                # Default value for rotor is the stator one
                self.obj.L1 = self.machine.stator.L1
            if self.obj.Kf1 is None:
                # Default value for rotor is the stator one
                self.obj.Kf1 = self.machine.stator.Kf1
        if self.obj.axial_vent is None:
            self.obj.axial_vent = list()

        self.w_mat.update(self.obj, "mat_type", self.material_dict)

        self.lf_L1.setValue(self.obj.L1)
        self.lf_Kf1.setValue(self.obj.Kf1)

        # Ventilation setup
        self.update_avd_text()
        if len(self.obj.axial_vent) > 0 and self.obj.axial_vent[0].Zh > 0:
            self.g_ax_vent.setChecked(True)

        if self.obj.Nrvd is None or self.obj.Nrvd == 0:
            self.si_Nrvd.setValue(0)
        else:
            self.si_Nrvd.setValue(self.obj.Nrvd)
            self.g_rad_vent.setChecked(True)

        if self.obj.Wrvd is None or self.obj.Wrvd == 0:
            self.lf_Wrvd.setValue(0)
        else:
            self.lf_Wrvd.setValue(self.obj.Wrvd)
            self.g_rad_vent.setChecked(True)

        self.update_lenght()  # Update out_length if possible

        # Connecting the signal
        self.lf_L1.editingFinished.connect(self.set_L1)
        self.lf_Kf1.editingFinished.connect(self.set_Kf1)
        self.g_rad_vent.toggled.connect(self.enable_rad_vent)
        self.g_ax_vent.toggled.connect(self.enable_ax_vent)
        self.b_axial_duct.clicked.connect(self.set_avd)
        self.si_Nrvd.editingFinished.connect(self.set_Nrvd)
        self.lf_Wrvd.editingFinished.connect(self.set_Wrvd)
        self.b_plot.clicked.connect(self.s_plot)
        self.w_mat.saveNeeded.connect(self.emit_save)
Пример #47
0
 def __init__(self, parent):
     self.parent = parent
     QWidget.__init__(self)
     self.initUI()
Пример #48
0
    def __init__(self):
        QMainWindow.__init__(self)
        # Title and dimensions
        self.setWindowTitle("Patterns detection")
        self.setGeometry(0, 0, 800, 500)

        # Main menu bar
        self.menu = self.menuBar()
        self.menu_file = self.menu.addMenu("File")
        exit = QAction("Exit", self, triggered=qApp.quit)
        self.menu_file.addAction(exit)

        self.menu_about = self.menu.addMenu("&About")
        about = QAction("About Qt", self, shortcut=QKeySequence(QKeySequence.HelpContents),
                        triggered=qApp.aboutQt)
        self.menu_about.addAction(about)

        # Create a label for the display camera
        self.label = QLabel(self)
        self.label.setFixedSize(640, 480)

        # Thread in charge of updating the image
        self.th = Thread(self)
        self.th.finished.connect(self.close)
        self.th.updateFrame.connect(self.setImage)

        # Model group
        self.group_model = QGroupBox("Trained model")
        self.group_model.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
        model_layout = QHBoxLayout()

        self.combobox = QComboBox()
        for xml_file in os.listdir(cv2.data.haarcascades):
            if xml_file.endswith(".xml"):
                self.combobox.addItem(xml_file)

        model_layout.addWidget(QLabel("File:"), 10)
        model_layout.addWidget(self.combobox, 90)
        self.group_model.setLayout(model_layout)

        # Buttons layout
        buttons_layout = QHBoxLayout()
        self.button1 = QPushButton("Start")
        self.button2 = QPushButton("Stop/Close")
        self.button1.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
        self.button2.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
        buttons_layout.addWidget(self.button2)
        buttons_layout.addWidget(self.button1)

        right_layout = QHBoxLayout()
        right_layout.addWidget(self.group_model, 1)
        right_layout.addLayout(buttons_layout, 1)

        # Main layout
        layout = QVBoxLayout()
        layout.addWidget(self.label)
        layout.addLayout(right_layout)

        # Central widget
        widget = QWidget(self)
        widget.setLayout(layout)
        self.setCentralWidget(widget)

        # Connections
        self.button1.clicked.connect(self.start)
        self.button2.clicked.connect(self.kill_thread)
        self.button2.setEnabled(False)
        self.combobox.currentTextChanged.connect(self.set_model)
Пример #49
0
    def loadGui(self):

        self.pixmap = None
        self.zoom = 100

        self.loadModel()

        # Create viewing area
        self.frame = QScrollArea(self)
        cw = QWidget()
        self.frame.setCornerWidget(cw)
        self.frame.setAlignment(QtCore.Qt.AlignCenter)
        self.frame.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.setCentralWidget(self.frame)

        # connect pinch gesture (OSX)
        self.grabGesture(QtCore.Qt.PinchGesture)

        # Create plot image
        self.plotIm = PlotImage(self.model, self.frame, self)
        self.frame.setWidget(self.plotIm)

        # Dock
        self.dock = DomainDock(self.model, self.font_metric, self)
        self.dock.setObjectName("Domain Options Dock")
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.dock)

        # Tally Dock
        self.tallyDock = TallyDock(self.model, self.font_metric, self)
        self.tallyDock.update()
        self.tallyDock.setObjectName("Tally Options Dock")
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.tallyDock)

        # Color DialogtallyDock
        self.colorDialog = ColorDialog(self.model, self.font_metric, self)
        self.colorDialog.hide()

        # Tools
        self.exportDataDialog = ExportDataDialog(self.model, self.font_metric, self)

        # Restore Window Settings
        self.restoreWindowSettings()

        # Create menubar
        self.createMenuBar()
        self.updateEditMenu()

        # Status Bar
        self.coord_label = QLabel()
        self.statusBar().addPermanentWidget(self.coord_label)
        self.coord_label.hide()

        # Keyboard overlay
        self.shortcutOverlay = ShortcutsOverlay(self)
        self.shortcutOverlay.hide()

        # Load Plot
        self.statusBar().showMessage('Generating Plot...')
        self.dock.updateDock()
        self.tallyDock.update()
        self.colorDialog.updateDialogValues()
        self.statusBar().showMessage('')

        # Timer allows GUI to render before plot finishes loading
        QtCore.QTimer.singleShot(0, self.plotIm.generatePixmap)
        QtCore.QTimer.singleShot(0, self.showCurrentView)
Пример #50
0
class mainWindow(QObject):

    signalRun = Signal(SpiderThread)
    signalRunApi = Signal(apiTester)
    def __init__(self):
        QObject.__init__(self)  # must init parent QObject,if you want to use signal
        self.widget = QWidget()
        self.ipLabel = QLabel(self.widget)
        self.thread = QThread()
        self.worker = Worker()
        self.worker.moveToThread(self.thread)
        self.man = SpiderThread()
        self.api = apiTester()
        # 1 2:loop 3: time
        self.testStatus = [False,1,0,"ip","mac"]

        # advance config
        self.findCoreStop = True
        self.cleanCacheSet = False
        self.useApiTest = False
        self.showTestProgress = True
        self.saveTestLog = False
        self.saveLogPath = ""
        self.chromePath =  ""
        self.showChrome = False
        self.coreDumpPath = ""

        # ui form
        self.passwordLabel = QLabel(self.widget)

        self.ipLineEdit = QLineEdit(self.widget)
        self.passwordLineEdit = QLineEdit(self.widget)

        self.startBtn = QPushButton(self.widget)
        self.stopBtn = QPushButton(self.widget)

        self.messageBox = QTextEdit(self.widget)
        self.messageBox.setReadOnly(True)

        self.userLabel = QLabel(self.widget)
        self.userLineEdit = QLineEdit(self.widget)

        self.intervalLabel = QLabel(self.widget)
        self.intervalSpinBox = QSpinBox(self.widget)

        self.loopLabel = QLabel(self.widget)
        self.loopSpinBox = QSpinBox(self.widget)

        self.intervalSpinBox.setRange(0,9999)
        self.loopSpinBox.setRange(1,9999)

        self.radioReboot = QRadioButton(self.widget)
        self.radioProvision = QRadioButton(self.widget)
        self.radioFactory = QRadioButton(self.widget)

        # self.apiCheckBox = QCheckBox(self.widget)

        self.menu = QMenu()
        self.gxpAction = QAction("Classic UI")
        self.grp2602Action = QAction("Ant Design UI")
        self.gxpAction.setCheckable(True)
        self.grp2602Action.setCheckable(True)
        self.menu.addAction(self.gxpAction)
        self.menu.addAction(self.grp2602Action)
        self.webLabel = QLabel(self.widget)
        self.webBtn = QPushButton(self.widget)
        self.webBtn.setMenu(self.menu)
        self.clearBtn = QPushButton(self.widget)
        self.messageList = deque()
        self.timer = QTimer()


        self.advanceBtn = QPushButton(self.widget)
        self.infoLabel = QLabel(self.widget)

        # provision widget
        self.provWidget = QWidget(self.widget)
        self.ver1Label = QLabel(self.provWidget)
        self.ver2Label = QLabel(self.provWidget)
        self.ver3Label = QLabel(self.provWidget)
        self.ver1LineEdit = QLineEdit(self.provWidget)
        self.ver2LineEdit = QLineEdit(self.provWidget)
        self.ver3LineEdit = QLineEdit(self.provWidget)

        self.dir1Label = QLabel(self.provWidget)
        self.dir2Label = QLabel(self.provWidget)
        self.dir3Label = QLabel(self.provWidget)
        self.dir1LineEdit = QLineEdit(self.provWidget)
        self.dir2LineEdit = QLineEdit(self.provWidget)
        self.dir3LineEdit = QLineEdit(self.provWidget)

        self.radioHttp = QRadioButton(self.provWidget)
        self.radioHttps = QRadioButton(self.provWidget)
        self.radioTftp = QRadioButton(self.provWidget)
        self.radioFtp = QRadioButton(self.provWidget)
        self.radioFtps = QRadioButton(self.provWidget)
        self.radioWindow = QRadioButton(self.provWidget)

        # advance widget
        self.advanceWidget = QWidget()
        self.checkCoreBox = QCheckBox(self.advanceWidget)
        self.cleanCache = QCheckBox(self.advanceWidget)
        self.checkSaveLogBox = QCheckBox(self.advanceWidget)
        self.selectDirBtn = QPushButton(self.advanceWidget)
        self.saveDirLabel = QLabel(self.advanceWidget)
        self.saveDirLabel.setStyleSheet("background:white")
        self.checkProgressBox = QCheckBox(self.advanceWidget)
        self.advanceOkBtn = QPushButton(self.advanceWidget)
        self.selectChromeBtn = QPushButton(self.advanceWidget)
        self.chromePathLabel = QLabel(self.advanceWidget)
        self.chromePathLabel.setStyleSheet("background:white")
        self.checkShowChromeBox = QCheckBox(self.advanceWidget)
        self.chromeLabel = QLabel(self.advanceWidget)
        self.pcapLabel = QLabel(self.advanceWidget)
        self.apiCheckBox = QCheckBox(self.advanceWidget)
        self.corePathLabel = QLabel(self.advanceWidget)
        self.corePathLabel.setStyleSheet("background:white")
        self.corePathBtn = QPushButton(self.advanceWidget)

        self.interfaceMenu = QComboBox(self.advanceWidget)
        self.interfaceMenu.addItem('Default')

        self.aiOptionBox= QCheckBox(self.advanceWidget)

        a = IFACES
        print(a)
        for i in a.keys():
            print(a[i].description)
            self.interfaceMenu.addItem(a[i].description)

        # connect singal and slot
        self.startBtn.clicked.connect(self.clickedStarBtn)
        self.radioProvision.clicked.connect(self.clickedProvision)
        self.radioReboot.clicked.connect(self.clickedOthers)
        self.radioFactory.clicked.connect(self.clickedOthers)
        self.stopBtn.clicked.connect(self.clickedStopBtn)
        self.grp2602Action.triggered.connect(self.clickedGrp2602)
        self.gxpAction.triggered.connect(self.clickedGxpType)
        self.timer.timeout.connect(self.updateMessage)
        self.apiCheckBox.stateChanged.connect(self.apiTestBoxCheck)
        self.clearBtn.clicked.connect(self.clickedClearBtn)

        self.advanceBtn.clicked.connect(self.clickedAdvanceBtn)
        self.advanceOkBtn.clicked.connect(self.clickedAdvanceOkBtn)
        self.checkSaveLogBox.stateChanged.connect(self.saveLogBoxCheck)
        self.selectChromeBtn.clicked.connect(self.clickedSelectChromeBtn)
        self.selectDirBtn.clicked.connect(self.clickedSelectDirBtn)
        self.corePathBtn.clicked.connect(self.clickedCorePathBtn)

        self.worker.signalJobEnd.connect(self.slotTestStoped)
        self.worker.apiTestFinished.connect(self.slotTestStoped)
        self.signalRun.connect(self.worker.dowork)
        self.signalRunApi.connect(self.worker.doworkApi)

        # self.man.signalUpdateMessage.connect(self.pushMessage)

    def setupUI(self):
        # set text content /value
        self.widget.setWindowTitle("自动重启升降级测试工具")
        self.ipLabel.setText("初始IP:")
        self.passwordLabel.setText("密码:")
        self.startBtn.setText("开始测试")
        self.stopBtn.setText("停止测试")
        self.userLabel.setText("用户名:")
        self.intervalLabel.setText("间隔时间:")
        self.loopLabel.setText("测试次数:")
        self.intervalSpinBox.setValue(130)
        self.radioFactory.setText("恢复出厂")
        self.radioProvision.setText("升降级")
        self.radioReboot.setText("重启")
        self.ver1Label.setText("版本 1:")
        self.ver2Label.setText("版本 2:")
        self.ver3Label.setText("版本 3:")
        self.dir1Label.setText("路径 1:")
        self.dir2Label.setText("路径 2:")
        self.dir3Label.setText("路径 3:")
        self.radioHttp.setText("Http")
        self.radioHttps.setText("Https")
        self.radioTftp.setText("Tftp")
        self.radioFtp.setText("Ftp")
        self.radioFtps.setText("Ftps")
        self.apiCheckBox.setText("使用API测试,配置CoreDump下载路径")
        self.webLabel.setText("网页类型:")
        self.webBtn.setText("请选择UI类型")
        self.clearBtn.setText("清空输入")

        self.advanceWidget.setWindowTitle("高级设置")
        self.advanceBtn.setText("高级设置")
        self.checkCoreBox.setText("发现Core Dump时停止测试")
        self.cleanCache.setText("清除页面cache")
        self.checkSaveLogBox.setText("保存测试日志")
        self.selectDirBtn.setText("浏览")
        self.checkProgressBox.setText("显示底部状态条")
        self.advanceOkBtn.setText("OK")
        self.checkShowChromeBox.setText("测试时显示Chrome浏览器")
        self.selectChromeBtn.setText("浏览")
        self.chromeLabel.setText("Chrome浏览器路径")
        self.infoLabel.setText("未开始测试")
        self.pcapLabel.setText("Net Interface")
        self.corePathBtn.setText("浏览")
        self.radioWindow.setText("网页拖拽文件")
        # self.aiOptionBox.setText("AI")

        #init value
        self.saveDirLabel.hide()
        self.selectDirBtn.hide()

        self.gxpAction.setChecked(True)
        self.radioReboot.click()
        self.radioHttp.click()
        self.stopBtn.setEnabled(False)
        self.passwordLineEdit.setEchoMode(QLineEdit.PasswordEchoOnEdit)

        # set position-------------------------------
        xPos = 20
        yPos = 30
        colum2 = xPos +200

        # line 1
        self.ipLabel.move(xPos,yPos)
        self.intervalLabel.move(colum2,yPos)
        self.intervalSpinBox.move(colum2+60,yPos-2)
        self.ipLineEdit.move(xPos+50,yPos-2)

        # line 2
        line2 = yPos +40
        self.passwordLabel.move(xPos,line2)
        self.passwordLineEdit.move(xPos+50,line2-2)
        self.loopLabel.move(colum2,line2)
        self.loopSpinBox.move(colum2+60,line2-2)

        # line3
        line3 = yPos +80
        self.userLabel.move(xPos,line3)
        self.userLineEdit.move(xPos+50,line3-2)

        self.radioReboot.move(colum2,line3)
        self.radioFactory.move(colum2+60,line3)
        self.radioProvision.move(colum2,line3+30)

        self.webLabel.move(xPos,line3+40)
        self.webBtn.move(xPos+60,line3+35)

        # provWidget
        self.provWidget.resize(400,130)
        self.provWidget.move(xPos,line3+70)
        spaceY = 30
        x = 0
        y = 0
        cl = 200
        self.ver1Label.move(x,y)
        self.ver1LineEdit.move(x+50,y)
        self.ver2Label.move(x,y+spaceY)
        self.ver2LineEdit.move(x+50,y+spaceY)
        self.ver3Label.move(x,y+spaceY*2)
        self.ver3LineEdit.move(x+50,y+spaceY*2)

        self.dir1Label.move(cl,y)
        self.dir1LineEdit.move(cl+50,y)
        self.dir2Label.move(cl,y+spaceY)
        self.dir2LineEdit.move(cl+50,y+spaceY)
        self.dir3Label.move(cl,y+spaceY*2)
        self.dir3LineEdit.move(cl+50,y+spaceY*2)

        self.radioHttp.move(x,y+spaceY*3)
        self.radioHttps.move(x+50,y+spaceY*3)
        self.radioTftp.move(x+110,y+spaceY*3)
        self.radioFtp.move(x+160,y+spaceY*3)
        self.radioFtps.move(x+210,y+spaceY*3)
        self.radioWindow.move(x+265,y+spaceY*3)

        # advance widget
        self.advanceWidget.resize(300,400)
        x = 20
        y = 20
        space = 30

        self.checkCoreBox.move(x,y)
        self.cleanCache.move(x,y+space)
        self.checkProgressBox.move(x,y+space*2)
        self.checkShowChromeBox.move(x,y+space*3)
        self.apiCheckBox.move(x,y+space*4)
        self.corePathBtn.move(x-2,y+space*5-8)
        self.corePathLabel.move(x+35,y+space*5-8)

        y += 40
        self.chromeLabel.move(x,y+space*4+10)
        self.selectChromeBtn.move(x-2,y+space*5)
        self.chromePathLabel.move(x+35,y+space*5+2)

        self.checkSaveLogBox.move(x,y+space*6+10)
        self.selectDirBtn.move(x-2,y+space*7)
        self.saveDirLabel.move(x+35,y+space*7+2)
        self.advanceOkBtn.move(x+170,y+space*10+10)
        self.interfaceMenu.move(x-5,y+space*8+10)
        self.pcapLabel.move(x,y+space*8-2)
        # self.aiOptionBox.move(x, y+space*9+8)
        # set size
        self.messageBox.resize(373,155)
        # self.widget.resize(410,400)
        self.loopSpinBox.resize(60,25)
        self.intervalSpinBox.resize(60,25)
        self.webBtn.resize(100,25)

        self.saveDirLabel.resize(185,22)
        self.selectDirBtn.resize(32,24)
        self.selectChromeBtn.resize(32,24)
        self.chromePathLabel.resize(185,22)
        self.infoLabel.resize(400, 25)
        self.corePathBtn.resize(32,24)
        self.corePathLabel.resize(185,22)
        #
        self.provWidget.hide()
        self.changePosition(True)
        self.widget.show()
        self.loadCache()
    # ----------------end of setupUI ---------------------


    def changePosition(self,hide):
        xPos = 20
        if hide:
            buttonLine = 200
            self.widget.resize(420,415)
        else:
            buttonLine = 310
            self.widget.resize(420,524)

        self.startBtn.move(xPos,buttonLine)
        self.stopBtn.move(xPos+90,buttonLine)
        self.clearBtn.move(xPos+180,buttonLine)
        self.advanceBtn.move(xPos+270,buttonLine)
        self.messageBox.move(xPos,buttonLine+30)
        boxH = self.messageBox.height()
        self.infoLabel.move(xPos,buttonLine+boxH+35)

    def setItemEnable(self,enable):
        self.provWidget.setEnabled(enable)
        self.ipLineEdit.setEnabled(enable)
        self.passwordLineEdit.setEnabled(enable)
        self.userLineEdit.setEnabled(enable)
        self.intervalSpinBox.setEnabled(enable)
        self.loopSpinBox.setEnabled(enable)
        self.radioFactory.setEnabled(enable)
        self.radioReboot.setEnabled(enable)
        self.radioProvision.setEnabled(enable)
        self.advanceBtn.setEnabled(enable)
        self.startBtn.setEnabled(enable)
        self.clearBtn.setEnabled(enable)
        if self.useApiTest:
            self.webBtn.setEnabled(False)
        else:
            self.webBtn.setEnabled(enable)
        self.stopBtn.setEnabled(not enable)

    def outputError(self,str):
        appstr = "<span style=\"color:red\">"
        appstr += str + "</span>"
        self.messageBox.append(appstr)

    def outputWarning(self,str):
        appstr = "<span style=\"color:orange\">"
        appstr += str + "</span>"
        self.messageBox.append(appstr)

    def loadCache(self):
        file = QFile("cache")
        if not file.open(QIODevice.ReadOnly | QIODevice.Text):
            return

        inStream = QTextStream(file)

        # ip
        self.ipLineEdit.setText(inStream.readLine())
        # passwordLabel
        self.passwordLineEdit.setText(inStream.readLine())
        # user
        self.userLineEdit.setText(inStream.readLine())
        # ver1
        self.ver1LineEdit.setText(inStream.readLine())
        self.dir1LineEdit.setText(inStream.readLine())
        # ver2
        self.ver2LineEdit.setText(inStream.readLine())
        self.dir2LineEdit.setText(inStream.readLine())
        # ver3
        self.ver3LineEdit.setText(inStream.readLine())
        self.dir3LineEdit.setText(inStream.readLine())

        self.intervalSpinBox.setValue(int(inStream.readLine()))
        self.loopSpinBox.setValue(int(inStream.readLine()))

        # web type button
        webType = inStream.readLine()
        if webType == "gxpAction":
            self.grp2602Action.setChecked(False)
            self.gxpAction.setChecked(True)
            self.webBtn.setText(self.gxpAction.text())
        else:
            self.grp2602Action.setChecked(True)
            self.gxpAction.setChecked(False)
            self.webBtn.setText(self.grp2602Action.text())

        testType = inStream.readLine()
        if testType == "reboot":
            self.radioReboot.setChecked(True)
        elif testType == "provision":
            self.radioProvision.setChecked(True)
            self.changePosition(False)
            self.provWidget.show()
        else:
            self.radioFactory.setChecked(True)

        serverType = inStream.readLine()
        if serverType == "Http":
            self.radioHttp.setChecked(True)
        elif serverType == "Https":
            self.radioHttps.setChecked(True)
        elif serverType == "Tftp":
            self.radioTftp.setChecked(True)
        elif serverType == "Ftp":
            self.radioFtp.setChecked(True)
        elif serverType == "Ftps":            
            self.radioFtps.setChecked(True)
        else:
            self.radioWindow.setChecked(True)

        if inStream.readLine() == "True":
            self.findCoreStop = True
        else:
            self.findCoreStop = False

        if inStream.readLine() == "True":
            self.cleanCacheSet = True
        else:
            self.cleanCacheSet = False

        if inStream.readLine() == "True":
            self.useApiTest = True
            self.webBtn.setEnabled(False)
        else:
            self.useApiTest = False
            self.corePathBtn.hide()
            self.corePathLabel.hide()

        if inStream.readLine() == "True":
            self.showTestProgress = True
        else:
            self.showTestProgress = False
            self.infoLabel.hide()

        if inStream.readLine() == "True":
            self.showChrome = True
        else:
            self.showChrome = False

        self.chromePath = inStream.readLine()

        if inStream.readLine() == "True":
            self.saveTestLog = True
        else:
            self.saveTestLog = False

        self.saveLogPath = inStream.readLine()

        self.coreDumpPath = inStream.readLine()

        file.close()

    def saveCache(self):
        file = QFile("cache")
        if not file.open(QIODevice.WriteOnly):
            return

        content = self.ipLineEdit.text() + "\n"
        content += self.passwordLineEdit.text() + "\n"
        content += self.userLineEdit.text() + "\n"
        content += self.ver1LineEdit.text() + "\n"
        content += self.dir1LineEdit.text() + "\n"
        content += self.ver2LineEdit.text() + "\n"
        content += self.dir2LineEdit.text() + "\n"
        content += self.ver3LineEdit.text() + "\n"
        content += self.dir3LineEdit.text() + "\n"

        content += str(self.intervalSpinBox.value()) + "\n"
        content += str(self.loopSpinBox.value()) + "\n"

        if self.gxpAction.isChecked():
            content += "gxpAction\n"
        else:
            content += "grp2602Action\n"

        if self.radioReboot.isChecked():
            content += "reboot\n"
        elif self.radioProvision.isChecked():
            content += "provision\n"
        else:
            content += "factory\n"

        if self.radioHttp.isChecked():
            content += "Http\n"
        elif self.radioHttps.isChecked():
            content += "Https\n"
        elif self.radioTftp.isChecked():
            content += "Tftp\n"
        elif self.radioFtp.isChecked():
            content += "Ftp\n"
        elif self.radioFtps.isChecked():
            content += "Ftps\n"
        else :
            content += "Window\n"

        content += str(self.findCoreStop) + "\n"
        content += str(self.cleanCacheSet) + "\n"
        content += str(self.useApiTest) + "\n"
        content += str(self.showTestProgress) + "\n"
        content += str(self.showChrome) + "\n"
        content += self.chromePath +"\n"
        content += str(self.saveTestLog) +"\n"
        content += self.saveLogPath +"\n"
        content += self.coreDumpPath +"\n"

        byteArr = bytes(content,"utf-8")
        file.write(QByteArray(byteArr))
        file.close()


    def checkBeforeRun(self):
        containError = False
        #---------check Ip address--------------
        if self.ipLineEdit.text() == "":
            containError = True
            self.outputError("IP地址不能为空!")
        else:
            pattern = re.compile("^((1[0-9][0-9]\.)|(2[0-4][0-9]\.)|(25[0-5]\.)|([1-9][0-9]\.)|([0-9]\.)){3}((1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])|([1-9][0-9])|([0-9]))$")
            if not pattern.search(self.ipLineEdit.text()):
                containError = True
                self.outputError("IP地址格式错误,检查是否含有多余空格!(仅支持IPV4)")

        #------------------------
        if self.passwordLineEdit.text() == "":
            containError = True
            self.outputError("密码不能为空!")
        if self.userLineEdit.text() == "":
            containError = True
            self.outputError("用户名不能为空!")
        if self.intervalSpinBox.value() <= 40:
            self.outputWarning("间隔时间过短,可能对测试造成影响")
        if not self.radioProvision.isChecked() and not self.radioReboot.isChecked() and \
           not self.radioFactory.isChecked():
            containError = True
            self.outputError("必须选择测试方式(重启,升降级,恢复出厂)")

        # check provision ----------
        if self.radioProvision.isChecked():
            if self.ver1LineEdit.text() == "" or self.ver2LineEdit.text() == "" or \
               self.dir1LineEdit.text() == "" or self.dir2LineEdit.text() == "":
                containError = True
                self.outputError("升降级测试至少填上前两个版本及其路径")

            bin_name = ""
            if os.path.exists(os.path.abspath("config.ini") ):
                f = open(os.path.abspath("config.ini") , "r")
                line = f.readline()
                while line:
                    option = line.split("=")
                    if option[0] == "firmbinname":
                        if option[1].strip('"') != "":
                            filenamebin = option[1].strip()
                            bin_name = filenamebin.strip('"')
                        pass
                    line = f.readline()
                f.close()

            filename = os.path.join(self.dir1LineEdit.text(), bin_name)
            if not os.path.exists(filename) and self.radioWindow.isChecked():
                containError = True
                self.outputError("firmware1 文件不存在!" + filename)
            filename = os.path.join(self.dir2LineEdit.text(), bin_name)
            if not os.path.exists(filename) and self.radioWindow.isChecked():
                containError = True
                self.outputError("firmware2 文件不存在!" + filename)
           

            filename = os.path.join(self.dir3LineEdit.text(), bin_name)
            if self.ver3LineEdit.text() != "" and self.dir3LineEdit.text() == "":
                containError = True
                self.outputError("填写了版本3,但对应路径为空!")
            if self.dir3LineEdit.text() != "" and self.ver3LineEdit.text() == "":
                containError = True
                self.outputError("填写了路径3,但对应版本为空!")
            elif self.dir3LineEdit.text() != "" and self.radioWindow.isChecked() and not os.path.exists(filename):
                containError = True
                self.outputError("firmware3 文件不存在!" + filename)

            if not self.radioFtp.isChecked() and not self.radioFtps.isChecked() and \
               not self.radioHttp.isChecked() and not self.radioHttps.isChecked() and \
               not self.radioTftp.isChecked() and not self.radioWindow.isChecked():
                containError = True
                self.outputError("升降级测试必须选择服务器类型(Tftp,Ftp,Ftps,Http,Https)")
        return containError



    def startTest(self):
        ip = self.ipLineEdit.text()
        passwd = self.passwordLineEdit.text()
        username = self.userLineEdit.text()
        ptime = self.intervalSpinBox.value()
        loop = self.loopSpinBox.value()
        modelType = self.webBtn.text()
        if self.gxpAction.isChecked():
            device_type = "GXP21XX"
        elif self.grp2602Action.isChecked():
            device_type = "GRP260X"

        if self.radioReboot.isChecked():
            task_type = "reboot"
        elif self.radioProvision.isChecked():
            task_type = "provision"
            text_ver1 = self.ver1LineEdit.text()
            text_ver2 = self.ver2LineEdit.text()
            text_ver3 = self.ver3LineEdit.text()
            text_dir1 = self.dir1LineEdit.text()
            text_dir2 = self.dir2LineEdit.text()
            text_dir3 = self.dir3LineEdit.text()
            prov_dict = {"ver1": text_ver1.strip(), "dir1": text_dir1.strip(), "ver2": text_ver2.strip(),
                        "dir2": text_dir2.strip(), "ver3": text_ver3.strip(), "dir3": text_dir3.strip()}

            if self.radioHttp.isChecked():
                self.man.update_prov_setting("HTTP", prov_dict)
            elif self.radioHttps.isChecked():
                self.man.update_prov_setting("HTTPS", prov_dict)
            elif self.radioTftp.isChecked():
                self.man.update_prov_setting("TFTP", prov_dict)
            elif self.radioFtp.isChecked():
                self.man.update_prov_setting("FTP", prov_dict)
            elif self.radioFtps.isChecked():
                self.man.update_prov_setting("FTPS", prov_dict)
            elif self.radioWindow.isChecked():
                self.man.update_prov_setting("browser", prov_dict)

        else:
            task_type = "reset"

        coredump_stop = True
        headless_flag = False
        clean_cache = False
        if self.checkCoreBox.isChecked() == False:
            self.messageBox.append("Find core dump will not stop")
            coredump_stop = False
        if self.cleanCache.isChecked() == True:
            clean_cache = True
            
        if self.checkShowChromeBox.isChecked() == True or self.radioWindow.isChecked() == True:
            headless_flag = False
        else:
            headless_flag = True

        # ai_mode = False
        # if self.aiOptionBox.isChecked() == True:
        #     ai_mode = True

        browser_path = ""
        if self.chromePathLabel.text() != "":
            browser_path = self.chromePathLabel.text()

        self.testStatus = [True,1,0,"ip",""]
        print(self.interfaceMenu.currentText())
        self.man.setStatus(self.testStatus)
        self.man.setMessageList(self.messageList)
        self.man.update_setting(ip.strip(), username.strip(), passwd.strip(), device_type, \
                                task_type, loop, ptime, coredump_stop, headless_flag, browser_path, \
                                clean_cache, self.interfaceMenu.currentText(), False)
    
    def startApiTest(self):
        ip = self.ipLineEdit.text()
        passwd = self.passwordLineEdit.text()
        username = self.userLineEdit.text()
        ptime = self.intervalSpinBox.value()
        loop = self.loopSpinBox.value()
        
        testType = "Reboot"
        if self.radioProvision.isChecked():
            testType = "Provision"
        self.api.setValue(ip,username,passwd,ptime,loop,testType)

        v1 = self.ver1LineEdit.text()
        v2 = self.ver2LineEdit.text()
        v3 = self.ver3LineEdit.text()
        d1 = self.dir1LineEdit.text()
        d2 = self.dir2LineEdit.text()
        d3 = self.dir3LineEdit.text()
        self.api.setVersion(v1,v2,v3,d1,d2,d3)

        self.api.setTestStatus(self.testStatus,self.messageList,self.coreDumpPath)

        if self.radioHttp.isChecked():
            self.api.setServerType("http")
        elif self.radioHttps.isChecked():
            self.api.setServerType("https")
        elif self.radioTftp.isChecked():
            self.api.setServerType("tftp")
        elif self.radioFtp.isChecked():
            self.api.setServerType("ftp")
        else: #self.radioFtps.isChecked()
            self.api.setServerType("ftps")
        
        self.api.setFoundCoreStop(self.findCoreStop)


    # slot ---------------------------------
    def apiTestBoxCheck(self,state):
        if state == 2:
            self.corePathBtn.show()
            self.corePathLabel.show()
        else:
            self.corePathBtn.hide()
            self.corePathLabel.hide()

    def clickedCorePathBtn(self):
        dir = QFileDialog.getExistingDirectory(self.advanceWidget,"选择Core Dump存放路径","/home")
        if dir != "":
            self.corePathLabel.setText(dir)
            self.coreDumpPath = dir

    def clickedSelectDirBtn(self):
        dir = QFileDialog.getExistingDirectory(self.advanceWidget,"选择日志存放路径","/home")
        if dir != "":
            self.saveDirLabel.setText(dir)
            self.saveLogPath = dir

    def clickedSelectChromeBtn(self):
        fileName = QFileDialog.getOpenFileName(self.advanceWidget,"选择谷歌浏览器","/home","Chrome (*.exe)")
        if fileName != "":
            self.chromePathLabel.setText(fileName[0])
            self.chromePath = fileName[0]

    def saveLogBoxCheck(self,state):
        if state == 2: # checked
            self.selectDirBtn.show()
            self.saveDirLabel.show()
        else:
            self.selectDirBtn.hide()
            self.saveDirLabel.hide()

    def clickedAdvanceOkBtn(self):
        self.findCoreStop = self.checkCoreBox.isChecked()
        self.cleanCacheSet = self.cleanCache.isChecked()
        self.useApiTest = self.apiCheckBox.isChecked()
        self.showTestProgress = self.checkProgressBox.isChecked()
        self.saveTestLog = self.checkSaveLogBox.isChecked()
        self.saveLogPath = self.saveDirLabel.text()
        self.showChrome = self.checkShowChromeBox.isChecked()
        self.chromePath = self.chromePathLabel.text()
        self.coreDumpPath = self.corePathLabel.text()

        if self.useApiTest:
            self.webBtn.setEnabled(False)
            self.corePathBtn.show()
            self.corePathLabel.show()
        else:
            self.webBtn.setEnabled(True)
            self.corePathBtn.hide()
            self.corePathLabel.hide()

        if self.showTestProgress:
            self.infoLabel.show()
        else:
            self.infoLabel.hide()
                
        self.saveCache()
        self.advanceWidget.hide()


    def clickedAdvanceBtn(self):
        self.advanceWidget.hide()
        self.checkCoreBox.setChecked(self.findCoreStop)
        self.cleanCache.setChecked(self.cleanCacheSet)
        self.apiCheckBox.setChecked(self.useApiTest)
        self.checkProgressBox.setChecked(self.showTestProgress)
        self.checkSaveLogBox.setChecked(self.saveTestLog)
        self.saveDirLabel.setText(self.saveLogPath)
        self.checkShowChromeBox.setChecked(self.showChrome)
        self.chromePathLabel.setText(self.chromePath)
        self.corePathLabel.setText(self.coreDumpPath)
        self.advanceWidget.show()

    def slotTestStoped(self):
        self.testStatus[0] = False
        self.setItemEnable(True)
        self.timer.stop()
        self.updateMessage()
        self.thread.quit()

        # save Test log
        if self.saveTestLog:
            fileName = time.strftime("%Y_%m_%d.%H_%M_%S.",time.localtime())
            if self.radioReboot.isChecked():
                fileName += "reboot"
            elif self.radioProvision:
                fileName += "provision"
            else:
                fileName += "factoryReset"
            fileName += ".htm"
            if self.saveLogPath == "":
                self.outputWarning("日志地址没有设置,无法保存")
            else:
                fileName = self.saveLogPath + "\\" + fileName
                print(fileName)

                file = QFile(fileName)
                if not file.open(QIODevice.WriteOnly):
                    self.outputError("打开文件错误,保存日志失败")
                    return

                byteArr = bytes(self.messageBox.toHtml(),"utf-8")
                file.write(QByteArray(byteArr))
                file.close()

    def clickedClearBtn(self):
        self.ipLineEdit.setText("")
        self.passwordLineEdit.setText("")
        self.userLineEdit.setText("")
        self.ver1LineEdit.setText("")
        self.dir1LineEdit.setText("")
        self.ver2LineEdit.setText("")
        self.dir2LineEdit.setText("")
        self.ver3LineEdit.setText("")
        self.dir3LineEdit.setText("")

    def clickedStarBtn(self):
        if self.checkBeforeRun():
            return
        self.messageBox.clear()
        self.saveCache()
        self.messageBox.append("Init Setting...")
        self.setItemEnable(False)
        self.timer.start(500)
        self.thread.start()

        # deside use what to test
        if self.useApiTest:
            if self.radioFactory.isChecked():
                self.outputWarning("Api not support Factory Reset, will test as Gxp type web driver")	
                self.clickedGxpType()
                self.startTest()
                self.signalRun.emit(self.man)
            else:
                self.startApiTest()
                self.signalRunApi.emit(self.api)
        else:
            self.startTest()
            self.signalRun.emit(self.man)

    def clickedStopBtn(self):
        self.stopBtn.setEnabled(False)
        self.testStatus[0] = False
        self.man.quit()
        self.outputWarning("正在停止...")

    def clickedProvision(self):
        self.provWidget.show()
        self.changePosition(False)

    def clickedOthers(self):
        self.provWidget.hide()
        self.changePosition(True)

    def clickedGxpType(self):
        self.gxpAction.setChecked(True)
        self.grp2602Action.setChecked(False)
        self.webBtn.setText(self.gxpAction.text())

    def clickedGrp2602(self):
        self.gxpAction.setChecked(False)
        self.grp2602Action.setChecked(True)
        self.webBtn.setText(self.grp2602Action.text())

    def updateMessage(self):
        while len(self.messageList) >0:
            info = self.messageList.popleft()
            self.messageBox.append(info)
        if self.testStatus[0] == False:
            self.infoLabel.setText("未开始测试")
        else:
            info = "第" + str(self.testStatus[1]) + "次测试   "
            if self.testStatus[2] > 0:
                info += "等待:{} 秒".format( self.testStatus[2] )
            else:
                info += "运行中"
            
            info += "  " + self.testStatus[3]
            info += "  " + self.testStatus[4]
            self.infoLabel.setText(info)
Пример #51
0
 def __init__(self, parent=None):
     QWidget.__init__(self, parent)
     QIntValidator.__init__(self, parent)
Пример #52
0
    def __init__(self):
        QObject.__init__(self)  # must init parent QObject,if you want to use signal
        self.widget = QWidget()
        self.ipLabel = QLabel(self.widget)
        self.thread = QThread()
        self.worker = Worker()
        self.worker.moveToThread(self.thread)
        self.man = SpiderThread()
        self.api = apiTester()
        # 1 2:loop 3: time
        self.testStatus = [False,1,0,"ip","mac"]

        # advance config
        self.findCoreStop = True
        self.cleanCacheSet = False
        self.useApiTest = False
        self.showTestProgress = True
        self.saveTestLog = False
        self.saveLogPath = ""
        self.chromePath =  ""
        self.showChrome = False
        self.coreDumpPath = ""

        # ui form
        self.passwordLabel = QLabel(self.widget)

        self.ipLineEdit = QLineEdit(self.widget)
        self.passwordLineEdit = QLineEdit(self.widget)

        self.startBtn = QPushButton(self.widget)
        self.stopBtn = QPushButton(self.widget)

        self.messageBox = QTextEdit(self.widget)
        self.messageBox.setReadOnly(True)

        self.userLabel = QLabel(self.widget)
        self.userLineEdit = QLineEdit(self.widget)

        self.intervalLabel = QLabel(self.widget)
        self.intervalSpinBox = QSpinBox(self.widget)

        self.loopLabel = QLabel(self.widget)
        self.loopSpinBox = QSpinBox(self.widget)

        self.intervalSpinBox.setRange(0,9999)
        self.loopSpinBox.setRange(1,9999)

        self.radioReboot = QRadioButton(self.widget)
        self.radioProvision = QRadioButton(self.widget)
        self.radioFactory = QRadioButton(self.widget)

        # self.apiCheckBox = QCheckBox(self.widget)

        self.menu = QMenu()
        self.gxpAction = QAction("Classic UI")
        self.grp2602Action = QAction("Ant Design UI")
        self.gxpAction.setCheckable(True)
        self.grp2602Action.setCheckable(True)
        self.menu.addAction(self.gxpAction)
        self.menu.addAction(self.grp2602Action)
        self.webLabel = QLabel(self.widget)
        self.webBtn = QPushButton(self.widget)
        self.webBtn.setMenu(self.menu)
        self.clearBtn = QPushButton(self.widget)
        self.messageList = deque()
        self.timer = QTimer()


        self.advanceBtn = QPushButton(self.widget)
        self.infoLabel = QLabel(self.widget)

        # provision widget
        self.provWidget = QWidget(self.widget)
        self.ver1Label = QLabel(self.provWidget)
        self.ver2Label = QLabel(self.provWidget)
        self.ver3Label = QLabel(self.provWidget)
        self.ver1LineEdit = QLineEdit(self.provWidget)
        self.ver2LineEdit = QLineEdit(self.provWidget)
        self.ver3LineEdit = QLineEdit(self.provWidget)

        self.dir1Label = QLabel(self.provWidget)
        self.dir2Label = QLabel(self.provWidget)
        self.dir3Label = QLabel(self.provWidget)
        self.dir1LineEdit = QLineEdit(self.provWidget)
        self.dir2LineEdit = QLineEdit(self.provWidget)
        self.dir3LineEdit = QLineEdit(self.provWidget)

        self.radioHttp = QRadioButton(self.provWidget)
        self.radioHttps = QRadioButton(self.provWidget)
        self.radioTftp = QRadioButton(self.provWidget)
        self.radioFtp = QRadioButton(self.provWidget)
        self.radioFtps = QRadioButton(self.provWidget)
        self.radioWindow = QRadioButton(self.provWidget)

        # advance widget
        self.advanceWidget = QWidget()
        self.checkCoreBox = QCheckBox(self.advanceWidget)
        self.cleanCache = QCheckBox(self.advanceWidget)
        self.checkSaveLogBox = QCheckBox(self.advanceWidget)
        self.selectDirBtn = QPushButton(self.advanceWidget)
        self.saveDirLabel = QLabel(self.advanceWidget)
        self.saveDirLabel.setStyleSheet("background:white")
        self.checkProgressBox = QCheckBox(self.advanceWidget)
        self.advanceOkBtn = QPushButton(self.advanceWidget)
        self.selectChromeBtn = QPushButton(self.advanceWidget)
        self.chromePathLabel = QLabel(self.advanceWidget)
        self.chromePathLabel.setStyleSheet("background:white")
        self.checkShowChromeBox = QCheckBox(self.advanceWidget)
        self.chromeLabel = QLabel(self.advanceWidget)
        self.pcapLabel = QLabel(self.advanceWidget)
        self.apiCheckBox = QCheckBox(self.advanceWidget)
        self.corePathLabel = QLabel(self.advanceWidget)
        self.corePathLabel.setStyleSheet("background:white")
        self.corePathBtn = QPushButton(self.advanceWidget)

        self.interfaceMenu = QComboBox(self.advanceWidget)
        self.interfaceMenu.addItem('Default')

        self.aiOptionBox= QCheckBox(self.advanceWidget)

        a = IFACES
        print(a)
        for i in a.keys():
            print(a[i].description)
            self.interfaceMenu.addItem(a[i].description)

        # connect singal and slot
        self.startBtn.clicked.connect(self.clickedStarBtn)
        self.radioProvision.clicked.connect(self.clickedProvision)
        self.radioReboot.clicked.connect(self.clickedOthers)
        self.radioFactory.clicked.connect(self.clickedOthers)
        self.stopBtn.clicked.connect(self.clickedStopBtn)
        self.grp2602Action.triggered.connect(self.clickedGrp2602)
        self.gxpAction.triggered.connect(self.clickedGxpType)
        self.timer.timeout.connect(self.updateMessage)
        self.apiCheckBox.stateChanged.connect(self.apiTestBoxCheck)
        self.clearBtn.clicked.connect(self.clickedClearBtn)

        self.advanceBtn.clicked.connect(self.clickedAdvanceBtn)
        self.advanceOkBtn.clicked.connect(self.clickedAdvanceOkBtn)
        self.checkSaveLogBox.stateChanged.connect(self.saveLogBoxCheck)
        self.selectChromeBtn.clicked.connect(self.clickedSelectChromeBtn)
        self.selectDirBtn.clicked.connect(self.clickedSelectDirBtn)
        self.corePathBtn.clicked.connect(self.clickedCorePathBtn)

        self.worker.signalJobEnd.connect(self.slotTestStoped)
        self.worker.apiTestFinished.connect(self.slotTestStoped)
        self.signalRun.connect(self.worker.dowork)
        self.signalRunApi.connect(self.worker.doworkApi)
Пример #53
0
 def wheelEvent(self, event):
     QWidget.wheelEvent(self, event)
     event.accept()
Пример #54
0
class DLPGUI(QWidget):
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.parent = parent
        self.supported_setups = ['BOTTOM-UP', 'TOP-DOWN']
        self.supported_projectors = ['VisitechLRSWQ', 'VisitechLRS4KA']
        self.supported_motors = ['ClearpathSDSK', 'ClearpathSCSK', 'Nanostage']
        self.selected_setup = self.supported_setups[0]
        self.selected_projector = self.supported_projectors[0]
        self.selected_motor = self.supported_motors[0]
        self.stacked_layout = QStackedLayout()
        self.__setup_widget = None
        self.__dlp_main_widget = None
        if not self.__load_settings__():
            self.__init_configuration_selection_widget__()
            self.__init_projector_selection_widget__()
            self.__init_motor_selection_widget__()
            self.stacked_layout.setCurrentIndex(0)
        self.setLayout(self.stacked_layout)

    def minimumSizeHint(self):
        return self.stacked_layout.currentWidget().minimumSizeHint()

    def sizeHint(self):
        return self.stacked_layout.currentWidget().sizeHint()

    def __load_settings__(self):
        base_path = Path(__file__).parent
        settings_path = str(
            (base_path / '../resources/PRINTER_SETTINGS.json').resolve())
        settings_file = QFile(settings_path)
        if settings_file.open(QIODevice.ReadOnly | QIODevice.Text):
            file_data = QJsonDocument.fromJson(
                settings_file.readAll()).object()
            if "dlp_settings" in file_data:
                printer_setup = str(file_data["dlp_settings"]["printer_setup"])
                if printer_setup == self.supported_setups[0]:
                    self.__select_setup__(0)
                elif printer_setup == self.supported_setups[1]:
                    self.__select_setup__(1)
                else:
                    return False
                projector_setup = str(
                    file_data["dlp_settings"]["projector_setup"])
                if projector_setup == self.supported_projectors[0]:
                    self.__select_projector__(None, 0)
                elif projector_setup == self.supported_projectors[1]:
                    self.__select_projector__(None, 1)
                else:
                    return False
                motor_setup = str(file_data["dlp_settings"]["motor_setup"])
                if motor_setup == self.supported_motors[0]:
                    self.__select_motor__(None, 0)
                elif motor_setup == self.supported_motors[1]:
                    self.__select_motor__(None, 1)
                elif motor_setup == self.supported_motors[2]:
                    self.__select_motor__(None, 2)
                else:
                    return False
                return True
            settings_file.close()
        return False

    def __init_configuration_selection_widget__(self):
        self.__setup_widget = QWidget(self)
        setup_layout = QHBoxLayout()
        for idx in range(len(self.supported_setups)):
            button = QPushButton(self.supported_setups[idx],
                                 self.__setup_widget)
            button.setFixedSize(200, 200)
            button.clicked.connect(self.__select_setup__)
            setup_layout.addWidget(button)
        self.__setup_widget.setLayout(setup_layout)
        self.stacked_layout.addWidget(self.__setup_widget)
        # self.stacked_layout.setCurrentIndex(0)

    def __init_projector_selection_widget__(self):
        self.__projector_setup_widget = QWidget(self)
        projector_setup_layout = QHBoxLayout()
        for idx in range(len(self.supported_projectors)):
            button = QPushButton(self.supported_projectors[idx],
                                 self.__setup_widget)
            button.setFixedSize(200, 200)
            button.clicked.connect(
                lambda state=None, x=idx: self.__select_projector__(state, x))
            projector_setup_layout.addWidget(button)
        self.__projector_setup_widget.setLayout(projector_setup_layout)
        self.stacked_layout.addWidget(self.__projector_setup_widget)

    def __init_motor_selection_widget__(self):
        self.__motor_setup_widget = QWidget(self)
        motor_setup_layout = QHBoxLayout()
        for idx in range(len(self.supported_motors)):
            button = QPushButton(self.supported_motors[idx],
                                 self.__setup_widget)
            button.setFixedSize(200, 200)
            button.clicked.connect(
                lambda state=None, x=idx: self.__select_motor__(state, x))
            motor_setup_layout.addWidget(button)
        self.__motor_setup_widget.setLayout(motor_setup_layout)
        self.stacked_layout.addWidget(self.__motor_setup_widget)

    def __select_setup__(self, idx):
        self.selected_setup = self.supported_setups[idx]
        self.stacked_layout.setCurrentIndex(1)

    def __select_projector__(self, button_state, projector_id):
        self.selected_projector = self.supported_projectors[projector_id]
        self.stacked_layout.setCurrentIndex(2)

    def __select_motor__(self, button_state, motor_id):
        self.selected_motor = self.supported_motors[motor_id]
        self.__init_main_widget__()
        self.stacked_layout.setCurrentIndex(3)
        # self.parent.move(self.desktops.screen(0).rect().center() - self.__dlp_main_widget.rect().center())

    def __init_main_widget__(self):
        self.__dlp_main_widget = QTabWidget(self)
        self.__dlp_main_widget.setSizePolicy(QSizePolicy.Maximum,
                                             QSizePolicy.Maximum)
        self.dlp_controller = DLPMainController(self.selected_setup,
                                                self.selected_projector,
                                                self.selected_motor)
        self.__printer_widget = DLPPrinterGUI(
            dlp_controller=self.dlp_controller, parent=self.__dlp_main_widget)
        self.__slicer_widget = DLPSlicerGUI(dlp_controller=self.dlp_controller,
                                            parent=self.__dlp_main_widget)
        self.__settings_widget = DLPSettingsGUI(
            dlp_controller=self.dlp_controller, parent=self.__dlp_main_widget)
        self.__printer_widget.setSizePolicy(QSizePolicy.Maximum,
                                            QSizePolicy.Maximum)
        self.__slicer_widget.setSizePolicy(QSizePolicy.Maximum,
                                           QSizePolicy.Maximum)
        self.__settings_widget.setSizePolicy(QSizePolicy.Maximum,
                                             QSizePolicy.Maximum)
        self.__dlp_main_widget.addTab(self.__printer_widget, 'DLP')
        self.__dlp_main_widget.addTab(self.__slicer_widget, 'Slicer')
        self.__dlp_main_widget.addTab(self.__settings_widget,
                                      'Advanced Settings')
        self.stacked_layout.addWidget(self.__dlp_main_widget)
        self.dlp_controller.save_default_parameters()
        # self.__dlp_main_widget.move()
        # self.desktops = QDesktopWidget()
        # self.parent.move(self.desktops.screen(0).rect().center() - self.__dlp_main_widget.rect().center())
        # self.__dlp_main_widget.move(QGuiApplication.desktop().screen().rect().center() - self.rect().center())

    def reset_main_widget(self):
        self.dlp_controller.close_projector()
        self.__init_main_widget__()
        self.stacked_layout.setCurrentIndex(3)
        # self.parent.move(self.desktops.screen(0).rect().center() - self.__dlp_main_widget.rect().center())

    @Slot()
    def closeEvent(self, event: QCloseEvent):
        if self.__setup_widget:
            self.__setup_widget.close()
        if self.__dlp_main_widget:
            self.__printer_widget.close()
            self.__slicer_widget.close()
            self.__settings_widget.close()
            self.__dlp_main_widget.close()
        event.accept()

    def get_settings_window(self, parent=None):
        printer_settings = QGroupBox("DLP Printer Settings:", parent)
        dlp_setup_label = QLabel("DLP Setup:", printer_settings)
        self.dlp_setup_combo = QComboBox(printer_settings)
        self.dlp_setup_combo.addItems(self.supported_setups)
        self.dlp_setup_combo.setCurrentIndex(
            self.supported_setups.index(self.selected_setup))
        dlp_projector_label = QLabel("DLP Projector:", printer_settings)
        self.dlp_projector_combo = QComboBox(printer_settings)
        self.dlp_projector_combo.addItems(self.supported_projectors)
        self.dlp_projector_combo.setCurrentIndex(
            self.supported_projectors.index(self.selected_projector))
        dlp_motor_label = QLabel("DLP Motor:", printer_settings)
        self.dlp_motor_combo = QComboBox(printer_settings)
        self.dlp_motor_combo.addItems(self.supported_motors)
        self.dlp_motor_combo.setCurrentIndex(
            self.supported_motors.index(self.selected_motor))
        apply_button = QPushButton("Apply Changes", printer_settings)
        apply_button.clicked.connect(self.__apply_settings)
        printer_settings_layout = QGridLayout(printer_settings)
        printer_settings_layout.addWidget(dlp_setup_label, 1, 0)
        printer_settings_layout.addWidget(self.dlp_setup_combo, 1, 1)
        printer_settings_layout.addWidget(dlp_projector_label, 2, 0)
        printer_settings_layout.addWidget(self.dlp_projector_combo, 2, 1)
        printer_settings_layout.addWidget(dlp_motor_label, 3, 0)
        printer_settings_layout.addWidget(self.dlp_motor_combo, 3, 1)
        printer_settings_layout.addWidget(apply_button, 4, 1)
        return printer_settings

    @Slot()
    def __apply_settings(self):
        self.selected_setup = self.supported_setups[
            self.dlp_setup_combo.currentIndex()]
        if self.supported_motors[self.dlp_motor_combo.currentIndex(
        )] is not self.selected_motor:
            self.selected_motor = self.supported_motors[
                self.dlp_motor_combo.currentIndex()]
            self.dlp_controller.change_motor(self.selected_setup,
                                             self.selected_motor)
        if self.supported_projectors[self.dlp_projector_combo.currentIndex(
        )] is not self.selected_projector:
            self.selected_projector = self.supported_projectors[
                self.dlp_projector_combo.currentIndex()]
            self.dlp_controller.change_projector(self.selected_projector)
        self.dlp_controller.save_default_parameters()
Пример #55
0
 def build(self):
     self.form = QWidget()
     self.form.setLayout(QVBoxLayout())
     self.form.layout().addWidget(QLabel("Your App here :)"))
class PreprocessingImageWindow(QMainWindow):

    def close_application(self):
        """
            This function close the window.
        """
        sys.exit()
    
    def save(self) :
        self.dico = saveColumn1Dataset (self.dataset_path)
        saveColumn2Dataset (self.training_data, self.dico, self.file_name)
    
    def showTable(self):
        """
            This function display the corresponding matrix to an image
        """
        self.tableWidget.setVisible (True)
        if hasattr (self, 'image') :
            self.image.setVisible (False)
        self.pushButton_table.setEnabled (False)
        self.pushButton_next.setEnabled(True)
        global index_data_pre
    
        self.frame_3.setGeometry (QtCore.QRect (10, 180, 1000, 450))
        self.tableWidget.setRowCount(int (globals.height_m))
        self.tableWidget.setColumnCount(int (globals.length_m))
        matrix_image, id_class = self.training_data[globals.index_data_pre]
        for i, row in enumerate (matrix_image) :
            for j, val in enumerate (row) :
                self.tableWidget.setItem (i, j, QTableWidgetItem (str (val)))
    
    def preprocess(self):
        """
            This function preprocess an image dataset.
        """
        if self.dataset_path != None :
            if self.input_length.text() == "0" or self.input_length.text() == "":
                self.input_length.setText("30")
    
            if self.input_height.text() == "0" or self.input_height.text() == "":
                self.input_height.setText("30")
    
            # Setting values for matrix sizes
        global length_m
        global height_m
        globals.length_m = int(self.input_length.text())
        globals.height_m = int(self.input_height.text())
        ## Preprocessing
        global input_array
        global output_array
        f = open(self.dataset_path,'r')
        categories = list()
        f.readline()
        for ligne in f.readlines() :
            var=ligne.strip().split(',')
            classe=var[1] #class
            if classe not in categories :
                categories.append(classe)
        self.training_data = Preprocessing (self.dataset_path, self.file_path)
        for i in range (len (self.training_data)) :
            matrix, id_class = self.training_data[i]
            globals.input_array.append (matrix)
            globals.output_array.append (categories[id_class])
        self.start.setEnabled (False)
        self.input_height.setEnabled(False)
        self.input_length.setEnabled (False)
        self.pushButton_table.setEnabled (True)
        self.pushButton_save.setEnabled (True)


    def open_dataset (self) :
        """
            This function looks for the csv file and initializes the Window attributes.
        """
        global dataset_name
        dlg = QFileDialog()
        dlg.setFileMode(QFileDialog.AnyFile)
        dlg.selectNameFilter("Csv data files (*.csv)")
        dlg.setNameFilter("Arff data files (*.arff) ;; Csv data files (*.csv) ;; All files (*.*)")
        filenames = []
        if dlg.exec_():
            filenames = dlg.selectedFiles()
            f = open(filenames[0], 'r')
            self.dataset_path = str(filenames[0])
            with f:
                self.textEdit.setText(filenames[0].split('/')[-1])
                self.file_name = filenames[0].split('/')[-1].split('.')[0]
        if self.dataset_path != None :
            self.file_path = os.path.dirname(self.dataset_path) + globals.directory
            globals.dataset_name = self.file_name
    
        ## RESET
        global input_height
        global input_length
        global index_data
        global index_data_pre
        global input_array
        global output_array
    
        globals.input_height = 0
        globals.input_length = 0
        globals.index_data = 0
        globals.index_data_pre = 0
        globals.input_array = []
        globals.output_array = []
        self.frame_3.setGeometry(QtCore.QRect(10, 180, 1000, 450))
        self.pushButton_next.setEnabled (False)
        self.pushButton_previous.setEnabled (False)
        self.start.setEnabled (False)
        self.valider.setEnabled(True)
        self.pushButton_save.setEnabled (False)
        self.pushButton_table.setEnabled (False)
        if hasattr (self, 'tableWidget') :
            self.tableWidget.setVisible (False)
        if hasattr (self, 'image') :
            self.image.setVisible (False)



    def get_dataset_information(self):
        """
            This function gets information about the dataset such as the number of instances and the number of classes.
        """
        text="Nombre d'instances: "+str(get_number_instances(self.dataset_path))
        self.label_instances.setText(text)
        text = "Nombre de classes: " + str (get_number_class (self.dataset_path))
        self.label_classes.setText(text)
    
        self.input_height.setEnabled(True)
        self.input_length.setEnabled(True)
        self.valider.setEnabled (False)
        self.start.setEnabled(True)
        self.pushButton_next.setEnabled (True)
        if hasattr (self, 'training_data') :
            self.pushButton_table.setEnabled (True)
    
        self.frame_3.setGeometry (QtCore.QRect (250, 180, 500, 450))
        if not hasattr (self, 'image') :
            self.image = QLabel (self.frame_3)
            self.image.setGeometry (QtCore.QRect (0,0,500, 450))
            self.image.setObjectName ("image")
        image_list = []
        global index_data
        csv_file = open (self.dataset_path, "r")
        csv_file.readline()
        for line in csv_file.readlines() :
            var = line.strip().split(',')
            image_list.append (var[0])
        csv_file.close()
        self.image.setPixmap (QtGui.QPixmap (self.file_path + image_list[globals.index_data]).scaled (500, 450))
        self.image.show()




    def previous_state(self):
        """
            This function returns to the previous instance in the dataset.
        """
        global index_data
        global index_data_pre
        if self.pushButton_table.isEnabled() or not hasattr(self, 'training_data'):
            if globals.index_data - 1 >= 0 :
                globals.index_data -= 1
            if globals.index_data - 1 < 0:
                self.pushButton_next.setEnabled(True)
                self.pushButton_previous.setEnabled(False)
    
        else :
            if globals.index_data_pre - 1 >= 0 :
                globals.index_data_pre -= 1
            if globals.index_data_pre - 1 < 0:
                self.pushButton_next.setEnabled(True)
                self.pushButton_previous.setEnabled(False)
    
        if not self.valider.isEnabled () and not hasattr(self, "training_data"):
            if hasattr (self, 'training_data') and self.start.isEnabled():
                self.pushButton_table.setEnabled(False)
            elif hasattr (self, 'training_data') :
                self.pushButton_table.setEnabled (True)
    
            self.frame_3.setGeometry (QtCore.QRect (250, 180, 500, 450))
            if not hasattr (self, 'image') :
                self.image = QLabel (self.frame_3)
                self.image.setGeometry (QtCore.QRect (0,0,500, 450))
                self.image.setObjectName ("image")
            image_list = []
            global index_data
            csv_file = open (self.dataset_path, "r")
            csv_file.readline()
            for line in csv_file.readlines() :
                var = line.strip().split(',')
                image_list.append (var[0])
            csv_file.close()
    
            self.image.setPixmap (QtGui.QPixmap (self.file_path + image_list[globals.index_data]).scaled (500, 450))
            self.image.show()
        else :
            self.showTable()


    def next_state(self):
        """
            This function goes to the next instance in the dataset.
        """
        global index_data
        global index_data_pre
        if self.pushButton_table.isEnabled() or not hasattr( self, 'training_data' ): # Image Mode
            if globals.index_data + 1 < get_number_instances (self.dataset_path):
                globals.index_data += 1
            if globals.index_data + 1 >= get_number_instances(self.dataset_path):
                self.pushButton_next.setEnabled(False)
                self.pushButton_previous.setEnabled(True)
    
        else :
            if globals.index_data_pre + 1 < get_number_instances (self.dataset_path) * 2:
                globals.index_data_pre += 1
            if globals.index_data_pre + 1 >= get_number_instances(self.dataset_path):
                self.pushButton_next.setEnabled(False)
                self.pushButton_previous.setEnabled(True)
        if not self.valider.isEnabled () and not hasattr (self, "training_data"):
            if hasattr (self, 'training_data') and self.start.isEnabled():
                self.pushButton_table.setEnabled(False)
            elif hasattr (self, 'training_data') :
                self.pushButton_table.setEnabled (True)
    
            self.frame_3.setGeometry (QtCore.QRect (250, 180, 500, 450))
            if not hasattr (self, 'image') :
                self.image = QLabel (self.frame_3)
                self.image.setGeometry (QtCore.QRect (0,0,500, 450))
                self.image.setObjectName ("image")
            image_list = []
            global index_data
            csv_file = open (self.dataset_path, "r")
            csv_file.readline()
            for line in csv_file.readlines() :
                var = line.strip().split(',')
                image_list.append (var[0])
            csv_file.close()
    
            self.image.setPixmap (QtGui.QPixmap (self.file_path + image_list[globals.index_data]).scaled (500, 450))
            self.image.show()
        else :
            self.showTable ()

## GUI
    
    def __init__(self, *args, **kwargs):
        super(PreprocessingImageWindow, self).__init__(*args, **kwargs)
        self.file_path = None
        self.file_name = None
        self.dataset_path = None


        self.setObjectName("self")
        self.resize(1280, 720)
        self.setAutoFillBackground(True)
        self.setFixedSize(1280, 720)
    
        self.centralwidget = QWidget(self)
        self.centralwidget.setAutoFillBackground(True)
        self.centralwidget.setObjectName("centralwidget")



        self.gridLayout = QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.tabWidget = QTabWidget(self.centralwidget)
        self.tabWidget.setAutoFillBackground(True)
        self.tabWidget.setObjectName("tabWidget")


        ## INFO BOX:
        self.tab1 = QWidget()
        self.tab1.setAutoFillBackground(True)
        self.tab1.setObjectName("tab1")
        self.frame = QFrame(self.tab1)
        self.frame.setGeometry(QtCore.QRect(10, 60, 1000, 111))
        self.frame.setAutoFillBackground(True)
        self.frame.setFrameShape(QFrame.StyledPanel)
        self.frame.setFrameShadow(QFrame.Raised)
        self.frame.setObjectName("frame")
        self.label_2 = QLabel(self.frame)
        self.label_2.setGeometry(QtCore.QRect(11, 10, 184, 17))
        font = QtGui.QFont()
        font.setItalic(True)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.widget = QWidget(self.frame)
        self.widget.setGeometry(QtCore.QRect(100, 30, 301, 65))
        self.widget.setObjectName("widget")
        self.verticalLayout = QVBoxLayout(self.widget)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setObjectName("verticalLayout")
        self.label_instances = QLabel(self.widget)
        self.label_instances.setObjectName("label_instances")
        self.verticalLayout.addWidget(self.label_instances)
        self.label_classes = QLabel(self.widget)
        self.label_classes.setObjectName("label_classes")
        self.verticalLayout.addWidget(self.label_classes)
    
        ## Frame 2 PARAMETERS
        self.frame_2 = QFrame(self.tab1)
        self.frame_2.setGeometry(QtCore.QRect(1030, 60, 211, 261))
        self.frame_2.setAutoFillBackground(True)
        self.frame_2.setFrameShape(QFrame.StyledPanel)
        self.frame_2.setFrameShadow(QFrame.Raised)
        self.frame_2.setObjectName("frame_2")
    
        self.toolBox = QToolBox(self.frame_2)
        self.toolBox.setGeometry(QtCore.QRect(10, 40, 191, 151))
        self.toolBox.setObjectName("toolBox")
    
        self.page_resize = QWidget()
        self.page_resize.setGeometry(QtCore.QRect(100, 0, 191, 89))
        self.page_resize.setObjectName("page_resize")
    
        self.layoutWidget = QWidget(self.page_resize)
        self.layoutWidget.setGeometry(QtCore.QRect(0, 0, 188, 52))
        self.layoutWidget.setObjectName("layoutWidget")
    
        self.verticalLayout_2 = QVBoxLayout(self.layoutWidget)
        self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
    
        self.form = QFormLayout ()
    
        self.input_length = QLineEdit()
        self.input_length.setValidator (QtGui.QIntValidator())
        self.input_length.setObjectName("Choose_length")
        self.verticalLayout_2.addWidget(self.input_length)
        self.input_length.setEnabled (False)


        self.input_height = QLineEdit()
        self.input_height.setValidator (QtGui.QIntValidator())
        self.input_height.setObjectName("Choose_height")
        self.verticalLayout_2.addWidget(self.input_height)
        self.input_height.setEnabled (False)
    
        self.form.addRow ("Length :", self.input_length)
    
        self.start = QPushButton(self.frame_2)
        self.start.setObjectName("pushButton_start")
        self.verticalLayout_2.addWidget(self.start)
        self.page_resize.setLayout (self.form)
    
        self.form.addRow ("height :", self.input_height)
        self.form.addRow (self.start)


        self.input_length.setText ("40")
        self.input_height.setText ("40")



        self.toolBox.addItem(self.page_resize, "")
        self.label_3 = QLabel(self.frame_2)
        self.label_3.setGeometry(QtCore.QRect(10, 10, 181, 17))
        font = QtGui.QFont()
        font.setItalic(True)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")


        ## Frame 3 DISPLAY
        self.frame_3 = QFrame(self.tab1)
        self.frame_3.setGeometry(QtCore.QRect(10, 180, 1000, 450))
        self.frame_3.setAutoFillBackground(True)
        self.frame_3.setFrameShape(QFrame.StyledPanel)
        self.frame_3.setFrameShadow(QFrame.Raised)
        self.frame_3.setObjectName("frame_3")
    
        ## Display matrix
        self.tableWidget = QTableWidget(self.frame_3)
        self.tableWidget.setGeometry(QtCore.QRect(0, 0, 1000, 450))
        self.tableWidget.setAutoFillBackground(True)
        self.tableWidget.setObjectName("tableWidget")
        self.tableWidget.setColumnCount(0)
        self.tableWidget.setRowCount(0)


        ## Frame 4 VISUALIZATION
        self.frame_4 = QFrame(self.tab1)
        self.frame_4.setGeometry(QtCore.QRect(1030, 330, 211, 191))
        self.frame_4.setFrameShape(QFrame.StyledPanel)
        self.frame_4.setFrameShadow(QFrame.Raised)
        self.frame_4.setObjectName("frame_4")


        ## BUTTON FOR VISUALIZATION
        self.pushButton_previous= QPushButton(self.frame_4)
        self.pushButton_previous.setGeometry(QtCore.QRect(50, 40, 121, 41))
        self.pushButton_previous.setIconSize(QtCore.QSize(30, 30))
        self.pushButton_previous.setAutoDefault(False)
        self.pushButton_previous.setDefault(False)
        self.pushButton_previous.setFlat(False)
        self.pushButton_previous.setObjectName("pushButton_previous")
    
        self.pushButton_next = QPushButton(self.frame_4)
        self.pushButton_next.setGeometry(QtCore.QRect(50, 85, 121, 41))
        self.pushButton_next.setObjectName("pushButton_next")


        self.pushButton_table = QPushButton (self.frame_4)
        self.pushButton_table.setGeometry (QtCore.QRect (50, 130, 121, 41))
        self.pushButton_table.setObjectName ("pushButton_table")


        ## SAVE
        self.frame_5 = QFrame(self.tab1)
        self.frame_5.setGeometry(QtCore.QRect(1080, 550, 121, 41))
        self.frame_5.setFrameShape(QFrame.StyledPanel)
        self.frame_5.setFrameShadow(QFrame.Raised)
        self.frame_5.setObjectName("frame_5")
    
        self.pushButton_save = QPushButton (self.frame_5)
        self.pushButton_save.setGeometry (QtCore.QRect (0, 0, 121, 41))
        self.pushButton_save.setObjectName ("pushButton_save")


        ## RETURN BUTTON
        self.frame_6 = QFrame(self.tab1)
        self.frame_6.setGeometry(QtCore.QRect(1080, 10, 121, 41))
        self.frame_6.setFrameShape(QFrame.StyledPanel)
        self.frame_6.setFrameShadow(QFrame.Raised)
        self.frame_6.setObjectName("frame_6")
    
        self.pushButton_return = QPushButton (self.frame_6)
        self.pushButton_return.setGeometry (QtCore.QRect (0, 0, 121, 41))
        self.pushButton_return.setObjectName ("pushButton_return")



        self.label_4 = QLabel(self.frame_4)
        self.label_4.setGeometry(QtCore.QRect(10, 10, 111, 17))
        font = QtGui.QFont()
        font.setItalic(True)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.layoutWidget2 = QWidget(self.tab1)
        self.layoutWidget2.setGeometry(QtCore.QRect(10, 20, 611, 31))
        self.layoutWidget2.setObjectName("layoutWidget2")
        self.horizontalLayout = QHBoxLayout(self.layoutWidget2)
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.label = QLabel(self.layoutWidget2)
        font = QtGui.QFont()
        font.setItalic(True)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.horizontalLayout.addWidget(self.label)
        self.textEdit = QTextEdit(self.layoutWidget2)
        self.textEdit.setObjectName("textEdit")
        self.horizontalLayout.addWidget(self.textEdit)
        self.toolButton = QToolButton(self.layoutWidget2)
        self.toolButton.setObjectName("toolButton")
        self.horizontalLayout.addWidget(self.toolButton)
        self.valider = QPushButton(self.layoutWidget2)
        self.valider.setObjectName("valider")
        self.horizontalLayout.addWidget(self.valider)
        self.tabWidget.addTab(self.tab1, "")
        self.gridLayout.addWidget(self.tabWidget, 0, 1, 1, 1)
        self.setCentralWidget(self.centralwidget)


        self.lbl = QLabel(self.frame_3)
        self.lbl.setGeometry(QtCore.QRect(10, 180, 0, 381))


        ## ACTIVATED OR NOT
        self.tableWidget.setVisible(False)
        self.pushButton_next.setEnabled(False)
        self.pushButton_previous.setEnabled(False)
        self.valider.setEnabled(False)
        self.start.setEnabled(False)
        self.pushButton_table.setEnabled (False)
        self.pushButton_save.setEnabled (False)


        self.toolButton.clicked.connect(self.open_dataset)
        self.start.clicked.connect(self.preprocess)
        self.pushButton_previous.clicked.connect(self.previous_state)
        self.pushButton_next.clicked.connect(self.next_state)
        self.valider.clicked.connect (self.get_dataset_information)
        self.pushButton_table.clicked.connect (self.showTable)
        self.pushButton_save.clicked.connect (self.save)
    
        p = QtGui.QPalette()
        p.setColor(QtGui.QPalette.Window, QtGui.QColor(133,132,130))
        p.setColor(QtGui.QPalette.Button, QtGui.QColor(153,150,150))
        p.setColor(QtGui.QPalette.WindowText, QtGui.QColor(13,13,12))
        p.setColor(self.toolBox.backgroundRole(), QtGui.QColor(189,187,185))
        p.setColor(QtGui.QPalette.ButtonText, QtGui.QColor(13,13,12))
        self.setPalette(p)
    
        self.retranslateUi(self)
        self.tabWidget.setCurrentIndex(0)
        self.toolBox.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(self)
    
    def retranslateUi(self,MainWindow):
        _translate = QtCore.QCoreApplication.translate


        MainWindow.setWindowTitle(_translate("MainWindow", "Graphic Interface"))
        self.label_2.setText(_translate("MainWindow", "Dataset Information:"))
        self.label_instances.setText(_translate("MainWindow", "Number of instances:"))
        self.label_classes.setText(_translate("MainWindow", "Number of classes:"))
        self.label.setText(_translate("MainWindow", "Select a dataset:"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab1), _translate("MainWindow", "Preprocessing"))


        self.toolBox.setItemText(self.toolBox.indexOf(self.page_resize), _translate("MainWindow", "Resizing"))
        self.label_3.setText(_translate("MainWindow", "Preprocessing parameters:"))
        self.start.setText(_translate("MainWindow", "Start"))


        self.pushButton_previous.setText(_translate("MainWindow", "Previous image"))
        self.pushButton_next.setText(_translate("MainWindow", "Next image"))
        self.pushButton_table.setText (_translate ("MainWindow", "Show Matrix"))
        self.pushButton_save.setText (_translate ("MainWindow", "Save"))
        self.pushButton_return.setText (_translate ("MainWindow", "Back"))




        self.label_4.setText(_translate("MainWindow", "Visualization:"))
        self.toolButton.setText(_translate("MainWindow", "..."))
        self.valider.setText(_translate("MainWindow", "Validate"))
Пример #57
0
 def testBasic(self):
     # Also related to bug #244, on existence of setVisible'''
     widget = QWidget()
     self.assert_(not widget.isVisible())
     widget.setVisible(True)
     self.assert_(widget.isVisible())
def template(qtbot):
    return QWidget()
Пример #59
0
 def show(self):
     QWidget.show(self)
     self.called = True
Пример #60
0
from PySide2.QtWidgets import QLabel, QWidget, QPushButton, QApplication, QVBoxLayout
app = QApplication([])
mainWidget = QWidget()

layout = QVBoxLayout()

label = QLabel("Ceci est un QLabel")
button = QPushButton("Ceci est un QPushButton")
button2 = QPushButton("Cancel")

layout.addWidget(label)
layout.addWidget(button)
layout.addWidget(button2)

mainWidget.setLayout(layout)

mainWidget.show()
app.exec_()