Ejemplo n.º 1
0
    def addControls(self):
        wid = QWidget(self)
        self.setCentralWidget(wid)
        # Status
        self.status = QLabel()
        self.status.setAlignment(QtCore.Qt.AlignCenter)
        self.status.setStyleSheet('color: #1DB954')
        self.status.setText('Xin chào')
        # List
        self.result_label = QLabel()
        self.result_label.setAlignment(QtCore.Qt.AlignCenter)
        self.result_label.setStyleSheet('color: #1DB954')
        self.result_label.setText('Danh sách phát')
        # Search
        self.searchInput = QLineEdit()
        self.searchInput.setFixedHeight(25)
        #self.searchInput.setText("ok binz")
        self.searchBtn = QPushButton('Tìm kiếm')
        self.searchBtn.setFixedHeight(40)
        self.searchBtn.clicked.connect(self.Search)

        self.voicesearchBtn = QPushButton('Tìm bằng giọng nói')
        self.voicesearchBtn.setFixedHeight(40)
        self.voicesearchBtn.clicked.connect(self.VoiceSearch)

        self.listAudio = QListWidget()
        self.listAudio.setFixedHeight(120)

        self.current_vol = 50
        self.mediaplayer.audio_set_volume(self.current_vol)

        self.voldown = QPushButton('-')
        self.volup = QPushButton('+')
        self.volup.setFixedHeight(50)
        self.volup.setFixedWidth(50)
        self.voldown.setFixedHeight(50)
        self.voldown.setFixedWidth(50)

        self.playbutton = QPushButton('Phát/Tạm dừng')  # play button
        self.playbutton.setFixedHeight(50)
        self.stopbutton = QPushButton('Dừng')  # Stop button
        self.stopbutton.setFixedHeight(50)
        self.nextbutton = QPushButton('Tiếp theo')  # Next button
        self.nextbutton.setFixedHeight(50)
        self.nextbutton2 = QPushButton('Tiếp theo')  # Next button
        self.nextbutton2.setFixedHeight(50)
        self.command = QPushButton('Ra lệnh bằng giọng nói')  # Next button
        self.command.setFixedHeight(50)

        self.shortcut = QShortcut(QKeySequence("Space"), self)
        self.shortcut.activated.connect(self.excCommand)

        self.exit = QPushButton('Thoát')  # Next button
        self.exit.setFixedHeight(40)
        # Add button layouts
        mainLayout = QVBoxLayout()

        controls = QHBoxLayout()
        controls.addWidget(self.voldown)
        controls.addWidget(self.playbutton)
        controls.addWidget(self.nextbutton2)
        controls.addWidget(self.stopbutton)
        controls.addWidget(self.volup)

        #volgroup = QHBoxLayout()

        # Add to vertical layout
        mainLayout.addWidget(self.status)
        mainLayout.addWidget(self.searchInput)
        mainLayout.addWidget(self.result_label)
        mainLayout.addWidget(self.listAudio)
        mainLayout.addWidget(self.searchBtn)
        mainLayout.addWidget(self.voicesearchBtn)
        print(controls)
        #print(volgroup)
        mainLayout.addLayout(controls)
        mainLayout.addWidget(self.command)
        mainLayout.addWidget(self.exit)
        wid.setLayout(mainLayout)
        # Connect each signal to their appropriate function
        self.playbutton.clicked.connect(self.PlayPause)
        self.stopbutton.clicked.connect(self.Stop)
        #self.nextbutton.clicked.connect(self.Next)
        self.nextbutton2.clicked.connect(self.Next)
        self.volup.clicked.connect(self.volUp)
        self.voldown.clicked.connect(self.volDown)

        self.command.clicked.connect(self.excCommand)
        #self.volumeslider.valueChanged.connect(self.setVolume)
        # self.volumeslider.valueChanged.connect(self.volumeslabel.setNum)
        self.exit.clicked.connect(self.exitApp)
        self.statusBar()
Ejemplo n.º 2
0
    def setupUi(self, MainWindow):
        resolution = QDesktopWidget().screenGeometry(self)
        # MainWindow.setGeometry(QRect(0,0,0,0))
        MainWindow.setFixedSize(resolution.size().width() * 0.99,
                                resolution.size().height() * 0.90)  #1200 800
        # self.setWindowState(Qt.WindowMaximized)
        print("resol : ", MainWindow.size())

        #메인 화면 색상py
        self.setStyleSheet("color: black;" "background-color: white;")

        font = QFont()
        font.setFamily("NanumGothic")
        MainWindow.setFont(font)
        self.centralwidget = QWidget(MainWindow)
        self.label = QLabel(self.centralwidget)
        self.label.setGeometry(QRect(20, 20, 130, 35))
        font = QFont()
        font.setFamily("NanumGothic")
        font.setPointSize(18)
        font.setBold(True)
        font.setWeight(75)
        self.label.setFont(font)
        self.button_add = QPushButton(self.centralwidget)
        self.button_add.setGeometry(
            QRect(MainWindow.size().width() * 0.05,
                  MainWindow.size().height() - 80, 131, 34))
        #버튼 스타일 변경
        self.button_add.setStyleSheet(staticValues.blueButtonStyleSheet)
        self.button_add.setFont(staticValues.buttonFont)

        self.button_modi = QPushButton(self.centralwidget)
        self.button_modi.setGeometry(
            QRect(MainWindow.size().width() * 0.20,
                  MainWindow.size().height() - 80, 131, 34))
        self.button_modi.setStyleSheet(staticValues.blueButtonStyleSheet)
        self.button_modi.setFont(staticValues.buttonFont)

        self.button_del = QPushButton(self.centralwidget)
        self.button_del.setGeometry(
            QRect(MainWindow.size().width() * 0.35,
                  MainWindow.size().height() - 80, 131, 34))
        self.button_del.setStyleSheet(staticValues.redButtonStyleSheet)
        self.button_del.setFont(staticValues.buttonFont)

        self.button_upload = QPushButton(self.centralwidget)
        self.button_upload.setGeometry(
            QRect(MainWindow.size().width() * 0.7,
                  MainWindow.size().height() - 80, 131, 34))
        self.button_upload.setStyleSheet(staticValues.grayButtonStyleSheet)
        self.button_upload.setFont(staticValues.buttonFont)

        self.tabWidget = QTabWidget(self.centralwidget)
        self.tabWidget.setGeometry(
            QRect(10, 70,
                  MainWindow.size().width() - 15,
                  MainWindow.size().height() - 180))
        self.tab = QWidget()
        self.tab.layout = QVBoxLayout()
        self.tabWidget.addTab(self.tab, "회원 목록")
        self.tableWidget = QTableWidget(self.tab)
        self.tableWidget.setGeometry(
            QRect(0, 0,
                  self.tabWidget.size().width() - 5,
                  self.tabWidget.size().height() - 25))
        self.tableWidget.setColumnCount(13)
        self.tableWidget.setRowCount(0)
        self.tableWidget.setSelectionBehavior(QAbstractItemView.SelectRows)

        self.tableWidget.setHorizontalHeaderLabels([
            "회원 ID", "단톡방", "코인명", "구매", "입금", "판매", "출근", "보유잔량", "총구매금액",
            "총판매금액", "수익", "평단가", "지갑주소"
        ])

        self.tab2 = QWidget()
        self.tab2.layout = QVBoxLayout()
        self.tabWidget.addTab(self.tab, "회원 목록")
        self.tableWidget2 = QTableWidget(self.tab2)
        self.tableWidget2.setGeometry(
            QRect(0, 0,
                  self.tabWidget.size().width() - 5,
                  self.tabWidget.size().height() - 25))
        self.tableWidget2.setColumnCount(3)
        self.tableWidget2.setRowCount(0)
        self.tableWidget2.setSelectionBehavior(QAbstractItemView.SelectRows)

        self.tableWidget.setHorizontalHeaderLabels(
            ["회원 ID", "현재 단톡방", "중복 단톡방"])

        self.edit_search = QLineEdit(self.centralwidget)
        self.edit_search.setGeometry(
            QRect(MainWindow.size().width() - 280, 35, 200, 30))
        self.edit_search.setStyleSheet(staticValues.solidStyleSheet)

        self.button_search = QPushButton(self.centralwidget)
        self.button_search.setGeometry(
            QRect(MainWindow.size().width() - 80, 35, 70, 30))
        self.button_search.setStyleSheet(staticValues.grayButtonStyleSheet)
        self.button_search.setFont(staticValues.buttonFont)

        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)
        self.tabWidget.setCurrentIndex(0)
        QMetaObject.connectSlotsByName(MainWindow)
Ejemplo n.º 3
0
    def __init__(self, prev, parent=None):
        QMainWindow.__init__(self, parent)
        self.setWindowTitle("规则录制界面")
        self.prev = prev

        self.split = QSplitter(self)
        self.split.setOrientation(Qt.Vertical)
        self.split.setContentsMargins(0, 10, 10, 0)

        self.label = QLabel(self.split)
        self.label.setText("请填写任务基本信息")
        self.label.setStyleSheet("font:bold;color:#8A2BE2")
        self.label.setContentsMargins(10, 10, 10, 10)

        self.basic_widget = QWidget(self.split)
        self.basic_widget_layout = QGridLayout()
        self.basic_widget.setLayout(self.basic_widget_layout)
        self.basic_widget_layout.setAlignment(Qt.AlignTop)
        self.basic_widget.setStyleSheet("background:white")

        label_style = r'QLabel{font:bold}'
        edit_style = r'QLineEdit{border: 1px solid #D1D1D1;font-size: 20px;} ' \
                     r'QLineEdit:focus{border: 1px solid #87CEEB;color: #87CEEB;}'
        box_style = r'QComboBox{border: 1px solid #D1D1D1;font-size: 20px;}' \
                    r'QComboBox QAbstractItemView{ border: 1px solid #87CEEB;selection-background-color: #87CEEB;}'
        site_name_label = QLabel(self.basic_widget)
        site_name_label.setText("任务名称     ")
        site_name_label.setStyleSheet(label_style)
        self.site_name_edit = QLineEdit(self.basic_widget)
        self.site_name_edit.setFixedSize(700, 40)
        self.site_name_edit.setStyleSheet(edit_style)
        self.site_name_edit.setFocus(True)
        self.site_name_edit.setText("百度")
        site_url_label = QLabel(self.basic_widget)
        site_url_label.setText("采集网址      ")
        site_url_label.setStyleSheet(label_style)
        self.site_url_edit = QLineEdit(self.basic_widget)
        self.site_url_edit.setFixedSize(700, 40)
        self.site_url_edit.setStyleSheet(edit_style)
        self.site_url_edit.setText(
            "http://www.ccgp-neimenggu.gov.cn/category/cggg?type_name=1")
        task_theme_label = QLabel(self.basic_widget)
        task_theme_label.setText("所属主题      ")
        task_theme_label.setStyleSheet(label_style)
        self.task_theme_box = QComboBox(self.basic_widget)
        self.task_theme_box.setFixedSize(700, 40)
        self.task_theme_box.setStyleSheet(box_style)
        self.task_theme_box.currentIndexChanged.connect(self.category_by_theme)
        task_category_label = QLabel(self.basic_widget)
        task_category_label.setText("所属类别      ")
        task_category_label.setStyleSheet(label_style)
        self.task_category_box = QComboBox(self.basic_widget)
        self.task_category_box.setFixedSize(700, 40)
        self.task_category_box.setStyleSheet(box_style)

        self.basic_widget_layout.addWidget(site_name_label, 0, 0, 1, 1,
                                           Qt.AlignLeft)
        self.basic_widget_layout.addWidget(self.site_name_edit, 0, 1, 1, 1,
                                           Qt.AlignLeft)
        self.basic_widget_layout.addWidget(site_url_label, 1, 0, 1, 1,
                                           Qt.AlignLeft)
        self.basic_widget_layout.addWidget(self.site_url_edit, 1, 1, 1, 1,
                                           Qt.AlignLeft)
        self.basic_widget_layout.addWidget(task_theme_label, 2, 0, 1, 1,
                                           Qt.AlignLeft)
        self.basic_widget_layout.addWidget(self.task_theme_box, 2, 1, 1, 1,
                                           Qt.AlignLeft)
        self.basic_widget_layout.addWidget(task_category_label, 3, 0, 1, 1,
                                           Qt.AlignLeft)
        self.basic_widget_layout.addWidget(self.task_category_box, 3, 1, 1, 1,
                                           Qt.AlignLeft)
        self.basic_widget_layout.setColumnStretch(0, 1)
        self.basic_widget_layout.setColumnStretch(1, 100)

        self.split.addWidget(self.label)
        self.split.addWidget(self.basic_widget)
        self.split.setStretchFactor(0, 1)
        self.split.setStretchFactor(1, 30)
        self.setCentralWidget(self.split)

        BasicProcess(self).load_data(self.prev.task_id)
Ejemplo n.º 4
0
    def createUi(self):
        self.content = Expander("Content", ":/images/parts.svg")
        self.images = Expander("Images", ":/images/images.svg")
        self.settings = Expander("Settings", ":/images/settings.svg")

        self.setWindowTitle(QCoreApplication.applicationName() + " " +
                            QCoreApplication.applicationVersion())
        vbox = QVBoxLayout()
        vbox.addWidget(self.content)
        vbox.addWidget(self.images)
        vbox.addWidget(self.settings)
        vbox.addStretch()

        self.content_list = QListWidget()
        self.content_list.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed)
        content_box = QVBoxLayout()
        content_box.addWidget(self.content_list)
        self.item_edit = QLineEdit()
        self.item_edit.setMaximumHeight(0)
        self.item_edit.editingFinished.connect(self.editItemFinished)
        self.item_anim = QPropertyAnimation(self.item_edit,
                                            "maximumHeight".encode("utf-8"))
        content_box.addWidget(self.item_edit)
        button_layout = QHBoxLayout()
        plus_button = FlatButton(":/images/plus.svg")
        self.edit_button = FlatButton(":/images/edit.svg")
        self.trash_button = FlatButton(":/images/trash.svg")
        self.up_button = FlatButton(":/images/up.svg")
        self.down_button = FlatButton(":/images/down.svg")
        self.trash_button.enabled = False
        self.up_button.enabled = False
        self.down_button.enabled = False
        button_layout.addWidget(plus_button)
        button_layout.addWidget(self.up_button)
        button_layout.addWidget(self.down_button)
        button_layout.addWidget(self.edit_button)
        button_layout.addWidget(self.trash_button)
        content_box.addLayout(button_layout)
        self.content.addLayout(content_box)
        plus_button.clicked.connect(self.addPart)
        self.trash_button.clicked.connect(self.dropPart)
        self.up_button.clicked.connect(self.partUp)
        self.down_button.clicked.connect(self.partDown)
        self.edit_button.clicked.connect(self.editPart)

        self.image_list = QListWidget()
        self.image_list.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed)
        image_box = QVBoxLayout()
        image_box.addWidget(self.image_list)
        image_button_layout = QHBoxLayout()
        image_plus_button = FlatButton(":/images/plus.svg")
        self.image_trash_button = FlatButton(":/images/trash.svg")
        self.image_trash_button.enabled = False
        image_button_layout.addWidget(image_plus_button)
        image_button_layout.addWidget(self.image_trash_button)
        image_box.addLayout(image_button_layout)
        self.images.addLayout(image_box)
        image_plus_button.clicked.connect(self.addImage)
        self.image_trash_button.clicked.connect(self.dropImage)

        scroll_content = QWidget()
        scroll_content.setLayout(vbox)
        scroll = QScrollArea()
        scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        scroll.setWidget(scroll_content)
        scroll.setWidgetResizable(True)
        scroll.setMaximumWidth(200)
        scroll.setMinimumWidth(200)

        self.navigationdock = QDockWidget("Navigation", self)
        self.navigationdock.setAllowedAreas(Qt.LeftDockWidgetArea
                                            | Qt.RightDockWidgetArea)
        self.navigationdock.setWidget(scroll)
        self.navigationdock.setObjectName("Navigation")
        self.addDockWidget(Qt.LeftDockWidgetArea, self.navigationdock)

        self.splitter = QSplitter()
        self.text_edit = MarkdownEdit()
        self.text_edit.setFont(QFont("Courier", 11))
        self.preview = QWebEngineView()
        self.preview.setMinimumWidth(300)
        self.setWindowTitle(QCoreApplication.applicationName())

        self.splitter.addWidget(self.text_edit)
        self.splitter.addWidget(self.preview)
        self.setCentralWidget(self.splitter)

        self.content.expanded.connect(self.contentExpanded)
        self.images.expanded.connect(self.imagesExpanded)
        self.settings.expanded.connect(self.settingsExpanded)
        self.settings.clicked.connect(self.openSettings)
        self.content_list.currentItemChanged.connect(self.partSelectionChanged)
        self.image_list.currentItemChanged.connect(self.imageSelectionChanged)
        self.image_list.itemDoubleClicked.connect(self.insertImage)

        self.text_edit.undoAvailable.connect(self.undoAvailable)
        self.text_edit.redoAvailable.connect(self.redoAvailable)
        self.text_edit.copyAvailable.connect(self.copyAvailable)

        QApplication.clipboard().dataChanged.connect(self.clipboardDataChanged)
Ejemplo n.º 5
0
    def create_wallet_mn_tab(self):
        w = QWidget()
        hw = QWidget()

        self.w_label = QLabel(self.wallet_label())
        self.w_add_btn = QPushButton(_('Add / Import'))
        self.w_file_btn = QPushButton(_('File'))
        self.w_del_btn = QPushButton(_('Remove'))
        self.w_up_params_btn = QPushButton(_('Update Params'))
        self.w_up_coll_btn = QPushButton(_('Change Collateral'))
        self.w_protx_btn = QPushButton(_('Register'))
        self.w_up_srv_btn = QPushButton(_('Update Service'))
        self.w_up_reg_btn = QPushButton(_('Update Registrar'))
        self.w_add_btn.clicked.connect(self.on_add_masternode)
        self.w_file_btn.clicked.connect(self.on_file)
        self.w_del_btn.clicked.connect(self.on_del_masternode)
        self.w_up_params_btn.clicked.connect(self.on_update_params)
        self.w_up_coll_btn.clicked.connect(self.on_update_collateral)
        self.w_protx_btn.clicked.connect(self.on_make_pro_reg_tx)
        self.w_up_srv_btn.clicked.connect(self.on_make_pro_up_srv_tx)
        self.w_up_reg_btn.clicked.connect(self.on_make_pro_up_reg_tx)

        self.w_view = QTableView()
        self.w_view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.w_view.customContextMenuRequested.connect(self.create_wallet_menu)
        self.w_hheader = QHeaderView(Qt.Horizontal, self.w_view)
        self.w_hheader.setSectionResizeMode(QHeaderView.ResizeToContents)
        self.w_hheader.setStretchLastSection(True)

        self.w_view.setHorizontalHeader(self.w_hheader)
        self.w_view.verticalHeader().hide()
        self.w_view.setSelectionMode(QAbstractItemView.SingleSelection)
        self.w_view.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.w_view.doubleClicked.connect(self.w_mn_dbl_clicked)

        row_h = self.w_view.verticalHeader().defaultSectionSize()
        self.w_hheader.setMinimumSectionSize(row_h)
        src_model = WalletMNsModel(self.manager, self.mn_list, self.gui, row_h)
        src_model.dataChanged.connect(self.w_data_changed)
        self.w_model = Dip3FilterProxyModel()
        self.w_model.setSourceModel(src_model)
        self.w_view.setModel(self.w_model)

        sel_model = self.w_view.selectionModel()
        sel_model.selectionChanged.connect(self.on_wallet_selection_changed)
        self.w_model.modelReset.connect(self.on_wallet_model_reset)

        hbox = QHBoxLayout()
        vbox = QVBoxLayout()
        hbox.setContentsMargins(0, 0, 0, 0)
        hbox.addWidget(self.w_label)
        hbox.addStretch(1)
        hbox.addWidget(self.w_del_btn)
        hbox.addWidget(self.w_up_params_btn)
        hbox.addWidget(self.w_up_coll_btn)
        hbox.addWidget(self.w_protx_btn)
        hbox.addWidget(self.w_up_reg_btn)
        hbox.addWidget(self.w_up_srv_btn)
        hbox.addWidget(self.w_file_btn)
        hbox.addWidget(self.w_add_btn)
        hw.setLayout(hbox)
        vbox.addWidget(hw)
        vbox.addWidget(self.w_view)
        w.setLayout(vbox)
        self.addTab(w, read_QIcon('tab_dip3.png'), _('Wallet MNs'))
        if not self.mn_list.protx_loading:
            self.w_model.reload_data()
        return w
Ejemplo n.º 6
0
    def __init__(self, parent=None):
        super(VideoWindow, self).__init__(parent)
        self.setWindowTitle("PyQt5 VideoPlayer") 

        self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface)

        videoWidget = QVideoWidget()

        self.playButton = QPushButton()
        self.playButton.setEnabled(False)
        self.playButton.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay))
        self.playButton.clicked.connect(self.play)

        self.positionSlider = QSlider(Qt.Horizontal)
        self.positionSlider.setRange(0, 0)
        self.positionSlider.sliderMoved.connect(self.setPosition)

        self.errorLabel = QLabel()
        self.errorLabel.setSizePolicy(QSizePolicy.Preferred,
                QSizePolicy.Maximum)

        # Create new action
        openAction = QAction(QIcon('open.png'), '&Open', self)        
        openAction.setShortcut('Ctrl+O')
        openAction.setStatusTip('Open movie')
        openAction.triggered.connect(self.openFile)

        # Create exit action
        exitAction = QAction(QIcon('exit.png'), '&Exit', self)        
        exitAction.setShortcut('Ctrl+Q')
        exitAction.setStatusTip('Exit application')
        exitAction.triggered.connect(self.exitCall)

        # Create menu bar and add action
        menuBar = self.menuBar()
        fileMenu = menuBar.addMenu('&File')
        #fileMenu.addAction(newAction)
        fileMenu.addAction(openAction)
        fileMenu.addAction(exitAction)

        # Create a widget for window contents
        wid = QWidget(self)
        self.setCentralWidget(wid)

        # Create layouts to place inside widget
        controlLayout = QHBoxLayout()
        controlLayout.setContentsMargins(0, 0, 0, 0)
        controlLayout.addWidget(self.playButton)
        controlLayout.addWidget(self.positionSlider)

        layout = QVBoxLayout()
        layout.addWidget(videoWidget)
        layout.addLayout(controlLayout)
        layout.addWidget(self.errorLabel)

        # Set widget to contain window contents
        wid.setLayout(layout)

        self.mediaPlayer.setVideoOutput(videoWidget)
        self.mediaPlayer.stateChanged.connect(self.mediaStateChanged)
        self.mediaPlayer.positionChanged.connect(self.positionChanged)
        self.mediaPlayer.durationChanged.connect(self.durationChanged)
        self.mediaPlayer.error.connect(self.handleError)
Ejemplo n.º 7
0
    def __init__(self, parent, title, reportSerializer, reportItem):
        super(EditReportWidget, self).__init__(parent)

        self.m_reportSerializer = reportSerializer
        self.m_reportItem = reportItem

        self.setWindowTitle(title)

        self.resize(859, 704)
        self.m_mainLayout = QVBoxLayout(self)
        self.m_scriptEdit = QPlainTextEdit(self)
        self.m_mainLayout.addWidget(self.m_scriptEdit)
        self.m_line1 = QFrame(self)
        self.m_line1.setFrameShape(QFrame.HLine)
        self.m_line1.setFrameShadow(QFrame.Sunken)
        self.m_mainLayout.addWidget(self.m_line1)
        self.m_attriburesWidget = QWidget(self)
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.m_attriburesWidget.sizePolicy().hasHeightForWidth())
        self.m_attriburesWidget.setSizePolicy(sizePolicy)
        self.m_attriburesWidget.setMinimumSize(QSize(0, 100))
        self.verticalLayout = QVBoxLayout(self.m_attriburesWidget)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.m_attributesLayout = QGridLayout()
        self.m_attributesLayout.setSizeConstraint(QLayout.SetDefaultConstraint)
        self.m_descrPTEdit = QPlainTextEdit(self.m_attriburesWidget)
        self.m_descrPTEdit.setMaximumSize(QSize(16777215, 90))
        self.m_attributesLayout.addWidget(self.m_descrPTEdit, 1, 1, 1, 1)
        self.m_descriptionLabel = QLabel(self.m_attriburesWidget)
        self.m_descriptionLabel.setAlignment(Qt.AlignLeading | Qt.AlignLeft
                                             | Qt.AlignTop)
        self.m_attributesLayout.addWidget(self.m_descriptionLabel, 1, 0, 1, 1)
        self.m_typeLabel = QLabel(self.m_attriburesWidget)
        self.m_attributesLayout.addWidget(self.m_typeLabel, 2, 0, 1, 1)
        self.m_nameLabel = QLabel(self.m_attriburesWidget)
        self.m_attributesLayout.addWidget(self.m_nameLabel, 0, 0, 1, 1)
        self.m_nameEdit = QLineEdit(self.m_attriburesWidget)
        self.m_attributesLayout.addWidget(self.m_nameEdit, 0, 1, 1, 1)
        self.m_typeLayout = QHBoxLayout()
        self.m_typeComboBox = QComboBox(self.m_attriburesWidget)
        self.m_typeComboBox.addItem("")
        self.m_typeComboBox.addItem("")
        self.m_typeLayout.addWidget(self.m_typeComboBox)
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        self.m_typeLayout.addItem(spacerItem)
        self.m_attributesLayout.addLayout(self.m_typeLayout, 2, 1, 1, 1)
        self.verticalLayout.addLayout(self.m_attributesLayout)
        self.m_saveLayout = QHBoxLayout()
        self.m_saveLayout.setSpacing(0)
        self.m_storeInFileCheckBox = QCheckBox(self.m_attriburesWidget)
        self.m_saveLayout.addWidget(self.m_storeInFileCheckBox)
        self.m_browseLayout = QHBoxLayout()
        self.m_browseLayout.setSpacing(0)
        self.m_filePathEdit = QLineEdit(self.m_attriburesWidget)
        self.m_browseLayout.addWidget(self.m_filePathEdit)
        self.m_filePathBrowseBtn = QPushButton(self.m_attriburesWidget)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.m_filePathBrowseBtn.sizePolicy().hasHeightForWidth())
        self.m_filePathBrowseBtn.setSizePolicy(sizePolicy)
        self.m_filePathBrowseBtn.setMaximumSize(QSize(25, 16777215))
        self.m_browseLayout.addWidget(self.m_filePathBrowseBtn)
        self.m_saveLayout.addLayout(self.m_browseLayout)
        self.verticalLayout.addLayout(self.m_saveLayout)
        self.m_mainLayout.addWidget(self.m_attriburesWidget)
        self.m_line2 = QFrame(self)
        self.m_line2.setFrameShape(QFrame.HLine)
        self.m_line2.setFrameShadow(QFrame.Sunken)
        self.m_mainLayout.addWidget(self.m_line2)
        self.m_buttonsLayout = QHBoxLayout()
        spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                  QSizePolicy.Minimum)
        self.m_buttonsLayout.addItem(spacerItem1)
        self.m_saveBtn = QPushButton(self)
        self.m_buttonsLayout.addWidget(self.m_saveBtn)
        self.m_saveAndCloseBtn = QPushButton(self)
        self.m_buttonsLayout.addWidget(self.m_saveAndCloseBtn)
        self.m_cancelBtn = QPushButton(self)
        self.m_buttonsLayout.addWidget(self.m_cancelBtn)
        self.m_mainLayout.addLayout(self.m_buttonsLayout)

        self.m_descriptionLabel.setText("Description:")
        self.m_typeLabel.setText("Type:")
        self.m_nameLabel.setText("Name:")
        self.m_typeComboBox.setItemText(0, "SQL")
        self.m_typeComboBox.setItemText(1, "Python")
        self.m_storeInFileCheckBox.setText("Store In File")
        self.m_filePathBrowseBtn.setText("...")
        self.m_saveBtn.setText("Save")
        self.m_saveAndCloseBtn.setText("Save And Close")
        self.m_cancelBtn.setText("Cancel")

        self.m_filePathBrowseBtn.pressed.connect(self.browse)
        self.m_storeInFileCheckBox.toggled.connect(self.storeCheckboxToggled)

        self.storeCheckboxToggled()

        self.m_saveBtn.pressed.connect(self.save)
        self.m_saveAndCloseBtn.pressed.connect(self.saveAndAccept)
        self.m_cancelBtn.pressed.connect(self.close)

        if self.m_reportItem is not None:
            self.m_nameEdit.setText(self.m_reportItem.name)
            self.m_descrPTEdit.setPlainText(self.m_reportItem.description)
            self.m_typeComboBox.setCurrentText(self.m_reportItem.type)
            self.m_filePathEdit.setText(self.m_reportItem.scriptPath)
            self.m_storeInFileCheckBox.setChecked(
                self.m_reportItem.storeInFile)
            self.m_scriptEdit.setPlainText(
                self.m_reportSerializer.load(self.m_reportItem))
Ejemplo n.º 8
0
    def __init__(self, parent=None, **kw):
        # the current button
        self._ActiveButton = Qt.NoButton

        # private attributes
        self.__saveX = 0
        self.__saveY = 0
        self.__saveModifiers = Qt.NoModifier
        self.__saveButtons = Qt.NoButton
        self.__wheelDelta = 0

        # do special handling of some keywords:
        # stereo, rw

        try:
            stereo = bool(kw['stereo'])
        except KeyError:
            stereo = False

        try:
            rw = kw['rw']
        except KeyError:
            rw = None

        # create base qt-level widget
        if QVTKRWIBase == "QWidget":
            if "wflags" in kw:
                wflags = kw['wflags']
            else:
                wflags = Qt.WindowFlags()
            QWidget.__init__(self, parent, wflags | Qt.MSWindowsOwnDC)
        elif QVTKRWIBase == "QGLWidget":
            QGLWidget.__init__(self, parent)

        if rw:  # user-supplied render window
            self._RenderWindow = rw
        else:
            self._RenderWindow = vtkRenderWindow()

        WId = self.winId()

        # Python2
        if type(WId).__name__ == 'PyCObject':
            from ctypes import pythonapi, c_void_p, py_object

            pythonapi.PyCObject_AsVoidPtr.restype = c_void_p
            pythonapi.PyCObject_AsVoidPtr.argtypes = [py_object]

            WId = pythonapi.PyCObject_AsVoidPtr(WId)

        # Python3
        elif type(WId).__name__ == 'PyCapsule':
            from ctypes import pythonapi, c_void_p, py_object, c_char_p

            pythonapi.PyCapsule_GetName.restype = c_char_p
            pythonapi.PyCapsule_GetName.argtypes = [py_object]

            name = pythonapi.PyCapsule_GetName(WId)

            pythonapi.PyCapsule_GetPointer.restype = c_void_p
            pythonapi.PyCapsule_GetPointer.argtypes = [py_object, c_char_p]

            WId = pythonapi.PyCapsule_GetPointer(WId, name)

        self._RenderWindow.SetWindowInfo(str(int(WId)))

        if stereo:  # stereo mode
            self._RenderWindow.StereoCapableWindowOn()
            self._RenderWindow.SetStereoTypeToCrystalEyes()

        try:
            self._Iren = kw['iren']
        except KeyError:
            self._Iren = vtkGenericRenderWindowInteractor()
            self._Iren.SetRenderWindow(self._RenderWindow)

        # do all the necessary qt setup
        self.setAttribute(Qt.WA_OpaquePaintEvent)
        self.setAttribute(Qt.WA_PaintOnScreen)
        self.setMouseTracking(True)  # get all mouse events
        self.setFocusPolicy(Qt.WheelFocus)
        self.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))

        self._Timer = QTimer(self)
        self._Timer.timeout.connect(self.TimerEvent)

        self._Iren.AddObserver('CreateTimerEvent', self.CreateTimer)
        self._Iren.AddObserver('DestroyTimerEvent', self.DestroyTimer)
        self._Iren.GetRenderWindow().AddObserver('CursorChangedEvent',
                                                 self.CursorChangedEvent)

        #Create a hidden child widget and connect its destroyed signal to its
        #parent ``Finalize`` slot. The hidden children will be destroyed before
        #its parent thus allowing cleanup of VTK elements.
        self._hidden = QWidget(self)
        self._hidden.hide()
        self._hidden.destroyed.connect(self.Finalize)
Ejemplo n.º 9
0
 def updateLayout(self, layout):
     self.tasks = dbutil.getTasks()
     self.layout = layout
     self.setCentralWidget(QWidget())
     self.centralWidget().setLayout(self.layout)
Ejemplo n.º 10
0
 def InitUserInterface(self):
     self.about_dialog = None
     self.is_user_exit = False
     self.is_main_window_visible = True
     self.is_tray_icon_loaded = False
     self.is_not_first_run = False
     self.current_main_tab_index = 0
     self.basic_data_maker = None
     
     self.setWindowTitle(define.APP_TITLE_EN + " " + define.APP_VERSION)
     self.resize(define.DEF_MAIN_WINDOW_W, define.DEF_MAIN_WINDOW_H)
     
     geometry = self.frameGeometry()
     center = QDesktopWidget().availableGeometry().center()
     geometry.moveCenter(center)
     self.move(geometry.topLeft())
     
     self.setCorner(Qt.TopLeftCorner, Qt.LeftDockWidgetArea) # 默认顶部收缩
     self.setCorner(Qt.TopRightCorner, Qt.RightDockWidgetArea) # 默认顶部收缩
     self.setCorner(Qt.BottomRightCorner, Qt.BottomDockWidgetArea) # 默认底部扩展
     self.setCorner(Qt.BottomLeftCorner, Qt.BottomDockWidgetArea) # 默认底部扩展
     self.setDockOptions(QMainWindow.AnimatedDocks | QMainWindow.AllowNestedDocks | QMainWindow.AllowTabbedDocks);
     #self.setTabPosition(Qt.TopDockWidgetArea, QTabWidget.North) # 使顶部的停靠窗口嵌套后标签页在上面
     
     self.CreateActions()
     self.CreateMenuBar()
     self.CreateToolBar()
     self.CreateStatusBar()
     self.CreateLogsDock()
     
     self.main_widget = QWidget()
     self.setCentralWidget(self.main_widget)
     
     self.main_tab_panel_1 = strategy_panel.StrategyPanel(self)
     self.main_tab_panel_2 = analysis_panel.AnalysisPanel(self)
     self.main_tab_panel_3 = riskctrl_panel.RiskctrlPanel(self)
     self.main_tab_widget = QTabWidget()
     self.main_tab_widget.setTabPosition(QTabWidget.North)
     self.main_tab_widget.addTab(self.main_tab_panel_1, define.DEF_TEXT_MAIN_TAB_NAME_1)
     self.main_tab_widget.addTab(self.main_tab_panel_2, define.DEF_TEXT_MAIN_TAB_NAME_2)
     self.main_tab_widget.addTab(self.main_tab_panel_3, define.DEF_TEXT_MAIN_TAB_NAME_3)
     self.main_tab_widget.setTabIcon(0, QIcon(define.DEF_ICON_MAIN_TAB_HIDE))
     self.main_tab_widget.setTabIcon(1, QIcon(define.DEF_ICON_MAIN_TAB_HIDE))
     self.main_tab_widget.setTabIcon(2, QIcon(define.DEF_ICON_MAIN_TAB_HIDE))
     self.main_tab_widget.setFont(QFont("SimSun", 9))
     self.main_tab_widget.setCurrentIndex(0)
     self.main_tab_widget.setTabIcon(0, QIcon(define.DEF_ICON_MAIN_TAB_SHOW))
     self.main_tab_widget.setMovable(True)
     self.main_tab_widget.setTabsClosable(False)
     self.main_tab_widget.setUsesScrollButtons(True)
     self.main_tab_widget.currentChanged.connect(self.OnClickMainTabBar)
     
     self.v_box = QVBoxLayout()
     self.v_box.setContentsMargins(5, 5, 5, 5)
     self.v_box.addWidget(self.main_tab_widget, 1)
     
     self.main_widget.setLayout(self.v_box)
     
     self.tip_info_dialog = tip_info_dialog.TipInfoDialog(self)
     
     self.action_show_tab_1.setChecked(True)
     self.action_show_tab_2.setChecked(True)
     self.action_show_tab_3.setChecked(True)
     self.action_show_skin_norm.setChecked(True) # True
     self.action_show_skin_dark.setChecked(False) # False
     self.action_save_layout.setChecked(False)
Ejemplo n.º 11
0
    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)
        self.answer_ = ''

        self.setWindowTitle("Simple Calculator")
        self.setGeometry(500, 250, 300, 300)

        wid = QWidget(self)
        self.setCentralWidget(wid)
        grid = QGridLayout()
        wid.setLayout(grid)

        """names = ['AC', '+/-', '%', '',
                 '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 == '':
                label = QLabel("Ans")
                grid.addWidget(label, *position)
            else:
                button = QPushButton(name)
                print(button.objectName())
                #button.clicked.connect(self.handleButton(name))
                button.clicked.connect(lambda x: self.my_custom_fn(name))
                grid.addWidget(button, *position)"""

        #button = QPushButton('+/-')
        #button.clicked.connect(lambda x: self.my_custom_fn('5'))
        #grid.addWidget(button, *(2,3))

        #button = QPushButton('%')
        #button.clicked.connect(lambda x: self.my_custom_fn('6'))
        #grid.addWidget(button, *(2,4))

        button = QPushButton('/')
        button.clicked.connect(lambda x: self.my_custom_fn('/'))
        grid.addWidget(button, *(1,5))

        button = QPushButton('7')
        button.clicked.connect(lambda x: self.my_custom_fn('7'))
        grid.addWidget(button, *(2,2))

        button = QPushButton('8')
        button.clicked.connect(lambda x: self.my_custom_fn('8'))
        grid.addWidget(button, *(2,3))

        button = QPushButton('9')
        button.clicked.connect(lambda x: self.my_custom_fn('9'))
        grid.addWidget(button, *(2,4))

        button = QPushButton('X')
        button.clicked.connect(lambda x: self.my_custom_fn('*'))
        grid.addWidget(button, *(2,5))

        button = QPushButton('4')
        button.clicked.connect(lambda x: self.my_custom_fn('4'))
        grid.addWidget(button, *(3,2))

        button = QPushButton('5')
        button.clicked.connect(lambda x: self.my_custom_fn('5'))
        grid.addWidget(button, *(3,3))

        button = QPushButton('6')
        button.clicked.connect(lambda x: self.my_custom_fn('6'))
        grid.addWidget(button, *(3,4))

        button = QPushButton('-')
        button.clicked.connect(lambda x: self.my_custom_fn('-'))
        grid.addWidget(button, *(3,5))

        button = QPushButton('1')
        button.clicked.connect(lambda x: self.my_custom_fn('1'))
        grid.addWidget(button, *(4,2))

        button = QPushButton('2')
        button.clicked.connect(lambda x: self.my_custom_fn('2'))
        grid.addWidget(button, *(4,3))

        button = QPushButton('3')
        button.clicked.connect(lambda x: self.my_custom_fn('3'))
        grid.addWidget(button, *(4,4))

        button = QPushButton('+')
        button.clicked.connect(lambda x: self.my_custom_fn('+'))
        grid.addWidget(button, *(4,5))

        button = QPushButton('0')
        button.clicked.connect(lambda x: self.my_custom_fn('0'))
        grid.addWidget(button, *(5,3))

        button = QPushButton('.')
        button.clicked.connect(lambda x: self.my_custom_fn('.'))
        grid.addWidget(button, *(5,4))

        label = QLabel("Ans")
        grid.addWidget(label, *(0,0))

        button = QPushButton('=')
        button.clicked.connect(lambda x: self.my_custom_equal(label))
        grid.addWidget(button, *(5,5))

        button = QPushButton('AC')
        button.clicked.connect(lambda x: self.my_custom_clear(label))
        grid.addWidget(button, *(1,2))
Ejemplo n.º 12
0
import sys
from PyQt5.QtWidgets import QHBoxLayout, QMainWindow, QApplication, QPushButton, QWidget


def onClick_Button():
    print("1")
    print("widget.x()=%d" % widget.x())
    print("widget.y()=%d" % widget.y())


app = QApplication(sys.argv)
widget = QWidget()
btn = QPushButton(widget)
btn.setText("按钮")
btn.clicked.connect(onClick_Button)
btn.move(24, 52)
widget.resize(300, 240)
widget.move(250, 200)
widget.setWindowTitle("屏幕坐标系")
widget.show()
sys.exit(app.exec_())
Ejemplo n.º 13
0
    def initUI(self, pos_offset):

        self.setWindowTitle(f"DataViewer - {self.df.name}")
        self.setGeometry(80 + pos_offset, 300 + pos_offset, 900, 650)

        # for the status bar
        main_widget = QWidget()
        self.statusBar()

        self.tsCanvas = mkTimeSeriesCanvas()
        main_frame = QWidget()
        self.tsCanvas.setParent(main_frame)
        ntb = NavigationToolbar(self.tsCanvas, main_frame)  # full toolbar

        # the table instance,
        DataTable = QTableView()
        model = PandasModel(self.df)
        DataTable.setModel(model)
        DataTable.setSelectionBehavior(2)  # columns only
        DataTable.clicked.connect(
            self.Table_select)  # magically transports QModelIndex
        # so that it also works for header selection
        header = DataTable.horizontalHeader()  # returns QHeaderView
        header.sectionClicked.connect(
            self.Header_select)  # magically transports QModelIndex

        # size policy for DataTable, not needed..?!
        # size_pol= QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        # DataTable.setSizePolicy(size_pol)

        # the signal selection box
        SignalBox = QComboBox(self)
        SignalBox.setStatusTip(
            "..or just click directly on a signal in the table!")

        main_layout_v = QVBoxLayout()  # The whole Layout
        # Data selction drop-down
        dataLabel = QLabel("Select Signal", self)

        dt_label = QLabel("Sampling Interval:")
        self.dt_edit = QLineEdit()
        self.dt_edit.setStatusTip("How much time in between two recordings?")
        self.dt_edit.setMinimumSize(70, 0)  # no effect :/
        self.dt_edit.setValidator(posfloatV)

        unit_label = QLabel("Time Unit:")
        self.unit_edit = QLineEdit(self)
        self.unit_edit.setStatusTip("Changes only the axis labels..")
        self.unit_edit.setMinimumSize(70, 0)

        top_bar_box = QWidget()
        top_bar_layout = QHBoxLayout()

        top_bar_layout.addWidget(dataLabel)
        top_bar_layout.addWidget(SignalBox)
        top_bar_layout.addStretch(0)
        top_bar_layout.addWidget(dt_label)
        top_bar_layout.addWidget(self.dt_edit)
        top_bar_layout.addStretch(0)
        top_bar_layout.addWidget(unit_label)
        top_bar_layout.addWidget(self.unit_edit)
        top_bar_layout.addStretch(0)
        top_bar_box.setLayout(top_bar_layout)

        top_and_table = QGroupBox("Settings and Data")
        top_and_table_layout = QVBoxLayout()
        top_and_table_layout.addWidget(top_bar_box)
        top_and_table_layout.addWidget(DataTable)
        top_and_table.setLayout(top_and_table_layout)
        main_layout_v.addWidget(top_and_table)

        ## detrending parameter

        self.T_c_edit = QLineEdit()
        self.T_c_edit.setMaximumWidth(70)
        self.T_c_edit.setValidator(posfloatV)
        self.T_c_edit.setStatusTip("..in time units, e.g. 120min")

        sinc_options_box = QGroupBox("Sinc Detrending")
        sinc_options_layout = QGridLayout()
        sinc_options_layout.addWidget(QLabel("Cut-off Period:"), 0, 0)
        sinc_options_layout.addWidget(self.T_c_edit, 0, 1)
        sinc_options_box.setLayout(sinc_options_layout)

        ## Amplitude envelope parameter
        self.wsize_edit = QLineEdit()
        self.wsize_edit.setMaximumWidth(70)
        self.wsize_edit.setValidator(self.envelopeV)
        self.wsize_edit.setStatusTip("..in time units, e.g. 120min")

        envelope_options_box = QGroupBox("Amplitude Envelope")
        envelope_options_layout = QGridLayout()
        envelope_options_layout.addWidget(QLabel("Window Size:"), 0, 0)
        envelope_options_layout.addWidget(self.wsize_edit, 0, 1)
        envelope_options_box.setLayout(envelope_options_layout)

        # plot options box
        plot_options_box = QGroupBox("Plotting Options")
        plot_options_layout = QGridLayout()

        self.cb_raw = QCheckBox("Raw Signal", self)
        self.cb_raw.setStatusTip("Plots the raw unfiltered signal")

        self.cb_trend = QCheckBox("Trend", self)
        self.cb_trend.setStatusTip("Plots the sinc filtered signal")

        self.cb_detrend = QCheckBox("Detrended Signal", self)
        self.cb_detrend.setStatusTip(
            "Plots the signal after trend subtraction (detrending)")

        self.cb_envelope = QCheckBox("Envelope", self)
        self.cb_envelope.setStatusTip("Plots the estimated amplitude envelope")

        plotButton = QPushButton("Refresh Plot", self)
        plotButton.setStatusTip(
            "Updates the plot with the new filter parameter values")
        plotButton.clicked.connect(self.doPlot)

        saveButton = QPushButton("Save Filter Results", self)
        saveButton.clicked.connect(self.save_out_trend)
        saveButton.setStatusTip(
            "Writes the trend and the detrended signal into a file")

        ## checkbox layout
        plot_options_layout.addWidget(self.cb_raw, 0, 0)
        plot_options_layout.addWidget(self.cb_trend, 0, 1)
        plot_options_layout.addWidget(self.cb_detrend, 1, 0)
        plot_options_layout.addWidget(self.cb_envelope, 1, 1)
        plot_options_layout.addWidget(plotButton, 2, 0)
        plot_options_layout.addWidget(saveButton, 2, 1, 1, 1)
        plot_options_box.setLayout(plot_options_layout)

        ## checkbox signal set and change
        self.cb_raw.toggle()

        self.cb_raw.stateChanged.connect(self.toggle_raw)
        self.cb_trend.stateChanged.connect(self.toggle_trend)
        self.cb_detrend.stateChanged.connect(self.toggle_trend)
        self.cb_envelope.stateChanged.connect(self.toggle_envelope)

        # Ploting box/Canvas area
        plot_box = QGroupBox("Signal and Trend")
        plot_layout = QVBoxLayout()
        plot_layout.addWidget(self.tsCanvas)
        plot_layout.addWidget(ntb)
        plot_box.setLayout(plot_layout)

        # Analyzer box with tabs
        ana_widget = QGroupBox("Analysis")
        ana_box = QVBoxLayout()

        ## Initialize tab scresen
        tabs = QTabWidget()
        tab1 = QWidget()
        tab2 = QWidget()

        ## Add tabs
        tabs.addTab(tab1, "Wavelet Analysis")
        tabs.addTab(tab2, "Fourier Transform")

        ## Create first tab
        tab1.parameter_box = QFormLayout()

        ## for wavlet params, button, etc.
        self.Tmin_edit = QLineEdit()
        self.Tmin_edit.setStatusTip("This is the lower period limit")
        self.nT_edit = QLineEdit()
        self.nT_edit.setValidator(QRegExpValidator(QRegExp('[0-9]+')))
        self.nT_edit.setStatusTip(
            "Increase this number for more spectral resolution")
        self.Tmax_edit = QLineEdit()
        self.Tmax_edit.setStatusTip("This is the upper period limit")

        self.pow_max_edit = QLineEdit()
        self.pow_max_edit.setStatusTip(
            "Enter a fixed value or leave blank for automatic wavelet power scaling"
        )

        Tmin_lab = QLabel("Lowest period")
        step_lab = QLabel("Number of periods")
        Tmax_lab = QLabel("Highest  period")
        pow_max_lab = QLabel("Expected maximal power")

        Tmin_lab.setWordWrap(True)
        step_lab.setWordWrap(True)
        Tmax_lab.setWordWrap(True)
        pow_max_lab.setWordWrap(True)

        wletButton = QPushButton("Analyze Signal", self)
        wletButton.setStyleSheet("background-color: lightblue")
        wletButton.setStatusTip("Opens the wavelet analysis..")
        wletButton.clicked.connect(self.run_wavelet_ana)

        batchButton = QPushButton("Analyze All..", self)
        batchButton.clicked.connect(self.run_batch)
        batchButton.setStatusTip("Starts the batch processing")

        ## add  button to layout
        wlet_button_layout_h = QHBoxLayout()

        wlet_button_layout_h.addStretch(0)
        wlet_button_layout_h.addWidget(wletButton)
        wlet_button_layout_h.addStretch(0)
        wlet_button_layout_h.addWidget(batchButton)
        wlet_button_layout_h.addStretch(0)

        self.cb_use_detrended = QCheckBox("Use Detrended Signal", self)
        # self.cb_use_detrended.stateChanged.connect(self.toggle_trend)
        self.cb_use_detrended.setChecked(True)  # detrend by default

        self.cb_use_envelope = QCheckBox("Normalize with Envelope", self)
        self.cb_use_envelope.stateChanged.connect(self.toggle_envelope)
        self.cb_use_envelope.setChecked(False)  # no envelope by default

        ## Add Wavelet analyzer options to tab1.parameter_box layout

        tab1.parameter_box.addRow(Tmin_lab, self.Tmin_edit)
        tab1.parameter_box.addRow(Tmax_lab, self.Tmax_edit)
        tab1.parameter_box.addRow(step_lab, self.nT_edit)
        tab1.parameter_box.addRow(pow_max_lab, self.pow_max_edit)
        tab1.parameter_box.addRow(self.cb_use_detrended)
        tab1.parameter_box.addRow(self.cb_use_envelope)
        tab1.parameter_box.addRow(wlet_button_layout_h)

        tab1.setLayout(tab1.parameter_box)

        # fourier button
        fButton = QPushButton("Analyze Signal", self)
        ## add  button to layout
        f_button_layout_h = QHBoxLayout()
        fButton.clicked.connect(self.run_fourier_ana)
        f_button_layout_h.addStretch(0)
        f_button_layout_h.addWidget(fButton)

        # fourier detrended switch
        self.cb_use_detrended2 = QCheckBox("Use Detrended Signal", self)
        self.cb_use_detrended2.setChecked(True)  # detrend by default

        self.cb_use_envelope2 = QCheckBox("Normalize with Envelope", self)
        self.cb_use_envelope2.setChecked(False)

        # fourier period or frequency view
        self.cb_FourierT = QCheckBox("Show Frequencies", self)
        self.cb_FourierT.setChecked(False)  # show periods per default

        ## Create second tab
        tab2.parameter_box = QFormLayout()
        # tab2.parameter_box.addRow(Tmin_lab,self.Tmin)
        # tab2.parameter_box.addRow(Tmax_lab,self.Tmax)
        tab2.parameter_box.addRow(self.cb_use_detrended2)
        tab2.parameter_box.addRow(self.cb_use_envelope2)
        tab2.parameter_box.addRow(self.cb_FourierT)
        tab2.parameter_box.addRow(f_button_layout_h)
        tab2.setLayout(tab2.parameter_box)

        # Add tabs to Vbox
        ana_box.addWidget(tabs)
        # set layout of ana_widget (will be added to options layout)
        # as ana_box (containing actual layout)
        ana_widget.setLayout(ana_box)

        # Fix size of table_widget containing parameter boxes
        # -> it's all done via column stretches of
        # the GridLayout below
        # size_pol= QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        # ana_widget.setSizePolicy(size_pol)

        # ==========Plot and Options Layout=================================
        # Merge Plotting canvas and options
        plot_and_options = QWidget()
        layout = QGridLayout()
        plot_and_options.setLayout(layout)

        layout.addWidget(plot_box, 0, 0, 4, 1)
        layout.addWidget(sinc_options_box, 0, 5, 1, 1)
        layout.addWidget(envelope_options_box, 0, 6, 1, 1)
        layout.addWidget(plot_options_box, 1, 5, 1, 2)
        layout.addWidget(ana_widget, 2, 5, 2, 2)

        # plotting-canvas column stretch <-> 1st (0th) column
        layout.setColumnStretch(0, 1)  # plot should stretch
        layout.setColumnMinimumWidth(0, 360)  # plot should not get too small

        layout.setColumnStretch(1, 0)  # options shouldn't stretch
        layout.setColumnStretch(2, 0)  # options shouldn't stretch

        # ==========Main Layout=======================================
        main_layout_v.addWidget(plot_and_options)  # is a VBox

        # populate signal selection box
        SignalBox.addItem("")  # empty initial selector

        for col in self.df.columns:
            SignalBox.addItem(col)

        # connect to plotting machinery
        SignalBox.activated[str].connect(self.select_signal_and_Plot)
        # to modify current index by table selections
        self.SignalBox = SignalBox

        # --- connect some parameter fields ---

        self.dt_edit.textChanged[str].connect(self.qset_dt)
        self.unit_edit.textChanged[str].connect(self.qset_time_unit)

        # --- initialize parameter fields from settings ---

        self.load_settings()

        main_widget.setLayout(main_layout_v)
        self.setCentralWidget(main_widget)
        self.show()
Ejemplo n.º 14
0
    def create_gui_layout(self):
        # self.setDockOptions(DockOption.AllowNestedDocks | DockOption.AllowTabbedDocks)
        self.setDockNestingEnabled(True)
        # self.setUnifiedTitleAndToolBarOnMac(False)
        # self.setTabbedDock(True)
        self.media_toolbar = ToolBar(
            title="Media",
            objects=[
                self.open_media_menu, ToolBar.Separator,
                self.toggle_playlist_act
            ],
            parent=self,
            collapsible=True,
            icon_size=32,
        )
        self.view_toolbar = ToolBar(
            title="View",
            objects=[
                self.frame_scale_menu,
                self.always_on_top_act,
                self.fullscreen_menu,
            ],
            parent=self,
            collapsible=True,
            icon_size=32,
        )
        self.connect_toolbar = ToolBar(
            title="Connect",
            objects=[self.connect_wide_button_builder, self.open_settings_act],
            parent=self,
            collapsible=True,
            icon_size=32,
        )
        self.connect_toolbar.setObjectName("borderedbuttons")

        self.button_bar_widget = QWidget(self)
        self.button_bar_widget.setContentsMargins(0, 0, 0, 0)
        self.button_bar_widget.setLayout(QGridLayout())
        self.button_bar_widget.setSizePolicy(QSizePolicy.Expanding,
                                             QSizePolicy.Expanding)
        self.button_bar_widget.layout().addWidget(self.view_toolbar, 0, 0, 1,
                                                  1, Qt.AlignLeft)
        self.button_bar_widget.layout().addWidget(self.connect_toolbar, 0, 1,
                                                  1, 1, Qt.AlignCenter)
        self.button_bar_widget.layout().addWidget(self.media_toolbar, 0, 2, 1,
                                                  1, Qt.AlignRight)
        self.addToolBar(
            Qt.TopToolBarArea,
            ToolBar("Toolbar", parent=self, objects=[self.button_bar_widget]),
        )

        self.playback_slider_widget = QWidget(self)
        self.playback_slider_widget.setContentsMargins(0, 0, 0, 0)
        self.playback_slider_widget.setLayout(QGridLayout())
        self.playback_slider_widget.layout().addWidget(
            self.playback_ctrls_slider, 0, 0, 1, -1, Qt.AlignTop)
        self.playback_bttns_left = ToolBar(
            title="Left Control",
            objects=[self.open_player_prefs_act, self.open_adjustments_act],
            collapsible=False,
            parent=self,
            icon_size=32,
        )
        self.playback_bttns_middle = ToolBar(
            title="Playback Controls",
            objects=self.play_actions.actions(),
            parent=self,
            collapsible=False,
            icon_size=60,
        )
        self.playback_bttns_right = ToolBar(
            title="Right Controls",
            objects=[self.playback_mode_act, self.vol_popup_bttn],
            collapsible=False,
            parent=self,
            icon_size=32,
        )
        self.playback_ctrls_widget = QWidget(self)
        self.playback_ctrls_widget.setContentsMargins(0, 0, 0, 0)
        self.playback_ctrls_widget.setLayout(
            QGridLayout(self.playback_ctrls_widget))
        self.playback_ctrls_widget.layout().addWidget(
            self.playback_slider_widget, 0, 0, 1, -1, Qt.AlignTop)
        self.playback_ctrls_widget.layout().addWidget(
            self.playback_bttns_left, 1, 0, 1, 1,
            Qt.AlignHCenter | Qt.AlignVCenter)
        self.playback_ctrls_widget.layout().addWidget(
            self.playback_bttns_middle, 1, 1, 1, 1,
            Qt.AlignHCenter | Qt.AlignVCenter)
        self.playback_ctrls_widget.layout().addWidget(
            self.playback_bttns_right, 1, 2, 1, 1,
            Qt.AlignJustify | Qt.AlignVCenter)
        self.playback_ctrls_dock_widget = DockableWidget(
            title="Playback",
            parent=self,
            widget=self.playback_ctrls_widget,
            w_titlebar=False,
        )

        self.addDockWidget(Qt.RightDockWidgetArea, self.dockable_playlist)
        self.addDockWidget(Qt.BottomDockWidgetArea,
                           self.playback_ctrls_dock_widget)
Ejemplo n.º 15
0
	def form_1(self):
		self.firstWindow = QWidget(self)
		self.but1 = QPushButton('next', self.firstWindow)
		self.but1.clicked.connect(self.next)
		self.setWindowTitle('Window 1')
    def __init__(self, parent=None):
        super(VideoWindow, self).__init__(parent)
        dataset = Dataset.Dataset(name='', json_path=config.argument_defaults['video_data_path']
                                  .format(config.argument_defaults['poc_mode']))

        self.setWindowTitle("Browse Annotated Datasets")

        self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface)
        self.setStyleSheet("QToolTip\n"
"{\n"
"     border: 1px solid black;\n"
"     background-color: #ffa02f;\n"
"     padding: 1px;\n"
"     border-radius: 3px;\n"
"     opacity: 100;\n"
"}\n"
"\n"
"QWidget\n"
"{\n"
"    color: #b1b1b1;\n"
"    background-color: #323232;\n"
"}\n"
"\n"
"QTreeView, QListView\n"
"{\n"
"    background-color: silver;\n"
"    margin-left: 5px;\n"
"}\n"
"\n"
"QWidget:item:hover\n"
"{\n"
"    background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #ca0619);\n"
"    color: #000000;\n"
"}\n"
"\n"
"QWidget:item:selected\n"
"{\n"
"    background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);\n"
"}\n"
"\n"
"QMenuBar::item\n"
"{\n"
"    background: transparent;\n"
"}\n"
"\n"
"QMenuBar::item:selected\n"
"{\n"
"    background: transparent;\n"
"    border: 1px solid #ffaa00;\n"
"}\n"
"\n"
"QMenuBar::item:pressed\n"
"{\n"
"    background: #444;\n"
"    border: 1px solid #000;\n"
"    background-color: QLinearGradient(\n"
"        x1:0, y1:0,\n"
"        x2:0, y2:1,\n"
"        stop:1 #212121,\n"
"        stop:0.4 #343434/*,\n"
"        stop:0.2 #343434,\n"
"        stop:0.1 #ffaa00*/\n"
"    );\n"
"    margin-bottom:-1px;\n"
"    padding-bottom:1px;\n"
"}\n"
"\n"
"QMenu\n"
"{\n"
"    border: 1px solid #000;\n"
"}\n"
"\n"
"QMenu::item\n"
"{\n"
"    padding: 2px 20px 2px 20px;\n"
"}\n"
"\n"
"QMenu::item:selected\n"
"{\n"
"    color: #000000;\n"
"}\n"
"\n"
"QWidget:disabled\n"
"{\n"
"    color: #808080;\n"
"    background-color: #323232;\n"
"}\n"
"\n"
"QAbstractItemView\n"
"{\n"
"    background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #4d4d4d, stop: 0.1 #646464, stop: 1 #5d5d5d);\n"
"}\n"
"\n"
"QWidget:focus\n"
"{\n"
"    /*border: 1px solid darkgray;*/\n"
"}\n"
"\n"
"QLineEdit\n"
"{\n"
"    background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #4d4d4d, stop: 0 #646464, stop: 1 #5d5d5d);\n"
"    padding: 1px;\n"
"    border-style: solid;\n"
"    border: 1px solid #1e1e1e;\n"
"    border-radius: 5;\n"
"}\n"
"\n"
"QPushButton\n"
"{\n"
"    color: #b1b1b1;\n"
"    background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #565656, stop: 0.1 #525252, stop: 0.5 #4e4e4e, stop: 0.9 #4a4a4a, stop: 1 #464646);\n"
"    border-width: 1px;\n"
"    border-color: #1e1e1e;\n"
"    border-style: solid;\n"
"    border-radius: 6;\n"
"    padding: 3px;\n"
"    font-size: 12px;\n"
"    padding-left: 5px;\n"
"    padding-right: 5px;\n"
"    min-width: 40px;\n"
"}\n"
"\n"
"QPushButton:pressed\n"
"{\n"
"    background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #2d2d2d, stop: 0.1 #2b2b2b, stop: 0.5 #292929, stop: 0.9 #282828, stop: 1 #252525);\n"
"}\n"
"\n"
"QComboBox\n"
"{\n"
"    selection-background-color: #ffaa00;\n"
"    background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #565656, stop: 0.1 #525252, stop: 0.5 #4e4e4e, stop: 0.9 #4a4a4a, stop: 1 #464646);\n"
"    border-style: solid;\n"
"    border: 1px solid #1e1e1e;\n"
"    border-radius: 5;\n"
"}\n"
"\n"
"QComboBox:hover,QPushButton:hover\n"
"{\n"
"    border: 2px solid QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);\n"
"}\n"
"\n"
"\n"
"QComboBox:on\n"
"{\n"
"    padding-top: 3px;\n"
"    padding-left: 4px;\n"
"    background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #2d2d2d, stop: 0.1 #2b2b2b, stop: 0.5 #292929, stop: 0.9 #282828, stop: 1 #252525);\n"
"    selection-background-color: #ffaa00;\n"
"}\n"
"\n"
"QComboBox QAbstractItemView\n"
"{\n"
"    border: 2px solid darkgray;\n"
"    selection-background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);\n"
"}\n"
"\n"
"QComboBox::drop-down\n"
"{\n"
"     subcontrol-origin: padding;\n"
"     subcontrol-position: top right;\n"
"     width: 15px;\n"
"\n"
"     border-left-width: 0px;\n"
"     border-left-color: darkgray;\n"
"     border-left-style: solid; /* just a single line */\n"
"     border-top-right-radius: 3px; /* same radius as the QComboBox */\n"
"     border-bottom-right-radius: 3px;\n"
" }\n"
"\n"
"QComboBox::down-arrow\n"
"{\n"
"     image: url(:/dark_orange/img/down_arrow.png);\n"
"}\n"
"\n"
"QGroupBox\n"
"{\n"
"    border: 1px solid darkgray;\n"
"    margin-top: 10px;\n"
"}\n"
"\n"
"QGroupBox:focus\n"
"{\n"
"    border: 1px solid darkgray;\n"
"}\n"
"\n"
"QTextEdit:focus\n"
"{\n"
"    border: 1px solid darkgray;\n"
"}\n"
"\n"
"QScrollBar:horizontal {\n"
"     border: 1px solid #222222;\n"
"     background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0.0 #121212, stop: 0.2 #282828, stop: 1 #484848);\n"
"     height: 7px;\n"
"     margin: 0px 16px 0 16px;\n"
"}\n"
"\n"
"QScrollBar::handle:horizontal\n"
"{\n"
"      background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #ffa02f, stop: 0.5 #d7801a, stop: 1 #ffa02f);\n"
"      min-height: 20px;\n"
"      border-radius: 2px;\n"
"}\n"
"\n"
"QScrollBar::add-line:horizontal {\n"
"      border: 1px solid #1b1b19;\n"
"      border-radius: 2px;\n"
"      background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #ffa02f, stop: 1 #d7801a);\n"
"      width: 14px;\n"
"      subcontrol-position: right;\n"
"      subcontrol-origin: margin;\n"
"}\n"
"\n"
"QScrollBar::sub-line:horizontal {\n"
"      border: 1px solid #1b1b19;\n"
"      border-radius: 2px;\n"
"      background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #ffa02f, stop: 1 #d7801a);\n"
"      width: 14px;\n"
"     subcontrol-position: left;\n"
"     subcontrol-origin: margin;\n"
"}\n"
"\n"
"QScrollBar::right-arrow:horizontal, QScrollBar::left-arrow:horizontal\n"
"{\n"
"      border: 1px solid black;\n"
"      width: 1px;\n"
"      height: 1px;\n"
"      background: white;\n"
"}\n"
"\n"
"QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal\n"
"{\n"
"      background: none;\n"
"}\n"
"\n"
"QScrollBar:vertical\n"
"{\n"
"      background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0.0 #121212, stop: 0.2 #282828, stop: 1 #484848);\n"
"      width: 7px;\n"
"      margin: 16px 0 16px 0;\n"
"      border: 1px solid #222222;\n"
"}\n"
"\n"
"QScrollBar::handle:vertical\n"
"{\n"
"      background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 0.5 #d7801a, stop: 1 #ffa02f);\n"
"      min-height: 20px;\n"
"      border-radius: 2px;\n"
"}\n"
"\n"
"QScrollBar::add-line:vertical\n"
"{\n"
"      border: 1px solid #1b1b19;\n"
"      border-radius: 2px;\n"
"      background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);\n"
"      height: 14px;\n"
"      subcontrol-position: bottom;\n"
"      subcontrol-origin: margin;\n"
"}\n"
"\n"
"QScrollBar::sub-line:vertical\n"
"{\n"
"      border: 1px solid #1b1b19;\n"
"      border-radius: 2px;\n"
"      background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #d7801a, stop: 1 #ffa02f);\n"
"      height: 14px;\n"
"      subcontrol-position: top;\n"
"      subcontrol-origin: margin;\n"
"}\n"
"\n"
"QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical\n"
"{\n"
"      border: 1px solid black;\n"
"      width: 1px;\n"
"      height: 1px;\n"
"      background: white;\n"
"}\n"
"\n"
"\n"
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical\n"
"{\n"
"      background: none;\n"
"}\n"
"\n"
"QTextEdit\n"
"{\n"
"    background-color: #242424;\n"
"}\n"
"\n"
"QPlainTextEdit\n"
"{\n"
"    background-color: #242424;\n"
"}\n"
"\n"
"QHeaderView::section\n"
"{\n"
"    background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #616161, stop: 0.5 #505050, stop: 0.6 #434343, stop:1 #656565);\n"
"    color: white;\n"
"    padding-left: 4px;\n"
"    border: 1px solid #6c6c6c;\n"
"}\n"
"\n"
"QCheckBox:disabled\n"
"{\n"
"color: #414141;\n"
"}\n"
"\n"
"QDockWidget::title\n"
"{\n"
"    text-align: center;\n"
"    spacing: 3px; /* spacing between items in the tool bar */\n"
"    background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #323232, stop: 0.5 #242424, stop:1 #323232);\n"
"}\n"
"\n"
"QDockWidget::close-button, QDockWidget::float-button\n"
"{\n"
"    text-align: center;\n"
"    spacing: 1px; /* spacing between items in the tool bar */\n"
"    background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #323232, stop: 0.5 #242424, stop:1 #323232);\n"
"}\n"
"\n"
"QDockWidget::close-button:hover, QDockWidget::float-button:hover\n"
"{\n"
"    background: #242424;\n"
"}\n"
"\n"
"QDockWidget::close-button:pressed, QDockWidget::float-button:pressed\n"
"{\n"
"    padding: 1px -1px -1px 1px;\n"
"}\n"
"\n"
"QMainWindow::separator\n"
"{\n"
"    background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #161616, stop: 0.5 #151515, stop: 0.6 #212121, stop:1 #343434);\n"
"    color: white;\n"
"    padding-left: 4px;\n"
"    border: 1px solid #4c4c4c;\n"
"    spacing: 3px; /* spacing between items in the tool bar */\n"
"}\n"
"\n"
"QMainWindow::separator:hover\n"
"{\n"
"\n"
"    background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #d7801a, stop:0.5 #b56c17 stop:1 #ffa02f);\n"
"    color: white;\n"
"    padding-left: 4px;\n"
"    border: 1px solid #6c6c6c;\n"
"    spacing: 3px; /* spacing between items in the tool bar */\n"
"}\n"
"\n"
"QToolBar::handle\n"
"{\n"
"     spacing: 3px; /* spacing between items in the tool bar */\n"
"     background: url(:/dark_orange/img/handle.png);\n"
"}\n"
"\n"
"QMenu::separator\n"
"{\n"
"    height: 2px;\n"
"    background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #161616, stop: 0.5 #151515, stop: 0.6 #212121, stop:1 #343434);\n"
"    color: white;\n"
"    padding-left: 4px;\n"
"    margin-left: 10px;\n"
"    margin-right: 5px;\n"
"}\n"
"\n"
"QProgressBar\n"
"{\n"
"    border: 2px solid grey;\n"
"    border-radius: 5px;\n"
"    text-align: center;\n"
"}\n"
"\n"
"QProgressBar::chunked\n"
"{\n"
"    background-color: #d7801a;\n"
"    width: 2.15px;\n"
"    margin: 0.5px;\n"
"}\n"
"\n"
"QTabBar::tab {\n"
"    color: #b1b1b1;\n"
"    border: 1px solid #444;\n"
"    border-bottom-style: none;\n"
"    background-color: #323232;\n"
"    padding-left: 10px;\n"
"    padding-right: 10px;\n"
"    padding-top: 3px;\n"
"    padding-bottom: 2px;\n"
"    margin-right: -1px;\n"
"}\n"
"\n"
"QTabWidget::pane {\n"
"    border: 1px solid #444;\n"
"    top: 1px;\n"
"}\n"
"\n"
"QTabBar::tab:last\n"
"{\n"
"    margin-right: 0; /* the last selected tab has nothing to overlap with on the right */\n"
"    border-top-right-radius: 3px;\n"
"}\n"
"\n"
"QTabBar::tab:first:!selected\n"
"{\n"
" margin-left: 0px; /* the last selected tab has nothing to overlap with on the right */\n"
"\n"
"\n"
"    border-top-left-radius: 3px;\n"
"}\n"
"\n"
"QTabBar::tab:!selected\n"
"{\n"
"    color: #b1b1b1;\n"
"    border-bottom-style: solid;\n"
"    margin-top: 3px;\n"
"    background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:1 #212121, stop:.4 #343434);\n"
"}\n"
"\n"
"QTabBar::tab:selected\n"
"{\n"
"    border-top-left-radius: 3px;\n"
"    border-top-right-radius: 3px;\n"
"    margin-bottom: 0px;\n"
"}\n"
"\n"
"QTabBar::tab:!selected:hover\n"
"{\n"
"    /*border-top: 2px solid #ffaa00;\n"
"    padding-bottom: 3px;*/\n"
"    border-top-left-radius: 3px;\n"
"    border-top-right-radius: 3px;\n"
"    background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:1 #212121, stop:0.4 #343434, stop:0.2 #343434, stop:0.1 #ffaa00);\n"
"}\n"
"\n"
"QRadioButton::indicator:checked, QRadioButton::indicator:unchecked{\n"
"    color: #b1b1b1;\n"
"    background-color: #323232;\n"
"    border: 1px solid #b1b1b1;\n"
"    border-radius: 6px;\n"
"}\n"
"\n"
"QRadioButton::indicator:checked\n"
"{\n"
"    background-color: qradialgradient(\n"
"        cx: 0.5, cy: 0.5,\n"
"        fx: 0.5, fy: 0.5,\n"
"        radius: 1.0,\n"
"        stop: 0.25 #ffaa00,\n"
"        stop: 0.3 #323232\n"
"    );\n"
"}\n"
"\n"
"QCheckBox::indicator{\n"
"    color: #b1b1b1;\n"
"    background-color: #323232;\n"
"    border: 1px solid #b1b1b1;\n"
"    width: 9px;\n"
"    height: 9px;\n"
"}\n"
"\n"
"QRadioButton::indicator\n"
"{\n"
"    border-radius: 6px;\n"
"}\n"
"\n"
"QRadioButton::indicator:hover, QCheckBox::indicator:hover\n"
"{\n"
"    border: 1px solid #ffaa00;\n"
"}\n"
"\n"
"QCheckBox::indicator:checked\n"
"{\n"
"    image:url(:/dark_orange/img/checkbox.png);\n"
"}\n"
"\n"
"QCheckBox::indicator:disabled, QRadioButton::indicator:disabled\n"
"{\n"
"    border: 1px solid #444;\n"
"}\n"
"\n"
"\n"
"QSlider::groove:horizontal {\n"
"    border: 1px solid #3A3939;\n"
"    height: 8px;\n"
"    background: #201F1F;\n"
"    margin: 2px 0;\n"
"    border-radius: 2px;\n"
"}\n"
"\n"
"QSlider::handle:horizontal {\n"
"    background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1,\n"
"      stop: 0.0 silver, stop: 0.2 #a8a8a8, stop: 1 #727272);\n"
"    border: 1px solid #3A3939;\n"
"    width: 14px;\n"
"    height: 14px;\n"
"    margin: -4px 0;\n"
"    border-radius: 2px;\n"
"}\n"
"\n"
"QSlider::groove:vertical {\n"
"    border: 1px solid #3A3939;\n"
"    width: 8px;\n"
"    background: #201F1F;\n"
"    margin: 0 0px;\n"
"    border-radius: 2px;\n"
"}\n"
"\n"
"QSlider::handle:vertical {\n"
"    background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0.0 silver,\n"
"      stop: 0.2 #a8a8a8, stop: 1 #727272);\n"
"    border: 1px solid #3A3939;\n"
"    width: 14px;\n"
"    height: 14px;\n"
"    margin: 0 -4px;\n"
"    border-radius: 2px;\n"
"}\n"
"\n"
"QAbstractSpinBox {\n"
"    padding-top: 2px;\n"
"    padding-bottom: 2px;\n"
"    border: 1px solid darkgray;\n"
"\n"
"    border-radius: 2px;\n"
"    min-width: 50px;\n"
"}\n"
"\n"
"")
        videoWidget = QVideoWidget()

        self.playButton = QPushButton()
        self.playButton.setEnabled(False)
        self.playButton.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay))
        self.playButton.clicked.connect(self.play)

        self.positionSlider = QSlider(Qt.Horizontal)
        self.positionSlider.setRange(0, 0)
        self.positionSlider.sliderMoved.connect(self.setPosition)
        self.comboBox = QComboBox()
        self.comboBox.setMaxVisibleItems(10)
        self.comboBox.setSizeAdjustPolicy(QComboBox.AdjustToContents)
        self.comboBox.setObjectName("comboBox")
        self.comboBox.addItem("Select video...")
        self.comboBox.addItems(sorted(ntpath.basename(videoData.video_path) for videoData in dataset.videos))
        self.comboBox.currentTextChanged.connect(self.openVideo)


        self.progress1 = QProgressBar(self)
        self.progress2 = QProgressBar(self)

        self.progress1.setMaximum(dataset.number_of_people.maximum)
        self.progress1.setStyleSheet("QProgressBar::chunk { background-color: #53201a; }")

        self.progress1.setMinimum(dataset.number_of_people.minimum)
        self.progress1.setFormat('min # of people:'+str(dataset.number_of_people.minimum)+'\t\t\t\t\t\t\t\t\t\t\t\tcurrent video: %v\t\t\t\t\t\t\t\t\t\t\t\t'+'max # of people:'+str(dataset.number_of_people.maximum))

        self.progress2.setMaximum(dataset.number_of_vehicles.maximum)
        self.progress2.setStyleSheet("QProgressBar::chunk { background-color: #53201a; }")

        self.progress2.setMinimum(dataset.number_of_vehicles.minimum)
        self.progress2.setFormat('min # of vehicles: ' + str(
            dataset.number_of_vehicles.minimum) + '\t\t\t\t\t\t\t\t\t\t\t\tcurrent video: %v\t\t\t\t\t\t\t\t\t\t\t\t' + 'max # of vehicles: ' + str(
            dataset.number_of_vehicles.maximum))

        self.backToMenu = QPushButton()
        self.backToMenu.setEnabled(True)
        self.backToMenu.setText('Back to Main Menu')
        self.backToMenu.clicked.connect(self.exitCall)

        # Create exit action
        exitAction = QAction(QIcon('exit.png'), '&Exit', self)
        exitAction.setShortcut('Ctrl+Q')
        exitAction.setStatusTip('Exit application')
        exitAction.triggered.connect(self.exitCall)

        # Create a widget for window contents
        wid = QWidget(self)
        self.setCentralWidget(wid)

        # Create layouts to place inside widget
        controlLayout = QHBoxLayout()
        controlLayout.setContentsMargins(0, 0, 0, 0)
        controlLayout.addWidget(self.playButton)
        controlLayout.addWidget(self.positionSlider)

        statsLayout = QVBoxLayout()
        statsLayout.setContentsMargins(0, 0, 0, 0)
        statsLayout.addWidget(self.progress1)
        statsLayout.addWidget(self.progress2)

        # statsLayout.addWidget(self.positionSlider)

        layout = QVBoxLayout()
        layout.addWidget(self.comboBox)
        layout.addWidget(videoWidget)
        layout.addLayout(controlLayout)
        layout.addLayout(statsLayout)
        layout.addWidget(self.backToMenu)

        # Set widget to contain window contents
        wid.setLayout(layout)

        self.mediaPlayer.setVideoOutput(videoWidget)
        self.mediaPlayer.stateChanged.connect(self.mediaStateChanged)
        self.mediaPlayer.positionChanged.connect(self.positionChanged)
        self.mediaPlayer.durationChanged.connect(self.durationChanged)
Ejemplo n.º 17
0
	def form_2(self):
		self.secondWindow = QWidget(self)
		self.but2 = QPushButton('back', self.secondWindow)
		self.but2.clicked.connect(self.back)
		self.setWindowTitle('Window 2')
Ejemplo n.º 18
0
    def __init__(self, parent):
        super(QWidget, self).__init__(parent)
        self.layout = QVBoxLayout(self)

        #Fonts
        boldFont = QFont()
        boldFont.setBold(True)

        # Initialize tab screen
        self.tabs = QTabWidget()
        self.tab1 = QScrollArea()
        self.tab2 = QScrollArea()
        self.tab3 = QWidget()

        # Add tabs
        self.tabs.addTab(self.tab1, "Session Stats")
        self.tabs.addTab(self.tab2, "Total Stats")
        self.tabs.addTab(self.tab3, "Settings")

        #self.dataStruct = getDatastruct()

        #Set up update timer
        self.update_timer = QTimer(self)
        self.update_timer.timeout.connect(self.updateTabs)
        self.update_timer.start(5000)

        sessionLength = 12
        #self.dataStruct['sessionStats'].pop('sessionLength', None)
        #sorted_totalStats = sorted(self.dataStruct['totalStats'].items(),key=lambda x:operator.getitem(x[1],'count'), reverse=True)
        #sorted_sessionStats = sorted(self.dataStruct['sessionStats'].items(),key=lambda x:operator.getitem(x[1],'count'), reverse=True)
        #print(self.dataStruct)
        self.lastLength = 0

        #Create Session stats tab with content
        self.content_widget = QWidget()
        self.tab1.setWidget(self.content_widget)
        self.tab2Layer = QGridLayout(self.content_widget)
        self.tab1.setWidgetResizable(True)
        self.leftColumn = QLabel('Instance Name:', self)
        self.leftColumn.setFont(boldFont)
        self.middleColumn = QLabel('Instance Count:', self)
        self.middleColumn.setFont(boldFont)
        self.rightColumn = QLabel('Avg Time in Instance(secs):', self)
        self.rightColumn.setFont(boldFont)
        self.tab2Layer.addWidget(self.leftColumn, 0, 0)
        self.tab2Layer.addWidget(self.middleColumn, 0, 1)
        self.tab2Layer.addWidget(self.rightColumn, 0, 2)
        #self.AddSessionDataForTab1(sorted_sessionStats)

        # Create second tab
        self.content_widget = QWidget()
        self.tab2.setWidget(self.content_widget)
        self.flay = QGridLayout(self.content_widget)
        self.tab2.setWidgetResizable(True)

        self.leftColumn = QLabel('Instance Name:', self)
        self.leftColumn.setFont(boldFont)
        self.middleColumn = QLabel('Instance Count:', self)
        self.middleColumn.setFont(boldFont)
        self.rightColumn = QLabel('Avg Time in Instance(secs):', self)
        self.rightColumn.setFont(boldFont)
        self.flay.addWidget(self.leftColumn, 0, 0)
        self.flay.addWidget(self.middleColumn, 0, 1)
        self.flay.addWidget(self.rightColumn, 0, 2)
        #self.AddTotalDataForTab2(sorted_totalStats)

        #Create third tab
        self.tab3.layout = QGridLayout(self)
        self.textbox = QLineEdit(self)
        self.textbox.resize(50, 40)
        self.pathLabel = QLabel('Client.txt location', self)
        self.browseButton = QPushButton('Browse')
        self.browseButton.clicked.connect(self.on_click)

        self.tab3.layout.addWidget(self.pathLabel, 0, 0)
        self.tab3.layout.addWidget(self.textbox, 0, 1)
        self.tab3.layout.addWidget(self.browseButton, 0, 2)
        self.tab3.setLayout(self.tab3.layout)

        print(self.textbox.text())

        # Add tabs to widget
        self.layout.addWidget(self.tabs)
        self.setLayout(self.layout)
        self.tabs.resize(300, 100)
Ejemplo n.º 19
0
import sys
#这里我们提供必要的引用。基本控件位于pyqt5.qtwidgets模块中。
from PyQt5.QtWidgets import QApplication, QWidget

if __name__ == '__main__':
    #每个pyqt5应用程序必须创建一个应用程序对象。sys.argv参数是一个列表,从命令行输入参数。
    app = QApplication(sys.argv)
#QWidget部件是pyqt5所有用户界面对象的基类。他为QWidget提供默认构造函数。默认构造函数没有父类。
w = QWidget()
#resize()方法调整窗口的大小。这里是250px宽150px高
w.resize(250, 150)
#move()方法移动窗口在屏幕上的位置到x = 300,y = 300坐标。
w.move(300, 300)
#设置窗口的标题
w.setWindowTitle('Simple')
#显示在屏幕上
w.show()

#系统exit()方法确保应用程序干净的退出
#exec_()方法有下划线。因为执行是一个Python关键词。因此,exec_()代替
sys.exit(app.exec_())
Ejemplo n.º 20
0
 def mouseDoubleClickEvent(self, event):
     """双击标题栏事件"""
     self.showMaximized()
     return QWidget().mouseDoubleClickEvent(event)
#python用户图形界面编程实现
import sys  #简单用户图形界面实现
from PyQt5.QtWidgets import  QApplication,QWidget,QPushButton
from PyQt5.QtGui import QIcon
import sys

app=QApplication(sys.argv)   #sys.argv是一组命令行参数的列表
w=QWidget()              #QWidget控件是一个用户界面的基本控件,这里是一个窗口(window)
w.resize(500,800)        #窗口的大小设置,宽和高
w.move(900,300)    #修改控件位置的方法
w.setWindowTitle("大数据与数据挖掘")     #窗口添加标题
w.setWindowIcon(QIcon("rose-1.jpg"))      #设置标题图标
w.show()
sys.exit(app.exec())  #关闭界面窗口
Ejemplo n.º 22
0
 def mouseReleaseEvent(self, event):
     """鼠标弹起事件"""
     self.mPos = None
     return QWidget().mouseReleaseEvent(event)
Ejemplo n.º 23
0
    def setupUi(self):
        self.gridLayoutWidget = QWidget(self)
        self.gridLayoutWidget.setGeometry(QtCore.QRect(0, 0, 500, 350))
        self.gridLayoutWidget.setObjectName("gridLayoutWidget")
        self.gridLayout = QGridLayout(self.gridLayoutWidget)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setObjectName("gridLayout")

        self.tips_lab = QLabel(self.gridLayoutWidget)
        self.tips_lab.setMaximumSize(QtCore.QSize(130, 15))
        self.tips_lab.setText('暂不支持stmp')
        self.tips_lab.setObjectName("tips_lab")
        self.gridLayout.addWidget(self.tips_lab, 0, 0, 1, 1)

        self.email_list = QListWidget(self.gridLayoutWidget)
        for record in self._email_records:
            item = QListWidgetItem(record['addr'])
            if record['is_default'] == 1:
                brush = QtGui.QBrush(QtGui.QColor(1, 203, 31))
                brush.setStyle(QtCore.Qt.NoBrush)
                item.setForeground(brush)
            item.data = record
            self.email_list.addItem(item)
        self.email_list.itemClicked.connect(self.set_email_config_form)
        self.gridLayout.addWidget(self.email_list, 1, 0, 4, 4)

        self.default_email_btn = QPushButton(self.gridLayoutWidget)
        self.default_email_btn.setText('设置默认')
        self.default_email_btn.clicked.connect(self._selectDefualt)
        self.gridLayout.addWidget(self.default_email_btn, 5, 0, 1, 1)

        self.del_email_btn = QPushButton(self.gridLayoutWidget)
        self.del_email_btn.setText('删除')
        self.del_email_btn.clicked.connect(self.del_email_config)
        self.gridLayout.addWidget(self.del_email_btn, 5, 3, 1, 1)

        self.add_email_btn = QPushButton(self.gridLayoutWidget)
        self.add_email_btn.setText('添加邮箱')
        self.add_email_btn.clicked.connect(self.set_email_config_form)
        self.gridLayout.addWidget(self.add_email_btn, 5, 1, 1, 1)

        self.email_lab = QLabel(self.gridLayoutWidget)
        self.email_lab.setText('邮箱地址')
        self.gridLayout.addWidget(self.email_lab, 1, 4, 1, 1)

        self.email_le = QLineEdit(self.gridLayoutWidget)
        self.gridLayout.addWidget(self.email_le, 1, 5, 1, 2)

        self.password_lab = QLabel(self.gridLayoutWidget)
        self.password_lab.setText('密码')
        self.gridLayout.addWidget(self.password_lab, 2, 4, 1, 1)

        self.password_le = QLineEdit(self.gridLayoutWidget)
        self.gridLayout.addWidget(self.password_le, 2, 5, 1, 2)
        self.password_le.setEchoMode(QLineEdit.Password)

        self.ssl_lab = QLabel(self.gridLayoutWidget)
        self.ssl_lab.setText('ssl端口')
        self.gridLayout.addWidget(self.ssl_lab, 3, 4, 1, 1)

        self.ssl_rbtn = QRadioButton(self.gridLayoutWidget)
        self.ssl_rbtn.setText("")
        self.ssl_rbtn.setObjectName("ssl_rbtn")
        self.ssl_rbtn.clicked.connect(self.chcek_radio_slot)
        self.gridLayout.addWidget(self.ssl_rbtn, 3, 5, 1, 1)

        self.ssl_port_le = QLineEdit(self.gridLayoutWidget)
        self.ssl_port_le.setObjectName("ssl_le")
        self.gridLayout.addWidget(self.ssl_port_le, 3, 6, 1, 1)

        self.sender_le = QLineEdit(self.gridLayoutWidget)
        self.sender_le.setObjectName("sender_le")
        self.gridLayout.addWidget(self.sender_le, 4, 5, 1, 2)

        self.sender_lab = QLabel(self.gridLayoutWidget)
        self.sender_lab.setText('发信名称')
        self.gridLayout.addWidget(self.sender_lab, 4, 4, 1, 1)

        self.save_email_btn = QPushButton(self.gridLayoutWidget)
        self.save_email_btn.setText('保存')
        self.save_email_btn.clicked.connect(self.save_email_config)
        self.gridLayout.addWidget(self.save_email_btn, 5, 6, 1, 1)
Ejemplo n.º 24
0
def get_item_source(msms):
    # 读取属性
    title = msms[0]
    info = msms[1]
    language = msms[2]
    url = msms[3]

    wight = QWidget()
    wight.setObjectName("widget_main")
    wight.setStyleSheet(
        "QWidget#widget_main{background:Transparent;border:0px solid grey;}QWidget#widget_main:hover{background-color:rgba(240,245,255,0.8);}")
    wight.setMinimumSize(QtCore.QSize(0, 100))
    wight.setMaximumSize(QtCore.QSize(16777215, 100))
    layout_main = QHBoxLayout()
    layout_main.setContentsMargins(11, 0, 11, 0)
    layout_main.setSpacing(6)
    layout_right = QVBoxLayout()
    layout_right_down = QHBoxLayout()  # 右下的横向布局

    pushButton_info = QtWidgets.QPushButton()
    pushButton_info.setStyleSheet(
        "QPushButton{background:Transparent;border:0px solid grey;text-align:left;color:Gray}")
    pushButton_info.setIcon(qtawesome.icon('fa.info-circle', color="Green"))
    pushButton_info.setText("")
    # pushButton_info.setWordWrap(True)
    layout_right_down.addWidget(pushButton_info)

    label_info = QtWidgets.QLabel()
    label_info.setStyleSheet("QLabel{background:Transparent;border:0px solid grey;}")
    font = QtGui.QFont()
    font.setFamily("微软雅黑")
    # font.setPointSize(7)
    label_info.setFont(font)
    label_info.setText(info)
    # label_info.setWordWrap(True)
    layout_right_down.addWidget(label_info)

    spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
    layout_right_down.addItem(spacerItem)

    layout_right_up = QHBoxLayout()  # 右上的横向布局
    label_tag = QtWidgets.QLabel()
    label_tag.setAlignment(QtCore.Qt.AlignCenter)
    label_tag.setStyleSheet("QLabel{background:Transparent;border:1px solid grey;border-radius:5px;}")
    label_tag.setMaximumHeight(20)
    font = QtGui.QFont()
    font.setFamily("微软雅黑")
    font.setPointSize(7)
    label_tag.setFont(font)
    label_tag.setText(f" {language} ")
    layout_right_up.addWidget(label_tag)
    label_title = QtWidgets.QLabel()
    font = QtGui.QFont()
    font.setFamily("微软雅黑")
    font.setPointSize(10)
    font.setBold(True)
    font.setWeight(50)
    label_title.setFont(font)
    label_title.setText(title)
    layout_right_up.addWidget(label_title)
    spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
    layout_right_up.addItem(spacerItem)
    layout_right.addLayout(layout_right_up)  # 右边的纵向布局
    layout_right.addLayout(layout_right_down)  # 右下角横向布局
    layout_main.addLayout(layout_right)  # 右边的布局
    wight.setLayout(layout_main)  # 布局给wight
    return wight  # 返回wight
Ejemplo n.º 25
0
    def __init__(self, parent, protx_hash=None, alias=None):
        '''
        Show information about registred Masternodes with given prot_hash,
        or Masternodes in manager with given alias.
        '''
        super(Dip3MNInfoDialog, self).__init__(parent)
        self.setMinimumSize(950, 450)
        self.setWindowIcon(read_QIcon('electrum-axe.png'))

        self.parent = parent
        self.gui = parent.gui
        self.manager = parent.manager
        self.mn_list = parent.mn_list
        self.diff_updated.connect(self.on_diff_updated)
        self.info_updated.connect(self.on_info_updated)

        if alias:
            self.mn = self.manager.mns.get(alias)
        else:
            self.mn = None

        if self.mn:
            self.protx_hash = self.mn.protx_hash
            self.setWindowTitle(_('%s Dip3 Masternode Info') % alias)
        elif protx_hash:
            self.protx_hash = protx_hash
            self.setWindowTitle(
                _('%s... Dip3 Masternode Info') % protx_hash[:32])

        if self.mn_list and self.protx_hash:
            mn_list = self.mn_list
            sml_entry = mn_list.protx_mns.get(self.protx_hash, {})
            self.diff_info = sml_entry.as_dict() if sml_entry else {}
            self.mn_list.register_callback(self.on_mn_list_diff_updated,
                                           ['mn-list-diff-updated'])
            self.mn_list.register_callback(self.on_mn_list_info_updated,
                                           ['mn-list-info-updated'])
            self.info = mn_list.protx_info.get(self.protx_hash, {})
            if not self.info and self.gui.network.is_connected():
                self.gui.network.run_from_another_thread(
                    self.gui.network.request_protx_info(self.protx_hash))
        else:
            self.diff_info = {}
            self.info = {}

        layout = QGridLayout()
        self.setLayout(layout)
        self.tabs = QTabWidget(self)
        self.close_btn = b = QPushButton(_('Close'))
        b.setDefault(True)
        b.clicked.connect(self.close)
        layout.addWidget(self.tabs, 0, 0, 1, -1)
        layout.setColumnStretch(0, 1)
        layout.addWidget(b, 1, 1)

        if self.mn:
            self.mn_tab = QWidget()
            self.mn_label = QLabel(_('Wallet Masternode: %s') % self.mn.alias)
            self.mn_view = QTextEdit()
            self.mn_view.setReadOnly(True)
            self.mn_view.setText(pformat(self.mn.as_dict()))
            mn_vbox = QVBoxLayout()
            mn_vbox.addWidget(self.mn_label)
            mn_vbox.addWidget(self.mn_view)
            self.mn_tab.setLayout(mn_vbox)
            self.tabs.addTab(self.mn_tab, _('Wallet'))
        if self.protx_hash:
            self.diff_info_tab = QWidget()
            self.diff_info_view = QTextEdit()
            self.diff_info_view.setReadOnly(True)
            self.diff_info_view.setText(pformat(self.diff_info))
            diff_info_vbox = QVBoxLayout()
            diff_info_vbox.addWidget(self.diff_info_view)
            self.diff_info_tab.setLayout(diff_info_vbox)
            self.tabs.addTab(self.diff_info_tab,
                             _('protx.diff data (merkle '
                               'root verified)'))

            self.info_tab = QWidget()
            self.info_view = QTextEdit()
            self.info_view.setReadOnly(True)
            self.info_view.setText(pformat(self.info))
            info_vbox = QVBoxLayout()
            info_vbox.addWidget(self.info_view)
            self.info_tab.setLayout(info_vbox)
            self.tabs.addTab(self.info_tab, _('protx.info data (unverified)'))
Ejemplo n.º 26
0
    def __setupUi(self):
        """
        Private method to perform the general setup of the configuration
        widget.
        """
        self.setObjectName("ConfigurationDialog")
        self.resize(900, 650)
        self.verticalLayout_2 = QVBoxLayout(self)
        self.verticalLayout_2.setSpacing(6)
        self.verticalLayout_2.setContentsMargins(6, 6, 6, 6)
        self.verticalLayout_2.setObjectName("verticalLayout_2")

        self.configSplitter = QSplitter(self)
        self.configSplitter.setOrientation(Qt.Horizontal)
        self.configSplitter.setObjectName("configSplitter")

        self.configListWidget = QWidget(self.configSplitter)
        self.leftVBoxLayout = QVBoxLayout(self.configListWidget)
        self.leftVBoxLayout.setContentsMargins(0, 0, 0, 0)
        self.leftVBoxLayout.setSpacing(0)
        self.leftVBoxLayout.setObjectName("leftVBoxLayout")
        self.configListSearch = E5ClearableLineEdit(
            self, self.tr("Enter search text..."))
        self.configListSearch.setObjectName("configListSearch")
        self.leftVBoxLayout.addWidget(self.configListSearch)
        self.configList = QTreeWidget()
        self.configList.setObjectName("configList")
        self.leftVBoxLayout.addWidget(self.configList)
        self.configListSearch.textChanged.connect(self.__searchTextChanged)

        self.scrollArea = QScrollArea(self.configSplitter)
        self.scrollArea.setFrameShape(QFrame.NoFrame)
        self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.scrollArea.setWidgetResizable(False)
        self.scrollArea.setObjectName("scrollArea")

        self.configStack = QStackedWidget()
        self.configStack.setFrameShape(QFrame.Box)
        self.configStack.setFrameShadow(QFrame.Sunken)
        self.configStack.setObjectName("configStack")
        self.scrollArea.setWidget(self.configStack)

        self.emptyPage = QWidget()
        self.emptyPage.setGeometry(QRect(0, 0, 372, 591))
        self.emptyPage.setObjectName("emptyPage")
        self.vboxlayout = QVBoxLayout(self.emptyPage)
        self.vboxlayout.setSpacing(6)
        self.vboxlayout.setContentsMargins(6, 6, 6, 6)
        self.vboxlayout.setObjectName("vboxlayout")
        spacerItem = QSpacerItem(20, 20, QSizePolicy.Minimum,
                                 QSizePolicy.Expanding)
        self.vboxlayout.addItem(spacerItem)
        self.emptyPagePixmap = QLabel(self.emptyPage)
        self.emptyPagePixmap.setAlignment(Qt.AlignCenter)
        self.emptyPagePixmap.setObjectName("emptyPagePixmap")
        self.emptyPagePixmap.setPixmap(
            QPixmap(os.path.join(getConfig('ericPixDir'), 'eric.png')))
        self.vboxlayout.addWidget(self.emptyPagePixmap)
        self.textLabel1 = QLabel(self.emptyPage)
        self.textLabel1.setAlignment(Qt.AlignCenter)
        self.textLabel1.setObjectName("textLabel1")
        self.vboxlayout.addWidget(self.textLabel1)
        spacerItem1 = QSpacerItem(20, 40, QSizePolicy.Minimum,
                                  QSizePolicy.Expanding)
        self.vboxlayout.addItem(spacerItem1)
        self.configStack.addWidget(self.emptyPage)

        self.verticalLayout_2.addWidget(self.configSplitter)

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Apply
                                          | QDialogButtonBox.Cancel
                                          | QDialogButtonBox.Ok
                                          | QDialogButtonBox.Reset)
        self.buttonBox.setObjectName("buttonBox")
        if (not self.fromEric
                and self.displayMode == ConfigurationWidget.DefaultMode):
            self.buttonBox.button(QDialogButtonBox.Apply).hide()
        self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(False)
        self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(False)
        self.verticalLayout_2.addWidget(self.buttonBox)

        self.setWindowTitle(self.tr("Preferences"))

        self.configList.header().hide()
        self.configList.header().setSortIndicator(0, Qt.AscendingOrder)
        self.configList.setSortingEnabled(True)
        self.textLabel1.setText(
            self.tr("Please select an entry of the list \n"
                    "to display the configuration page."))

        QMetaObject.connectSlotsByName(self)
        self.setTabOrder(self.configList, self.configStack)

        self.configStack.setCurrentWidget(self.emptyPage)

        self.configList.setFocus()
# Dołączenie modułów QApplication, QLabel z pakietu PyQt5.QtWidgets
from PyQt5.QtWidgets import QApplication, QLabel, QWidget, QFormLayout, QGridLayout

# Inicjalizacja okna aplikacji
app = QApplication([])

# Tworzenie widżetu przechowującego elementy interfejsu (np. pola tekstowe)
window = QWidget()

# Ustawienie tytułu okna
window.setWindowTitle('PyQt5 Lab')

# Ustawienie wielkości okna
window.setGeometry(100, 100, 280, 80)

# Ustawienie pozycji początkowej okna
window.move(60, 15)

# Tworzenie prostego tekstu tekstu do wyświetlenia
label_1 = QLabel("Tekst z pierwszego okna")

# Tworzenie drugiego tekstu do wyświetlenia
label_2 = QLabel("Tekst z drugiego okna")

# Tworzenie layoutu (dostępne są również inne typy layoutów np. rozmieszczające elementy automatycznie w pionie lub poziomie: QHBoxLayout, QVBoxLayout)
layout = QGridLayout()

# Dodanie pierwszego elementu do layoutu - do lewego górnego rogu
layout.addWidget(label_1, 0, 0)

# Dodanie drugiego elementu do layoutu - do prawego górnego rogu
Ejemplo n.º 28
0
    def initUI(self):
        #Key attribute creation
        self.statusBar()

        #Load config file
        self.configFile = 'config.scn'
        if os.path.exists(self.configFile):
            #If the file exists, load in the config data
            with open(self.configFile, 'rb') as inFile:
                self.configData = pickle.load(inFile)
                self.historyFileList = self.configData['historyFileList']
        else:
            self.historyFileList = []
            self.configData = dict()
            self.configData['historyFileList'] = self.historyFileList
            with open(self.configFile, 'wb') as outFile:
                pickle.dump(self.configData, outFile, protocol=3) #Use protocol 3 because the PI is on python 3.7

        #Main Layout creation
        self.CentralWindow = QWidget()
        MainLayout = QVBoxLayout()

        #self.setFixedWidth(600)
        #self.setFixedHeight(300)

        #Add the main buttons. Lots of detail later.
        ButtonHeight = 75
        ButtonStyleSheet = "QPushButton{ border-radius:8px;\
                            border: 1px solid;\
                            background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, \
                            stop: 0 #ccd9ff, stop: 1 #2b50bd); }\
                            QPushButton:pressed {background-color: #fae22d}"
        #UHF Button setup
        self.UHF_Button = QPushButton('UHF Scan')
        self.UHF_Button.clicked.connect(self.UHFScanMethod)
        self.UHF_Button.setFixedHeight(ButtonHeight)
        self.UHF_Button.setStyleSheet(ButtonStyleSheet)
        MainLayout.addWidget(self.UHF_Button)

        #VHF Button setup
        self.VHF_Button = QPushButton('VHF Scan')
        self.VHF_Button.clicked.connect(self.VHFScanMethod)
        self.VHF_Button.setFixedHeight(ButtonHeight)
        self.VHF_Button.setStyleSheet(ButtonStyleSheet)
        MainLayout.addWidget(self.VHF_Button)

        #Full Button setup
        self.Full_Button = QPushButton('Full Scan')
        self.Full_Button.clicked.connect(self.FullScanMethod)
        self.Full_Button.setFixedHeight(ButtonHeight)
        self.Full_Button.setStyleSheet(ButtonStyleSheet)
        MainLayout.addWidget(self.Full_Button)

        #Calibrate Button setup
        self.Calibrate_Button = QPushButton('Calibrate')
        self.Calibrate_Button.clicked.connect(self.calibrateMethod)
        self.Calibrate_Button.setFixedHeight(ButtonHeight)
        self.Calibrate_Button.setStyleSheet(ButtonStyleSheet)
        MainLayout.addWidget(self.Calibrate_Button)

        #Browse History Button setup
        self.browseHistory_Button = QPushButton('Browse History')
        self.browseHistory_Button.clicked.connect(self.browseHistoryMethod)
        self.browseHistory_Button.setFixedHeight(ButtonHeight)
        self.browseHistory_Button.setStyleSheet(ButtonStyleSheet)
        MainLayout.addWidget(self.browseHistory_Button)

        #Open the window and display the UI
        self.CentralWindow.setLayout(MainLayout)
        self.setCentralWidget(self.CentralWindow)
        self.setWindowTitle('Tactical Footprint Scanner')
        self.showMaximized()
Ejemplo n.º 29
0
 def flush(self):
     self.layout().setEnabled(False)
     QWidget().setLayout(self.layout())
     self.set_grid()
     self.repaint()
Ejemplo n.º 30
0
    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 MonetaryUnits 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 MonetaryUnits 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 or use the Trezor website instead."
                  ))
        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 MonetaryUnits.").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 MonetaryUnits "
              "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)