コード例 #1
0
ファイル: wizard.py プロジェクト: FLuptak/rpg
    def __init__(self, Wizard, parent=None):
        super(FinalPage, self).__init__(parent)

        self.base = Wizard.base
        self.Wizard = Wizard
        ''' On this page will be "Finish button" instead of "Next" '''
        FinalPage.setFinalPage(self, True)
        self.setTitle(self.tr("Final page"))
        self.setSubTitle(self.tr("Your package was successfully created"))
        self.finalLabel = QLabel()
        self.coprLabel = QLabel()
        self.coprLabel.setText(
            "<html><head/><body><p align=\"center\"><span" +
            "style=\" font-size:14pt;\">" +
            "For upload your package to Copr, choose Next " +
            "button, otherwise use Finish button." +
            "</p></body></html>")
        self.rpmButton = QPushButton("Build compiled rpm package")
        self.rpmButton.setMinimumHeight(45)
        self.rpmButton.setMinimumWidth(200)
        self.rpmButton.setMaximumHeight(45)
        self.rpmButton.setMaximumWidth(250)
        self.rpmButton.clicked.connect(self.buildRpm)

        mainLayout = QVBoxLayout()
        grid = QGridLayout()
        grid.addWidget(self.rpmButton)
        grid.setAlignment(QtCore.Qt.AlignCenter)
        mainLayout.addSpacing(100)
        mainLayout.addWidget(self.finalLabel)
        mainLayout.addSpacing(50)
        mainLayout.addWidget(self.coprLabel)
        mainLayout.addSpacing(50)
        mainLayout.addLayout(grid)
        self.setLayout(mainLayout)
コード例 #2
0
ファイル: tabledialog.py プロジェクト: starofrainnight/retext
    def __init__(self, parent):
        QDialog.__init__(self, parent)
        self.parent = parent
        self.setWindowTitle(self.tr('Insert table'))
        buttonBox = QDialogButtonBox(self)
        buttonBox.setStandardButtons(QDialogButtonBox.Ok |
                                     QDialogButtonBox.Cancel)
        buttonBox.accepted.connect(self.makeTable)
        buttonBox.rejected.connect(self.close)

        layout = QGridLayout(self)

        rowsLabel = QLabel(self.tr('Number of rows') + ':', self)
        columnsLabel = QLabel(self.tr('Number of columns') + ':', self)
        self.rowsSpinBox = QSpinBox(self)
        self.columnsSpinBox = QSpinBox(self)

        self.rowsSpinBox.setRange(1, 10)
        self.columnsSpinBox.setRange(1, 10)
        self.rowsSpinBox.setValue(3)
        self.columnsSpinBox.setValue(3)

        layout.addWidget(rowsLabel, 0, 0)
        layout.addWidget(self.rowsSpinBox, 0, 1, Qt.AlignRight)
        layout.addWidget(columnsLabel, 1, 0)
        layout.addWidget(self.columnsSpinBox, 1, 1, Qt.AlignRight)
        layout.addWidget(buttonBox, 2, 0, 1, 2)
コード例 #3
0
ファイル: qt.py プロジェクト: JustinTArthur/electrum
    def virtual_keyboard(self, i, pw):
        i = i % 3
        if i == 0:
            chars = 'abcdefghijklmnopqrstuvwxyz '
        elif i == 1:
            chars = 'ABCDEFGHIJKLMNOPQRTSUVWXYZ '
        elif i == 2:
            chars = '1234567890!?.,;:/%&()[]{}+-'

        n = len(chars)
        s = []
        for i in range(n):
            while True:
                k = random.randint(0, n - 1)
                if k not in s:
                    s.append(k)
                    break

        def add_target(t):
            return lambda: pw.setText(str(pw.text()) + t)

        vbox = QVBoxLayout()
        grid = QGridLayout()
        grid.setSpacing(2)
        for i in range(n):
            l_button = QPushButton(chars[s[i]])
            l_button.setFixedWidth(25)
            l_button.setFixedHeight(25)
            l_button.clicked.connect(add_target(chars[s[i]]))
            grid.addWidget(l_button, i // 6, i % 6)

        vbox.addLayout(grid)

        return vbox
コード例 #4
0
ファイル: web.py プロジェクト: devkang89/QWebview-plus
    def _setupInspector(self):
        """
        F12키를 누르면 "개발자 도구"가 노출됨
        """
        # webinspector
        self.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
        self.webInspector = QWebInspector(self)
        self.webInspector.setPage(self.page())

        #Keyboard shortcuts
        shortcut = {}
        shortcut['F12'] = QShortcut(self)
        shortcut['F12'].setContext(Qt.ApplicationShortcut)
        shortcut['F12'].setKey(Qt.Key_F12)
        shortcut['F12'].activated.connect(self._toggleInspector)
        #F5 - Page reloading
        shortcut['F5'] = QShortcut(self)
        shortcut['F5'].setKey(Qt.Key_F5)
        shortcut['F5'].activated.connect(self.reload)

        # Devtools
        self.webInspector.setVisible(True)
        self.devTool = QDialog(self)
        self.devTool.setWindowTitle("Development Tool")
        self.devTool.resize(950, 400)
        layout = QGridLayout()
        layout.setContentsMargins(0,0,0,0)
        layout.addWidget(self.webInspector)
        self.devTool.setLayout(layout)
コード例 #5
0
    def init(self):

        vbox = QVBoxLayout()
        self.setLayout(vbox)

        text = QLineEdit('0.')
        text.setReadOnly(True)
        vbox.addWidget(text)

        grid = QGridLayout()
        vbox.addLayout(grid)

        names = ['Exit', 'AC', 'DEL', '+/-',
                 '7', '8', '9', '/',
                 '4', '5', '6', '*',
                 '1', '2', '3', '-',
                 '0', '.', '=', '+']

        positions = [(i, j) for i in range(5) for j in range(4)]

        for position, name in zip(positions, names):
            btn = QPushButton(name)
            grid.addWidget(btn, *position)

        self.move(300, 200)
        self.setWindowTitle('Calculator')
        self.show()
コード例 #6
0
ファイル: shortcut.py プロジェクト: Prodesire/SimpleProjects
class ShortcutWindow(QMainWindow):
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)
        self.setWindowTitle('Shortcut')
        self.setWindowIcon(QIcon(os.path.join(os.curdir, 'icons/Shortcut.ico')))
        self.resize(300, 400)
        screenRect = QDesktopWidget().screenGeometry()
        self.move((screenRect.width() - self.width()) / 2, (screenRect.height() - self.height()) / 2)

        self.mainWidget = QWidget()
        self.gridlayout = QGridLayout()
        self.mainWidget.setLayout(self.gridlayout)
        self.setCentralWidget(self.mainWidget)

        try:
            configloader = ConfigLoader()
        except ConfigError as e:
            QMessageBox.about(self, 'Config Error', str(e))
            return

        for i, (title, action) in enumerate(configloader.config.items()):
            if 'open' in action[0]:
                button = OpenButton(title, action[1])
            elif 'edit' in action[0]:
                button = EditButton(title, action[1], action[2])
            elif 'cmd' in action[0]:
                button = CmdButton(title, action[1])
            else:
                continue

            colnum = 2
            self.gridlayout.addWidget(button, i / colnum, i % colnum)
コード例 #7
0
    def __init__(self, parent=None):
        super().__init__(parent)

        date = self.getdata()
        rates = sorted(self.rates.keys(), key=str.lower)
     #   print(rates)

        dateLabel = QLabel(date)
        self.fromComboBox = QComboBox()
        self.fromComboBox.addItems(rates)
        self.fromSpinBox = QDoubleSpinBox()
        self.fromSpinBox.setRange(0.01, 10000000.00)
        self.fromSpinBox.setValue(1.00)
        self.toComboBox = QComboBox()
        self.toComboBox.addItems(rates)
        self.toLabel = QLabel("1.00")
        grid = QGridLayout()
        grid.addWidget(dateLabel, 0, 0)
        grid.addWidget(self.fromComboBox, 1, 0)
        grid.addWidget(self.fromSpinBox, 1, 1)
        grid.addWidget(self.toComboBox, 2, 0)
        grid.addWidget(self.toLabel, 2, 1)
        self.setLayout(grid)
        self.fromComboBox.currentIndexChanged.connect(self.updateUi)
        self.toComboBox.currentIndexChanged.connect(self.updateUi)
        self.fromSpinBox.valueChanged.connect(self.updateUi)
        self.setWindowTitle("Currency")
コード例 #8
0
    def initView(self):
        '''创建界面'''
        scrollArea = QScrollArea(self)    # 滚动区域
        scrollArea.setWidgetResizable(True)
        self.setCentralWidget(scrollArea)

        scrollWidget = QWidget()
        scrollArea.setWidget(scrollWidget)
        gridLayout = QGridLayout(scrollWidget)    # 网格布局

        # 从QEasingCurve获取所有的type
        curve_types = [(n, c) for n, c in QEasingCurve.__dict__.items()
            if isinstance(c, QEasingCurve.Type)]
        curve_types.sort(key = lambda ct: ct[1])
        i = 0
        for curve_name, curve_type in curve_types:
            index = curve_type % 4
            widget = QWidget()
            widget.setObjectName("_BorderWidget")
            widget.setStyleSheet("QWidget#_BorderWidget{border: 1px solid black;}")
            name = QLabel("QEasingCurve." + curve_name, widget)
            mpb = MetroProgressCircleBar(widget, curve_type)
            layout = QVBoxLayout(widget)
            layout.addWidget(name)
            layout.addWidget(mpb)
            gridLayout.addWidget(widget, i, index, 1, 1)
            if index == 3:
                i += 1
コード例 #9
0
ファイル: resizedlg.py プロジェクト: drongh/pyqt5-book-code
    def __init__(self, width, height, parent=None):
        super(ResizeDlg, self).__init__(parent)

        widthLabel = QLabel("&Width:")
        self.widthSpinBox = QSpinBox()
        widthLabel.setBuddy(self.widthSpinBox)
        self.widthSpinBox.setAlignment(Qt.AlignRight|Qt.AlignVCenter)
        self.widthSpinBox.setRange(4, width * 4)
        self.widthSpinBox.setValue(width)
        heightLabel = QLabel("&Height:")
        self.heightSpinBox = QSpinBox()
        heightLabel.setBuddy(self.heightSpinBox)
        self.heightSpinBox.setAlignment(Qt.AlignRight|
                                        Qt.AlignVCenter)
        self.heightSpinBox.setRange(4, height * 4)
        self.heightSpinBox.setValue(height)

        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok|
                                     QDialogButtonBox.Cancel)

        layout = QGridLayout()
        layout.addWidget(widthLabel, 0, 0)
        layout.addWidget(self.widthSpinBox, 0, 1)
        layout.addWidget(heightLabel, 1, 0)
        layout.addWidget(self.heightSpinBox, 1, 1)
        layout.addWidget(buttonBox, 2, 0, 1, 2)
        self.setLayout(layout)

        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
#        self.connect(buttonBox, SIGNAL("accepted()"), self.accept)
#        self.connect(buttonBox, SIGNAL("rejected()"), self.reject)

        self.setWindowTitle("Image Changer - Resize")
コード例 #10
0
ファイル: importdialog.py プロジェクト: johnymachine/csv2db
    def __init__(self, parent=None):
        super(ImportDialog, self).__init__(parent)

        self.done = False
        self.requestCancel = False

        self.rowsChunk = CsvReader.ROWS_CHUNK

        self.rowCount = 0
        self.timeStart = time.time()

        self.timer = QTimer()
        self.timer.timeout.connect(self.updateProcessed)
        self.timer.start(500)

        label = QLabel("Probíhá zpracování, prosím čekejte.")
        
        self.labelRows = QLabel("0")
        self.labelSpeed = QLabel("0")

        mainLayout = QGridLayout()
        mainLayout.addWidget(label, 0, 0, 1, 2)
        mainLayout.addWidget(QLabel("Zpracováno řádků: "), 1, 0)
        mainLayout.addWidget(self.labelRows, 1, 1)
        mainLayout.addWidget(QLabel("Rychlost zpracování: "), 2, 0)
        mainLayout.addWidget(self.labelSpeed, 2, 1)
        self.setLayout(mainLayout)

        self.setWindowTitle("Import")
        self.setModal(True)
コード例 #11
0
    def initUI(self):
        
        # widgetを作る
        widgets = [ [None for j in range(10)] for i in range(10) ]
        for j in range(10):
            for i in range(10):
                widgets[j][i] = return_widget(i+j)

        # connectする
        H = 10
        W = 10
        for j in range(H):
            for i in range(W):
                if i == W-1:
                    i2 = 0
                    j2 = (j + 1) % W
                else:
                    i2 = i + 1
                    j2 = j
                widgets[j][i].valueChanged.connect(widgets[j2][i2].setValue)

        # gridに配置
        grid = QGridLayout()
        self.setLayout(grid)
        for j in range(H):
            for i in range(W):
                grid.addWidget(widgets[j][i], j, i)
                
        self.move(300, 150)
        self.setWindowTitle('Too Many Sliders')
        self.show()
コード例 #12
0
ファイル: CalendarGrid.py プロジェクト: JamesWrigley/paion
class CalendarGrid(QWidget):
    currentDay = -1
    monthModel = []
    mainLayout = None

    def __init__(self):
        super().__init__()

        self.mainLayout = QGridLayout()
        self.setLayout(self.mainLayout)

    def onSelectionChanged(self, day):
        dayIndex = self.mainLayout.indexOf(day)
        if self.currentDay != -1 and dayIndex != self.currentDay:
            self.monthModel[self.currentDay].isSelected = False
            self.monthModel[self.currentDay].leaveEvent(None)

        self.currentDay = dayIndex

    def setMonth(self, month):
        assert all(type(week) == list for week in month)

        # Clear the grid and the month model
        while self.mainLayout.count():
            self.mainLayout.itemAt(self.mainLayout.count() - 1).widget().setParent(None)
        self.monthModel.clear()

        for i, week in enumerate(month):
            for j, day in enumerate(week):
                cell = Day(day)
                self.monthModel.append(cell)
                cell.selected.connect(self.onSelectionChanged)
                self.mainLayout.addWidget(cell, i, j)
コード例 #13
0
    def _createEncodingBox(self):
        groupbox = QGroupBox(_("File Encoding"))
        layout = QGridLayout()


        self._autoEncoding = QCheckBox(_("Auto input encoding"), self)
        self._inputEncoding = QComboBox(self)
        self._inputEncoding.addItems(ALL_ENCODINGS)
        self._inputEncoding.setDisabled(self._autoEncoding.isChecked())
        inputLabel = QLabel(_("Input encoding"))

        self._changeEncoding = QCheckBox(_("Change encoding on save"), self)
        self._outputEncoding = QComboBox(self)
        self._outputEncoding.addItems(ALL_ENCODINGS)
        self._outputEncoding.setEnabled(self._changeEncoding.isChecked())
        outputLabel = QLabel(_("Output encoding"))

        layout.addWidget(self._autoEncoding, 0, 0)
        layout.addWidget(self._inputEncoding, 1, 0)
        layout.addWidget(inputLabel, 1, 1)
        layout.addWidget(self._changeEncoding, 2, 0)
        layout.addWidget(self._outputEncoding, 3, 0)
        layout.addWidget(outputLabel, 3, 1)
        groupbox.setLayout(layout)
        return groupbox
コード例 #14
0
	def initUI(self):

		# self.setStyleSheet( "background-color : grey")
		researchLabel = QLabel('Player Name')
		researchLabel.setFont( QFont("Fira Mono Bold", 11))
		researchLabel.adjustSize()
		resultsLabel = QLabel('Search results')
		resultsLabel.setFont( QFont("Fira Mono Bold", 11))
		resultsLabel.adjustSize()

		researchEdit = QLineEdit()
		researchEdit.setStyleSheet( "border : 2px solid #75FF6961; border-radius : 5px; background-color : #cbcbcb")
		researchEdit.setFont( QFont("Fira Mono Bold",12))
		researchEdit.returnPressed.connect(self.newResearch)

		grid = QGridLayout()
		grid.setSpacing(4)
		grid.addWidget(researchLabel, 1, 0)
		grid.addWidget(researchEdit, 1, 1)
		grid.addWidget(resultsLabel, 2, 0)
		self.setLayout(grid)
		# self.setGeometry(100, 100, 1000, 400)
		self.setWindowTitle('Player Searcher')
		self.show()

		self.researchEdit = researchEdit
		self.grid = grid
コード例 #15
0
ファイル: configurator.py プロジェクト: np/MadCatz
class T_window(QWidget):
    def __init__(self):
        super().__init__()
        self.tabs = QTabWidget()
        self.com = T_communication()
        self.pbar = QProgressBar()
        self.pbar.setFormat("Battery : %p%")
        self.grid = QGridLayout()

        self.setLayout(self.grid)
        self.grid.addWidget(self.pbar)
        self.grid.addWidget(self.tabs)

        self.dpi = T_dpi()
        self.com.getDpi(self.dpi)
        self.dpi.dataHasBeenSent()
        self.t = []
        for i in range(0, 4):
            self.t.append(T_tab(i, self.dpi, self.com))
            self.tabs.addTab(self.t[i], "Mode " + str(i + 1))

        self.data = T_data(self.pbar, self.tabs, self.dpi, self.com)
        for i in range(0, 4):
            self.t[i].sendButton.clicked.connect(self.data.sendDpi)
            self.t[i].resetButton.clicked.connect(self.com.resetDpi)
        self.timer = QBasicTimer()
        self.timer.start(100, self.data)
        self.tabs.currentChanged.connect(self.com.sendMode)
コード例 #16
0
ファイル: pyelmemu.py プロジェクト: michalsz89/pyelmemu
    def init_ui(self):
        grid = QGridLayout()

        btn0 = QPushButton("key_0")
        btn0.clicked.connect(lambda:self.btn_clicked(0))
        grid.addWidget(btn0)

        btn1 = QPushButton("key_1")
        btn1.clicked.connect(lambda:self.btn_clicked(1))
        grid.addWidget(btn1)

        btn2 = QPushButton("key_2")
        btn2.clicked.connect(lambda:self.btn_clicked(2))
        grid.addWidget(btn2)

        btn3 = QPushButton("key_3")
        btn3.clicked.connect(lambda:self.btn_clicked(3))
        grid.addWidget(btn3)

        btnExit = QPushButton("Exit")
        btnExit.clicked.connect(self.deinit);
        grid.addWidget(btnExit)

        self.setLayout(grid)
        self.setGeometry(0, 0, 500, 500)
        self.setWindowTitle("pyelmemu")
        self.show()
コード例 #17
0
    def _initUi(self, name, baseDate):
        self.setWindowTitle('行业对比[{0}]-基准日期[{1}]'.format(name, baseDate))
 
        # 控件
        forwardNTDaysLabel = QLabel('向前N日涨幅(%)')
        self._forwardNTDaysLineEdit = QLineEdit('30')

        self._industry2CheckBox = QCheckBox('行业二级分级')
        #self._industry2CheckBox.setChecked(True)

        self._industry3CheckBox = QCheckBox('行业三级分级')
        self._industry3CheckBox.setChecked(True)

        cancelPushButton = QPushButton('Cancel')
        okPushButton = QPushButton('OK')
        cancelPushButton.clicked.connect(self._cancel)
        okPushButton.clicked.connect(self._ok)

        # 布局
        grid = QGridLayout()
        grid.setSpacing(10)
 
        grid.addWidget(forwardNTDaysLabel, 0, 0)
        grid.addWidget(self._forwardNTDaysLineEdit, 0, 1)

        grid.addWidget(self._industry2CheckBox, 1, 0)
        grid.addWidget(self._industry3CheckBox, 1, 1)

        grid.addWidget(okPushButton, 2, 1)
        grid.addWidget(cancelPushButton, 2, 0)
 
        self.setLayout(grid)

        self.setMinimumWidth(QApplication.desktop().size().width()//5)
コード例 #18
0
 def __init__(self, parent=None):
     super(GlobalFontDialog, self).__init__(parent)
     self._messageLabel.setWordWrap(True)
     
     layout = QGridLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     self.mainWidget().setLayout(layout)
     
     self.romanLabel = QLabel()
     self.romanCombo = QFontComboBox()
     self.sansLabel = QLabel()
     self.sansCombo = QFontComboBox()
     self.typewriterLabel = QLabel()
     self.typewriterCombo = QFontComboBox(fontFilters=QFontComboBox.MonospacedFonts)
     
     layout.addWidget(self.romanLabel, 0, 0)
     layout.addWidget(self.romanCombo, 0, 1, 1, 2)
     layout.addWidget(self.sansLabel, 1, 0)
     layout.addWidget(self.sansCombo, 1, 1, 1, 2)
     layout.addWidget(self.typewriterLabel, 2, 0)
     layout.addWidget(self.typewriterCombo, 2, 1, 1, 2)
     
     self.loadSettings()
     self.finished.connect(self.saveSettings)
     app.translateUI(self)
コード例 #19
0
def createReportDesignPage():
    page = QWizardPage()
    page.setTitle("Report Design")
    page.setSubTitle("Choose Fields to report.")

    listWidget = QtWidgets.QListWidget()
    listWidget.setGeometry(QtCore.QRect(130, 50, 131, 192))
    listWidget.setTabKeyNavigation(True)
    listWidget.setObjectName("FieldList")


    # nameLabel = QLabel("Name:")
    # nameLineEdit = QLineEdit()
    #
    # emailLabel = QLabel("Email address:")
    # emailLineEdit = QLineEdit()

    layout = QGridLayout()
    layout.addWidget(listWidget, 0, 0)
    # layout.addWidget(nameLineEdit, 0, 1)
    # layout.addWidget(emailLabel, 1, 0)
    # layout.addWidget(emailLineEdit, 1, 1)
    page.setLayout(layout)

    return page
コード例 #20
0
    def dialogExtract2csv(self):
        d = QDialog(self)
        d.setFixedWidth(450)
        d.setWindowTitle("Extract data to Csv")
        d.setVisible(True)
        vbox = QVBoxLayout()
        tabWidget = QTabWidget()
        for name, mod in list(self.moduleDict.items()):
            wid = QWidget()
            grid = QGridLayout()
            grid.setSpacing(20)
            wid.dateStart = QLineEdit('%s00:00' % dt.datetime.now().strftime("%Y-%m-%dT"))
            wid.dateEnd = QLineEdit("Now")
            grid.addWidget(QLabel("From"), 0, 0)
            grid.addWidget(wid.dateStart, 0, 1)
            grid.addWidget(QLabel("To"), 0, 2)
            grid.addWidget(wid.dateEnd, 0, 3)
            for i, device in enumerate(mod.devices):
                checkbox = QCheckBox(device.deviceLabel)
                checkbox.stateChanged.connect(partial(self.csvUpdateTab, name, checkbox, device))
                checkbox.setCheckState(2)
                grid.addWidget(checkbox, 1 + i, 0, 1, 3)

            wid.setLayout(grid)
            tabWidget.addTab(wid, name)

        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        buttonBox.button(QDialogButtonBox.Ok).clicked.connect(partial(self.extract2csv, tabWidget, d))
        buttonBox.button(QDialogButtonBox.Cancel).clicked.connect(d.close)

        vbox.addWidget(tabWidget)
        vbox.addWidget(buttonBox)
        d.setLayout(vbox)
コード例 #21
0
ファイル: gui_z3.py プロジェクト: EdwardBetts/python101
    def __init__(self, parent=None):
        super(LoginDialog, self).__init__(parent)

        # etykiety, pola edycyjne i przyciski ###
        loginLbl = QLabel('Login')
        hasloLbl = QLabel('Hasło')
        self.login = QLineEdit()
        self.haslo = QLineEdit()
        self.przyciski = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
            Qt.Horizontal, self)

        # układ główny ###
        uklad = QGridLayout(self)
        uklad.addWidget(loginLbl, 0, 0)
        uklad.addWidget(self.login, 0, 1)
        uklad.addWidget(hasloLbl, 1, 0)
        uklad.addWidget(self.haslo, 1, 1)
        uklad.addWidget(self.przyciski, 2, 0, 2, 0)

        # sygnały i sloty ###
        self.przyciski.accepted.connect(self.accept)
        self.przyciski.rejected.connect(self.reject)

        # właściwości widżetu ###
        self.setModal(True)
        self.setWindowTitle('Logowanie')
コード例 #22
0
ファイル: friptext.py プロジェクト: takedaiori/fripText
 def initUI(self):
     # 按钮
     self.frip_button = QPushButton('反转', self)
     self.frip_text = QTextEdit(self)
     self.frip_options = QPushButton('关于', self)
     self.frip_horizion = QPushButton('竖转', self)
     self.frip_backup = QPushButton('复原', self)
     self.frip_button.setStyleSheet('font-size: 10pt;')
     self.frip_horizion.setStyleSheet('font-size: 10pt;')
     self.frip_backup.setStyleSheet('font-size: 10pt;')
     self.frip_options.setStyleSheet('font-size: 10pt;')
     self.frip_text.setStyleSheet('font-size: 11pt;')
     # 备份
     self.backup = ''
     # 布局
     frip_grid = QGridLayout()
     frip_grid.setSpacing(10)
     frip_grid.addWidget(self.frip_text, 1, 0, 5, 1)
     frip_grid.addWidget(self.frip_button, 1, 1)
     frip_grid.addWidget(self.frip_horizion, 2, 1)
     frip_grid.addWidget(self.frip_backup, 3, 1)
     frip_grid.addWidget(self.frip_options, 4, 1)
     # Clipboard
     # self.frip_board = QApplication.clipboard()
     # 按钮信号映射
     self.frip_button.clicked.connect(self.frip_method)
     self.frip_horizion.clicked.connect(self.horizon)
     self.frip_options.clicked.connect(self.about)
     self.frip_backup.clicked.connect(self.makebackup)
     # 应用布局和规划窗口
     self.setLayout(frip_grid)
     self.setGeometry(300, 300, 350, 300)
     self.setWindowTitle('fripText')
     self.show()
コード例 #23
0
    def _initUi(self, colNames):
        self.setWindowTitle('列运算')
 
        # 控件
        table = DyTableWidget(parent=None, readOnly=True, index=False, floatCut=True, autoScroll=False)
        table.setColNames(['列名', '表达式'])
        rows = [[name, 'x[{0}]'.format(i)] for i, name in enumerate(colNames)]
        table.fastAppendRows(rows)

        descriptionLabel = QLabel('列运算表达式(Pandas语法)')
        self._expressionTextEdit = QTextEdit()

        cancelPushButton = QPushButton('Cancel')
        okPushButton = QPushButton('OK')
        cancelPushButton.clicked.connect(self._cancel)
        okPushButton.clicked.connect(self._ok)

        # 布局
        grid = QGridLayout()
        grid.setSpacing(10)
 
        grid.addWidget(table, 0, 0, 22, 1)

        grid.addWidget(descriptionLabel, 0, 1)

        grid.addWidget(self._expressionTextEdit, 1, 1, 20, 20)
 
        grid.addWidget(okPushButton, 0, 21)
        grid.addWidget(cancelPushButton, 1, 21)
 
 
        self.setLayout(grid)
        self.resize(QApplication.desktop().size().width()//2, QApplication.desktop().size().height()//4*3)
コード例 #24
0
    def _initUi(self):
        self.setWindowTitle('生成策略准备数据')
 
        # 控件
        dateLable = QLabel('日期')
        self._dateLineEdit = QLineEdit(datetime.now().strftime("%Y-%m-%d"))

        cancelPushButton = QPushButton('Cancel')
        okPushButton = QPushButton('OK')
        cancelPushButton.clicked.connect(self._cancel)
        okPushButton.clicked.connect(self._ok)

        self._strategies = {}
        self._strategyWidget = DyTreeWidget(self._getFields())

        # 布局
        grid = QGridLayout()
        grid.setSpacing(10)
 
        grid.addWidget(self._strategyWidget, 0, 0, 20, 10)
 
        grid.addWidget(dateLable, 0, 10, 1, 2)
        grid.addWidget(self._dateLineEdit, 1, 10, 1, 2)

        grid.addWidget(okPushButton, 2, 11)
        grid.addWidget(cancelPushButton, 2, 10)
 
        self.setLayout(grid)
        self.resize(QApplication.desktop().size().width()//3, QApplication.desktop().size().height()//2)
コード例 #25
0
class HelpDialog(QDialog):
    def __init__(self, parent, help_file):
        super(HelpDialog, self).__init__(parent)
        #QDialog.__init__(self, parent)

        self.setWindowTitle(_translate("Packaga Manager","Package Manager Help"))
        self.resize(700,500)
        self.setModal(True)

        self.layout = QGridLayout(self)
        self.htmlPart = QTextBrowser(self)
        self.layout.addWidget(self.htmlPart, 1, 1)

        locale = setSystemLocale(justGet = True)

        if locale in ["tr", "es", "en", "fr", "nl", "de", "sv"]:
            self.htmlPart.setSource(
                    QUrl("/usr/share/package-manager/help/%s/%s" %
                        (locale, help_files[help_file])))

        else:
            self.htmlPart.setSource(
                    QUrl("/usr/share/package-manager/help/en/%s" %
                        help_files[help_file]))
                    
        self.show()
コード例 #26
0
    def __init__(self):
        super(Window, self).__init__()

        aliasedLabel = self.createLabel("Aliased")
        antialiasedLabel = self.createLabel("Antialiased")
        intLabel = self.createLabel("Int")
        floatLabel = self.createLabel("Float")

        layout = QGridLayout()
        layout.addWidget(aliasedLabel, 0, 1)
        layout.addWidget(antialiasedLabel, 0, 2)
        layout.addWidget(intLabel, 1, 0)
        layout.addWidget(floatLabel, 2, 0)

        timer = QTimer(self)

        for i in range(2):
            for j in range(2):
                w = CircleWidget()
                w.setAntialiased(j != 0)
                w.setFloatBased(i != 0)

                timer.timeout.connect(w.nextAnimationFrame)

                layout.addWidget(w, i + 1, j + 1)

        timer.start(100)
        self.setLayout(layout)

        self.setWindowTitle("Concentric Circles")
コード例 #27
0
ファイル: settingsWindow.py プロジェクト: madig/trufont
    def __init__(self, parent=None):
        super().__init__(parent)
        self.name = self.tr("Misc")

        self.markColorLabel = QLabel(self.tr("Default flag colors:"), self)
        # TODO: enforce duplicate names avoidance
        self.markColorWidget = QTreeWidget(self)
        self.markColorWidget.setHeaderLabels(
            (self.tr("Color"), self.tr("Name")))
        self.markColorWidget.setRootIsDecorated(False)
        self.markColorWidget.setSelectionBehavior(
            QAbstractItemView.SelectRows)
        # TODO: make this work correctly, top-level items only
        # self.markColorWidget.setDragDropMode(QAbstractItemView.InternalMove)
        self.addItemButton = QPushButton("+", self)
        self.addItemButton.clicked.connect(self.addItem)
        self.removeItemButton = QPushButton("−", self)
        self.removeItemButton.clicked.connect(self.removeItem)

        self.loadRecentFileBox = QCheckBox(
            self.tr("Load most recent file on start"), self)

        layout = QGridLayout(self)
        l = 0
        layout.addWidget(self.markColorLabel, l, 0, 1, 3)
        l += 1
        layout.addWidget(self.markColorWidget, l, 0, 1, 3)
        l += 1
        layout.addWidget(self.addItemButton, l, 0)
        layout.addWidget(self.removeItemButton, l, 1)
        l += 1
        layout.addWidget(self.loadRecentFileBox, l, 0, 1, 3)
        self.setLayout(layout)

        self.readSettings()
コード例 #28
0
ファイル: qt.py プロジェクト: thrasher-/electrum-ltc
    def __init__(self, parent):
        super(MatrixDialog, self).__init__(parent)
        self.setWindowTitle(_("Trezor Matrix Recovery"))
        self.num = 9
        self.loop = QEventLoop()

        vbox = QVBoxLayout(self)
        vbox.addWidget(WWLabel(MATRIX_RECOVERY))

        grid = QGridLayout()
        grid.setSpacing(0)
        self.char_buttons = []
        for y in range(3):
            for x in range(3):
                button = QPushButton('?')
                button.clicked.connect(partial(self.process_key, ord('1') + y * 3 + x))
                grid.addWidget(button, 3 - y, x)
                self.char_buttons.append(button)
        vbox.addLayout(grid)

        self.backspace_button = QPushButton("<=")
        self.backspace_button.clicked.connect(partial(self.process_key, Qt.Key_Backspace))
        self.cancel_button = QPushButton(_("Cancel"))
        self.cancel_button.clicked.connect(partial(self.process_key, Qt.Key_Escape))
        buttons = Buttons(self.backspace_button, self.cancel_button)
        vbox.addSpacing(40)
        vbox.addLayout(buttons)
        self.refresh()
        self.show()
コード例 #29
0
ファイル: SubtitleTabs.py プロジェクト: mgoral/subconvert
    def __initWidgets(self):
        minimalSizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)

        # List of subtitles
        subListDelegate = SubListItemDelegate()
        self._model = QStandardItemModel(0, 3, self)
        self._model.setHorizontalHeaderLabels([_("Begin"), _("End"), _("Subtitle")])
        self._subList = QTableView(self)
        self._subList.setModel(self._model)
        self._subList.setItemDelegateForColumn(0, subListDelegate)
        self._subList.setItemDelegateForColumn(1, subListDelegate)
        self._subList.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch)

        self._searchBar = SearchBar(self)
        self._searchBar.hide()

        # Top toolbar
        toolbar = QHBoxLayout()
        toolbar.setAlignment(Qt.AlignLeft)
        #toolbar.addWidget(someWidget....)
        toolbar.addStretch(1)

        # Main layout
        grid = QGridLayout()
        grid.setSpacing(10)
        grid.setContentsMargins(0, 3, 0, 0)
        grid.addLayout(toolbar, 0, 0, 1, 1) # stretch to the right
        grid.addWidget(self._subList, 1, 0)
        grid.addWidget(self._searchBar, 2, 0)
        self.setLayout(grid)
コード例 #30
0
ファイル: grid_layout.py プロジェクト: anontx/pyqt_study
    def initUI(self):

        grid = QGridLayout()
        self.setLayout(grid)

        names = ['Cls', 'Bck', '', 'Close',
            '7', '8', '9', '/',
            '4', '5', '6', '*',
            '1', '2', '3', '-',
            '0', '.', '=', '+']

        positions = [(i, j) for i in range(5) for j in range(4)]

        for position, name in zip(positions, names):
            if name == '':
                continue

            button = QPushButton(name)
            grid.addWidget(button, *position)
            print(*position)
            print(grid.addWidget)

            self.setGeometry(300, 300, 500, 350)
            self.setWindowTitle('calculator')
            self.show()
コード例 #31
0
class DashboardMainWindow(QMainWindow):

    def __init__(self, gui_concentrate_handler, parent=None):
        super(DashboardMainWindow, self).__init__(parent)

        self.gui_concentrate_handler = gui_concentrate_handler

        self.__setup_ui__()

    def __setup_ui__(self):
        self.setObjectName(DashboardMainWindowStyles.main_page_style[0])
        self.setWindowModality(Qt.ApplicationModal)
        self.setContextMenuPolicy(Qt.NoContextMenu)
        self.setAcceptDrops(False)
        self.setAutoFillBackground(False)
        self.setDocumentMode(False)
        self.setDockNestingEnabled(False)
        self.setMouseTracking(True)
        self.central_widget = QWidget(self)
        self.central_widget.setStyleSheet(DashboardMainWindowStyles.central_widget_style)

        # Add Central Layout
        self.central_vlayout = QVBoxLayout(self.central_widget)
        self.central_vlayout.setContentsMargins(0, 0, 0, 0)
        self.central_vlayout.setObjectName("central_vlayout")

        # Add Containers
        self.containers = QFrame(self.central_widget)
        self.containers.setObjectName(DashboardMainWindowStyles.main_window_containers_style[0])
        self.containers.setStyleSheet(DashboardMainWindowStyles.main_window_containers_style[1])
        self.containers.setFrameShape(QFrame.NoFrame)
        self.containers.setFrameShadow(QFrame.Plain)
        self.containers.setLineWidth(0)

        # Add Containers Layout
        self.containers_gridlayout = QGridLayout(self.containers)
        self.containers_gridlayout.setContentsMargins(0, 0, 0, 0)
        self.containers_gridlayout.setSpacing(0)
        self.containers_gridlayout.setObjectName("containers_gridlayout")

        # Add Scroll Layout
        self.navigation_scroll_layout = QScrollArea(self.containers)
        self.navigation_scroll_layout.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.navigation_scroll_layout.setObjectName(DashboardMainWindowStyles.navigation_scroll_layout_style[0])
        self.navigation_scroll_layout.setStyleSheet(DashboardMainWindowStyles.navigation_scroll_layout_style[1])
        self.navigation_scroll_layout.setWidgetResizable(True)
        self.navigation_scroll_layout.setMinimumSize(QSize(71, 0))
        self.navigation_scroll_layout.setMaximumSize(QSize(71, 16777215))
        # add contents
        self.navigation_scroll_layout_contents = QWidget()
        self.navigation_scroll_layout_contents.setGeometry(QRect(0, 0, 71, self.height()))
        self.navigation_scroll_layout_contents.setObjectName("scroll_area_contents_page_containers")
        # َAdd navigation_layout
        self.navigation_grid_layout = QGridLayout(self.navigation_scroll_layout_contents)
        self.navigation_grid_layout.setContentsMargins(0, 0, 0, 0)
        self.navigation_grid_layout.setVerticalSpacing(0)
        self.navigation_grid_layout.setObjectName("navigation_grid_layout")
        # Add Navigation
        self.navigation_menu = QFrame(self.navigation_scroll_layout_contents)
        self.navigation_menu.setObjectName(DashboardMainWindowStyles.navigation_menu_style[0])
        self.navigation_menu.setStyleSheet(DashboardMainWindowStyles.navigation_menu_style[1])
        self.navigation_menu.setMaximumSize(QSize(71, 16777215))
        self.navigation_menu.setFrameShape(QFrame.StyledPanel)
        self.navigation_menu.setFrameShadow(QFrame.Raised)
        # set Media Screen
        self.__media_screen__()
        # Add MainFrame
        self.main_frame = QFrame(self.containers)
        size_policy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
        size_policy.setHorizontalStretch(0)
        size_policy.setVerticalStretch(0)
        size_policy.setHeightForWidth(self.main_frame.sizePolicy().hasHeightForWidth())
        self.main_frame.setSizePolicy(size_policy)
        self.main_frame.setObjectName("main_frame")

        # Add MainFrameLayout
        self.main_frame_gridLayout = QGridLayout(self.main_frame)
        self.main_frame_gridLayout.setContentsMargins(8, 8, 8, 8)
        self.main_frame_gridLayout.setSpacing(0)
        self.main_frame_gridLayout.setObjectName("gridLayout")
        # Add pic_main_logo
        self.pic_main_logo = QLabel(self.navigation_menu)
        self.pic_main_logo.setGeometry(QRect(0, 35, 71, 71))
        self.pic_main_logo.setAlignment(Qt.AlignCenter)
        self.pic_main_logo.setPixmap(QPixmap(AppPaths.GUI_ASSETS_ICONS_PATH + "/main_window/kodiak_icon.svg"))
        self.pic_main_logo.setObjectName("pic_main_logo")

        # Add LblTime
        self.lbl_time = QLabel(self.navigation_menu)
        self.lbl_time.setGeometry(QRect(0, 120, 69, 20))
        self.lbl_time.setObjectName(DashboardMainWindowStyles.lbl_time_style[0])
        self.lbl_time.setStyleSheet(DashboardMainWindowStyles.lbl_time_style[1])
        self.lbl_time.setAlignment(Qt.AlignCenter)

        # Add lblDate
        self.lbl_date = QLabel(self.navigation_menu)
        self.lbl_date.setGeometry(QRect(0, 140, 71, 21))
        self.lbl_date.setObjectName(DashboardMainWindowStyles.lbl_date_style[0])
        self.lbl_date.setStyleSheet(DashboardMainWindowStyles.lbl_date_style[1])
        self.lbl_date.setAlignment(Qt.AlignCenter)

        self.navigation_item_vlayout = QWidget(self.navigation_menu)
        self.navigation_item_vlayout.setGeometry(QRect(0, 220, 64, 431))
        self.navigation_item_vlayout.setObjectName("navigation_item_vlayout")

        # set li_hacktor_logo
        self.li_hacktor = QLabel(self.navigation_menu)
        self.li_hacktor.setAccessibleName("hacktor_logo")
        is_extra_screen, extra_screen_width, extra_screen_height = MediaScreen().is_extra_large()
        if is_extra_screen:
            if extra_screen_height <= 800:
                self.li_hacktor.hide()
            else:
                self.li_hacktor.setGeometry(QRect(25, self.height() - 80, 22, 33))
        else:
            if extra_screen_height > 800:
                self.li_hacktor.setGeometry(QRect(25, self.height() - 80, 22, 33))
            else:
                if extra_screen_height <= 600:
                    self.li_hacktor.hide()
                else:
                    self.li_hacktor.setGeometry(QRect(25, self.height(), 22, 33))

        self.li_hacktor.setPixmap(QPixmap(AppPaths.GUI_ASSETS_ICONS_PATH + "/main_window/hacktor_logo.svg"))
        self.li_hacktor.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter)

        self.page_containers = QFrame(self.main_frame)
        self.page_containers.setFrameShape(QFrame.StyledPanel)
        self.page_containers.setFrameShadow(QFrame.Raised)
        self.page_containers.setObjectName("center_page_maker")
        self.page_containers.setMinimumSize(self.width() - 111, self.height() - 111)

        self.main_frame_gridLayout.addWidget(self.page_containers, 1, 0, 1, 4)
        self.page_containers_grid_layout = QGridLayout(self.page_containers)
        self.page_containers_grid_layout.setObjectName("page_containers_gridLayout")

        from ...components.menu_containers.menu_containers import MenuContainers
        self.menu = MenuContainers(
            self.page_containers_grid_layout, gui_concentrate_handler=self.gui_concentrate_handler
        )
        self.menu.setup_ui(
            navigation_item_vlayout=self.navigation_item_vlayout, containers=self.containers,
            page_containers=self.page_containers
        )
        from ...components.top_navigation_bar_containers.top_navigation_bar_containers import TopNavigationBarContainers
        TopNavigationBarContainers(
            gui_concentrate_handler=self.gui_concentrate_handler
        ).setup_ui(containers=self.main_frame, main_gridLayout=self.main_frame_gridLayout)

        main_icon = QIcon()
        main_icon.addPixmap(QPixmap(AppPaths.GUI_ASSETS_ICONS_PATH + "/main_window/main_logo.ico"))
        self.setWindowIcon(main_icon)
        self.setAutoFillBackground(False)
        self.setStyleSheet(DashboardMainWindowStyles.main_page_style[1])
        self.setDocumentMode(False)
        self.setDockNestingEnabled(False)
        self.navigation_grid_layout.addWidget(self.navigation_menu, 0, 0, 1, 1)
        self.containers_gridlayout.addWidget(self.navigation_scroll_layout, 2, 2, 1, 1)
        self.navigation_scroll_layout.setWidget(self.navigation_scroll_layout_contents)

        # self.central_widget = QWidget(self)
        # self.central_widget.setStyleSheet(DashboardMainWindowStyles.central_widget_style)

        self.central_vlayout.addWidget(self.containers)
        self.containers_gridlayout.addWidget(self.main_frame, 2, 1, 1, 1)
        self.setCentralWidget(self.central_widget)
        self.__retranslateUi__()

    def __retranslateUi__(self):
        """
            this method for retranslate data in UI
        """
        _translate = QCoreApplication.translate
        self.setWindowTitle(_translate("MainWindow", "Kodiak"))
        self.lbl_time.setText("04:20")
        self.lbl_date.setText("2020/15/19")

    def __media_screen__(self):
        """
        this is private method for set a standard size window for Your monitor , Tablet or ...
        """
        is_small_screen, small_screen_width, small_screen_height = MediaScreen().is_small()
        is_medium_screen, medium_screen_width, medium_screen_height = MediaScreen().is_medium()
        is_large_screen, large_screen_width, large_screen_height = MediaScreen().is_large()
        is_extra_large_screen, extra_large_screen_width, extra_large_screen_height = MediaScreen().is_extra_large()

        if is_extra_large_screen:
            if extra_large_screen_height <= 900:

                self.setMinimumSize(QSize(extra_large_screen_width - (extra_large_screen_width / 4),
                                          extra_large_screen_height - (extra_large_screen_height / 4) + 100))
            else:

                self.setMinimumSize(QSize(extra_large_screen_width - (extra_large_screen_width / 4),
                                          extra_large_screen_height - (extra_large_screen_height / 6) + 50))
            self.navigation_menu.setMinimumSize(QSize(71, 700))
        elif is_large_screen:
            self.setMinimumSize(QSize(large_screen_width - 200, large_screen_height - 90))
            self.navigation_menu.setMinimumSize(QSize(71, 550))
        elif is_medium_screen:
            self.setMinimumSize(QSize(medium_screen_width - 100, medium_screen_height - 100))
            self.navigation_menu.setMinimumSize(QSize(71, 700))
        elif is_small_screen:
            self.setMinimumSize(QSize(small_screen_width - 150, small_screen_width - 250))
            self.navigation_menu.setMinimumSize(QSize(71, 700))
        else:
            # any thing else
            self.setMinimumSize(QSize(1150, 800))
            self.navigation_menu.setMinimumSize(QSize(71, 700))

        # Delete From Memory
        del is_small_screen, is_medium_screen, is_large_screen
        del small_screen_width, medium_screen_width, large_screen_width
        del small_screen_height, medium_screen_height, large_screen_height
コード例 #32
0
    def __init__(self):
        super().__init__()

        title = QLabel("Title")
        author = QLabel("Author")
        review = QLabel("Review")

        title_edit = QLineEdit()
        author_edit = QLineEdit()
        review_edit = QTextEdit()

        grid = QGridLayout()
        grid.setSpacing(10)

        grid.addWidget(title, 1, 0)
        grid.addWidget(title_edit, 1, 1)

        grid.addWidget(author, 2, 0)
        grid.addWidget(author_edit, 2, 1)

        grid.addWidget(review, 3, 0)
        grid.addWidget(review_edit, 3, 1, 5, 1)

        self.setLayout(grid)
        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle("Review")
        self.show()
コード例 #33
0
    def init_t1_ui(self, tab):
        '''
            Initialise l'onglet 1
            @param : onglet 1
        '''
        self.tab = tab
        layout = QGridLayout(self)

        #Combobox prof/salle
        self.cb_filtre = QComboBox(self)
        self.cb_filtre.addItems(["Professeur", "Salle"])
        self.cb_filtre.currentIndexChanged.connect(self.selectionchange)
        layout.addWidget(self.cb_filtre, 1, 1, 1, 1)

        #Combobox pr/salle
        self.cb_pr_salle = QComboBox(self)
        self.cb_pr_salle.addItems(self.df_param_pr)
        layout.addWidget(self.cb_pr_salle, 2, 1, 1, 1)

        #Textbox période validité
        self.box_dt_deb = QLineEdit(self)
        self.box_dt_deb.setPlaceholderText(
            "Début période validité - ex : 2020-01-01")
        layout.addWidget(self.box_dt_deb, 2, 2, 1, 1)
        self.box_dt_fin = QLineEdit(self)
        self.box_dt_fin.setPlaceholderText(
            "Fin période validité - ex : 2020-01-07")
        layout.addWidget(self.box_dt_fin, 2, 3, 1, 1)

        #Résultat
        self.result = QTextEdit(self)
        layout.addWidget(self.result, 4, 1, 5, 3)

        #Boutton validation
        self.button = QPushButton("Filtrer", self)
        layout.addWidget(self.button, 3, 1, 1, 1)
        self.button.clicked.connect(self.on_click_t1)

        self.tab.setLayout(layout)
        self.show()
コード例 #34
0
    def init_t2_ui(self, tab):
        '''
            Initialise l'onglet 2
            @param : onglet 2
        '''
        self.tab = tab
        layout = QGridLayout(self)

        #Combobox jour
        self.cb_jour = QComboBox(self)
        self.cb_jour.addItems(self.df_jour)
        layout.addWidget(self.cb_jour, 2, 1, 1, 1)

        #Textbox période validité
        self.box_dt_deb_t2 = QLineEdit(self)
        self.box_dt_deb_t2.setPlaceholderText(
            "Début période validité - ex : 2020-01-01")
        layout.addWidget(self.box_dt_deb_t2, 2, 2, 1, 1)
        self.box_dt_fin_t2 = QLineEdit(self)
        self.box_dt_fin_t2.setPlaceholderText(
            "Fin période validité - ex : 2020-01-07")
        layout.addWidget(self.box_dt_fin_t2, 2, 3, 1, 1)

        #Textbox créneau
        self.box_cren_deb = QLineEdit(self)
        self.box_cren_deb.setPlaceholderText("Début du créneau - ex : 20:00")
        layout.addWidget(self.box_cren_deb, 3, 2, 1, 1)
        self.box_cren_fin = QLineEdit(self)
        self.box_cren_fin.setPlaceholderText("Fin du créneau - ex : 21:00")
        layout.addWidget(self.box_cren_fin, 3, 3, 1, 1)

        #Affichage résultat
        self.result_t2 = QTextEdit(self)
        layout.addWidget(self.result_t2, 5, 1, 4, 3)

        #Boutton validation
        self.button = QPushButton("Filtrer", self)
        layout.addWidget(self.button, 4, 1, 1, 1)
        self.button.clicked.connect(self.on_click_t2)

        self.tab.setLayout(layout)
        self.show()
コード例 #35
0
    def initUI(self):
        """combo_daq = []
                for i in list(range(8)):
                        exec("ch%d" % i)
                        "ch%d"%i=QComboBox(self)
                        "ch%d"%i.addItem("Not_use")
                        #exec("ch%d.addItem('Ge')" % i)
                        #exec("ch%d.addItem('CsI')" % i)
                        #exec("ch%d.addItem('LqS')" % i)
                 for i in list(range(8)):
                        combo_daq[i]=QComboBox
                        combo_daq[i].addItem("Not_use")
                        combo_daq[i].addItem("Ge")
                        combo_daq[i].addItem("CsI")
                        combo_daq[i].addItem("LS")
                """
        combo_daq = QComboBox(self)
        combo_daq.addItem("kill")
        combo_daq.addItem("Ge")
        combo_daq.addItem("CsI")
        combo_daq.addItem("Ls")

        combo_beam = QComboBox(self)
        combo_beam.addItem("30 MeV")
        combo_beam.addItem("246 MeV")

        combo_RI = QComboBox(self)
        combo_RI.addItem("137Cs")
        combo_RI.addItem("60Co")
        combo_RI.addItem("22Na")
        combo_RI.addItem("252Cf")
        combo_RI.addItem("241AmBe")
        combo_RI.addItem("Background")

        event = QLabel("n")
        time = QLabel("t")
        source = QLabel("Source")
        beam = QLabel("Beam")
        RI = QLabel("RI")
        event_edit = QLineEdit(self)
        time_edit = QLineEdit(self)

        Run = QPushButton("Run", self)
        Edit = QPushButton("Edit", self)
        Edit.clicked.connect(self.EditbuttonClicked)
        Stop = QPushButton("Stop", self)

        ch = list(range(8))
        for i in list(range(8)):
            ch[i] = QLabel("ch%d" % i, self)

        layout = QGridLayout()
        """for i in list(range(8)):
                        layout.addWidget(ch[i], i, 0)
                """
        for i in list(range(8)):
            layout.addWidget(ch[i], i, 0)
        """layout.addWidget(ch, 0, 1)
                layout.addWidget(ch, 1, 1)
                layout.addWidget(ch, 2, 1)
                layout.addWidget(ch, 3, 1)
                layout.addWidget(ch, 4, 1)
                layout.addWidget(ch, 5, 1)
                layout.addWidget(ch, 6, 1)
                layout.addWidget(ch, 7, 1)"""

        layout.addWidget(combo_daq, 0, 1)
        layout.addWidget(combo_daq, 1, 1)
        layout.addWidget(combo_daq, 2, 1)
        layout.addWidget(combo_daq, 3, 1)
        layout.addWidget(combo_daq, 4, 1)
        layout.addWidget(combo_daq, 5, 1)
        layout.addWidget(combo_daq, 6, 1)
        layout.addWidget(combo_daq, 7, 1)
        layout.addWidget(event, 10, 0)
        layout.addWidget(event_edit, 10, 1)
        layout.addWidget(time, 11, 0)
        layout.addWidget(time_edit, 11, 1)
        layout.addWidget(source, 12, 0)
        layout.addWidget(beam, 13, 0)
        layout.addWidget(RI, 13, 1)
        layout.addWidget(combo_beam, 14, 0)
        layout.addWidget(combo_RI, 14, 1)
        layout.addWidget(Run, 15, 4)
        layout.addWidget(Edit, 15, 2)
        layout.addWidget(Stop, 15, 0)
        self.setLayout(layout)

        self.setGeometry(100, 200, 300, 400)
        self.show()
コード例 #36
0
    def __init__(self):
        super().__init__()
        grid = QGridLayout()
        self.setLayout(grid)

        N_box = QHBoxLayout()
        self.N = QTextEdit()
        self.N.setFixedHeight(30)
        N_box.addStretch()
        N_box.addWidget(QLabel("N=", self))
        N_box.addWidget(self.N)
        grid.addLayout(N_box, 0, 0)

        phi_N_box = QHBoxLayout()
        self.phi_N = QTextEdit()
        self.phi_N.setFixedHeight(30)
        phi_N_box.addStretch()
        phi_N_box.addWidget(QLabel("phi(N)=", self))
        phi_N_box.addWidget(self.phi_N)
        grid.addLayout(phi_N_box, 0, 1)

        e_box = QHBoxLayout()
        self.e = QTextEdit()
        self.e.setFixedHeight(30)
        e_box.addStretch()
        e_box.addWidget(QLabel("e=", self))
        e_box.addWidget(self.e)
        grid.addLayout(e_box, 1, 0)

        d_box = QHBoxLayout()
        self.d = QTextEdit()
        self.d.setFixedHeight(30)
        d_box.addStretch()
        d_box.addWidget(QLabel("d=", self))
        d_box.addWidget(self.d)
        grid.addLayout(d_box, 1, 1)

        self.message = QTextEdit()
        self.message.setPlainText("message")
        grid.addWidget(self.message, 2, 0)

        self.result_text = QTextEdit()
        grid.addWidget(self.result_text, 2, 1)

        hbox = QHBoxLayout()

        encode_btn = QPushButton("encode")
        decode_btn = QPushButton("decode")
        generate_btn = QPushButton("generate")

        encode_btn.clicked.connect(self.on_encode_clicked)
        decode_btn.clicked.connect(self.on_decode_clicked)
        generate_btn.clicked.connect(self.on_generate_clicked)

        hbox.addStretch()
        hbox.addWidget(generate_btn)
        hbox.addWidget(decode_btn)
        hbox.addWidget(encode_btn)

        grid.addLayout(hbox, 3, 0, 1, 3)

        self.show()
コード例 #37
0
    def setup_ui(self):
        """ Setup UI for the color options window.
        """
        self.setWindowTitle(self.title)
        centerPoint = QtWidgets.QDesktopWidget().availableGeometry().center()
        self.setGeometry(centerPoint.x() - self.width / 2,
                         centerPoint.y() - self.height / 2, self.width,
                         self.height)

        grid_lt = QGridLayout()

        lbl_info = QLabel(
            "Select the color for each channel:\n Please note that any non-standard channel "
            + "\n or names not recognized by the program will be " +
            "\nassigned the color of the midline.")
        grid_lt.addWidget(lbl_info, 0, 0)

        lbl_left = QLabel("Left hemisphere:")
        grid_lt.addWidget(lbl_left, 1, 0)
        lbl_right = QLabel("Right hemisphere:")
        grid_lt.addWidget(lbl_right, 2, 0)
        lbl_mid = QLabel("Midline:")
        grid_lt.addWidget(lbl_mid, 3, 0)

        groupbox_left_colors = QGroupBox()
        self.radio_col_r_lt = QRadioButton("R")
        self.radio_col_g_lt = QRadioButton("G")
        self.radio_col_b_lt = QRadioButton("B")
        self.radio_col_k_lt = QRadioButton("")
        self.k_btn_lt = QPushButton("Custom")
        self.k_btn_lt.clicked.connect(self.select_col_k_lt)
        hbox_left = QHBoxLayout()
        hbox_left.addWidget(self.radio_col_r_lt)
        hbox_left.addWidget(self.radio_col_g_lt)
        hbox_left.addWidget(self.radio_col_b_lt)
        hbox_left.addWidget(self.radio_col_k_lt)
        hbox_left.addWidget(self.k_btn_lt)
        groupbox_left_colors.setLayout(hbox_left)
        grid_lt.addWidget(groupbox_left_colors, 1, 1)

        groupbox_right_colors = QGroupBox()
        self.radio_col_r_rt = QRadioButton("R")
        self.radio_col_g_rt = QRadioButton("G")
        self.radio_col_b_rt = QRadioButton("B")
        self.radio_col_k_rt = QRadioButton("")
        self.k_btn_rt = QPushButton("Custom")
        self.k_btn_rt.clicked.connect(self.select_col_k_rt)
        hbox_right = QHBoxLayout()
        hbox_right.addWidget(self.radio_col_r_rt)
        hbox_right.addWidget(self.radio_col_g_rt)
        hbox_right.addWidget(self.radio_col_b_rt)
        hbox_right.addWidget(self.radio_col_k_rt)
        hbox_right.addWidget(self.k_btn_rt)
        groupbox_right_colors.setLayout(hbox_right)
        grid_lt.addWidget(groupbox_right_colors, 2, 1)

        groupbox_mid_colors = QGroupBox()
        self.radio_col_r_mid = QRadioButton("R")
        self.radio_col_g_mid = QRadioButton("G")
        self.radio_col_b_mid = QRadioButton("B")
        self.radio_col_k_mid = QRadioButton("")
        self.k_btn_mid = QPushButton("Custom")
        self.k_btn_mid.clicked.connect(self.select_col_k_mid)
        hbox_mid = QHBoxLayout()
        hbox_mid.addWidget(self.radio_col_r_mid)
        hbox_mid.addWidget(self.radio_col_g_mid)
        hbox_mid.addWidget(self.radio_col_b_mid)
        hbox_mid.addWidget(self.radio_col_k_mid)
        hbox_mid.addWidget(self.k_btn_mid)
        groupbox_mid_colors.setLayout(hbox_mid)
        grid_lt.addWidget(groupbox_mid_colors, 3, 1)

        self._set_init_col("lt")
        self._set_init_col("rt")
        self._set_init_col("mid")

        btn_exit = QPushButton('Ok', self)
        btn_exit.clicked.connect(self.check)
        grid_lt.addWidget(btn_exit, 4, 0)
        self.setLayout(grid_lt)

        self.show()
コード例 #38
0
    def __init__(self, parent=None):
        super(QueryPage, self).__init__(parent)

        packagesGroup = QGroupBox("Look for packages")

        nameLabel = QLabel("Name:")
        nameEdit = QLineEdit()

        dateLabel = QLabel("Released after:")
        dateEdit = QDateTimeEdit(QDate.currentDate())

        releasesCheckBox = QCheckBox("Releases")
        upgradesCheckBox = QCheckBox("Upgrades")

        hitsSpinBox = QSpinBox()
        hitsSpinBox.setPrefix("Return up to ")
        hitsSpinBox.setSuffix(" results")
        hitsSpinBox.setSpecialValueText("Return only the first result")
        hitsSpinBox.setMinimum(1)
        hitsSpinBox.setMaximum(100)
        hitsSpinBox.setSingleStep(10)

        startQueryButton = QPushButton("Start query")

        packagesLayout = QGridLayout()
        packagesLayout.addWidget(nameLabel, 0, 0)
        packagesLayout.addWidget(nameEdit, 0, 1)
        packagesLayout.addWidget(dateLabel, 1, 0)
        packagesLayout.addWidget(dateEdit, 1, 1)
        packagesLayout.addWidget(releasesCheckBox, 2, 0)
        packagesLayout.addWidget(upgradesCheckBox, 3, 0)
        packagesLayout.addWidget(hitsSpinBox, 4, 0, 1, 2)
        packagesGroup.setLayout(packagesLayout)

        mainLayout = QVBoxLayout()
        mainLayout.addWidget(packagesGroup)
        mainLayout.addSpacing(12)
        mainLayout.addWidget(startQueryButton)
        mainLayout.addStretch(1)

        self.setLayout(mainLayout)
コード例 #39
0
 def show_summary(self):
     h = self.parent.wallet.get_detailed_history()['summary']
     if not h:
         self.parent.show_message(_("Nothing to summarize."))
         return
     start_date = h.get('start_date')
     end_date = h.get('end_date')
     format_amount = lambda x: self.parent.format_amount(
         x.value) + ' ' + self.parent.base_unit()
     d = WindowModalDialog(self, _("Summary"))
     d.setMinimumSize(600, 150)
     vbox = QVBoxLayout()
     grid = QGridLayout()
     grid.addWidget(QLabel(_("Start")), 0, 0)
     grid.addWidget(QLabel(self.format_date(start_date)), 0, 1)
     grid.addWidget(QLabel(str(h.get('fiat_start_value')) + '/BTC'), 0, 2)
     grid.addWidget(QLabel(_("Initial balance")), 1, 0)
     grid.addWidget(QLabel(format_amount(h['start_balance'])), 1, 1)
     grid.addWidget(QLabel(str(h.get('fiat_start_balance'))), 1, 2)
     grid.addWidget(QLabel(_("End")), 2, 0)
     grid.addWidget(QLabel(self.format_date(end_date)), 2, 1)
     grid.addWidget(QLabel(str(h.get('fiat_end_value')) + '/BTC'), 2, 2)
     grid.addWidget(QLabel(_("Final balance")), 4, 0)
     grid.addWidget(QLabel(format_amount(h['end_balance'])), 4, 1)
     grid.addWidget(QLabel(str(h.get('fiat_end_balance'))), 4, 2)
     grid.addWidget(QLabel(_("Income")), 5, 0)
     grid.addWidget(QLabel(format_amount(h.get('incoming'))), 5, 1)
     grid.addWidget(QLabel(str(h.get('fiat_incoming'))), 5, 2)
     grid.addWidget(QLabel(_("Expenditures")), 6, 0)
     grid.addWidget(QLabel(format_amount(h.get('outgoing'))), 6, 1)
     grid.addWidget(QLabel(str(h.get('fiat_outgoing'))), 6, 2)
     grid.addWidget(QLabel(_("Capital gains")), 7, 0)
     grid.addWidget(QLabel(str(h.get('fiat_capital_gains'))), 7, 2)
     grid.addWidget(QLabel(_("Unrealized gains")), 8, 0)
     grid.addWidget(QLabel(str(h.get('fiat_unrealized_gains', ''))), 8, 2)
     vbox.addLayout(grid)
     vbox.addLayout(Buttons(CloseButton(d)))
     d.setLayout(vbox)
     d.exec_()
コード例 #40
0
ファイル: dialog.py プロジェクト: peters71/Grabber
    def __init__(self,
                 parent=None,
                 name: str = '',
                 description: str = '',
                 allow_empty=False,
                 password=False):
        super(Dialog, self).__init__(parent)
        self.option = QLineEdit()
        if password:
            self.option.setEchoMode(QLineEdit.Password)
        self.allow_empty = allow_empty

        self.label = QLabel(color_text('Insert option:', 'limegreen'))
        self.name_label = QLabel(color_text(name + ':', 'limegreen'))
        self.tooltip = QLabel(description)
        self.ok_button = QPushButton('Ok', self)
        self.ok_button.setFixedSize(self.ok_button.sizeHint())
        self.ok_button.setDisabled(not allow_empty)
        self.ok_button.clicked.connect(self.accept)

        self.cancel_button = QPushButton('Cancel', self)
        self.cancel_button.setFixedSize(self.cancel_button.sizeHint())
        self.cancel_button.clicked.connect(self.reject)

        layout = QGridLayout(self)
        layout.addWidget(self.name_label, 0, 0, 1, 3)
        layout.addWidget(self.tooltip, 1, 0, 1, 3)

        layout.addWidget(self.label, 2, 0, 1, 3)
        layout.addWidget(self.option, 3, 0, 1, 3)

        layout.setColumnStretch(0, 1)
        layout.setColumnStretch(1, 0)
        layout.setColumnStretch(2, 0)
        layout.addWidget(self.ok_button, 4, 1)
        layout.addWidget(self.cancel_button, 4, 2)

        self.option.textChanged.connect(self.input_check)
        self.setFixedHeight(self.sizeHint().height())
        self.setFixedWidth(self.sizeHint().width())
        self.option.setFocus()
コード例 #41
0
class FilterSliderWidgetUI(QWidget):
    
#    waveforms_generated = pyqtSignal(object, object, list, int)
#    SignalForContourScanning = pyqtSignal(int, int, int, np.ndarray, np.ndarray)
#    MessageBack = pyqtSignal(str)
    
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
#        os.chdir('./')# Set directory to current folder.
        self.setFont(QFont("Arial"))
        
        self.resize(265,130)
        self.setWindowTitle("FilterSliderWidget")
        self.layout = QGridLayout(self)
        
        #**************************************************************************************************************************************
        #--------------------------------------------------------------------------------------------------------------------------------------
        #-----------------------------------------------------------GUI for Filter movement----------------------------------------------------
        #--------------------------------------------------------------------------------------------------------------------------------------          
        #**************************************************************************************************************************************
        ControlContainer = StylishQT.roundQGroupBox(title = 'Filter Control', background_color = 'azure')
        ControlContainerLayout = QGridLayout()
        
        ND_filtercontrolContainer = StylishQT.roundQGroupBox(title = '2P ND', background_color = 'azure')
        self.filtercontrolLayout = QGridLayout()
        self.filtercontrolLayout.setSpacing(2)
            
        self.FilterButtongroup_1 = QButtonGroup(self)

        self.filter1_pos0 = QPushButton('0')
        self.filter1_pos0.setCheckable(True)
        self.FilterButtongroup_1.addButton(self.filter1_pos0)
        self.filtercontrolLayout.addWidget(self.filter1_pos0, 0, 1)
#        self.filter1_pos0.clicked.connect(lambda: self.filter_move_towards("COM9", 0))

        self.filter1_pos1 = QPushButton('1')
        self.filter1_pos1.setCheckable(True)
        self.FilterButtongroup_1.addButton(self.filter1_pos1)
        self.filtercontrolLayout.addWidget(self.filter1_pos1, 0, 2)    
#        self.filter1_pos1.clicked.connect(lambda: self.filter_move_towards("COM9", 1))
        
        self.filter1_pos2 = QPushButton('2')
        self.filter1_pos2.setCheckable(True)
        self.FilterButtongroup_1.addButton(self.filter1_pos2)
        self.filtercontrolLayout.addWidget(self.filter1_pos2, 0, 3)
#        self.filter1_pos2.clicked.connect(lambda: self.filter_move_towards("COM9", 2))
        
        self.filter1_pos3 = QPushButton('3')
        self.filter1_pos3.setCheckable(True)
        self.FilterButtongroup_1.addButton(self.filter1_pos3)
        self.filtercontrolLayout.addWidget(self.filter1_pos3, 0, 4)
#        self.filter1_pos3.clicked.connect(lambda: self.filter_move_towards("COM9", 3)) 
        self.FilterButtongroup_1.setExclusive(True)
        self.FilterButtongroup_1.buttonClicked[int].connect(self.DecodeFilterMove)
        
        self.FilterButtongroup_2 = QButtonGroup(self)

        self.filter2_pos0 = QPushButton('0')
        self.filter2_pos0.setCheckable(True)
        self.FilterButtongroup_2.addButton(self.filter2_pos0)
        self.filtercontrolLayout.addWidget(self.filter2_pos0, 1, 1)
#        self.filter1_pos0.clicked.connect(lambda: self.filter_move_towards("COM9", 0))

        self.filter2_pos1 = QPushButton('0.1')
        self.filter2_pos1.setCheckable(True)
        self.FilterButtongroup_2.addButton(self.filter2_pos1)
        self.filtercontrolLayout.addWidget(self.filter2_pos1, 1, 2)    
#        self.filter1_pos1.clicked.connect(lambda: self.filter_move_towards("COM9", 1))
        
        self.filter2_pos2 = QPushButton('0.3')
        self.filter2_pos2.setCheckable(True)
        self.FilterButtongroup_2.addButton(self.filter2_pos2)
        self.filtercontrolLayout.addWidget(self.filter2_pos2, 1, 3)
#        self.filter1_pos2.clicked.connect(lambda: self.filter_move_towards("COM9", 2))
        
        self.filter2_pos3 = QPushButton('0.5')
        self.filter2_pos3.setCheckable(True)
        self.FilterButtongroup_2.addButton(self.filter2_pos3)
        self.filtercontrolLayout.addWidget(self.filter2_pos3, 1, 4)
#        self.filter1_pos3.clicked.connect(lambda: self.filter_move_towards("COM9", 3)) 
        self.FilterButtongroup_2.setExclusive(True)
        self.FilterButtongroup_2.buttonClicked[int].connect(self.DecodeFilterMove)
#        
#        self.filtercontrolLayout.addWidget(QLabel('Filter-1 pos: '), 0, 0)
#
#        self.filtercontrolLayout.addWidget(QLabel('Filter-2 pos: '), 1, 0)        
#        bGBackupFromIntExt_1 = QButtonGroup(self)
#
#        self.filter2_pos0 = QPushButton('0')
#        self.filter2_pos0.setCheckable(True)
#        bGBackupFromIntExt_1.addButton(self.filter2_pos0)
#        self.filtercontrolLayout.addWidget(self.filter2_pos0, 1, 1)
#        self.filter2_pos0.clicked.connect(lambda: self.filter_move_towards("COM7", 0))
#
#        self.filter2_pos1 = QPushButton('0.1')
#        self.filter2_pos1.setCheckable(True)
#        bGBackupFromIntExt_1.addButton(self.filter2_pos1)
#        self.filtercontrolLayout.addWidget(self.filter2_pos1, 1, 2)    
#        self.filter2_pos1.clicked.connect(lambda: self.filter_move_towards("COM7", 1))
#        
#        self.filter2_pos2 = QPushButton('0.3')
#        self.filter2_pos2.setCheckable(True)
#        bGBackupFromIntExt_1.addButton(self.filter2_pos2)
#        self.filtercontrolLayout.addWidget(self.filter2_pos2, 1, 3)
#        self.filter2_pos2.clicked.connect(lambda: self.filter_move_towards("COM7", 2))
#        
#        self.filter2_pos3 = QPushButton('0.5')
#        self.filter2_pos3.setCheckable(True)
#        bGBackupFromIntExt_1.addButton(self.filter2_pos3)
#        self.filtercontrolLayout.addWidget(self.filter2_pos3, 1, 4)
#        self.filter2_pos3.clicked.connect(lambda: self.filter_move_towards("COM7", 3))
        
        #----------------------------------------------------------------------        
#        self.filter1_pos0 =  QDial()
#        self.filter1_pos0.setMinimum(0)
#        self.filter1_pos0.setMaximum(3)
#        self.filter1_pos0.setValue(0)
#        self.filter1_pos0.setNotchesVisible(True)
#        self.filter1_pos0.valueChanged.connect(lambda: self.filter_move_towards("COM9", self.filter1_pos0.value()))
        
#        self.filter2_pos0 =  QDial()
#        self.filter2_pos0.setMinimum(0)
#        self.filter2_pos0.setMaximum(3)
#        self.filter2_pos0.setValue(0)
#        self.filter2_pos0.setNotchesVisible(True)
#        self.filter2_pos0.valueChanged.connect(lambda: self.filter_move_towards("COM7", self.filter2_pos0.value()))
#        
#        self.filter3_pos0 =  QDial()
#        self.filter3_pos0.setMinimum(0)
#        self.filter3_pos0.setMaximum(3)
#        self.filter3_pos0.setValue(0)
#        self.filter3_pos0.setNotchesVisible(True)
#        self.filter3_pos0.valueChanged.connect(lambda: self.filter_move_towards("COM15", self.filter3_pos0.value()))
        
        #----------------------------------------------------------------------
#        self.filter1_pos0 = QSlider(Qt.Horizontal)
#        self.filter1_pos0.setMinimum(0)
#        self.filter1_pos0.setMaximum(3)
#        self.filter1_pos0.setTickPosition(QSlider.TicksBothSides)
#        self.filter1_pos0.setTickInterval(1)
#        self.filter1_pos0.setSingleStep(1)
#        self.filter1_pos0.sliderReleased.connect(lambda: self.filter_move_towards("COM9", self.filter1_pos0.value()))
#        
#        self.filter2_pos0 = QSlider(Qt.Horizontal)
#        self.filter2_pos0.setMinimum(0)
#        self.filter2_pos0.setMaximum(3)
#        self.filter2_pos0.setTickPosition(QSlider.TicksBothSides)
#        self.filter2_pos0.setTickInterval(1)
#        self.filter2_pos0.setSingleStep(1)
#        self.filter2_pos0.sliderReleased.connect(lambda: self.filter_move_towards("COM7", self.filter2_pos0.value()))
#        
#        self.filter3_pos0 = QSlider(Qt.Vertical)
#        self.filter3_pos0.setMinimum(0)
#        self.filter3_pos0.setMaximum(1)
#        self.filter3_pos0.setTickPosition(QSlider.TicksBothSides)
#        self.filter3_pos0.setTickInterval(1)
#        self.filter3_pos0.setSingleStep(1)
#        self.filter3_pos0.sliderReleased.connect(lambda: self.filter_move_towards("COM15", self.filter3_pos0.value()))
        
#        self.filtercontrolLayout.addWidget(QLabel('ND 0 | 1 | 2 | 3'), 0, 1)
#        self.filtercontrolLayout.addWidget(self.filter1_pos0, 1, 1)
#        self.filtercontrolLayout.addWidget(QLabel('ND 0 | 0.1 | 0.3 | 0.5'), 0, 2)
#        self.filtercontrolLayout.addWidget(self.filter2_pos0, 1, 2)
        
#        self.filtercontrolLayout.addWidget(self.filter3_pos0, 1, 3)
        
        
#        oImage = QImage('./Icons/filtersliderpanel.png')
##        sImage = oImage.scaled(QSize(292,208))                   # resize Image to widgets size
#        palette = QPalette()
#        palette.setBrush(QPalette.Window, QBrush(oImage))
                     
        EM_filtercontrolContainer = StylishQT.roundQGroupBox(title = 'Emission', background_color = 'honeydew')
        self.EM_filtercontrolContainerLayout = QGridLayout()
        self.EM_filtercontrolContainerLayout.setSpacing(2)

        self.FilterButtongroup_3 = QButtonGroup(self)
        

        self.filter3_pos0 = QPushButton('Arch')
        self.filter3_pos0.setCheckable(True)
        self.FilterButtongroup_3.addButton(self.filter3_pos0)
        self.EM_filtercontrolContainerLayout.addWidget(self.filter3_pos0, 1, 0)
#        self.filter1_pos0.clicked.connect(lambda: self.filter_move_towards("COM9", 0))

        self.filter3_pos1 = QPushButton('Citrine')
        self.filter3_pos1.setCheckable(True)
        self.FilterButtongroup_3.addButton(self.filter3_pos1)
        self.EM_filtercontrolContainerLayout.addWidget(self.filter3_pos1, 0, 0)   
        self.FilterButtongroup_3.setExclusive(True)
        self.FilterButtongroup_3.buttonClicked[int].connect(self.DecodeFilterMove)
        
        EM_filtercontrolContainer.setLayout(self.EM_filtercontrolContainerLayout)
        EM_filtercontrolContainer.setFixedWidth(65)
        
        ND_filtercontrolContainer.setLayout(self.filtercontrolLayout)
        # ND_filtercontrolContainer.setFixedHeight(110)
        ND_filtercontrolContainer.setFixedWidth(200)
#        self.setPalette(palette)
#        self.setAutoFillBackground(True)
        
        ControlContainerLayout.addWidget(ND_filtercontrolContainer, 0, 0) 
        ControlContainerLayout.addWidget(EM_filtercontrolContainer, 0, 1) 
        ControlContainer.setLayout(ControlContainerLayout)
        
        self.layout.addWidget(ControlContainer, 0, 0) 
        
        #**************************************************************************************************************************************
        #--------------------------------------------------------------------------------------------------------------------------------------
        #-----------------------------------------------------------Fucs for filter movement---------------------------------------------------
        #--------------------------------------------------------------------------------------------------------------------------------------          
        #************************************************************************************************************************************** 
    def run_in_thread(self, fn, *args, **kwargs):
        """
        Send target function to thread.
        Usage: lambda: self.run_in_thread(self.fn)
        
        Parameters
        ----------
        fn : function
            Target function to put in thread.

        Returns
        -------
        thread : TYPE
            Threading handle.

        """
        thread = threading.Thread(target=fn, args=args, kwargs=kwargs)
        thread.start()
        
        return thread
    
    def DecodeFilterMove(self):
        
        if self.FilterButtongroup_1.checkedId() == -2:
            self.run_in_thread(self.filter_move_towards("COM9", 0))
        elif self.FilterButtongroup_1.checkedId() == -3:
            self.run_in_thread(self.filter_move_towards("COM9", 1))
        elif self.FilterButtongroup_1.checkedId() == -4:
            self.run_in_thread(self.filter_move_towards("COM9", 2))
        elif self.FilterButtongroup_1.checkedId() == -5:
            self.run_in_thread(self.filter_move_towards("COM9", 3))
    
        if self.FilterButtongroup_2.checkedId() == -2:
            self.run_in_thread(self.filter_move_towards("COM7", 0))
        elif self.FilterButtongroup_2.checkedId() == -3:
            self.run_in_thread(self.filter_move_towards("COM7", 1))
        elif self.FilterButtongroup_2.checkedId() == -4:
            self.run_in_thread(self.filter_move_towards("COM7", 2))
        elif self.FilterButtongroup_2.checkedId() == -5:
            self.run_in_thread(self.filter_move_towards("COM7", 3))
            
        if self.FilterButtongroup_3.checkedId() == -2:
            # Move to Arch
            self.run_in_thread(self.filter_move_towards("COM15", 0))
        elif self.FilterButtongroup_3.checkedId() == -3:
            self.run_in_thread(self.filter_move_towards("COM15", 1))

    # def start_up_event(self):
    #     ports = ["COM9", "COM7", "COM15"]
    #     try:
    #         for port in ports:
    #             ELL9Filter_ins = ELL9Filter(port)
    #             pos = 

    def filter_move_towards(self, COMport, pos):
        ELL9Filter_ins = ELL9Filter(COMport)
        ELL9Filter_ins.moveToPosition(pos)
        
    def update_slider_current_pos(self, current_pos):
#        .setValue(current_pos)
        print('Slider current position: {}'.format(current_pos))
コード例 #42
0
ファイル: dagger.py プロジェクト: Bleyddyn/malpi
    def initGrid(self):
        if self.data is None:
            return

        # This needs to be generalized to handle multiple input and output types
        self.imageLabels = []
        self.actionRows = []
        self.actionLabels = []

        for i in range(self.gridWidth):
            self.imageLabels.append(QLabel(self))

        ot = self.data.outputTypes()
        for output in ot:
            oneRow = []
            for i in range(self.gridWidth):
                labels = output[
                    "categories"] if "categories" in output else None
                cb = self.makeActionComboBox(atype=output["type"],
                                             labels=labels)
                oneRow.append(cb)
                self.actionLabels.append(cb)
            self.actionRows.append(oneRow)

        grid = QGridLayout()
        self.grid = grid
        grid.setSpacing(10)

        otypes = self.data.outputTypes()
        itypes = self.data.inputTypes()

        row = 1
        grid.addWidget(QLabel("Index"), row, 0)
        self.indexes = []
        for i in range(self.gridWidth):
            idx = QLabel(self)
            idx.setAlignment(Qt.AlignCenter)
            self.indexes.append(idx)
        for i in range(len(self.indexes)):
            grid.addWidget(self.indexes[i], row, i + 1)

        row += 1
        grid.addWidget(QLabel(itypes[0]["name"]), row, 0)
        for i in range(len(self.imageLabels)):
            grid.addWidget(self.imageLabels[i], row, i + 1)

        for lr in range(len(self.actionRows)):
            arow = self.actionRows[lr]
            row += 1
            grid.addWidget(QLabel(otypes[lr]["name"]), row, 0)
            for i in range(len(arow)):
                grid.addWidget(arow[i], row, i + 1)

        vlay = QVBoxLayout()
        vlay.addLayout(grid)
        row += 1
        sld = QSlider(Qt.Horizontal, self)
        self.slider = sld
        sld.setFocusPolicy(Qt.NoFocus)
        sld.valueChanged[int].connect(self.changeValue)
        #grid.addWidget(sld, row, 0, 1, self.gridWidth+1)
        vlay.addWidget(sld)

        self.setCentralWidget(QWidget(self))
        self.centralWidget().setLayout(vlay)

        if self.metaDock is None:
            self.metaDock = QDockWidget("Drive Info", self)
            self.addDockWidget(Qt.LeftDockWidgetArea, self.metaDock)
            self.metaText = QTextEdit(self)
            self.metaText.setEnabled(False)
            self.metaText.setReadOnly(True)
            #self.metaText.setMinimumWidth( 200.0 )
            self.metaDock.setWidget(self.metaText)
            self.viewMenu.addAction(self.metaDock.toggleViewAction())
        self.metaText.setText(self.data.metaString())

        if self.statsDock is None:
            self.statsDock = QDockWidget("Action Stats", self)
            self.addDockWidget(Qt.LeftDockWidgetArea, self.statsDock)
            self.statsTable = QTableWidget(self)
            self.statsTable.setEnabled(False)
            self.statsTable.horizontalHeader().hide()
            self.statsTable.verticalHeader().setDefaultSectionSize(18)
            self.statsTable.verticalHeader().hide()
            self.statsTable.setShowGrid(False)
            self.statsDock.setWidget(self.statsTable)
            self.viewMenu.addAction(self.statsDock.toggleViewAction())

        self.updateStats()
コード例 #43
0
ファイル: qt.py プロジェクト: justanwar/electrum-xzc
    def __init__(self, window, plugin, keystore, device_id):
        title = _("{} Settings").format(plugin.device)
        super(SettingsDialog, self).__init__(window, title)
        self.setMaximumWidth(540)

        devmgr = plugin.device_manager()
        config = devmgr.config
        handler = keystore.handler
        thread = keystore.thread
        hs_cols, hs_rows = (128, 64)

        def invoke_client(method, *args, **kw_args):
            unpair_after = kw_args.pop('unpair_after', False)

            def task():
                client = devmgr.client_by_id(device_id)
                if not client:
                    raise RuntimeError("Device not connected")
                if method:
                    getattr(client, method)(*args, **kw_args)
                if unpair_after:
                    devmgr.unpair_id(device_id)
                return client.features

            thread.add(task, on_success=update)

        def update(features):
            self.features = features
            set_label_enabled()
            if features.bootloader_hash:
                bl_hash = bh2u(features.bootloader_hash)
                bl_hash = "\n".join([bl_hash[:32], bl_hash[32:]])
            else:
                bl_hash = "N/A"
            noyes = [_("No"), _("Yes")]
            endis = [_("Enable Passphrases"), _("Disable Passphrases")]
            disen = [_("Disabled"), _("Enabled")]
            setchange = [_("Set a PIN"), _("Change PIN")]

            version = "%d.%d.%d" % (features.major_version,
                                    features.minor_version,
                                    features.patch_version)

            device_label.setText(features.label)
            pin_set_label.setText(noyes[features.pin_protection])
            passphrases_label.setText(disen[features.passphrase_protection])
            bl_hash_label.setText(bl_hash)
            label_edit.setText(features.label)
            device_id_label.setText(features.device_id)
            initialized_label.setText(noyes[features.initialized])
            version_label.setText(version)
            clear_pin_button.setVisible(features.pin_protection)
            clear_pin_warning.setVisible(features.pin_protection)
            pin_button.setText(setchange[features.pin_protection])
            pin_msg.setVisible(not features.pin_protection)
            passphrase_button.setText(endis[features.passphrase_protection])
            language_label.setText(features.language)

        def set_label_enabled():
            label_apply.setEnabled(label_edit.text() != self.features.label)

        def rename():
            invoke_client('change_label', label_edit.text())

        def toggle_passphrase():
            title = _("Confirm Toggle Passphrase Protection")
            currently_enabled = self.features.passphrase_protection
            if currently_enabled:
                msg = _("After disabling passphrases, you can only pair this "
                        "Electrum wallet if it had an empty passphrase.  "
                        "If its passphrase was not empty, you will need to "
                        "create a new wallet with the install wizard.  You "
                        "can use this wallet again at any time by re-enabling "
                        "passphrases and entering its passphrase.")
            else:
                msg = _("Your current Electrum wallet can only be used with "
                        "an empty passphrase.  You must create a separate "
                        "wallet with the install wizard for other passphrases "
                        "as each one generates a new set of addresses.")
            msg += "\n\n" + _("Are you sure you want to proceed?")
            if not self.question(msg, title=title):
                return
            invoke_client('toggle_passphrase', unpair_after=currently_enabled)

        def change_homescreen():
            dialog = QFileDialog(self, _("Choose Homescreen"))
            filename, __ = dialog.getOpenFileName()
            if not filename:
                return  # user cancelled

            if filename.endswith('.toif'):
                img = open(filename, 'rb').read()
                if img[:8] != b'TOIf\x90\x00\x90\x00':
                    handler.show_error(
                        'File is not a TOIF file with size of 144x144')
                    return
            else:
                from PIL import Image  # FIXME
                im = Image.open(filename)
                if im.size != (128, 64):
                    handler.show_error('Image must be 128 x 64 pixels')
                    return
                im = im.convert('1')
                pix = im.load()
                img = bytearray(1024)
                for j in range(64):
                    for i in range(128):
                        if pix[i, j]:
                            o = (i + j * 128)
                            img[o // 8] |= (1 << (7 - o % 8))
                img = bytes(img)
            invoke_client('change_homescreen', img)

        def clear_homescreen():
            invoke_client('change_homescreen', b'\x00')

        def set_pin():
            invoke_client('set_pin', remove=False)

        def clear_pin():
            invoke_client('set_pin', remove=True)

        def wipe_device():
            wallet = window.wallet
            if wallet and sum(wallet.get_balance()):
                title = _("Confirm Device Wipe")
                msg = _("Are you SURE you want to wipe the device?\n"
                        "Your wallet still has bitcoins in it!")
                if not self.question(
                        msg, title=title, icon=QMessageBox.Critical):
                    return
            invoke_client('wipe_device', unpair_after=True)

        def slider_moved():
            mins = timeout_slider.sliderPosition()
            timeout_minutes.setText(_("{:2d} minutes").format(mins))

        def slider_released():
            config.set_session_timeout(timeout_slider.sliderPosition() * 60)

        # Information tab
        info_tab = QWidget()
        info_layout = QVBoxLayout(info_tab)
        info_glayout = QGridLayout()
        info_glayout.setColumnStretch(2, 1)
        device_label = QLabel()
        pin_set_label = QLabel()
        passphrases_label = QLabel()
        version_label = QLabel()
        device_id_label = QLabel()
        bl_hash_label = QLabel()
        bl_hash_label.setWordWrap(True)
        language_label = QLabel()
        initialized_label = QLabel()
        rows = [
            (_("Device Label"), device_label),
            (_("PIN set"), pin_set_label),
            (_("Passphrases"), passphrases_label),
            (_("Firmware Version"), version_label),
            (_("Device ID"), device_id_label),
            (_("Bootloader Hash"), bl_hash_label),
            (_("Language"), language_label),
            (_("Initialized"), initialized_label),
        ]
        for row_num, (label, widget) in enumerate(rows):
            info_glayout.addWidget(QLabel(label), row_num, 0)
            info_glayout.addWidget(widget, row_num, 1)
        info_layout.addLayout(info_glayout)

        # Settings tab
        settings_tab = QWidget()
        settings_layout = QVBoxLayout(settings_tab)
        settings_glayout = QGridLayout()

        # Settings tab - Label
        label_msg = QLabel(
            _("Name this {}.  If you have multiple devices "
              "their labels help distinguish them.").format(plugin.device))
        label_msg.setWordWrap(True)
        label_label = QLabel(_("Device Label"))
        label_edit = QLineEdit()
        label_edit.setMinimumWidth(150)
        label_edit.setMaxLength(plugin.MAX_LABEL_LEN)
        label_apply = QPushButton(_("Apply"))
        label_apply.clicked.connect(rename)
        label_edit.textChanged.connect(set_label_enabled)
        settings_glayout.addWidget(label_label, 0, 0)
        settings_glayout.addWidget(label_edit, 0, 1, 1, 2)
        settings_glayout.addWidget(label_apply, 0, 3)
        settings_glayout.addWidget(label_msg, 1, 1, 1, -1)

        # Settings tab - PIN
        pin_label = QLabel(_("PIN Protection"))
        pin_button = QPushButton()
        pin_button.clicked.connect(set_pin)
        settings_glayout.addWidget(pin_label, 2, 0)
        settings_glayout.addWidget(pin_button, 2, 1)
        pin_msg = QLabel(
            _("PIN protection is strongly recommended.  "
              "A PIN is your only protection against someone "
              "stealing your bitcoins if they obtain physical "
              "access to your {}.").format(plugin.device))
        pin_msg.setWordWrap(True)
        pin_msg.setStyleSheet("color: red")
        settings_glayout.addWidget(pin_msg, 3, 1, 1, -1)

        # Settings tab - Homescreen
        homescreen_label = QLabel(_("Homescreen"))
        homescreen_change_button = QPushButton(_("Change..."))
        homescreen_clear_button = QPushButton(_("Reset"))
        homescreen_change_button.clicked.connect(change_homescreen)
        try:
            import PIL
        except ImportError:
            homescreen_change_button.setDisabled(True)
            homescreen_change_button.setToolTip(
                _("Required package 'PIL' is not available - Please install it."
                  ))
        homescreen_clear_button.clicked.connect(clear_homescreen)
        homescreen_msg = QLabel(
            _("You can set the homescreen on your "
              "device to personalize it.  You must "
              "choose a {} x {} monochrome black and "
              "white image.").format(hs_cols, hs_rows))
        homescreen_msg.setWordWrap(True)
        settings_glayout.addWidget(homescreen_label, 4, 0)
        settings_glayout.addWidget(homescreen_change_button, 4, 1)
        settings_glayout.addWidget(homescreen_clear_button, 4, 2)
        settings_glayout.addWidget(homescreen_msg, 5, 1, 1, -1)

        # Settings tab - Session Timeout
        timeout_label = QLabel(_("Session Timeout"))
        timeout_minutes = QLabel()
        timeout_slider = QSlider(Qt.Horizontal)
        timeout_slider.setRange(1, 60)
        timeout_slider.setSingleStep(1)
        timeout_slider.setTickInterval(5)
        timeout_slider.setTickPosition(QSlider.TicksBelow)
        timeout_slider.setTracking(True)
        timeout_msg = QLabel(
            _("Clear the session after the specified period "
              "of inactivity.  Once a session has timed out, "
              "your PIN and passphrase (if enabled) must be "
              "re-entered to use the device."))
        timeout_msg.setWordWrap(True)
        timeout_slider.setSliderPosition(config.get_session_timeout() // 60)
        slider_moved()
        timeout_slider.valueChanged.connect(slider_moved)
        timeout_slider.sliderReleased.connect(slider_released)
        settings_glayout.addWidget(timeout_label, 6, 0)
        settings_glayout.addWidget(timeout_slider, 6, 1, 1, 3)
        settings_glayout.addWidget(timeout_minutes, 6, 4)
        settings_glayout.addWidget(timeout_msg, 7, 1, 1, -1)
        settings_layout.addLayout(settings_glayout)
        settings_layout.addStretch(1)

        # Advanced tab
        advanced_tab = QWidget()
        advanced_layout = QVBoxLayout(advanced_tab)
        advanced_glayout = QGridLayout()

        # Advanced tab - clear PIN
        clear_pin_button = QPushButton(_("Disable PIN"))
        clear_pin_button.clicked.connect(clear_pin)
        clear_pin_warning = QLabel(
            _("If you disable your PIN, anyone with physical access to your "
              "{} device can spend your bitcoins.").format(plugin.device))
        clear_pin_warning.setWordWrap(True)
        clear_pin_warning.setStyleSheet("color: red")
        advanced_glayout.addWidget(clear_pin_button, 0, 2)
        advanced_glayout.addWidget(clear_pin_warning, 1, 0, 1, 5)

        # Advanced tab - toggle passphrase protection
        passphrase_button = QPushButton()
        passphrase_button.clicked.connect(toggle_passphrase)
        passphrase_msg = WWLabel(PASSPHRASE_HELP)
        passphrase_warning = WWLabel(PASSPHRASE_NOT_PIN)
        passphrase_warning.setStyleSheet("color: red")
        advanced_glayout.addWidget(passphrase_button, 3, 2)
        advanced_glayout.addWidget(passphrase_msg, 4, 0, 1, 5)
        advanced_glayout.addWidget(passphrase_warning, 5, 0, 1, 5)

        # Advanced tab - wipe device
        wipe_device_button = QPushButton(_("Wipe Device"))
        wipe_device_button.clicked.connect(wipe_device)
        wipe_device_msg = QLabel(
            _("Wipe the device, removing all data from it.  The firmware "
              "is left unchanged."))
        wipe_device_msg.setWordWrap(True)
        wipe_device_warning = QLabel(
            _("Only wipe a device if you have the recovery seed written down "
              "and the device wallet(s) are empty, otherwise the bitcoins "
              "will be lost forever."))
        wipe_device_warning.setWordWrap(True)
        wipe_device_warning.setStyleSheet("color: red")
        advanced_glayout.addWidget(wipe_device_button, 6, 2)
        advanced_glayout.addWidget(wipe_device_msg, 7, 0, 1, 5)
        advanced_glayout.addWidget(wipe_device_warning, 8, 0, 1, 5)
        advanced_layout.addLayout(advanced_glayout)
        advanced_layout.addStretch(1)

        tabs = QTabWidget(self)
        tabs.addTab(info_tab, _("Information"))
        tabs.addTab(settings_tab, _("Settings"))
        tabs.addTab(advanced_tab, _("Advanced"))
        dialog_vbox = QVBoxLayout(self)
        dialog_vbox.addWidget(tabs)
        dialog_vbox.addLayout(Buttons(CloseButton(self)))

        # Update information
        invoke_client(None)
コード例 #44
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
#        os.chdir('./')# Set directory to current folder.
        self.setFont(QFont("Arial"))
        
        self.resize(265,130)
        self.setWindowTitle("FilterSliderWidget")
        self.layout = QGridLayout(self)
        
        #**************************************************************************************************************************************
        #--------------------------------------------------------------------------------------------------------------------------------------
        #-----------------------------------------------------------GUI for Filter movement----------------------------------------------------
        #--------------------------------------------------------------------------------------------------------------------------------------          
        #**************************************************************************************************************************************
        ControlContainer = StylishQT.roundQGroupBox(title = 'Filter Control', background_color = 'azure')
        ControlContainerLayout = QGridLayout()
        
        ND_filtercontrolContainer = StylishQT.roundQGroupBox(title = '2P ND', background_color = 'azure')
        self.filtercontrolLayout = QGridLayout()
        self.filtercontrolLayout.setSpacing(2)
            
        self.FilterButtongroup_1 = QButtonGroup(self)

        self.filter1_pos0 = QPushButton('0')
        self.filter1_pos0.setCheckable(True)
        self.FilterButtongroup_1.addButton(self.filter1_pos0)
        self.filtercontrolLayout.addWidget(self.filter1_pos0, 0, 1)
#        self.filter1_pos0.clicked.connect(lambda: self.filter_move_towards("COM9", 0))

        self.filter1_pos1 = QPushButton('1')
        self.filter1_pos1.setCheckable(True)
        self.FilterButtongroup_1.addButton(self.filter1_pos1)
        self.filtercontrolLayout.addWidget(self.filter1_pos1, 0, 2)    
#        self.filter1_pos1.clicked.connect(lambda: self.filter_move_towards("COM9", 1))
        
        self.filter1_pos2 = QPushButton('2')
        self.filter1_pos2.setCheckable(True)
        self.FilterButtongroup_1.addButton(self.filter1_pos2)
        self.filtercontrolLayout.addWidget(self.filter1_pos2, 0, 3)
#        self.filter1_pos2.clicked.connect(lambda: self.filter_move_towards("COM9", 2))
        
        self.filter1_pos3 = QPushButton('3')
        self.filter1_pos3.setCheckable(True)
        self.FilterButtongroup_1.addButton(self.filter1_pos3)
        self.filtercontrolLayout.addWidget(self.filter1_pos3, 0, 4)
#        self.filter1_pos3.clicked.connect(lambda: self.filter_move_towards("COM9", 3)) 
        self.FilterButtongroup_1.setExclusive(True)
        self.FilterButtongroup_1.buttonClicked[int].connect(self.DecodeFilterMove)
        
        self.FilterButtongroup_2 = QButtonGroup(self)

        self.filter2_pos0 = QPushButton('0')
        self.filter2_pos0.setCheckable(True)
        self.FilterButtongroup_2.addButton(self.filter2_pos0)
        self.filtercontrolLayout.addWidget(self.filter2_pos0, 1, 1)
#        self.filter1_pos0.clicked.connect(lambda: self.filter_move_towards("COM9", 0))

        self.filter2_pos1 = QPushButton('0.1')
        self.filter2_pos1.setCheckable(True)
        self.FilterButtongroup_2.addButton(self.filter2_pos1)
        self.filtercontrolLayout.addWidget(self.filter2_pos1, 1, 2)    
#        self.filter1_pos1.clicked.connect(lambda: self.filter_move_towards("COM9", 1))
        
        self.filter2_pos2 = QPushButton('0.3')
        self.filter2_pos2.setCheckable(True)
        self.FilterButtongroup_2.addButton(self.filter2_pos2)
        self.filtercontrolLayout.addWidget(self.filter2_pos2, 1, 3)
#        self.filter1_pos2.clicked.connect(lambda: self.filter_move_towards("COM9", 2))
        
        self.filter2_pos3 = QPushButton('0.5')
        self.filter2_pos3.setCheckable(True)
        self.FilterButtongroup_2.addButton(self.filter2_pos3)
        self.filtercontrolLayout.addWidget(self.filter2_pos3, 1, 4)
#        self.filter1_pos3.clicked.connect(lambda: self.filter_move_towards("COM9", 3)) 
        self.FilterButtongroup_2.setExclusive(True)
        self.FilterButtongroup_2.buttonClicked[int].connect(self.DecodeFilterMove)
#        
#        self.filtercontrolLayout.addWidget(QLabel('Filter-1 pos: '), 0, 0)
#
#        self.filtercontrolLayout.addWidget(QLabel('Filter-2 pos: '), 1, 0)        
#        bGBackupFromIntExt_1 = QButtonGroup(self)
#
#        self.filter2_pos0 = QPushButton('0')
#        self.filter2_pos0.setCheckable(True)
#        bGBackupFromIntExt_1.addButton(self.filter2_pos0)
#        self.filtercontrolLayout.addWidget(self.filter2_pos0, 1, 1)
#        self.filter2_pos0.clicked.connect(lambda: self.filter_move_towards("COM7", 0))
#
#        self.filter2_pos1 = QPushButton('0.1')
#        self.filter2_pos1.setCheckable(True)
#        bGBackupFromIntExt_1.addButton(self.filter2_pos1)
#        self.filtercontrolLayout.addWidget(self.filter2_pos1, 1, 2)    
#        self.filter2_pos1.clicked.connect(lambda: self.filter_move_towards("COM7", 1))
#        
#        self.filter2_pos2 = QPushButton('0.3')
#        self.filter2_pos2.setCheckable(True)
#        bGBackupFromIntExt_1.addButton(self.filter2_pos2)
#        self.filtercontrolLayout.addWidget(self.filter2_pos2, 1, 3)
#        self.filter2_pos2.clicked.connect(lambda: self.filter_move_towards("COM7", 2))
#        
#        self.filter2_pos3 = QPushButton('0.5')
#        self.filter2_pos3.setCheckable(True)
#        bGBackupFromIntExt_1.addButton(self.filter2_pos3)
#        self.filtercontrolLayout.addWidget(self.filter2_pos3, 1, 4)
#        self.filter2_pos3.clicked.connect(lambda: self.filter_move_towards("COM7", 3))
        
        #----------------------------------------------------------------------        
#        self.filter1_pos0 =  QDial()
#        self.filter1_pos0.setMinimum(0)
#        self.filter1_pos0.setMaximum(3)
#        self.filter1_pos0.setValue(0)
#        self.filter1_pos0.setNotchesVisible(True)
#        self.filter1_pos0.valueChanged.connect(lambda: self.filter_move_towards("COM9", self.filter1_pos0.value()))
        
#        self.filter2_pos0 =  QDial()
#        self.filter2_pos0.setMinimum(0)
#        self.filter2_pos0.setMaximum(3)
#        self.filter2_pos0.setValue(0)
#        self.filter2_pos0.setNotchesVisible(True)
#        self.filter2_pos0.valueChanged.connect(lambda: self.filter_move_towards("COM7", self.filter2_pos0.value()))
#        
#        self.filter3_pos0 =  QDial()
#        self.filter3_pos0.setMinimum(0)
#        self.filter3_pos0.setMaximum(3)
#        self.filter3_pos0.setValue(0)
#        self.filter3_pos0.setNotchesVisible(True)
#        self.filter3_pos0.valueChanged.connect(lambda: self.filter_move_towards("COM15", self.filter3_pos0.value()))
        
        #----------------------------------------------------------------------
#        self.filter1_pos0 = QSlider(Qt.Horizontal)
#        self.filter1_pos0.setMinimum(0)
#        self.filter1_pos0.setMaximum(3)
#        self.filter1_pos0.setTickPosition(QSlider.TicksBothSides)
#        self.filter1_pos0.setTickInterval(1)
#        self.filter1_pos0.setSingleStep(1)
#        self.filter1_pos0.sliderReleased.connect(lambda: self.filter_move_towards("COM9", self.filter1_pos0.value()))
#        
#        self.filter2_pos0 = QSlider(Qt.Horizontal)
#        self.filter2_pos0.setMinimum(0)
#        self.filter2_pos0.setMaximum(3)
#        self.filter2_pos0.setTickPosition(QSlider.TicksBothSides)
#        self.filter2_pos0.setTickInterval(1)
#        self.filter2_pos0.setSingleStep(1)
#        self.filter2_pos0.sliderReleased.connect(lambda: self.filter_move_towards("COM7", self.filter2_pos0.value()))
#        
#        self.filter3_pos0 = QSlider(Qt.Vertical)
#        self.filter3_pos0.setMinimum(0)
#        self.filter3_pos0.setMaximum(1)
#        self.filter3_pos0.setTickPosition(QSlider.TicksBothSides)
#        self.filter3_pos0.setTickInterval(1)
#        self.filter3_pos0.setSingleStep(1)
#        self.filter3_pos0.sliderReleased.connect(lambda: self.filter_move_towards("COM15", self.filter3_pos0.value()))
        
#        self.filtercontrolLayout.addWidget(QLabel('ND 0 | 1 | 2 | 3'), 0, 1)
#        self.filtercontrolLayout.addWidget(self.filter1_pos0, 1, 1)
#        self.filtercontrolLayout.addWidget(QLabel('ND 0 | 0.1 | 0.3 | 0.5'), 0, 2)
#        self.filtercontrolLayout.addWidget(self.filter2_pos0, 1, 2)
        
#        self.filtercontrolLayout.addWidget(self.filter3_pos0, 1, 3)
        
        
#        oImage = QImage('./Icons/filtersliderpanel.png')
##        sImage = oImage.scaled(QSize(292,208))                   # resize Image to widgets size
#        palette = QPalette()
#        palette.setBrush(QPalette.Window, QBrush(oImage))
                     
        EM_filtercontrolContainer = StylishQT.roundQGroupBox(title = 'Emission', background_color = 'honeydew')
        self.EM_filtercontrolContainerLayout = QGridLayout()
        self.EM_filtercontrolContainerLayout.setSpacing(2)

        self.FilterButtongroup_3 = QButtonGroup(self)
        

        self.filter3_pos0 = QPushButton('Arch')
        self.filter3_pos0.setCheckable(True)
        self.FilterButtongroup_3.addButton(self.filter3_pos0)
        self.EM_filtercontrolContainerLayout.addWidget(self.filter3_pos0, 1, 0)
#        self.filter1_pos0.clicked.connect(lambda: self.filter_move_towards("COM9", 0))

        self.filter3_pos1 = QPushButton('Citrine')
        self.filter3_pos1.setCheckable(True)
        self.FilterButtongroup_3.addButton(self.filter3_pos1)
        self.EM_filtercontrolContainerLayout.addWidget(self.filter3_pos1, 0, 0)   
        self.FilterButtongroup_3.setExclusive(True)
        self.FilterButtongroup_3.buttonClicked[int].connect(self.DecodeFilterMove)
        
        EM_filtercontrolContainer.setLayout(self.EM_filtercontrolContainerLayout)
        EM_filtercontrolContainer.setFixedWidth(65)
        
        ND_filtercontrolContainer.setLayout(self.filtercontrolLayout)
        # ND_filtercontrolContainer.setFixedHeight(110)
        ND_filtercontrolContainer.setFixedWidth(200)
#        self.setPalette(palette)
#        self.setAutoFillBackground(True)
        
        ControlContainerLayout.addWidget(ND_filtercontrolContainer, 0, 0) 
        ControlContainerLayout.addWidget(EM_filtercontrolContainer, 0, 1) 
        ControlContainer.setLayout(ControlContainerLayout)
        
        self.layout.addWidget(ControlContainer, 0, 0) 
コード例 #45
0
    def __init__(self, parent=None):
        super(ResultHandler, self).__init__()
        self.setWindowTitle('Dash results')
        self.control_label = QLabel()
        self.rendered_label = QLabel()
        self.diff_label = QLabel()

        self.mask_label = QLabel()
        self.new_mask_label = QLabel()

        self.scrollArea = QScrollArea()
        self.widget = QWidget()

        self.test_name_label = QLabel()
        grid = QGridLayout()
        grid.addWidget(self.test_name_label, 0, 0)
        grid.addWidget(QLabel('Control'), 1, 0)
        grid.addWidget(QLabel('Rendered'), 1, 1)
        grid.addWidget(QLabel('Difference'), 1, 2)
        grid.addWidget(self.control_label, 2, 0)
        grid.addWidget(self.rendered_label, 2, 1)
        grid.addWidget(self.diff_label, 2, 2)
        grid.addWidget(QLabel('Current Mask'), 3, 0)
        grid.addWidget(QLabel('New Mask'), 3, 1)
        grid.addWidget(self.mask_label, 4, 0)
        grid.addWidget(self.new_mask_label, 4, 1)

        self.widget.setLayout(grid)
        self.scrollArea.setWidget(self.widget)
        v_layout = QVBoxLayout()
        v_layout.addWidget(self.scrollArea, 1)

        next_image_button = QPushButton()
        next_image_button.setText('Skip')
        next_image_button.pressed.connect(self.load_next)

        self.overload_spin = QDoubleSpinBox()
        self.overload_spin.setMinimum(1)
        self.overload_spin.setMaximum(255)
        self.overload_spin.setValue(1)
        self.overload_spin.valueChanged.connect(
            lambda: save_mask_button.setEnabled(False))

        preview_mask_button = QPushButton()
        preview_mask_button.setText('Preview New Mask')
        preview_mask_button.pressed.connect(self.preview_mask)
        preview_mask_button.pressed.connect(
            lambda: save_mask_button.setEnabled(True))

        save_mask_button = QPushButton()
        save_mask_button.setText('Save New Mask')
        save_mask_button.pressed.connect(self.save_mask)

        button_layout = QHBoxLayout()
        button_layout.addWidget(next_image_button)
        button_layout.addWidget(QLabel('Mask diff multiplier:'))
        button_layout.addWidget(self.overload_spin)
        button_layout.addWidget(preview_mask_button)
        button_layout.addWidget(save_mask_button)
        button_layout.addStretch()
        v_layout.addLayout(button_layout)
        self.setLayout(v_layout)
コード例 #46
0
class PlotConfig(QFrame):
    """
    This widget provides a configuration panel for manipulating plot widgets
    """

    def __init__(self, plot_widget: PlotWidget, *args, **kwargs):
        """
        Initialize plot config
        :param plot_widget: plot widget to access
        """
        super().__init__(*args, **kwargs)
        self._plot_widget = plot_widget
        self._ax = self._plot_widget.add_subplot(111)
        self.plot_items = list()

        self._layout = QGridLayout()
        self.scroll_layout = QVBoxLayout()
        self.setLayout(self._layout)
        self._setup_()

    def set_title(self, title):
        """
        Set plot title
        :param title: plot title
        """
        self._ax.set_title(title)
        self._plot_widget.update()

    def set_xlabel(self, value):
        """
        Set x-axis label of the plot
        :param value: x-axis label
        """
        self._ax.set_xlabel(value)
        self._plot_widget.update()

    def set_ylabel(self, value):
        """
        Set y-axis label of the plot
        :param value: y-axis label
        """
        self._ax.set_ylabel(value)
        self._plot_widget.update()

    def set_xrange(self, lower, upper):
        """
        Set x-axis range
        :param lower: left boundary
        :param upper: right boundary
        """
        self._ax.set_xlim(lower, upper)
        self._plot_widget.update()

    def set_yrange(self, lower, upper):
        """
        Set y-axis range
        :param lower: lower boundary
        :param upper: upper boundary
        """
        self._ax.set_ylim(lower, upper)
        self._plot_widget.update()

    def set_range(self, xl, xu, yl, yu):
        """
        Set plot range
        :param xl: left boundary
        :param xu: right boundary
        :param yl: lower boundary
        :param yu: upper boundary
        """
        self.set_xrange(xl, xu)
        self.set_yrange(yl, yu)

    def set_visibility(self, plot_item, visible):
        """
        Set visibility of the plot item
        :param plot_item: plot item
        :param visible: True for visible
        """
        plot_item.line_object._visible = visible
        self._plot_widget.update()

    def remove(self, plot_item):
        """
        Remove plot item
        :param plot_item: plot item to remove
        """
        plot_item.line_object.remove()
        self.plot_items.remove(plot_item)
        self._fill_plot_list_()
        self._plot_widget.update()

    def update_legend(self):
        """
        Update legend according to plot items
        """
        self._ax.legend([item.name for item in self.plot_items])

    def plot(self, *args, name=None, allow_remove=True, **kwargs):
        """
        Plot data
        :param args: x and y data (as well as more matplotlib compatible arguments)
        :param name: name of the plot
        :param allow_remove: True or false
        :param kwargs: keyword arguments
        """
        if name is None:
            name = 'plot item {}'.format(len(self.plot_items))

        line, = self._ax.plot(*args, **kwargs)
        plot_item = PlotWidgetItem(line, name, self._plot_widget, allow_remove, args, kwargs)
        self.plot_items.append(plot_item)

        self._fill_plot_list_()
        return plot_item

    def _fill_plot_list_(self):
        """
        Fill plot configuration list
        """
        # remove existing items
        for i in reversed(range(self.scroll_layout.count())):
            self.scroll_layout.itemAt(i).widget().setParent(None)

        # fill list
        for item in self.plot_items:
            item_widget = EnableDisableWidget(item, self)
            self.scroll_layout.addWidget(item_widget)
        self.update_legend()

    def _setup_(self):
        self._layout.addWidget(QLabel('Plot Settings:'), 0, 0)

        scroll_area = QScrollArea()
        group_box = QGroupBox()
        group_box.setLayout(self.scroll_layout)
        self.scroll_layout.setAlignment(Qt.AlignTop | Qt.AlignLeft)
        scroll_area.setWidget(group_box)
        scroll_area.setWidgetResizable(True)
        self._layout.addWidget(scroll_area, 1, 0)
コード例 #47
0
ファイル: qt06_vboxLayout02.py プロジェクト: ZzyMy/PyQt5-2
    def initUI(self):
        title = QLabel("标题")
        author = QLabel("提交人")
        review = QLabel("申告内容")

        titleEdit = QLineEdit()
        authorEdit = QLineEdit()
        reviewEdit = QTextEdit()

        grid = QGridLayout()
        grid.setSpacing(10)

        grid.addWidget(title, 1, 0)
        grid.addWidget(titleEdit, 1, 1)

        grid.addWidget(author, 2, 0)
        grid.addWidget(authorEdit, 2, 1)

        grid.addWidget(review, 3, 0)
        grid.addWidget(reviewEdit, 3, 1, 5, 1)

        self.setLayout(grid)
        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle("故障申告")
コード例 #48
0
    def initUI(self):
        '''
        # 标签1
        lb1 = QLabel("源目录", self)
        #lb1.move(20,30)
        # 标签2
        lb2=QLabel("目标目录",self)
        #lb2.move(20, 70)
        # 输入框1
        self.ledit1 = QLineEdit(self)
        #self.ledit1.setGeometry(QtCore.QRect(110, 30, 200, 30))
        # 输入框2
        self.ledit2 = QLineEdit(self)
        #self.ledit2.setGeometry(QtCore.QRect(110, 70, 200, 30))
        # 按钮1
        btn_start=QPushButton('开始处理',self)
        #btn_start.move(20,120)
        btn_start.setToolTip('<b>开始合并CMO的版本</b>')
        btn_start.clicked.connect(self.process_dir)
        #按钮2
        btn_quit = QPushButton('退出', self)
        #btn_quit.move(220, 120)
        btn_quit.setToolTip('<b>退出程序</b>')
        btn_quit.clicked.connect(qApp.quit)
        '''

        srcdir = QLabel('源目录')
        destdir = QLabel('目标目录')

        self.srcdir_edit = QLineEdit()
        self.destdir_edit = QLineEdit()

        ok_button = QPushButton("开始处理")
        ok_button.setToolTip('<b>开始合并CMO的版本</b>')
        ok_button.clicked.connect(self.process_dir)
        quit_button = QPushButton("退出")
        quit_button.setToolTip('<b>退出程序</b>')
        quit_button.clicked.connect(qApp.quit)

        log_lab = QLabel('日志信息')
        self.log_edit = QTextEdit()

        grid = QGridLayout()
        grid.setSpacing(10)

        grid.addWidget(srcdir, 1, 0)
        grid.addWidget(self.srcdir_edit, 1, 1, 2, 1)

        grid.addWidget(destdir, 3, 0)
        grid.addWidget(self.destdir_edit, 3, 1, 2, 1)

        grid.addWidget(quit_button, 5, 0, 1, 1)
        grid.addWidget(ok_button, 5, 1, 1, 1)

        grid.addWidget(log_lab, 7, 0, 1, 1)
        grid.addWidget(self.log_edit, 7, 1, 1, 1)
        self.setLayout(grid)

        self.setGeometry(300, 300, 550, 450)
        self.setWindowTitle("版本预处理")
        self.setWindowIcon(QtGui.QIcon('./download.png'))
        self.show()
コード例 #49
0
    def __init__(self,
                 msg,
                 kind,
                 OK_button,
                 wallet=None,
                 force_disable_encrypt_cb=False):
        self.wallet = wallet

        self.pw = QLineEdit()
        self.pw.setEchoMode(2)
        self.new_pw = QLineEdit()
        self.new_pw.setEchoMode(2)
        self.conf_pw = QLineEdit()
        self.conf_pw.setEchoMode(2)
        self.kind = kind
        self.OK_button = OK_button

        vbox = QVBoxLayout()
        label = QLabel(msg + "\n")
        label.setWordWrap(True)

        grid = QGridLayout()
        grid.setSpacing(8)
        grid.setColumnMinimumWidth(0, 150)
        grid.setColumnMinimumWidth(1, 100)
        grid.setColumnStretch(1, 1)

        if kind == PW_PASSPHRASE:
            vbox.addWidget(label)
            msgs = [_('Passphrase:'), _('Confirm Passphrase:')]
        else:
            logo_grid = QGridLayout()
            logo_grid.setSpacing(8)
            logo_grid.setColumnMinimumWidth(0, 70)
            logo_grid.setColumnStretch(1, 1)

            logo = QLabel()
            logo.setAlignment(Qt.AlignCenter)

            logo_grid.addWidget(logo, 0, 0)
            logo_grid.addWidget(label, 0, 1, 1, 2)
            vbox.addLayout(logo_grid)

            m1 = _('New Password:'******'Password:'******'Confirm Password:'******'Current Password:'******'Encrypt wallet file'))
        self.encrypt_cb.setEnabled(False)
        grid.addWidget(self.encrypt_cb, 4, 0, 1, 2)
        self.encrypt_cb.setVisible(kind != PW_PASSPHRASE)

        def enable_OK():
            ok = self.new_pw.text() == self.conf_pw.text()
            OK_button.setEnabled(ok)
            self.encrypt_cb.setEnabled(ok and bool(self.new_pw.text())
                                       and not force_disable_encrypt_cb)

        self.new_pw.textChanged.connect(enable_OK)
        self.conf_pw.textChanged.connect(enable_OK)

        self.vbox = vbox
コード例 #50
0
class ParticleComponent(QWidget):
    def __init__(self, parent, component):
        super().__init__(parent)
        self.parent = parent
        self.component = component

        self.name = QLabel("Particle", self)
        self.name.setAlignment(Qt.AlignHCenter)
        self.delete_btn = QPushButton("Delete", self)
        self.color = QLabel("Color", self)
        self.color_spins = [
            QSpinBox(self),
            QSpinBox(self),
            QSpinBox(self),
            QSpinBox(self)
        ]
        self.color_picker = QPushButton("Color Picker")
        self.final_color = QLabel("Final Color")
        self.final_color_spins = [
            QSpinBox(self),
            QSpinBox(self),
            QSpinBox(self),
            QSpinBox(self)
        ]
        self.final_color_picker = QPushButton("Color Picker")
        self.size_name = QLabel("Size", self)
        self.size_spins = [QSpinBox(self), QSpinBox(self)]
        self.final_size_name = QLabel("Final Size", self)
        self.final_size_spins = [QSpinBox(self), QSpinBox(self)]
        self.angle_range_name = QLabel("Angle", self)
        self.angle_range_spins = [QSpinBox(self), QSpinBox(self)]
        self.force_range_name = QLabel("Force", self)
        self.force_range_spins = [QSpinBox(self), QSpinBox(self)]
        self.offset_min_name = QLabel("Offset Minimum", self)
        self.offset_min_spins = [QSpinBox(self), QSpinBox(self)]
        self.offset_max_name = QLabel("Offset Maximum", self)
        self.offset_max_spins = [QSpinBox(self), QSpinBox(self)]
        self.lifetime = QLabel("Life Time")
        self.lifetime_spin = QSpinBox(self)
        self.spawn_time = QLabel("Spawn Time")
        self.spawn_time_spin = QDoubleSpinBox(self)
        self.spawn_number = QLabel("Spawn Number")
        self.spawn_number_spin = QSpinBox(self)

        self.color_picker.clicked.connect(self.select_color)
        self.lifetime_spin.setRange(-2147483648, 2147483647)
        self.lifetime_spin.setValue(self.component.lifetime)
        self.lifetime_spin.valueChanged.connect(self.change_value)
        self.spawn_time_spin.setRange(-2147483648, 2147483647)
        self.spawn_time_spin.setValue(self.component.spawn_time)
        self.spawn_time_spin.setSingleStep(0.01)
        self.spawn_time_spin.valueChanged.connect(self.change_value)
        self.spawn_number_spin.setRange(-2147483648, 2147483647)
        self.spawn_number_spin.setValue(self.component.spawn_number)
        self.spawn_number_spin.valueChanged.connect(self.change_value)
        for k, v in enumerate(component.color.rgba()):
            self.color_spins[k].setRange(0, 255)
            self.color_spins[k].setValue(v)
            self.color_spins[k].valueChanged.connect(self.change_value)

        self.final_color_picker.clicked.connect(self.select_final_color)
        for k, v in enumerate(component.final_color.rgba()):
            self.final_color_spins[k].setRange(0, 255)
            self.final_color_spins[k].setValue(v)
            self.final_color_spins[k].valueChanged.connect(self.change_value)

        for k, v in enumerate(self.component.size.coords()):
            self.size_spins[k].setRange(-2147483648, 2147483647)
            self.size_spins[k].setValue(v)

        for k, v in enumerate(self.component.final_size.coords()):
            self.final_size_spins[k].setRange(-2147483648, 2147483647)
            self.final_size_spins[k].setValue(v)

        for k, v in enumerate(self.component.angle_range.coords()):
            self.angle_range_spins[k].setRange(0, 359)
            self.angle_range_spins[k].setValue(v)

        for k, v in enumerate(self.component.force_range.coords()):
            self.force_range_spins[k].setRange(-2147483648, 2147483647)
            self.force_range_spins[k].setValue(v)

        for k, v in enumerate(self.component.offset_min.coords()):
            self.offset_min_spins[k].setRange(-2147483648, 2147483647)
            self.offset_min_spins[k].setValue(v)

        for k, v in enumerate(self.component.offset_max.coords()):
            self.offset_max_spins[k].setRange(-2147483648, 2147483647)
            self.offset_max_spins[k].setValue(v)

        spins = self.size_spins + self.final_size_spins + self.angle_range_spins + self.force_range_spins + \
                self.offset_min_spins + self.offset_max_spins
        for spin in spins:
            spin.valueChanged.connect(self.change_value)

        self.delete_btn.clicked.connect(self.delete)

        self.layout = QGridLayout()
        self.layout.addWidget(self.name, 0, 1, 1, 3)
        self.layout.addWidget(self.delete_btn, 0, 4)
        self.layout.addWidget(self.color, 1, 0)
        for i in range(len(self.color_spins)):
            self.layout.addWidget(self.color_spins[i], 1, 1 + i)
        self.layout.addWidget(self.color_picker, 2, 0, 1, 5)
        self.layout.addWidget(self.final_color, 3, 0)
        for i in range(len(self.final_color_spins)):
            self.layout.addWidget(self.final_color_spins[i], 3, 1 + i)
        self.layout.addWidget(self.final_color_picker, 4, 0, 1, 5)
        self.layout.addWidget(self.size_name, 5, 0)
        self.layout.addWidget(self.size_spins[0], 5, 1, 1, 2)
        self.layout.addWidget(self.size_spins[1], 5, 3, 1, 2)
        self.layout.addWidget(self.final_size_name, 6, 0)
        self.layout.addWidget(self.final_size_spins[0], 6, 1, 1, 2)
        self.layout.addWidget(self.final_size_spins[1], 6, 3, 1, 2)
        self.layout.addWidget(self.angle_range_name, 7, 0)
        self.layout.addWidget(self.angle_range_spins[0], 7, 1, 1, 2)
        self.layout.addWidget(self.angle_range_spins[1], 7, 3, 1, 2)
        self.layout.addWidget(self.force_range_name, 8, 0)
        self.layout.addWidget(self.force_range_spins[0], 8, 1, 1, 2)
        self.layout.addWidget(self.force_range_spins[1], 8, 3, 1, 2)
        self.layout.addWidget(self.offset_min_name, 9, 0)
        self.layout.addWidget(self.offset_min_spins[0], 9, 1, 1, 2)
        self.layout.addWidget(self.offset_min_spins[1], 9, 3, 1, 2)
        self.layout.addWidget(self.offset_max_name, 10, 0)
        self.layout.addWidget(self.offset_max_spins[0], 10, 1, 1, 2)
        self.layout.addWidget(self.offset_max_spins[1], 10, 3, 1, 2)
        self.layout.addWidget(self.lifetime, 11, 0)
        self.layout.addWidget(self.lifetime_spin, 11, 1, 1, 4)
        self.layout.addWidget(self.spawn_time, 12, 0)
        self.layout.addWidget(self.spawn_time_spin, 12, 1, 1, 4)
        self.layout.addWidget(self.spawn_number, 13, 0)
        self.layout.addWidget(self.spawn_number_spin, 13, 1, 1, 4)
        self.setLayout(self.layout)

    def delete(self):
        self.parent.remove_component(comp=self.component.name)

    def select_color(self):
        color = QColorDialog.getColor(QColor(*self.component.color.rgba()),
                                      parent=self)
        if color.isValid():
            self.color_spins[0].setValue(color.red())
            self.color_spins[1].setValue(color.green())
            self.color_spins[2].setValue(color.blue())
            self.color_spins[3].setValue(color.alpha())
            self.change_value(color=[
                color.red(),
                color.green(),
                color.blue(),
                color.alpha()
            ])

    def select_final_color(self):
        color = QColorDialog.getColor(
            QColor(*self.component.final_color.rgba()), parent=self)
        if color.isValid():
            self.final_color_spins[0].setValue(color.red())
            self.final_color_spins[1].setValue(color.green())
            self.final_color_spins[2].setValue(color.blue())
            self.final_color_spins[3].setValue(color.alpha())
            self.change_value(final_color=[
                color.red(),
                color.green(),
                color.blue(),
                color.alpha()
            ])

    def change_value(self, _=None, color=None, final_color=None):
        if color is None:
            self.component.color = Color.from_rgba(
                *(i.value() for i in self.color_spins))
        else:
            self.component.color = Color.from_rgba(*color)

        if final_color is None:
            self.component.final_color = Color.from_rgba(
                *(i.value() for i in self.final_color_spins))
        else:
            self.component.final_color = Color.from_rgba(*final_color)

        self.component.size = Vec2(*(i.value() for i in self.size_spins))
        self.component.final_size = Vec2(*(i.value()
                                           for i in self.final_size_spins))
        self.component.angle_range = Vec2(*(i.value()
                                            for i in self.angle_range_spins))
        self.component.force_range = Vec2(*(i.value()
                                            for i in self.force_range_spins))
        self.component.offset_min = Vec2(*(i.value()
                                           for i in self.offset_min_spins))
        self.component.offset_max = Vec2(*(i.value()
                                           for i in self.offset_max_spins))
        self.component.lifetime = self.lifetime_spin.value()
        self.component.spawn_time = self.spawn_time_spin.value()
        self.component.spawn_number = self.spawn_number_spin.value()

        self.parent.parent.project.save()
        self.parent.parent.viewport.update_screen()
コード例 #51
0
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)

        grid = QGridLayout()
        grid.addWidget(self.createExampleGroup('low h'), 0, 0)
        grid.addWidget(self.createExampleGroup('low s'), 0, 1)
        grid.addWidget(self.createExampleGroup('low v'), 0, 2)
        grid.addWidget(self.createExampleGroup('high h'), 1, 0)
        grid.addWidget(self.createExampleGroup('high s'), 1, 1)
        grid.addWidget(self.createExampleGroup('high v'), 1, 2)
        #grid.addWidget(self.createExampleGroup('threshold'), 2, 0)
        #myCommand = 'new command:'
        pybutton = QPushButton('Send HSV')
        sliders=self.table
        myHSV = (sliders['low h'].value(),sliders['low s'].value(),sliders['low v'].value(),sliders['high h'].value(),sliders['high s'].value(),sliders['high v'].value())
        pybutton.clicked.connect(lambda x, arg=(('HSV',myHSV)): self.clickMethodHSV(arg))
        grid.addWidget(pybutton, 2,0)        

        f2button = QPushButton('follow - forward')
        f2button.clicked.connect(lambda x, arg=(('follow','2')): self.clickMethod(arg))
        grid.addWidget(f2button, 3,0)  

        f1button = QPushButton('follow - inplace')
        f1button.clicked.connect(lambda x, arg=(('follow','1')): self.clickMethod(arg))
        grid.addWidget(f1button, 4,0)

        stop1button = QPushButton('stop!')
        stop1button.clicked.connect(lambda x, arg=(('move','stop')): self.clickMethod(arg))
        grid.addWidget(f1button, 5,0)




        upbutton = QPushButton('up')
        upbutton.clicked.connect(lambda x, arg=(('move','up')): self.clickMethod(arg))
        grid.addWidget(upbutton, 2,2)  


        leftbutton = QPushButton('left')
        leftbutton.clicked.connect(lambda x, arg=(('move','left')): self.clickMethod(arg))
        grid.addWidget(leftbutton, 3,1)  

        rightbutton = QPushButton('right')
        rightbutton.clicked.connect(lambda x, arg=(('move','right')): self.clickMethod(arg))
        grid.addWidget(rightbutton, 3,3)  



        #grid.addWidget()
    
        self.setLayout(grid)
        self.setWindowTitle("PyQt5 Sliders")
        self.resize(400, 300)
コード例 #52
0
class RunningCueWidget(QWidget):
    def __init__(self, cue, **kwargs):
        super().__init__(**kwargs)
        self.setGeometry(0, 0, self.parent().viewport().width(), 80)
        self.setFocusPolicy(Qt.NoFocus)
        self.setLayout(QHBoxLayout(self))
        self.layout().setContentsMargins(0, 0, 0, 1)

        self._accurate_time = False

        self.cue = cue
        self.cue_time = CueTime(cue)
        self.cue_time.notify.connect(self._time_updated, Connection.QtQueued)

        # Use this to avoid transparent background
        self.gridLayoutWidget = QWidget(self)
        self.gridLayout = QGridLayout(self.gridLayoutWidget)
        self.gridLayout.setContentsMargins(3, 3, 3, 3)
        self.gridLayout.setSpacing(2)
        self.layout().addWidget(self.gridLayoutWidget)

        self.nameLabel = QLabel(self.gridLayoutWidget)
        self.nameLabel.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.nameLabel.setText(cue.name)
        self.nameLabel.setToolTip(cue.name)
        self.gridLayout.addWidget(self.nameLabel, 0, 0, 1, 2)

        self.controlButtons = CueControlButtons(parent=self.gridLayoutWidget)
        self.gridLayout.addWidget(self.controlButtons, 1, 0)

        if CueAction.Stop in cue.CueActions:
            self.controlButtons.stopButton.clicked.connect(self._stop)
        else:
            self.controlButtons.stopButton.setEnabled(False)
        if CueAction.Pause in cue.CueActions:
            self.controlButtons.pauseButton.clicked.connect(self._pause)
            self.controlButtons.startButton.clicked.connect(self._restart)
        else:
            self.controlButtons.pauseButton.setEnabled(False)
            self.controlButtons.startButton.setEnabled(False)
        if CueAction.FadeIn in cue.CueActions:
            self.controlButtons.fadeInButton.clicked.connect(self._fadein)
        else:
            self.controlButtons.fadeInButton.setEnabled(False)
        if CueAction.FadeOut in cue.CueActions:
            self.controlButtons.fadeOutButton.clicked.connect(self._fadeout)
        else:
            self.controlButtons.fadeOutButton.setEnabled(False)
        if CueAction.Interrupt in cue.CueActions:
            self.controlButtons.interruptButton.clicked.connect(
                self._interrupt)
        else:
            self.controlButtons.interruptButton.setEnabled(False)

        self.timeDisplay = QLCDNumber(self.gridLayoutWidget)
        self.timeDisplay.setStyleSheet('background-color: transparent')
        self.timeDisplay.setSegmentStyle(QLCDNumber.Flat)
        self.timeDisplay.setDigitCount(8)
        self.timeDisplay.display(strtime(cue.duration))
        self.gridLayout.addWidget(self.timeDisplay, 1, 1)

        self.gridLayout.setRowStretch(0, 1)
        self.gridLayout.setRowStretch(1, 3)
        self.gridLayout.setColumnStretch(0, 7)
        self.gridLayout.setColumnStretch(1, 5)

        cue.changed('name').connect(self.name_changed, Connection.QtQueued)
        cue.started.connect(self.controlButtons.pauseMode, Connection.QtQueued)
        cue.paused.connect(self.controlButtons.startMode, Connection.QtQueued)

        # Fade enter/exit
        cue.fadein_start.connect(self.enter_fadein, Connection.QtQueued)
        cue.fadein_end.connect(self.exit_fade, Connection.QtQueued)
        cue.fadeout_start.connect(self.enter_fadeout, Connection.QtQueued)
        cue.fadeout_end.connect(self.exit_fade, Connection.QtQueued)

    def enter_fadein(self):
        p = self.timeDisplay.palette()
        p.setColor(p.Text, QColor(0, 255, 0))
        self.timeDisplay.setPalette(p)

    def enter_fadeout(self):
        p = self.timeDisplay.palette()
        p.setColor(p.Text, QColor(255, 50, 50))
        self.timeDisplay.setPalette(p)

    def exit_fade(self):
        self.timeDisplay.setPalette(self.palette())

    def name_changed(self, name):
        self.nameLabel.setText(name)
        self.nameLabel.setToolTip(name)

    def set_accurate_time(self, enable):
        self._accurate_time = enable

    def _time_updated(self, time):
        if not self.visibleRegion().isEmpty():
            # If the given value is the duration or < 0 set the time to 0
            if time == self.cue.duration or time < 0:
                time = 0

            self._update_timers(time)

    def _update_timers(self, time):
        self.timeDisplay.display(
            strtime(self.cue.duration - time, accurate=self._accurate_time))

    def _pause(self):
        self.cue.pause(fade=config['ListLayout'].getboolean('PauseCueFade'))

    def _restart(self):
        self.cue.restart(
            fade=config['ListLayout'].getboolean('RestartCueFade'))

    def _stop(self):
        self.cue.stop(fade=config['ListLayout'].getboolean('StopCueFade'))

    def _interrupt(self):
        self.cue.interrupt(
            fade=config['ListLayout'].getboolean('InterruptCueFade'))

    def _fadeout(self):
        self.cue.execute(CueAction.FadeOut)

    def _fadein(self):
        self.cue.execute(CueAction.FadeIn)
コード例 #53
0
ファイル: view.py プロジェクト: lpphub/Demos
    def _create_top_right_group_box(self):
        self.topRightGroupBox = QGroupBox("Operate")

        self.btnStart = QPushButton()
        self.btnStart.setText("Start")

        self.btnStop = QPushButton()
        self.btnStop.setText("Stop")
        self.btnStop.setDisabled(True)

        self.btnImport = QPushButton()
        self.btnImport.setText("Import")

        self.btnExport = QPushButton()
        self.btnExport.setText("Export")
        self.btnExport.setDisabled(True)

        self.btnAdd = QPushButton()
        self.btnAdd.setText("Add")

        self.btnRemove = QPushButton()
        self.btnRemove.setText("Remove")
        self.btnRemove.setDisabled(True)

        self.btnEnable = QPushButton()
        self.btnEnable.setText("Enable")
        self.btnEnable.setDisabled(True)

        self.btnDisable = QPushButton()
        self.btnDisable.setText("Disable")
        self.btnDisable.setDisabled(True)

        layout = QGridLayout()
        layout.addWidget(self.btnStart, 0, 0)
        layout.addWidget(self.btnStop, 0, 1)
        layout.addWidget(self.btnImport, 1, 0)
        layout.addWidget(self.btnExport, 1, 1)
        layout.addWidget(self.btnAdd, 2, 0)
        layout.addWidget(self.btnRemove, 2, 1)
        layout.addWidget(self.btnEnable, 3, 0)
        layout.addWidget(self.btnDisable, 3, 1)
        self.topRightGroupBox.setLayout(layout)
コード例 #54
0
class Daq_Main_Window(QMainWindow):
    def __init__(self, *args, **kwargs):
        super(Daq_Main_Window, self).__init__(*args, **kwargs)

        self.daq = None

        self.connect()
        self.setupUi()

    def closeEvent(self, event):
        reply = QMessageBox.question(self, 'Message', "Are you sure to quit?",
                                     QMessageBox.Yes, QMessageBox.No)

        if reply == QMessageBox.Yes:
            if self.daq is not None:
                self.daq.__del__()
                event.accept()
        else:
            event.ignore()

    def connect(self):
        try:
            importlib.reload(nidaqmx)
            self.daq = Daq("Dev1", "daq")
        except:
            msg = QMessageBox()
            msg.setText("Could not connect to the DAQ")
            msg.setWindowTitle("Connection Attempt")
            msg.setStandardButtons(QMessageBox.Close)
            msg.exec_()

    def reconnect(self):
        if self.daq is not None:
            msg = QMessageBox()
            msg.setText("Already connected to a DAQ")
            msg.setWindowTitle("Connection Attempt")
            msg.setStandardButtons(QMessageBox.Close)
            msg.exec_()
        else:
            self.connect()

    def setupUi(self):
        self.setObjectName("Main Window")
        self.resize(800, 338)
        self.centralwidget = QWidget(self)
        self.centralwidget.setObjectName("centralwidget")
        self.input_channels = QLabel(self.centralwidget)
        self.input_channels.setGeometry(qt.QtCore.QRect(20, 20, 73, 13))
        self.input_channels.setObjectName("input_channels")
        self.ai_grid = QWidget(self.centralwidget)
        self.ai_grid.setGeometry(qt.QtCore.QRect(20, 50, 301, 231))
        self.ai_grid.setObjectName("ai_grid")
        self.gridLayout = QGridLayout(self.ai_grid)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setObjectName("gridLayout")
        self.ai0_val = QLabel(self.ai_grid)
        self.ai0_val.setObjectName("ai0_val")
        self.gridLayout.addWidget(self.ai0_val, 0, 1, 1, 1)
        self.ai21_label = QLabel(self.ai_grid)
        self.ai21_label.setObjectName("ai21_label")
        self.gridLayout.addWidget(self.ai21_label, 5, 2, 1, 1)
        self.ai18_val = QLabel(self.ai_grid)
        self.ai18_val.setObjectName("ai18_val")
        self.gridLayout.addWidget(self.ai18_val, 2, 3, 1, 1)
        self.ai19_label = QLabel(self.ai_grid)
        self.ai19_label.setObjectName("ai19_label")
        self.gridLayout.addWidget(self.ai19_label, 3, 2, 1, 1)
        self.ai17_label = QLabel(self.ai_grid)
        self.ai17_label.setObjectName("ai17_label")
        self.gridLayout.addWidget(self.ai17_label, 1, 2, 1, 1)
        self.ai22_label = QLabel(self.ai_grid)
        self.ai22_label.setObjectName("ai22_label")
        self.gridLayout.addWidget(self.ai22_label, 6, 2, 1, 1)
        self.ai20_label = QLabel(self.ai_grid)
        self.ai20_label.setObjectName("ai20_label")
        self.gridLayout.addWidget(self.ai20_label, 4, 2, 1, 1)
        self.ai18_label = QLabel(self.ai_grid)
        self.ai18_label.setObjectName("ai18_label")
        self.gridLayout.addWidget(self.ai18_label, 2, 2, 1, 1)
        self.ai16_label = QLabel(self.ai_grid)
        self.ai16_label.setObjectName("ai16_label")
        self.gridLayout.addWidget(self.ai16_label, 0, 2, 1, 1)
        self.ai17_val = QLabel(self.ai_grid)
        self.ai17_val.setObjectName("ai17_val")
        self.gridLayout.addWidget(self.ai17_val, 1, 3, 1, 1)
        self.ai22_val = QLabel(self.ai_grid)
        self.ai22_val.setObjectName("ai22_val")
        self.gridLayout.addWidget(self.ai22_val, 6, 3, 1, 1)
        self.ai21_val = QLabel(self.ai_grid)
        self.ai21_val.setObjectName("ai21_val")
        self.gridLayout.addWidget(self.ai21_val, 5, 3, 1, 1)
        self.ai20_val = QLabel(self.ai_grid)
        self.ai20_val.setObjectName("ai20_val")
        self.gridLayout.addWidget(self.ai20_val, 4, 3, 1, 1)
        self.ai23_val = QLabel(self.ai_grid)
        self.ai23_val.setObjectName("ai23_val")
        self.gridLayout.addWidget(self.ai23_val, 7, 3, 1, 1)
        self.ai7_label = QLabel(self.ai_grid)
        self.ai7_label.setObjectName("ai7_label")
        self.gridLayout.addWidget(self.ai7_label, 7, 0, 1, 1)
        self.ai7_val = QLabel(self.ai_grid)
        self.ai7_val.setObjectName("ai7_val")
        self.gridLayout.addWidget(self.ai7_val, 7, 1, 1, 1)
        self.ai6_val = QLabel(self.ai_grid)
        self.ai6_val.setObjectName("ai6_val")
        self.gridLayout.addWidget(self.ai6_val, 6, 1, 1, 1)
        self.ai23_label = QLabel(self.ai_grid)
        self.ai23_label.setObjectName("ai23_label")
        self.gridLayout.addWidget(self.ai23_label, 7, 2, 1, 1)
        self.ai19_val = QLabel(self.ai_grid)
        self.ai19_val.setObjectName("ai19_val")
        self.gridLayout.addWidget(self.ai19_val, 3, 3, 1, 1)
        self.ai16_val = QLabel(self.ai_grid)
        self.ai16_val.setObjectName("ai16_val")
        self.gridLayout.addWidget(self.ai16_val, 0, 3, 1, 1)
        self.ai6_label = QLabel(self.ai_grid)
        self.ai6_label.setObjectName("ai6_label")
        self.gridLayout.addWidget(self.ai6_label, 6, 0, 1, 1)
        self.ai1_label = QLabel(self.ai_grid)
        self.ai1_label.setObjectName("ai1_label")
        self.gridLayout.addWidget(self.ai1_label, 1, 0, 1, 1)
        self.ai1_val = QLabel(self.ai_grid)
        self.ai1_val.setObjectName("ai1_val")
        self.gridLayout.addWidget(self.ai1_val, 1, 1, 1, 1)
        self.ai2_val = QLabel(self.ai_grid)
        self.ai2_val.setObjectName("ai2_val")
        self.gridLayout.addWidget(self.ai2_val, 2, 1, 1, 1)
        self.ai3_label = QLabel(self.ai_grid)
        self.ai3_label.setObjectName("ai3_label")
        self.gridLayout.addWidget(self.ai3_label, 3, 0, 1, 1)
        self.ai5_label = QLabel(self.ai_grid)
        self.ai5_label.setObjectName("ai5_label")
        self.gridLayout.addWidget(self.ai5_label, 5, 0, 1, 1)
        self.ai4_label = QLabel(self.ai_grid)
        self.ai4_label.setObjectName("ai4_label")
        self.gridLayout.addWidget(self.ai4_label, 4, 0, 1, 1)
        self.ai0_label = QLabel(self.ai_grid)
        self.ai0_label.setObjectName("ai0_label")
        self.gridLayout.addWidget(self.ai0_label, 0, 0, 1, 1)
        self.ai3_val = QLabel(self.ai_grid)
        self.ai3_val.setObjectName("ai3_val")
        self.gridLayout.addWidget(self.ai3_val, 3, 1, 1, 1)
        self.ai2_label = QLabel(self.ai_grid)
        self.ai2_label.setObjectName("ai2_label")
        self.gridLayout.addWidget(self.ai2_label, 2, 0, 1, 1)
        self.ai5_val = QLabel(self.ai_grid)
        self.ai5_val.setObjectName("ai5_val")
        self.gridLayout.addWidget(self.ai5_val, 5, 1, 1, 1)
        self.ai4_val = QLabel(self.ai_grid)
        self.ai4_val.setObjectName("ai4_val")
        self.gridLayout.addWidget(self.ai4_val, 4, 1, 1, 1)
        self.output_channels = QLabel(self.centralwidget)
        self.output_channels.setGeometry(qt.QtCore.QRect(410, 10, 81, 20))
        self.output_channels.setObjectName("output_channels")
        self.formLayoutWidget_2 = QWidget(self.centralwidget)
        self.formLayoutWidget_2.setGeometry(qt.QtCore.QRect(410, 80, 201, 61))
        self.formLayoutWidget_2.setObjectName("formLayoutWidget_2")
        self.OutputChannels = QGridLayout(self.formLayoutWidget_2)
        self.OutputChannels.setContentsMargins(0, 0, 0, 0)
        self.OutputChannels.setObjectName("OutputChannels")
        self.ao1_val = QLabel(self.formLayoutWidget_2)
        self.ao1_val.setObjectName("ao1_val")
        self.OutputChannels.addWidget(self.ao1_val, 1, 1, 1, 1)
        self.ao0_label = QLabel(self.formLayoutWidget_2)
        self.ao0_label.setObjectName("ao0_label")
        self.OutputChannels.addWidget(self.ao0_label, 0, 0, 1, 1)
        self.ao1_label = QLabel(self.formLayoutWidget_2)
        self.ao1_label.setObjectName("ao1_label")
        self.OutputChannels.addWidget(self.ao1_label, 1, 0, 1, 1)
        self.ao0_val = QLabel(self.formLayoutWidget_2)
        self.ao0_val.setObjectName("ao0_val")
        self.OutputChannels.addWidget(self.ao0_val, 0, 1, 1, 1)
        self.ao0_set = QLineEdit(self.formLayoutWidget_2)
        self.ao0_set.setObjectName("ao0_set")
        self.ao0_set.setMaximumSize(61, 20)
        self.ao0_set.setSizePolicy(QSizePolicy(0, 0))
        self.OutputChannels.addWidget(self.ao0_set, 0, 2, 1, 1)
        self.ao1_set = QLineEdit(self.formLayoutWidget_2)
        self.ao1_set.setObjectName("ao1_set")
        self.ao1_set.setMaximumSize(61, 20)
        self.OutputChannels.addWidget(self.ao1_set, 1, 2, 1, 1)
        self.out_cha = QLabel(self.centralwidget)
        self.out_cha.setGeometry(qt.QtCore.QRect(410, 50, 61, 20))
        self.out_cha.setObjectName("out_cha")
        self.out_val = QLabel(self.centralwidget)
        self.out_val.setGeometry(qt.QtCore.QRect(480, 40, 61, 41))
        self.out_val.setObjectName("out_val")
        self.out_set = QLabel(self.centralwidget)
        self.out_set.setGeometry(qt.QtCore.QRect(550, 50, 51, 20))
        self.out_set.setObjectName("out_set")
        self.setCentralWidget(self.centralwidget)

        # Buttons
        self.updateButton = QPushButton(self.centralwidget)
        self.updateButton.setGeometry(qt.QtCore.QRect(410, 170, 201, 41))
        self.updateButton.setObjectName("updateButton")
        self.updateButton.clicked.connect(self.set_vals)
        self.connectButton = QPushButton(self.centralwidget)
        self.connectButton.setGeometry(qt.QtCore.QRect(410, 220, 201, 41))
        self.connectButton.setObjectName("connectButton")
        self.connectButton.clicked.connect(self.reconnect)

        # Menu Bar
        self.menubar = QMenuBar(self)
        self.menubar.setGeometry(qt.QtCore.QRect(0, 0, 800, 21))
        self.menubar.setObjectName("menubar")

        # File Menu
        self.menuFile = QMenu(self.menubar)
        self.menuFile.setObjectName("menuFile")
        quitAction = QAction('&Quit', self)
        quitAction.triggered.connect(self.close)
        self.menuFile.addAction(quitAction)

        # Experiment Menu
        self.menuExperiments = QMenu(self.menubar)
        self.menuExperiments.setObjectName("menuExperiments")
        sweep1dAction = QAction('&1D Sweep', self)
        sweep1dAction.triggered.connect(self.disp_1D_Sweep)
        self.menuExperiments.addAction(sweep1dAction)
        sweep2dAction = QAction('&2D Sweep', self)
        sweep2dAction.triggered.connect(self.disp_2D_Sweep)
        self.menuExperiments.addAction(sweep2dAction)

        self.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(self)
        self.statusbar.setObjectName("statusbar")
        self.setStatusBar(self.statusbar)
        self.menubar.addAction(self.menuFile.menuAction())
        self.menubar.addAction(self.menuExperiments.menuAction())

        self.set_label_names()
        self.input_vals = [
            self.ai0_val, self.ai1_val, self.ai2_val, self.ai3_val,
            self.ai4_val, self.ai5_val, self.ai6_val, self.ai7_val,
            self.ai16_val, self.ai17_val, self.ai18_val, self.ai19_val,
            self.ai20_val, self.ai21_val, self.ai22_val, self.ai23_val
        ]
        self.output_vals = [self.ao0_val, self.ao1_val]

        self.update_vals()

        qt.QtCore.QMetaObject.connectSlotsByName(self)

    def disp_1D_Sweep(self):
        self.sweep_window = Sweep1DWindow(parent=self)
        self.sweep_window.show()

    def disp_2D_Sweep(self):
        pass

    def set_label_names(self):
        self.setWindowTitle("DAQ Controller - MeasureIt")
        self.input_channels.setText("Input Channels")
        self.ai0_val.setText("TextLabel")
        self.ai21_label.setText("AI21")
        self.ai18_val.setText("TextLabel")
        self.ai19_label.setText("AI19")
        self.ai17_label.setText("AI17")
        self.ai22_label.setText("AI22")
        self.ai20_label.setText("AI20")
        self.ai18_label.setText("AI18")
        self.ai16_label.setText("AI16")
        self.ai17_val.setText("TextLabel")
        self.ai22_val.setText("TextLabel")
        self.ai21_val.setText("TextLabel")
        self.ai20_val.setText("TextLabel")
        self.ai16_val.setText("TextLabel")
        self.ai7_label.setText("AI7")
        self.ai6_val.setText("TextLabel")
        self.ai7_val.setText("TextLabel")
        self.ai23_label.setText("AI23")
        self.ai19_val.setText("TextLabel")
        self.ai23_val.setText("TextLabel")
        self.ai6_label.setText("AI6")
        self.ai1_label.setText("AI1")
        self.ai1_val.setText("TextLabel")
        self.ai2_val.setText("TextLabel")
        self.ai3_label.setText("AI3")
        self.ai5_label.setText("AI5")
        self.ai4_label.setText("AI4")
        self.ai0_label.setText("AI0")
        self.ai3_val.setText("TextLabel")
        self.ai2_label.setText("AI2")
        self.ai5_val.setText("TextLabel")
        self.ai4_val.setText("TextLabel")
        self.output_channels.setText("Output Channels")
        self.ao1_val.setText("TextLabel")
        self.ao0_label.setText("AO0")
        self.ao1_label.setText("AO1")
        self.ao0_val.setText("TextLabel")
        self.updateButton.setText("Update Output")
        self.connectButton.setText("Connect DAQ")
        self.out_cha.setText("Channel")
        self.out_val.setText("Value")
        self.out_set.setText("Set Value")
        self.menuFile.setTitle("File")
        self.menuExperiments.setTitle("Experiments")

    def update_vals(self):
        if self.daq is not None:
            self.daq.update_all_inputs()
            for n, num in enumerate(
                [0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 18, 19, 20, 21, 22, 23]):
                name = "ai" + str(num)
                channel = self.daq.submodules[name]
                self.input_vals[n].setText(str(channel.get("voltage"))[0:7])

            for n, num in enumerate([0, 1]):
                name = "ao" + str(num)
                channel = self.daq.submodules[name]
                self.output_vals[n].setText(str(channel.get("voltage"))[0:7])

    def set_vals(self):
        if self.daq is not None:
            invalid = 0
            try:
                value0 = float(self.ao0_set.text())

                task = nidaqmx.Task()
                self.daq.submodules["ao0"].add_self_to_task(task)
                self.daq.ao0.set("voltage", float(value0))
                self.daq.submodules["ao0"].clear_task()
                task.close()

            except ValueError:
                invalid += 1

            try:
                value1 = float(self.ao1_set.text())

                task = nidaqmx.Task()
                self.daq.submodules["ao1"].add_self_to_task(task)
                self.daq.ao1.set("voltage", float(value1))
                self.daq.submodules["ao1"].clear_task()
                task.close()
            except ValueError:
                invalid += 1

            if invalid == 2:
                msg = QMessageBox()
                msg.setText("No valid inputs given")
                msg.setWindowTitle("Error")
                msg.setStandardButtons(QMessageBox.Close)
                msg.exec_()

            self.update_vals()
コード例 #55
0
ファイル: preliminaryWidget.py プロジェクト: Nick3869/UI
class Ui_widget0(QWidget):
    fileName = ""

    def __init__(self, parent):
        super(Ui_widget0, self).__init__(parent)
        parent.next.setEnabled(False)
        self.setupUi(parent)

    def setupUi(self, parent):

        self.vlayout = QtWidgets.QVBoxLayout()
        self.hlayout = QtWidgets.QHBoxLayout()
        self.frame = QtWidgets.QFrame(self)
        self.gridLayout = QGridLayout()
        self.gridLayout.setContentsMargins(0, 0, 0, 0)

        self.combo = QComboBox()
        self.combo.addItem("Whole process")
        self.combo.addItem("Step 1 :")
        self.combo.addItem("Step 2 :")
        self.combo.addItem("Step 3 :")
        self.combo.addItem("Step 4 :")
        self.combo.addItem("Step 5 :")
        self.combo.addItem("Step 6 :")
        self.combo.addItem("Step 7 :")
        self.combo.addItem("Step 8 :")
        self.combo.addItem("Step 9 :")
        self.combo.addItem("Step 10 :")
        self.combo.addItem("Step 11 :")

        self.multipleRadio = QtWidgets.QRadioButton("Directory")
        self.gridLayout.addWidget(self.multipleRadio, 3, 1, 1, 1)
        self.multipleRadio.clicked.connect(self.multipleCliked)

        self.multipleBrowse = QtWidgets.QPushButton("Browse")
        self.gridLayout.addWidget(self.multipleBrowse, 3, 3, 1, 1)
        self.multipleBrowse.setEnabled(False)
        self.multipleBrowse.clicked.connect(lambda: self.browseDir(parent))

        self.singleEdit = QtWidgets.QLineEdit()
        self.gridLayout.addWidget(self.singleEdit, 1, 2, 1, 1)
        self.singleEdit.setEnabled(False)

        self.singleBrowse = QtWidgets.QPushButton("Browse")
        self.gridLayout.addWidget(self.singleBrowse, 1, 3, 1, 1)
        self.singleBrowse.setEnabled(False)
        self.singleBrowse.clicked.connect(lambda: self.browse(parent))

        self.singleRadio = QtWidgets.QRadioButton("Single file")
        self.gridLayout.addWidget(self.singleRadio, 1, 1, 1, 1)
        self.singleRadio.clicked.connect(self.singleCliked)

        self.multipleEdit = QtWidgets.QLineEdit()
        self.gridLayout.addWidget(self.multipleEdit, 3, 2, 1, 1)
        self.multipleEdit.setEnabled(False)

        self.label = QtWidgets.QLabel("Choose input :")

        self.label_2 = QtWidgets.QLabel("MANDATORY OPTIONS")

        self.gridLayout.setContentsMargins(10, 10, 10, 10)
        self.gridLayout.setVerticalSpacing(10)

        self.frame.setLayout(self.gridLayout)
        self.frame.setFrameStyle(QtWidgets.QFrame.StyledPanel
                                 | QtWidgets.QFrame.Raised)

        self.hlayout.addStretch(1)
        self.hlayout.addWidget(self.label_2)
        self.hlayout.addStretch(1)

        self.vlayout.addStretch(1)
        self.vlayout.addLayout(self.hlayout)
        self.vlayout.addStretch(1)
        self.vlayout.addWidget(self.label)
        self.vlayout.addWidget(self.frame)
        self.vlayout.addStretch(1)
        self.vlayout.addWidget(self.combo)
        self.vlayout.addStretch(2)

        self.setLayout(self.vlayout)

        self.loadXML()

    def singleCliked(self):

        self.multipleEdit.setEnabled(False)
        self.multipleBrowse.setEnabled(False)
        self.singleEdit.setEnabled(True)
        self.singleBrowse.setEnabled(True)

    def multipleCliked(self):

        self.multipleEdit.setEnabled(True)
        self.multipleBrowse.setEnabled(True)
        self.singleEdit.setEnabled(False)
        self.singleBrowse.setEnabled(False)

    def browse(self, parent):

        self.fileName, _ = QtWidgets.QFileDialog.getOpenFileName(
            self, "Open File", ".", "*.nrrd")

        if self.fileName:
            self.singleEdit.setText(self.fileName)
            parent.next.setEnabled(True)

    def browseDir(self, parent):

        self.fileName = QtWidgets.QFileDialog.getExistingDirectory(
            self, caption='Choose directory', directory='.')

        if self.fileName:
            self.multipleEdit.setText(self.fileName)
            parent.next.setEnabled(True)

    def loadXML(self):

        stepTree = etree.parse("../PROTOCOLS/HARDIPrep_temp.xml")
        steps = stepTree.getroot()
        step0 = steps[0]

        if not (step0.getchildren() == []):
            path = step0[0]

            if not (path.text == "t"):
                if os.path.isdir(path.text):
                    self.multipleEdit.setText(path.text)
                else:
                    self.singleEdit.setText(path.text)

    def updateXML(self, parent):

        parent.xmlSaved = True
        stepTree = etree.parse("../PROTOCOLS/HARDIPrep_temp.xml")
        steps = stepTree.getroot()
        step0 = steps[0]

        if (step0.xpath("/Steps/step/Files") == []):
            subel = etree.SubElement(step0, "Files")
            subel.text = "t"

        if self.fileName:
            path = step0[0]
            path.text = self.fileName

        if not (step0.xpath("/Steps/step/toStep") == []):
            toStep = step0[1]
            toStep.text = self.combo.currentText()
        else:
            toStep = etree.SubElement(step0, "toStep")
            toStep.text = self.combo.currentText()

        xmlFile = open("../PROTOCOLS/HARDIPrep_temp.xml", "w")
        xmlFile.write(etree.tostring(stepTree, pretty_print=True))
        xmlFile.close()
コード例 #56
0
    def __init__(self,
                 name,
                 env_config,
                 instr_params,
                 gui=True,
                 dummy=False,
                 vr_name=''):
        QWidget.__init__(self,
                         env_config=env_config,
                         instr_params=instr_params)

        self.gui = gui
        self.dummy = dummy
        self.vr_name = vr_name
        self.progress_dialog = None
        self.timer = None
        self.time_passed = 0.
        self.steps_passed = 0
        self.log_scale_y = False
        self.sq_scale_x = False
        self.sim_status = '1/2 Подготовка'
        self.timer_p_int = self.configuration['Simulation poll timer']  # mcsec

        if not gui:
            return

        # setting up the figure and its canvas for plots
        self.figure = Figure()
        self.canvas = FigureCanvas(self.figure)
        self.toolbar = NavigationToolbar(self.canvas, self)
        self.canvas.setFixedWidth(self.configuration['Plot Width'])
        self.canvas.setFixedHeight(self.configuration['Plot Height'])

        # setting up plot axes
        if ('1D detector file name'
                in self.configuration) and ('2D detector file name'
                                            in self.configuration):
            self.axes_1d_detector, self.axes_2d_detector = self.canvas.figure.subplots(
                nrows=1, ncols=2)
        elif '1D detector file name' in self.configuration:
            self.axes_1d_detector = self.canvas.figure.subplots()
            self.axes_2d_detector = None
        elif '2D detector file name' in self.configuration:
            self.axes_1d_detector = None
            self.axes_2d_detector = self.canvas.figure.subplots()
        self.figure.tight_layout()

        # adding plot scale button and registering click callback
        self.log_by = QPushButton('Лог. интенсивность')
        self.log_by.setFixedWidth(0.2 * self.configuration['Plot Width'])
        self.log_by.clicked.connect(self.on_btn_log_y)
        self.sq_bx = QPushButton('Кв. ось x')
        self.sq_bx.setFixedWidth(0.2 * self.configuration['Plot Width'])
        self.sq_bx.clicked.connect(self.on_btn_sq_x)

        # adding the button to run the fit app
        self.fit_b = QPushButton('Анализ результатов')
        self.fit_b.setFixedWidth(0.2 * self.configuration['Plot Width'])
        self.fit_b.clicked.connect(self.on_btn_fit)

        self.save_b = QPushButton('Сохранить результаты')
        self.save_b.setFixedWidth(0.2 * self.configuration['Plot Width'])
        self.save_b.clicked.connect(self.on_btn_save)

        # adding simulation parameters buttons and labels
        self.param_buttons, self.param_labels = [], []
        for i, param in enumerate(self.instr_params):
            self.param_buttons.append(QPushButton(param.gui_name))
            self.param_labels.append(QLabel(str(param)))
            self.param_labels[i].setFrameStyle(QFrame.Sunken | QFrame.Panel)
            self.param_buttons[i].clicked.connect(self.make_callback(i))

        # adding "Simulate" button and registering click callback
        self.run_b = QPushButton('Запуск эксперимента')
        self.run_b.clicked.connect(self.on_btn_run)

        # adding instrument scheme picture
        p_map = QPixmap(self.configuration['instrument scheme'])
        p_map = p_map.scaledToHeight(200, Qt.SmoothTransformation)
        scheme_label = QLabel()
        scheme_label.setPixmap(p_map)

        # setting up Qt window layout
        main_layout = QHBoxLayout()
        param_layout = QGridLayout()
        plot_layout = QVBoxLayout()
        tbr_layout = QHBoxLayout()
        log_layout = QVBoxLayout()
        u_plot_layout = QHBoxLayout()

        tbr_layout.addWidget(self.toolbar, 0)
        log_layout.addWidget(self.log_by, 0)
        log_layout.addWidget(self.sq_bx, 1)
        tbr_layout.addLayout(log_layout, 1)
        plot_layout.addLayout(tbr_layout, 0)
        plot_layout.addWidget(self.canvas, 1)
        u_plot_layout.addWidget(self.fit_b, 0, Qt.AlignRight)
        u_plot_layout.addWidget(self.save_b, 1, Qt.AlignLeft)
        plot_layout.addLayout(u_plot_layout, 3)
        plot_layout.addWidget(scheme_label, 4, Qt.AlignCenter)

        for i, param in enumerate(self.instr_params):
            param_layout.addWidget(self.param_buttons[i], i, 0)
            param_layout.addWidget(self.param_labels[i], i, 1)
        param_layout.addWidget(self.run_b, len(self.instr_params), 1)

        main_layout.addLayout(param_layout, 0)
        main_layout.addLayout(plot_layout, 1)

        self.setLayout(main_layout)

        self.setWindowTitle(name)
コード例 #57
0
class TetrisWidget(QWidget):
    def __init__(self, parent):

        super().__init__(parent)

        self.btns = ['STOP', 'ROTATEL', 'RESTART', 'LEFT', 'ROTATER', 'RIGHT']
        pos = [(i + 1, j + 1) for i in range(2) for j in range(3)]

        self.lcd = QLCDNumber(Qt.Horizontal, self)
        self.btn = QPushButton('START', self)
        self.btn.clicked.connect(self.dealbtn)
        self.btn.setFocusPolicy(Qt.NoFocus)

        self.grid = QGridLayout()
        self.grid.setSpacing(10)

        self.tTritrisBoard = TritrisBoard(self)
        self.nextBoard = NextShapeBoard(self)
        #create buttons above the lcd
        self.grid.addWidget(self.tTritrisBoard, 1, 1, 5, 4)
        for pos, name in zip(pos, self.btns):
            button = QPushButton(name)
            button.setFocusPolicy(Qt.NoFocus)
            if name == 'STOP':
                button.clicked.connect(self.stop)
            elif name == 'ROTATEL':
                button.clicked.connect(self.tTritrisBoard.up)
            elif name == 'RESTART':
                button.clicked.connect(self.restart)
            elif name == 'LEFT':
                button.clicked.connect(self.tTritrisBoard.left)
            elif name == 'ROTATER':
                button.clicked.connect(self.tTritrisBoard.down)
            elif name == 'RIGHT':
                button.clicked.connect(self.tTritrisBoard.right)
            else:
                return
            self.grid.addWidget(button, pos[0], pos[1] + 4)
        self.grid.addWidget(self.nextBoard, 3, 5, 1, 3)
        self.grid.addWidget(self.lcd, 4, 5, 1, 3)
        self.grid.addWidget(self.btn, 5, 5, 1, 3)
        #show the score in lcd
        self.tTritrisBoard.score[int].connect(self.lcd.display)
        #handle tetris_board's operating status
        self.tTritrisBoard.status[str].connect(self.handle_status)
        #handle next shape signal
        self.tTritrisBoard.next[int].connect(self.nextBoard.showNext)
        self.tTritrisBoard.status.emit('wait_start')

        self.setLayout(self.grid)

    def start(self):
        if self.btn.text(
        ) == 'START' and not self.tTritrisBoard.timer.isActive():
            self.tTritrisBoard.start()
            self.tTritrisBoard.status.emit('running')

    def stop(self):
        self.tTritrisBoard.pause()

    def speed(self):
        self.tTritrisBoard.timer.stop()
        self.tTritrisBoard.timer.start(TritrisBoard.FastSpeed,
                                       self.tTritrisBoard)

    def restart(self):
        if not self.tTritrisBoard.timer.isActive():
            self.tTritrisBoard.pause()
        self.tTritrisBoard.clearTritrisBoard()
        self.tTritrisBoard.start()
        self.tTritrisBoard.status.emit('running')

        self.tTritrisBoard.msg2Statusbar.emit('Successly restarted,Good luck!')

    #change the start_button's text follwing the signal of tetris_board's operating status
    def handle_status(self, status):
        if status == 'wait_start':
            self.btn.setText('START')

        elif status == 'running':
            self.btn.setText('STOP')

        elif status == 'stopped':
            self.btn.setText('CONTINUE')

        else:
            return

    #control the function of start_button
    def dealbtn(self):
        if self.btn.text() == 'START':
            self.start()
        elif self.btn.text() == 'STOP':
            self.stop()
        elif self.btn.text() == 'CONTINUE':
            self.stop()
        else:
            return
コード例 #58
0
ファイル: material_box.py プロジェクト: ela-guit/dB-mapper
class MaterialBox(QGroupBox):
    update_view = pyqtSignal(bool)

    def __init__(self, str, parent=None):
        super().__init__(str)
        layout = QVBoxLayout()
        layout.setSpacing(10)

        self.surface_dropdown = self.create_surface_dropdown()
        self.material_dropdown = self.create_material_dropdown()
        self.set_material_changer(layout)
        self.sabine_table = self.create_sabine_table(freq=1000)
        layout.addWidget(self.sabine_table)
        self.create_material_view(layout)
        self.material_view = False
        layout.addItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding))
        self.setLayout(layout)

    def create_surface_dropdown(self, model_faces=None):
        """
        Populates the surfaces dropdown
        """
        self.model_faces = model_faces

        surfaces = QComboBox()

        if model_faces is not None:
            for i, face in enumerate(model_faces):
                if np.array_equal(face.normal.vec, [0.0, 1.0, 0.0]):
                    faceStr = "Ceiling [" + str(i) + "]"
                elif np.array_equal(face.normal.vec, [0.0, -1.0, 0.0]):
                    faceStr = "Floor [" + str(i) + "]"
                else:
                    faceStr = "Wall [" + str(i) + "]"
                surfaces.addItem(faceStr, face)
            surfaces.addItem("All", None)
            surfaces.model().sort(0)

        return surfaces

    def create_material_dropdown(self):
        """
        Populates the material dropdown
        """
        materials = QComboBox()

        materials.addItem("Hardwood", mtl.HARDWOOD)
        materials.addItem("Carpet", mtl.CARPET)
        materials.addItem("Drywall", mtl.DRYWALL)
        materials.addItem("Brick", mtl.BRICK)
        materials.addItem("Concrete", mtl.CONCRETE)
        materials.addItem("Foam", mtl.FOAM)

        return materials

    def set_material_changer(self, layout):
        """
        Creates the material changer section of the Material Box.
        """
        surface_label = QLabel("Surface")
        surface_label.setAlignment(Qt.AlignLeft)
        material_label = QLabel("Material")
        material_label.setAlignment(Qt.AlignLeft)

        set_material_btn = QPushButton("Set Material")
        set_material_btn.setToolTip("Set material for chosen surface")
        set_material_btn.clicked.connect(
            lambda: self.set_material(
                self.surface_dropdown.itemData(self.surface_dropdown.currentIndex()),
                self.material_dropdown.itemData(self.material_dropdown.currentIndex()),
            )
        )

        self.material_changer_layout = QGridLayout()
        self.material_changer_layout.addWidget(surface_label, 0, 0, 1, 1)
        self.material_changer_layout.addWidget(material_label, 0, 1, 1, 1)
        self.material_changer_layout.addWidget(self.surface_dropdown, 1, 0, 1, 1)
        self.material_changer_layout.addWidget(self.material_dropdown, 1, 1, 1, 1)
        self.material_changer_layout.addWidget(set_material_btn, 2, 0, 1, 2)

        layout.addLayout(self.material_changer_layout)

    def create_sabine_table(self, freq) -> QTableWidget:
        """
        Creates the Sabine absorption coefficient reference table for 
        the current frequency
        """
        sabine_table = QTableWidget()
        sabine_table.setRowCount(6)
        sabine_table.setColumnCount(2)
        sabine_table.setHorizontalHeaderLabels(["Material", "Absorption"])

        materials = [
            mtl.HARDWOOD,
            mtl.CARPET,
            mtl.DRYWALL,
            mtl.BRICK,
            mtl.CONCRETE,
            mtl.FOAM,
        ]

        for i, m in enumerate(materials):
            sabine_table.setItem(i, 0, QTableWidgetItem(mtl.name(m)))
            a = QTableWidgetItem(str(mtl.absorption(m, freq)))
            a.setTextAlignment(Qt.AlignCenter)
            sabine_table.setItem(i, 1, a)

        return sabine_table

    def create_material_view(self, layout):
        """
        Creates the checkbox that toggles the material view.
        """
        material_view_label = QLabel("Material View")
        material_view_label.setAlignment(Qt.AlignLeft)

        material_view_checkbox = QCheckBox()
        material_view_checkbox.stateChanged.connect(self.change_material_view)

        material_view_layout = QHBoxLayout()
        material_view_layout.addWidget(material_view_label)
        material_view_layout.addWidget(material_view_checkbox)

        layout.addLayout(material_view_layout)

    def update_material_box(self, model_faces, freq):
        """
        Updates the surface dropdown for the current model.
        """
        new_surface_dropdown = self.create_surface_dropdown(model_faces)
        self.material_changer_layout.replaceWidget(
            self.surface_dropdown, new_surface_dropdown
        )
        self.surface_dropdown.close()
        self.surface_dropdown = new_surface_dropdown

        # Update model based on current status of material view option
        self.update_view.emit(self.material_view)

    def update_freq(self, freq):
        """
        Updates the sabine table based on the current frequency.
        """
        new_sabine_table = self.create_sabine_table(freq)
        self.layout().replaceWidget(self.sabine_table, new_sabine_table)
        self.sabine_table.close()
        self.sabine_table = new_sabine_table

    @pyqtSlot()
    def set_material(self, face, mtl):
        """
        Changes the material of the specified face.
        """
        if face is None:
            for face in self.model_faces:
                face.material = mtl
        else:
            face.material = mtl
        self.update_view.emit(self.material_view)

    @pyqtSlot(int)
    def change_material_view(self, state):
        """
        Toggles the status of the material view option.
        """
        status = state == Qt.Checked
        self.material_view = status
        self.update_view.emit(status)
コード例 #59
0
    def createpreferencesPanel(self):
        self.labelV2raycoreVersion = QLabel(
            self.translate("bridgepreferencesPanel",
                           "v2ray core version is: "))
        self.labelv2raycorecurrentVersion = QLabel()
        self.labelV2raycoreFilePath = QLabel(
            self.translate("bridgepreferencesPanel", "v2ray core File Path: "))
        self.lineEditFilePath = QLineEdit()
        self.buttonOpenV2raycoreFile = QPushButton(
            self.translate("bridgepreferencesPanel", "Open"))

        self.buttonpreferenceApply = QPushButton(
            self.translate("bridgepreferencesPanel", "Apply and Close"))
        self.buttonpreferenceCancel = QPushButton(
            self.translate("bridgepreferencesPanel", "Cancel"))
        hboxbutton = QHBoxLayout()
        hboxbutton.addStretch()
        hboxbutton.addWidget(self.buttonpreferenceApply)
        hboxbutton.addWidget(self.buttonpreferenceCancel)

        gridBox = QGridLayout()
        gridBox.addWidget(self.labelV2raycoreVersion, 0, 0, 1, 1)
        gridBox.addWidget(self.labelv2raycorecurrentVersion, 0, 1, 1, 1)
        gridBox.addWidget(self.labelV2raycoreFilePath, 1, 0, 1, 1)
        gridBox.addWidget(self.lineEditFilePath, 2, 0, 1, 5)
        gridBox.addWidget(self.buttonOpenV2raycoreFile, 2, 5, 1, 1)

        self.grouBoxConnection = QGroupBox(
            self.translate("bridgepreferencesPanel",
                           "Configure Connection settings."), self)
        self.grouBoxConnection.setCheckable(True)
        self.grouBoxConnection.setChecked(False)

        self.radioButtonSwitch = QRadioButton(
            self.translate("bridgepreferencesPanel",
                           "Switch to the next server"))
        self.radioButtonSwitch.setChecked(True)
        self.radioButtonReconnect = QRadioButton(
            self.translate("bridgepreferencesPanel", "Reconnect the server"))
        hboxRadioButton = QHBoxLayout()
        hboxRadioButton.addWidget(self.radioButtonSwitch)
        hboxRadioButton.addWidget(self.radioButtonReconnect)
        hboxRadioButton.addStretch()

        labelInterval = QLabel(
            self.translate("bridgepreferencesPanel", "Check the Interval: "))
        self.spinBoxInterval = QSpinBox()
        self.spinBoxInterval.setRange(60, 360)
        self.spinBoxInterval.setValue(60)
        labelMinandMaxInterval = QLabel(
            self.translate("bridgepreferencesPanel",
                           "Interval time value is 60 to 360"))

        labelCheckProxyTimeout = QLabel(
            self.translate("bridgepreferencesPanel", "Check Proxy Timeout: "))
        self.spinBoxCheckProxyTimeout = QSpinBox()
        self.spinBoxCheckProxyTimeout.setRange(0, 15)
        self.spinBoxCheckProxyTimeout.setValue(3)
        labelCheckProxyTimeoutWarning = QLabel(
            self.translate("bridgepreferencesPanel",
                           "Set 0 to disable timeout."))

        labeltrytimes = QLabel(
            self.translate("bridgepreferencesPanel", "Try Times: "))
        self.spinboxTrytimes = QSpinBox()
        self.spinboxTrytimes.setRange(0, 12)
        self.spinboxTrytimes.setValue(3)
        labelMaxtrytimes = QLabel(
            self.translate(
                "bridgepreferencesPanel",
                "0 means immediately connect, \nthe maximum value of try times is 12"
            ))

        gridBoxConnection = QGridLayout()
        gridBoxConnection.addWidget(labelInterval, 0, 0, Qt.AlignLeft)
        gridBoxConnection.addWidget(self.spinBoxInterval, 0, 1, Qt.AlignLeft)
        gridBoxConnection.addWidget(labelMinandMaxInterval, 0, 2, Qt.AlignLeft)
        gridBoxConnection.addWidget(labelCheckProxyTimeout, 1, 0, Qt.AlignLeft)
        gridBoxConnection.addWidget(self.spinBoxCheckProxyTimeout, 1, 1,
                                    Qt.AlignLeft)
        gridBoxConnection.addWidget(labelCheckProxyTimeoutWarning, 1, 2,
                                    Qt.AlignLeft)
        gridBoxConnection.addWidget(labeltrytimes, 2, 0, Qt.AlignLeft)
        gridBoxConnection.addWidget(self.spinboxTrytimes, 2, 1, Qt.AlignLeft)
        gridBoxConnection.addWidget(labelMaxtrytimes, 2, 2, Qt.AlignLeft)

        hboxConnection = QHBoxLayout()
        hboxConnection.addLayout(gridBoxConnection)
        hboxConnection.addStretch()

        vboxConnection = QVBoxLayout()
        vboxConnection.addLayout(hboxRadioButton)
        vboxConnection.addLayout(hboxConnection)

        self.grouBoxConnection.setLayout(vboxConnection)

        labelLanguageSetting = QLabel(
            self.translate("bridgepreferencesPanel", "Language: "))
        self.comboBoxLanguage = QComboBox()
        hboxLanguage = QHBoxLayout()
        hboxLanguage.addWidget(labelLanguageSetting)
        hboxLanguage.addWidget(self.comboBoxLanguage)
        hboxLanguage.addStretch()

        self.comboxStarup = QCheckBox(
            self.translate("bridgepreferencesPanel",
                           "Starting Script Automatically on System Boot"))
        self.comboxStarup.setChecked(False)

        vboxpreferences = QVBoxLayout()
        vboxpreferences.addLayout(gridBox)
        vboxpreferences.addWidget(self.grouBoxConnection)
        vboxpreferences.addLayout(hboxLanguage)
        vboxpreferences.addWidget(self.comboxStarup)
        vboxpreferences.addStretch()
        vboxpreferences.addLayout(hboxbutton)

        self.setLayout(vboxpreferences)
        self.setWindowTitle(
            self.translate("bridgepreferencesPanel", "Preferences"))
        self.resize(QSize(680, 320))

        self.createpreferencePanelSignals()

        self.settingv2rayshellpreferencesPanel()

        if v2rayshellDebug:
            self.starupTest = startUp()
            hbox = QHBoxLayout()
            self.__testBtn = QPushButton("__testBtn")
            hbox.addWidget(self.__testBtn)
            vboxpreferences.addLayout(hbox)
            self.__testBtn.clicked.connect(
                lambda: self.starupTest.setStartUp(True))
コード例 #60
0
ファイル: readme.py プロジェクト: simondreutter/cruisetools
 def __init__(self,readme_text):
     '''Initialize ReadmeWindow'''
     super().__init__()
     # icon path
     self.icon_path = ':/plugins/cruisetools/icons'
     
     # set window size
     self.resize(600, 570)
     
     # set window icon
     icon = QIcon(f'{self.icon_path}/icon.png')
     self.setWindowIcon(icon)
     
     # set windows title
     self.setWindowTitle('Readme')
     
     # create layout
     layout = QGridLayout()
     
     # create title, big font, centered
     title = QLabel()
     title.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
     title_font = QFont('Default', 14, QFont.Bold)
     title.setFont(title_font)
     
     # add title to layout
     layout.addWidget(title, 0, 0)
     
     # create version text, centered under title
     version = QLabel()
     version.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
     version_font = QFont('Default', 10)
     version.setFont(version_font)
     
     # add version to layout
     layout.addWidget(version, 1, 0)
     
     # create toolbox
     toolbox = QToolBox()
     
     # toolbox styleSheet
     toolbox_style = '''
                         QToolBox::tab {
                             border: 1px solid #C4C4C3;
                             font-size: 9pt;
                         }
                         QToolBox::tab:selected {
                             background-color: RGB(200, 0, 200);
                         }
                     '''
     
     # set toolbox style
     toolbox.setStyleSheet(toolbox_style)
     
     # add toolbox to layout
     layout.addWidget(toolbox, 2, 0)
     
     # splot readme text in text blocks
     blocks = readme_text.split('\n## ')
     
     # handle title and version block
     for line in blocks[0].splitlines():
         line = line.strip()
         if line.startswith('# '):
             title_text = line.replace("# ","")
         elif line.startswith('*v'):
             version_text = line.replace("*","")
     
     # set version and title text
     title.setText(title_text)
     version.setText(version_text)
     
     # create toolbox content from text blocks
     idx = 0
     for block in blocks[1:]:
         # get block title and content
         block_title,md = block.split('\n',1)
         
         # convert markdown to html (cheap way) << setMarkdown in PyQt 5.15
         html = self.markdown(md)
         
         # create text field
         text = QTextEdit()
         
         # mak text field read only
         text.setReadOnly(True)
         
         # add content
         text.setHtml(html)
         
         # add text to toolbox
         toolbox.addItem(text, block_title)
         
         # get block icon
         icon = self.get_icon(block_title)
         
         # set block icon
         toolbox.setItemIcon(idx,icon)
         
         idx = idx + 1
     
     # set window layout
     self.setLayout(layout)