Exemplo n.º 1
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.tab2 = QWidget()
        self.tab2.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.tableWidget2 = QTableWidget(self.tab)
        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.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)
Exemplo n.º 2
0
    themeList.addItem("Ebony")
    themeList.addItem("Isabelle")

    colorGroupBox = QGroupBox("Custom gradient")

    grBtoY = QLinearGradient(0, 0, 1, 100)
    grBtoY.setColorAt(1.0, Qt.black)
    grBtoY.setColorAt(0.67, Qt.blue)
    grBtoY.setColorAt(0.33, Qt.red)
    grBtoY.setColorAt(0.0, Qt.yellow)
    pm = QPixmap(24, 100)
    pmp = QPainter(pm)
    pmp.setBrush(QBrush(grBtoY))
    pmp.setPen(Qt.NoPen)
    pmp.drawRect(0, 0, 24, 100)
    gradientBtoYPB = QPushButton()
    gradientBtoYPB.setIcon(QIcon(pm))
    gradientBtoYPB.setIconSize(QSize(24, 100))

    grGtoR = QLinearGradient(0, 0, 1, 100)
    grGtoR.setColorAt(1.0, Qt.darkGreen)
    grGtoR.setColorAt(0.5, Qt.yellow)
    grGtoR.setColorAt(0.2, Qt.red)
    grGtoR.setColorAt(0.0, Qt.darkRed)
    pmp.setBrush(QBrush(grGtoR))
    pmp.drawRect(0, 0, 24, 100)
    gradientGtoRPB = QPushButton()
    gradientGtoRPB.setIcon(QIcon(pm))
    gradientGtoRPB.setIconSize(QSize(24, 100))

    colorHBox = QHBoxLayout()
Exemplo n.º 3
0
    def __init__(self, project=None, parent=None):
        super(VideoWindow, self).__init__(parent)
        self.project = project
        self.setWindowTitle("Video")
        self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface)

        videoWidget = QVideoWidget()
        self.videoWidget = videoWidget
        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 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)   # Hide error Label

        # Set widget to contain window contents
        self.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)

        if self.project.current_animal.video_files:
            self.current_file = self.project.current_animal.video_files[0]
            self.current_time_range = [self.project.current_animal.video_init_time[0],
                                   self.project.current_animal.video_init_time[0] + self.project.current_animal.video_duration[0]]
            self.mediaPlayer.setMedia(QMediaContent(QUrl.fromLocalFile(self.current_file)))
            self.playButton.setEnabled(True)
        else:
            self.current_file = ''
            self.current_time_range = [0,0]
Exemplo n.º 4
0
    def __init__(self, modeldb, parent=None):
        """Initialize the StartTimeSetup instance."""
        super().__init__(parent=parent)

        self.modeldb = modeldb

        field_table_model = self.modeldb.field_table_model
        field_name_column = field_table_model.name_column

        # Scope selection (whole race vs a field).
        field_selection_widget = QGroupBox('Set up start times for:')

        scope_button_group = QButtonGroup()
        self.all_fields_radiobutton = QRadioButton('Entire race')
        self.all_fields_radiobutton.setChecked(True)
        scope_button_group.addButton(self.all_fields_radiobutton)
        self.selected_field_radiobutton = QRadioButton('A single field:')
        scope_button_group.addButton(self.selected_field_radiobutton)

        self.selected_field_combobox = QComboBox()
        self.selected_field_combobox.setModel(field_table_model)
        self.selected_field_combobox.setModelColumn(field_name_column)
        self.selected_field_combobox.setEnabled(False)

        field_selection_widget.setLayout(QHBoxLayout())
        field_selection_widget.layout().addWidget(self.all_fields_radiobutton)
        field_selection_widget.layout().addWidget(self.selected_field_radiobutton)
        field_selection_widget.layout().addWidget(self.selected_field_combobox)

        # Start time.
        start_time_widget = QGroupBox('Start time:')

        start_time_button_group = QButtonGroup()
        self.start_time_now_radiobutton = QRadioButton('Now')
        self.start_time_now_radiobutton.setChecked(True)
        start_time_button_group.addButton(self.start_time_now_radiobutton)
        self.start_time_specified_radiobutton = QRadioButton('At:')
        start_time_button_group.addButton(self.start_time_specified_radiobutton)
        self.start_time_datetimeedit = QDateTimeEdit() # Time "now" set in showEvent()
        self.start_time_datetimeedit.setDisplayFormat(defaults.DATETIME_FORMAT)
        self.start_time_datetimeedit.setEnabled(False)

        start_time_widget.setLayout(QHBoxLayout())
        start_time_widget.layout().addWidget(self.start_time_now_radiobutton)
        start_time_widget.layout().addWidget(self.start_time_specified_radiobutton)
        start_time_widget.layout().addWidget(self.start_time_datetimeedit)

        # Start time interval.
        interval_widget = QGroupBox('Interval:')

        interval_button_group = QButtonGroup()
        self.same_start_time_radiobutton = QRadioButton('Same for all')
        self.same_start_time_radiobutton.setChecked(True)
        interval_button_group.addButton(self.same_start_time_radiobutton)
        self.interval_start_time_radiobutton = QRadioButton('Use interval:')
        interval_button_group.addButton(self.interval_start_time_radiobutton)

        self.interval_lineedit = QLineEdit()
        self.interval_lineedit.setText(str(defaults.START_TIME_INTERVAL_SECS))
        self.interval_lineedit.setValidator(QRegExpValidator(QRegExp('[1-9][0-9]*')))
        interval_lineedit_group = QWidget()
        interval_lineedit_group.setLayout(QHBoxLayout())
        interval_lineedit_group.layout().addWidget(self.interval_lineedit)
        interval_lineedit_group.layout().addWidget(QLabel('secs'))
        interval_lineedit_group.setEnabled(False)

        interval_widget.setLayout(QHBoxLayout())
        interval_widget.layout().addWidget(self.same_start_time_radiobutton)
        interval_widget.layout().addWidget(self.interval_start_time_radiobutton)
        interval_widget.layout().addWidget(interval_lineedit_group)

        confirm_button = QPushButton('Assign Start Times')

        # Top-level widgets.
        self.setLayout(QVBoxLayout())
        self.layout().addWidget(field_selection_widget)
        self.layout().addWidget(start_time_widget)
        self.layout().addWidget(interval_widget)
        self.layout().addWidget(confirm_button)

        # Signals/slots plumbing.
        confirm_button.clicked.connect(self.handle_assign_start_times)
        self.selected_field_radiobutton.toggled.connect(self.selected_field_combobox.setEnabled)
        self.start_time_specified_radiobutton.toggled.connect(self.start_time_datetimeedit
                                                              .setEnabled)
        self.interval_start_time_radiobutton.toggled.connect(interval_lineedit_group
                                                             .setEnabled)
Exemplo n.º 5
0
    def init_ui(self):
        self.input = AutoMateLineEdit()
        self.input.setText(self.viewport_object.name)
        self.input.bind_on_unfocus(self.on_name_change)

        grid = QGridLayout()
        grid.setContentsMargins(0, 0, 0, 0)
        grid.setSpacing(0)
        grid.addWidget(self.input, 0, 0, 1, 3)

        close = QPushButton("X")
        close.clicked.connect(self.on_remove)
        grid.addWidget(close, 0, 3)

        region_color = QPushButton("Select Color")
        region_color.clicked.connect(self.on_region_color_select)
        grid.addWidget(region_color, 1, 1)

        show_hide = "Hide" if self.viewport_object.region_shown else "Show"
        show_region = QPushButton(show_hide)
        show_region.clicked.connect(self.on_region_shown)
        grid.addWidget(show_region, 1, 2)

        show_in_vp = QPushButton()
        show_in_vp.clicked.connect(self.on_viewport_tab_show)
        icon = QIcon(get_icon("eyeIcon.png"))
        show_in_vp.setIcon(icon)
        grid.addWidget(show_in_vp, 1, 3)

        self.x = SliderLineEdit(self, "X", self.viewport_object.x,
                                self.on_x_changed, self.on_slider_drag)
        grid.addWidget(self.x, 2, 0, 1, 3)
        self.y = SliderLineEdit(self, "Y", self.viewport_object.y,
                                self.on_y_changed, self.on_slider_drag)
        grid.addWidget(self.y, 3, 0, 1, 3)
        self.width = SliderLineEdit(self, "Width", self.viewport_object.width,
                                    self.on_width_changed, self.on_slider_drag)
        grid.addWidget(self.width, 4, 0, 1, 3)
        self.height = SliderLineEdit(self, "Height",
                                     self.viewport_object.height,
                                     self.on_height_changed,
                                     self.on_slider_drag)
        grid.addWidget(self.height, 5, 0, 1, 3)

        self.combo_box = QComboBox(self)
        self.combo_box.blockSignals(True)
        self.combo_box.clear()
        for each in REGION_TYPES:
            self.combo_box.addItem(each)
        self.combo_box.setCurrentIndex(-1)
        self.combo_box.blockSignals(False)
        cur_index = self.combo_box.findText(str(self.viewport_object.type),
                                            Qt.MatchFixedString)
        self.combo_box.setCurrentIndex(cur_index)
        self.combo_box.currentIndexChanged.connect(self.on_type_changed)
        grid.addWidget(self.combo_box, 6, 0, 1, 4)
        if self.viewport_object.type == "Color Range Mask":
            hr = QFrame()
            hr.setFrameShape(QFrame.HLine)
            hr.setFrameShadow(QFrame.Sunken)
            hr.setLineWidth(2)
            grid.addWidget(hr, 7, 0, 1, 4)

            lower_bound = QPushButton("Lower Bound Color")
            lower_bound.clicked.connect(self.on_lower_bound_select)
            grid.addWidget(lower_bound, 8, 1, 1, 3)

            upper_bound = QPushButton("Upper Bound Color")
            upper_bound.clicked.connect(self.on_upper_bound_select)
            grid.addWidget(upper_bound, 9, 1, 1, 3)

        self.update_states()

        self.setLayout(grid)
Exemplo n.º 6
0
    def __init__(self, parent=None):
        super(ResultHandler, self).__init__()
        self.setWindowTitle('Dash results')
        self.control_label = QLabel()
        self.rendered_label = QLabel()
        self.diff_label = QLabel()

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

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

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

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

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

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

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

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

        button_layout = QHBoxLayout()
        button_layout.addWidget(next_image_button)
        button_layout.addWidget(QLabel('Mask diff multiplier:'))
        button_layout.addWidget(self.overload_spin)
        button_layout.addWidget(preview_mask_button)
        button_layout.addWidget(save_mask_button)
        button_layout.addStretch()
        v_layout.addLayout(button_layout)
        self.setLayout(v_layout)
    def initToolbar(self, webview):
        pass
        ###使用QToolBar创建导航栏,并使用QAction创建按钮
        # 添加导航栏
        self.navigation_bar = QToolBar('Navigation')
        # 锁定导航栏
        self.navigation_bar.setMovable(False)
        # 设定图标的大小
        self.navigation_bar.setIconSize(QSize(2, 2))
        # 添加导航栏到窗口中
        self.addToolBar(self.navigation_bar)
        # 添加其它配置
        self.navigation_bar.setObjectName("navigation_bar")
        self.navigation_bar.setCursor(Qt.ArrowCursor)
        # QAction类提供了抽象的用户界面action,这些action可以被放置在窗口部件中
        # 添加前进、后退、停止加载和刷新的按钮
        self.reload_icon = unichr(0xf2f9)
        self.stop_icon = unichr(0xf00d)

        # 后退按钮
        self.back_action = QWidgetAction(self)
        self.back_button = QPushButton(unichr(0xf060), self,
                                       clicked=webview.back,
                                       font=fontawesome("far"),
                                       objectName='back_button')
        self.back_button.setToolTip("后退")
        self.back_button.setCursor(Qt.ArrowCursor)
        self.back_action.setDefaultWidget(self.back_button)

        # 前进按钮
        self.next_action = QWidgetAction(self)
        self.next_button = QPushButton(unichr(0xf061), self,
                                       clicked=webview.forward,
                                       font=fontawesome("far"),
                                       objectName='next_button')
        self.next_button.setToolTip("前进")
        self.next_button.setCursor(Qt.ArrowCursor)
        self.next_action.setDefaultWidget(self.next_button)

        # 刷新与停止按钮
        self.reload_action = QWidgetAction(self)

        self.reload_button = QPushButton(self.reload_icon, self,
                                         clicked=webview.reload,
                                         font=fontawesome("far"),
                                         objectName='reload_button')
        self.reload_button.setToolTip("刷新")
        self.reload_button.setCursor(Qt.ArrowCursor)
        self.reload_action.setDefaultWidget(self.reload_button)

        # 放大按钮
        self.zoom_in_button = QPushButton(unichr(0xf067), self,
                                          clicked=self.zoom_in_func,
                                          font=fontawesome("far"),
                                          objectName='zoom_in_btn')
        self.zoom_in_button.setToolTip("放大")
        self.zoom_in_button.setCursor(Qt.ArrowCursor)

        # 缩小按钮
        self.zoom_out_button = QPushButton(unichr(0xf068), self,
                                           clicked=self.zoom_out_func,
                                           font=fontawesome("far"),
                                           objectName='zoom_out_btn')
        self.zoom_out_button.setToolTip("缩小")
        self.zoom_out_button.setCursor(Qt.ArrowCursor)
        self.sf_label_rate = QLabel()
        self.sf_label_rate.setObjectName("sf_label_rate")
        self.sf_label_rate.setFixedWidth(30)
        self.sf_label_rate.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignVCenter)
        self.sf_label_rate.setProperty("class","qlabel")
        self.sf_label_rate.setText(str(int(self.webview.zoomFactor()*100))+"%")

        # 全屏按钮
        self.full_screen_button = QPushButton(unichr(0xe140), self,
                                           clicked=self.full_screen_func,
                                           font=fontawesome("boot"),
                                           objectName='full_screen_button')
        self.full_screen_button.setToolTip("全屏")
        self.full_screen_button.setCursor(Qt.ArrowCursor)

        # 其它按钮
        self.more_action = QWidgetAction(self)
        self.more_button = QPushButton(unichr(0xe235), self,
                                       clicked=self.moreMenuShow,
                                       font=fontawesome("boot"),
                                       objectName='more_button')
        self.more_button.setToolTip("页面控制及浏览器核心")
        self.more_button.setCursor(Qt.ArrowCursor)
        self.more_action.setDefaultWidget(self.more_button)

        # 首页按钮
        self.index_action = QWidgetAction(self)
        self.index_button = QPushButton(unichr(0xf015), self,
                                        # clicked=self.zoom_out_func,
                                        font=fontawesome("far"),
                                        objectName='index_button')
        self.index_button.setToolTip("主页")
        self.index_button.setCursor(Qt.ArrowCursor)
        self.index_action.setDefaultWidget(self.index_button)

        # self.back_button.triggered.connect(webview.back)
        # self.next_button.triggered.connect(webview.forward)
        # self.reload_button.triggered.connect(webview.reload)
        # self.zoom_in_btn.triggered.connect(self.zoom_in_func)
        # self.zoom_out_btn.triggered.connect(self.zoom_out_func)
        # 将按钮添加到导航栏上
        self.navigation_bar.addAction(self.back_action)
        self.navigation_bar.addAction(self.next_action)
        self.navigation_bar.addAction(self.reload_action)
        self.navigation_bar.addAction(self.index_action)
        # 添加URL地址栏
        self.urlbar = QLineEdit()
        # 让地址栏能响应回车按键信号
        self.urlbar.returnPressed.connect(self.navigate_to_url)
        # self.navigation_bar.addSeparator()
        self.navigation_bar.addWidget(self.urlbar)
        # self.navigation_bar.addSeparator()

        # self.navigation_bar.addAction(self.zoom_in_action)
        # self.navigation_bar.addAction(self.zoom_out_action)
        self.navigation_bar.addAction(self.more_action)
        # 让浏览器相应url地址的变化
        webview.urlChanged.connect(self.renew_urlbar)
        webview.loadProgress.connect(self.processLoad)
        webview.loadStarted.connect(self.loadPage)
        webview.loadFinished.connect(self.loadFinish)
        webview.titleChanged.connect(self.renew_title)
        webview.iconChanged.connect(self.renew_icon)
        self.webBind()
        webview.show()
        self.navigation_bar.setIconSize(QSize(20, 20))
        self.urlbar.setFont(QFont('SansSerif', 13))
Exemplo n.º 8
0
    def __init__(self, *args, **kwargs):
        super(TitleBarUI, self).__init__(*args, **kwargs)
        self._mouse_pos = None  # 方向记录

        main_layout = QHBoxLayout()

        self.title_icon = QLabel(self)  # 图标
        self.title_icon.setPixmap(QPixmap("media/logo.png"))
        self.title_icon.setScaledContents(True)
        main_layout.addWidget(self.title_icon, alignment=Qt.AlignLeft)

        self.title_text = QLabel(WINDOW_TITLE, self)
        main_layout.addWidget(self.title_text, alignment=Qt.AlignLeft)

        main_layout.addStretch()  # 撑开按钮与标题图标的

        # 最大、小、隐藏按钮
        font = QFont()
        font.setFamily('Webdings')

        self.minimum_button = QPushButton('0', self)
        self.minimum_button.setFont(font)
        self.minimum_button.clicked.connect(self.window_shown_minimum)
        self.minimum_button.setFocusPolicy(Qt.NoFocus)
        main_layout.addWidget(self.minimum_button,
                              alignment=Qt.AlignRight | Qt.AlignTop)

        self.maximum_button = QPushButton('1', self)
        self.maximum_button.setFont(font)
        self.maximum_button.clicked.connect(self.window_shown_maximum)
        self.maximum_button.setFocusPolicy(Qt.NoFocus)
        main_layout.addWidget(self.maximum_button,
                              alignment=Qt.AlignRight | Qt.AlignTop)

        self.close_button = QPushButton('r', self)
        self.close_button.setFont(font)
        self.close_button.clicked.connect(self.window_closed)
        self.close_button.setFocusPolicy(Qt.NoFocus)
        main_layout.addWidget(self.close_button,
                              alignment=Qt.AlignRight | Qt.AlignTop)

        self.menu_bar_layout = QHBoxLayout()
        self.menu_bar = QMenuBar(self)

        main_layout.addLayout(self.menu_bar_layout)

        self.setLayout(main_layout)

        # 样式,相关属性,大小设置
        main_layout.setContentsMargins(QMargins(2, 0, 0, 0))
        main_layout.setSpacing(0)
        self.setFixedHeight(TITLE_BAR_HEIGHT)
        self.title_icon.setFixedSize(TITLE_BAR_HEIGHT, TITLE_BAR_HEIGHT)
        self.title_icon.setMargin(4)
        self.title_text.setMargin(3)
        self.minimum_button.setFixedSize(TITLE_BAR_HEIGHT, TITLE_BAR_HEIGHT)
        self.maximum_button.setFixedSize(TITLE_BAR_HEIGHT, TITLE_BAR_HEIGHT)
        self.close_button.setFixedSize(TITLE_BAR_HEIGHT, TITLE_BAR_HEIGHT)
        self.minimum_button.setObjectName('minimumButton')
        self.maximum_button.setObjectName('maximumButton')
        self.close_button.setObjectName('closeButton')
        self.setAttribute(Qt.WA_StyledBackground, True)
        self.setObjectName('titleBar')
        self.title_text.setObjectName('titleText')
        self.setStyleSheet(
            "#titleBar{background-color:rgb(34,102,175);border-top-left-radius:5px;border-top-right-radius:5px;}"
            "#titleText{color:rgb(245,245,245)}"
            "#minimumButton,#maximumButton{border:none;background-color:rgb(34,102,175);}"
            "#closeButton{border:none;background-color:rgb(34,102,175);border-top-right-radius:5px;}"
            "#minimumButton:hover,#maximumButton:hover{background-color:rgb(33,165,229)}"
            "#closeButton:hover{background-color:rgb(200,49,61);border-top-right-radius:5px;}"
            "#minimumButton:pressed,#maximumButton:pressed{background-color:rgb(37,39,41)}"
            "#closeButton:pressed{color:white;background-color:rgb(161,73,92);border-top-right-radius:5px;}"
        )
Exemplo n.º 9
0
    def initUI(self):

        
        self.layout = QGridLayout()
        self.setLayout(self.layout)
        self.btns = []
        self.spremi = QPushButton("Save")
        self.uvezi = QPushButton("Import")
        self.prebaci = QPushButton("Export to Excell")
        self.i = 0
        self.j = 0

        self.setAcceptDrops(True)
        self.scroll = QScrollArea()
        self.widget = QWidget()
        self.drag = QDrag(self)
        
        SL = []
        ST1 = []
        ST2 = []
        ostalo = []
        date = QDate()
        label = []
        maximum = 0
        minimum = 53
        
        cursor.execute('SELECT naziv, dana, rok FROM pozicija JOIN pozicijaNarudzba ON pozicija.nacrt = pozicijaNarudzba.nacrt JOIN narudzba ON pozicijaNarudzba.narudzbenica = narudzba.narudzbenica WHERE pozicija.nacrt IN (SELECT nacrt FROM tehnologijapozicija WHERE cnc LIKE "SL")')
        tmp = cursor.fetchall()
        
        for x in range(len(tmp)):
            SL.append(x)
        
        for x in range(len(tmp)):
            SL[x] = Stroj(tmp[x][2], tmp[x][0], tmp[x][1])
            
        
        cursor.execute('SELECT naziv, dana, rok FROM pozicija JOIN pozicijaNarudzba ON pozicija.nacrt = pozicijaNarudzba.nacrt JOIN narudzba ON pozicijaNarudzba.narudzbenica = narudzba.narudzbenica WHERE pozicija.nacrt IN (SELECT nacrt FROM tehnologijapozicija WHERE cnc LIKE "ST1")')
        tmp = cursor.fetchall()
        
        for x in range(len(tmp)):
            ST1.append(x)
        
        for x in range(len(tmp)):
            ST1[x] = Stroj(tmp[x][2], tmp[x][0], tmp[x][1])
        
        cursor.execute('SELECT naziv, dana, rok FROM pozicija JOIN pozicijaNarudzba ON pozicija.nacrt = pozicijaNarudzba.nacrt JOIN narudzba ON pozicijaNarudzba.narudzbenica = narudzba.narudzbenica WHERE pozicija.nacrt IN (SELECT nacrt FROM tehnologijapozicija WHERE cnc LIKE "ST2")')
        tmp = cursor.fetchall()
        
        for x in range(len(tmp)):
            ST2.append(x)
        
        for x in range(len(tmp)):
            ST2[x] = Stroj(tmp[x][2], tmp[x][0], tmp[x][1])
        
        cursor.execute('SELECT naziv, dana, rok FROM pozicija JOIN pozicijaNarudzba ON pozicija.nacrt = pozicijaNarudzba.nacrt JOIN narudzba ON pozicijaNarudzba.narudzbenica = narudzba.narudzbenica WHERE pozicija.nacrt IN (SELECT nacrt FROM tehnologijapozicija WHERE NOT cnc LIKE "SL" AND NOT cnc LIKE "ST1" AND NOT cnc LIKE "ST2")')
        tmp = cursor.fetchall()
        
        for x in range(len(tmp)):
            ostalo.append(x)
        
        for x in range(len(tmp)):
            ostalo[x] = Stroj(tmp[x][2], tmp[x][0], tmp[x][1])
        
        for x in range(7):
            label.append(0)
            
        label = (QLabel("Ponedjeljak"), QLabel("Utorak"), QLabel("Srijeda"), QLabel("Četvrtak"), QLabel("Petak"), QLabel("Subota"), QLabel("Nedjelja"))
        
        for x in range(7):
            self.layout.addWidget(label[x], 0, x+1)
            
        for x in range(len(SL)):
            date = date.fromString(str(SL[x].rok), "yyyy-MM-dd")
            SL[x].trajanje = math.ceil(SL[x].trajanje)
            date = date.addDays(-SL[x].trajanje)
            tmp = date.weekNumber()
            if int(str(tmp[0])) > maximum:
                maximum = tmp[0]
            if int(str(tmp[0])) < minimum:
                minimum = tmp[0]
                
        for x in range(len(ST1)):
            date = date.fromString(str(ST1[x].rok), "yyyy-MM-dd")
            ST1[x].trajanje = math.ceil(ST1[x].trajanje)
            date = date.addDays(-ST1[x].trajanje)
            tmp = date.weekNumber()
            if int(str(tmp[0])) > maximum:
                maximum = tmp[0]
            if int(str(tmp[0])) < minimum:
                minimum = tmp[0]
                
        for x in range(len(ST2)):
            date = date.fromString(str(ST2[x].rok), "yyyy-MM-dd")
            ST2[x].trajanje = math.ceil(ST2[x].trajanje)
            date = date.addDays(-ST2[x].trajanje)
            tmp = date.weekNumber()
            if int(str(tmp[0])) > maximum:
                maximum = tmp[0]
            if int(str(tmp[0])) < minimum:
                minimum = tmp[0]
                
        for x in range(len(ostalo)):
            date = date.fromString(str(ostalo[x].rok), "yyyy-MM-dd")
            ostalo[x].trajanje = math.ceil(ostalo[x].trajanje)
            date = date.addDays(-ostalo[x].trajanje)
            tmp = date.weekNumber()
            if int(str(tmp[0])) > maximum:
                maximum = tmp[0]
            if int(str(tmp[0])) < minimum:
                minimum = tmp[0]
                
        for x in range((maximum - minimum + 1) * 28):
            self.btns.append(0)
        
        for x in range(maximum - minimum + 1):
            label = QLabel(str(minimum + x)+". Tjedan")
            self.layout.addWidget(label, 1 + x * 5, 0)
            label = (QLabel("SL"), QLabel("ST1"), QLabel("ST2"), QLabel("Ostalo"))
            for y in range(4):
                self.layout.addWidget(label[y], 2 + y + x * 5, 0)
                for z in range(7):
                    self.btns[self.i] = Button("/", self)
                    self.btns[self.i].setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
                    self.layout.addWidget(self.btns[self.i], y + 2 + x * 5, z + 1)
                    self.i += 1
                    
        self.spremi.clicked.connect(self.toCSV)
        self.uvezi.clicked.connect(self.uvoz)
        self.prebaci.clicked.connect(self.izvoz)
        self.layout.addWidget(self.spremi, 1 + (maximum - minimum + 1) * 5, 3)
        self.layout.addWidget(self.uvezi, 1 + (maximum - minimum + 1) * 5, 4)
        self.layout.addWidget(self.prebaci, 1 + (maximum - minimum + 1) * 5, 5)
        
        self.ubaci(SL, minimum, date, 2)
                
        self.ubaci(ST1, minimum, date, 3)
                
        self.ubaci(ST2, minimum, date, 4)
                
        self.ubaci(ostalo, minimum, date, 5)
                
        
        self.widget.setLayout(self.layout)
        self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.scroll.setWidgetResizable(True)
        self.scroll.setWidget(self.widget)

        self.setCentralWidget(self.scroll)

        self.setWindowTitle('Raspored')
        self.showMaximized()
Exemplo n.º 10
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():
            filename = getOpenFileName(
                parent=self,
                title=_("Choose Homescreen"),
                config=config,
            )
            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 strict_safety_check():
            invoke_client('set_safety_checks', SafetyCheckLevel.Strict)

        def prompt_safety_check():
            invoke_client('set_safety_checks', SafetyCheckLevel.Prompt)

        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 QTUMs 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 QTUMs 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)

        safety_check_label = QLabel(_("Safety Check Level"))
        strict_safety_check_button = QPushButton("strict")
        strict_safety_check_button.clicked.connect(strict_safety_check)
        prompt_safety_check_button = QPushButton("prompt")
        prompt_safety_check_button.clicked.connect(prompt_safety_check)
        settings_glayout.addWidget(safety_check_label, 4, 0)
        settings_glayout.addWidget(strict_safety_check_button, 4, 1)
        settings_glayout.addWidget(prompt_safety_check_button, 4, 2)

        # 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, 5, 0)
        settings_glayout.addWidget(homescreen_change_button, 5, 1)
        settings_glayout.addWidget(homescreen_clear_button, 5, 2)
        settings_glayout.addWidget(homescreen_msg, 6, 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, 7, 0)
        settings_glayout.addWidget(timeout_slider, 7, 1, 1, 3)
        settings_glayout.addWidget(timeout_minutes, 7, 4)
        settings_glayout.addWidget(timeout_msg, 8, 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 QTUMs.").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 QTUMs "
              "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)
Exemplo n.º 11
0
    def select_storage(
            self, path,
            get_wallet_from_daemon) -> Tuple[str, Optional[WalletStorage]]:

        vbox = QVBoxLayout()
        hbox = QHBoxLayout()
        hbox.addWidget(QLabel(_('Wallet') + ':'))
        self.name_e = QLineEdit()
        hbox.addWidget(self.name_e)
        button = QPushButton(_('Choose...'))
        hbox.addWidget(button)
        vbox.addLayout(hbox)

        self.msg_label = QLabel('')
        vbox.addWidget(self.msg_label)
        hbox2 = QHBoxLayout()
        self.pw_e = QLineEdit('', self)
        self.pw_e.setFixedWidth(150)
        self.pw_e.setEchoMode(2)
        self.pw_label = QLabel(_('Password') + ':')
        hbox2.addWidget(self.pw_label)
        hbox2.addWidget(self.pw_e)
        hbox2.addStretch()
        vbox.addLayout(hbox2)
        self.set_layout(vbox, title=_('Electrum wallet'))

        self.temp_storage = WalletStorage(path, manual_upgrades=True)
        wallet_folder = os.path.dirname(self.temp_storage.path)

        def on_choose():
            path, __ = QFileDialog.getOpenFileName(self,
                                                   "Select your wallet file",
                                                   wallet_folder)
            if path:
                self.name_e.setText(path)

        def on_filename(filename):
            path = os.path.join(wallet_folder, filename)
            wallet_from_memory = get_wallet_from_daemon(path)
            try:
                if wallet_from_memory:
                    self.temp_storage = wallet_from_memory.storage
                else:
                    self.temp_storage = WalletStorage(path,
                                                      manual_upgrades=True)
                self.next_button.setEnabled(True)
            except BaseException:
                traceback.print_exc(file=sys.stderr)
                self.temp_storage = None
                self.next_button.setEnabled(False)
            user_needs_to_enter_password = False
            if self.temp_storage:
                if not self.temp_storage.file_exists():
                    msg =_("This file does not exist.") + '\n' \
                          + _("Press 'Next' to create this wallet, or choose another file.")
                elif not wallet_from_memory:
                    if self.temp_storage.is_encrypted_with_user_pw():
                        msg = _("This file is encrypted with a password.") + '\n' \
                              + _('Enter your password or choose another file.')
                        user_needs_to_enter_password = True
                    elif self.temp_storage.is_encrypted_with_hw_device():
                        msg = _("This file is encrypted using a hardware device.") + '\n' \
                              + _("Press 'Next' to choose device to decrypt.")
                    else:
                        msg = _("Press 'Next' to open this wallet.")
                else:
                    msg = _("This file is already open in memory.") + "\n" \
                        + _("Press 'Next' to create/focus window.")
            else:
                msg = _('Cannot read file')
            self.msg_label.setText(msg)
            if user_needs_to_enter_password:
                self.pw_label.show()
                self.pw_e.show()
                self.pw_e.setFocus()
            else:
                self.pw_label.hide()
                self.pw_e.hide()

        button.clicked.connect(on_choose)
        self.name_e.textChanged.connect(on_filename)
        n = os.path.basename(self.temp_storage.path)
        self.name_e.setText(n)

        while True:
            if self.loop.exec_() != 2:  # 2 = next
                raise UserCancelled
            if self.temp_storage.file_exists(
            ) and not self.temp_storage.is_encrypted():
                break
            if not self.temp_storage.file_exists():
                break
            wallet_from_memory = get_wallet_from_daemon(self.temp_storage.path)
            if wallet_from_memory:
                raise WalletAlreadyOpenInMemory(wallet_from_memory)
            if self.temp_storage.file_exists(
            ) and self.temp_storage.is_encrypted():
                if self.temp_storage.is_encrypted_with_user_pw():
                    password = self.pw_e.text()
                    try:
                        self.temp_storage.decrypt(password)
                        break
                    except InvalidPassword as e:
                        self.show_message(title=_('Error'), msg=str(e))
                        continue
                    except BaseException as e:
                        self.logger.exception('')
                        self.show_message(title=_('Error'), msg=str(e))
                        raise UserCancelled()
                elif self.temp_storage.is_encrypted_with_hw_device():
                    try:
                        self.run('choose_hw_device',
                                 HWD_SETUP_DECRYPT_WALLET,
                                 storage=self.temp_storage)
                    except InvalidPassword as e:
                        self.show_message(
                            title=_('Error'),
                            msg=_(
                                'Failed to decrypt using this hardware device.'
                            ) + '\n' +
                            _('If you use a passphrase, make sure it is correct.'
                              ))
                        self.reset_stack()
                        return self.select_storage(path,
                                                   get_wallet_from_daemon)
                    except BaseException as e:
                        self.logger.exception('')
                        self.show_message(title=_('Error'), msg=str(e))
                        raise UserCancelled()
                    if self.temp_storage.is_past_initial_decryption():
                        break
                    else:
                        raise UserCancelled()
                else:
                    raise Exception('Unexpected encryption version')

        return self.temp_storage.path, (
            self.temp_storage if self.temp_storage.file_exists() else None)  #
Exemplo n.º 12
0
    def request_trezor_init_settings(self, wizard, method, device_id):
        vbox = QVBoxLayout()
        next_enabled = True

        devmgr = self.device_manager()
        client = devmgr.client_by_id(device_id)
        if not client:
            raise Exception(_("The device was disconnected."))
        model = client.get_trezor_model()
        fw_version = client.client.version
        capabilities = client.client.features.capabilities
        have_shamir = Capability.Shamir in capabilities

        # label
        label = QLabel(_("Enter a label to name your device:"))
        name = QLineEdit()
        hl = QHBoxLayout()
        hl.addWidget(label)
        hl.addWidget(name)
        hl.addStretch(1)
        vbox.addLayout(hl)

        # Backup type
        gb_backuptype = QGroupBox()
        hbox_backuptype = QHBoxLayout()
        gb_backuptype.setLayout(hbox_backuptype)
        vbox.addWidget(gb_backuptype)
        gb_backuptype.setTitle(_('Select backup type:'))
        bg_backuptype = QButtonGroup()

        rb_single = QRadioButton(gb_backuptype)
        rb_single.setText(_('Single seed (BIP39)'))
        bg_backuptype.addButton(rb_single)
        bg_backuptype.setId(rb_single, BackupType.Bip39)
        hbox_backuptype.addWidget(rb_single)
        rb_single.setChecked(True)

        rb_shamir = QRadioButton(gb_backuptype)
        rb_shamir.setText(_('Shamir'))
        bg_backuptype.addButton(rb_shamir)
        bg_backuptype.setId(rb_shamir, BackupType.Slip39_Basic)
        hbox_backuptype.addWidget(rb_shamir)
        rb_shamir.setEnabled(Capability.Shamir in capabilities)
        rb_shamir.setVisible(False)  # visible with "expert settings"

        rb_shamir_groups = QRadioButton(gb_backuptype)
        rb_shamir_groups.setText(_('Super Shamir'))
        bg_backuptype.addButton(rb_shamir_groups)
        bg_backuptype.setId(rb_shamir_groups, BackupType.Slip39_Advanced)
        hbox_backuptype.addWidget(rb_shamir_groups)
        rb_shamir_groups.setEnabled(Capability.ShamirGroups in capabilities)
        rb_shamir_groups.setVisible(False)  # visible with "expert settings"

        # word count
        word_count_buttons = {}

        gb_numwords = QGroupBox()
        hbox1 = QHBoxLayout()
        gb_numwords.setLayout(hbox1)
        vbox.addWidget(gb_numwords)
        gb_numwords.setTitle(_("Select seed/share length:"))
        bg_numwords = QButtonGroup()
        for count in (12, 18, 20, 24, 33):
            rb = QRadioButton(gb_numwords)
            word_count_buttons[count] = rb
            rb.setText(_("{:d} words").format(count))
            bg_numwords.addButton(rb)
            bg_numwords.setId(rb, count)
            hbox1.addWidget(rb)
            rb.setChecked(True)

        def configure_word_counts():
            if model == "1":
                checked_wordcount = 24
            else:
                checked_wordcount = 12

            if method == TIM_RECOVER:
                if have_shamir:
                    valid_word_counts = (12, 18, 20, 24, 33)
                else:
                    valid_word_counts = (12, 18, 24)
            elif rb_single.isChecked():
                valid_word_counts = (12, 18, 24)
                gb_numwords.setTitle(_('Select seed length:'))
            else:
                valid_word_counts = (20, 33)
                checked_wordcount = 20
                gb_numwords.setTitle(_('Select share length:'))

            word_count_buttons[checked_wordcount].setChecked(True)
            for c, btn in word_count_buttons.items():
                btn.setVisible(c in valid_word_counts)

        bg_backuptype.buttonClicked.connect(configure_word_counts)
        configure_word_counts()

        # set up conditional visibility:
        # 1. backup_type is only visible when creating new seed
        gb_backuptype.setVisible(method == TIM_NEW)
        # 2. word_count is not visible when recovering on TT
        if method == TIM_RECOVER and model != "1":
            gb_numwords.setVisible(False)

        # PIN
        cb_pin = QCheckBox(_('Enable PIN protection'))
        cb_pin.setChecked(True)
        vbox.addWidget(WWLabel(RECOMMEND_PIN))
        vbox.addWidget(cb_pin)

        # "expert settings" button
        expert_vbox = QVBoxLayout()
        expert_widget = QWidget()
        expert_widget.setLayout(expert_vbox)
        expert_widget.setVisible(False)
        expert_button = QPushButton(_("Show expert settings"))
        def show_expert_settings():
            expert_button.setVisible(False)
            expert_widget.setVisible(True)
            rb_shamir.setVisible(True)
            rb_shamir_groups.setVisible(True)
        expert_button.clicked.connect(show_expert_settings)
        vbox.addWidget(expert_button)

        # passphrase
        passphrase_msg = WWLabel(PASSPHRASE_HELP_SHORT)
        passphrase_warning = WWLabel(PASSPHRASE_NOT_PIN)
        passphrase_warning.setStyleSheet("color: red")
        cb_phrase = QCheckBox(_('Enable passphrases'))
        cb_phrase.setChecked(False)
        expert_vbox.addWidget(passphrase_msg)
        expert_vbox.addWidget(passphrase_warning)
        expert_vbox.addWidget(cb_phrase)

        # ask for recovery type (random word order OR matrix)
        bg_rectype = None
        if method == TIM_RECOVER and model == '1':
            gb_rectype = QGroupBox()
            hbox_rectype = QHBoxLayout()
            gb_rectype.setLayout(hbox_rectype)
            expert_vbox.addWidget(gb_rectype)
            gb_rectype.setTitle(_("Select recovery type:"))
            bg_rectype = QButtonGroup()

            rb1 = QRadioButton(gb_rectype)
            rb1.setText(_('Scrambled words'))
            bg_rectype.addButton(rb1)
            bg_rectype.setId(rb1, RecoveryDeviceType.ScrambledWords)
            hbox_rectype.addWidget(rb1)
            rb1.setChecked(True)

            rb2 = QRadioButton(gb_rectype)
            rb2.setText(_('Matrix'))
            bg_rectype.addButton(rb2)
            bg_rectype.setId(rb2, RecoveryDeviceType.Matrix)
            hbox_rectype.addWidget(rb2)

        # no backup
        cb_no_backup = None
        if method == TIM_NEW:
            cb_no_backup = QCheckBox(f'''{_('Enable seedless mode')}''')
            cb_no_backup.setChecked(False)
            if (model == '1' and fw_version >= (1, 7, 1)
                    or model == 'T' and fw_version >= (2, 0, 9)):
                cb_no_backup.setToolTip(SEEDLESS_MODE_WARNING)
            else:
                cb_no_backup.setEnabled(False)
                cb_no_backup.setToolTip(_('Firmware version too old.'))
            expert_vbox.addWidget(cb_no_backup)

        vbox.addWidget(expert_widget)
        wizard.exec_layout(vbox, next_enabled=next_enabled)

        return TrezorInitSettings(
            word_count=bg_numwords.checkedId(),
            label=name.text(),
            pin_enabled=cb_pin.isChecked(),
            passphrase_enabled=cb_phrase.isChecked(),
            recovery_type=bg_rectype.checkedId() if bg_rectype else None,
            backup_type=bg_backuptype.checkedId(),
            no_backup=cb_no_backup.isChecked() if cb_no_backup else False,
        )
Exemplo n.º 13
0
    def passphrase_dialog(self, msg, confirm):
        # If confirm is true, require the user to enter the passphrase twice
        parent = self.top_level_window()
        d = WindowModalDialog(parent, _('Enter Passphrase'))

        OK_button = OkButton(d, _('Enter Passphrase'))
        OnDevice_button = QPushButton(_('Enter Passphrase on Device'))

        new_pw = PasswordLineEdit()
        conf_pw = PasswordLineEdit()

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

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

        vbox.addWidget(label)

        grid.addWidget(QLabel(_('Passphrase:')), 0, 0)
        grid.addWidget(new_pw, 0, 1)

        if confirm:
            grid.addWidget(QLabel(_('Confirm Passphrase:')), 1, 0)
            grid.addWidget(conf_pw, 1, 1)

        vbox.addLayout(grid)

        def enable_OK():
            if not confirm:
                ok = True
            else:
                ok = new_pw.text() == conf_pw.text()
            OK_button.setEnabled(ok)

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

        vbox.addWidget(OK_button)

        if self.passphrase_on_device:
            vbox.addWidget(OnDevice_button)

        d.setLayout(vbox)

        self.passphrase = None

        def ok_clicked():
            self.passphrase = new_pw.text()

        def on_device_clicked():
            self.passphrase = PASSPHRASE_ON_DEVICE

        OK_button.clicked.connect(ok_clicked)
        OnDevice_button.clicked.connect(on_device_clicked)
        OnDevice_button.clicked.connect(d.accept)

        d.exec_()
        self.done.set()
Exemplo n.º 14
0
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout
app = QApplication([])
window = QWidget()
layout = QVBoxLayout()
layout.addWidget(QPushButton('Top'))
layout.addWidget(QPushButton('Bottom'))
window.setLayout(layout)
window.show()
app.exec_()
Exemplo n.º 15
0
    def __init__(self, parent=None):
        super(QtMapSettingsWidget, self).__init__(parent)

        self.setStyleSheet("background-color: rgb(40,40,40); color: white")

        self.setSizePolicy(QSizePolicy.MinimumExpanding,
                           QSizePolicy.MinimumExpanding)
        self.setMinimumWidth(300)
        self.setMinimumHeight(100)

        TEXT_SPACE = 100

        ###########################################################

        layoutH0 = QHBoxLayout()

        self.lblMapFile = QLabel("Map File: ")
        self.lblMapFile.setFixedWidth(TEXT_SPACE)
        self.lblMapFile.setAlignment(Qt.AlignRight)
        self.editMapFile = QLineEdit("map.png")
        self.editMapFile.setStyleSheet(
            "background-color: rgb(55,55,55); border: 1px solid rgb(90,90,90)")
        self.editMapFile.setMinimumWidth(300)
        self.btnChooseMapFile = QPushButton("...")
        self.btnChooseMapFile.setMaximumWidth(20)
        self.btnChooseMapFile.clicked.connect(self.chooseMapFile)

        layoutH0.setAlignment(Qt.AlignLeft)
        layoutH0.addWidget(self.lblMapFile)
        layoutH0.addWidget(self.editMapFile)
        layoutH0.addWidget(self.btnChooseMapFile)
        layoutH0.addStretch()

        ###########################################################

        layoutH1 = QHBoxLayout()

        self.lblAcquisitionDate = QLabel("Acquisition Date: ")
        self.lblAcquisitionDate.setFixedWidth(TEXT_SPACE)
        self.lblAcquisitionDate.setAlignment(Qt.AlignRight)
        self.editAcquisitionDate = QLineEdit("YYYY-MM-DD")
        self.editAcquisitionDate.setStyleSheet(
            "background-color: rgb(55,55,55); border: 1px solid rgb(90,90,90)")
        self.editAcquisitionDate.setMinimumWidth(150)

        layoutH1.setAlignment(Qt.AlignLeft)
        layoutH1.addWidget(self.lblAcquisitionDate)
        layoutH1.addWidget(self.editAcquisitionDate)
        layoutH1.addStretch()

        ###########################################################

        layoutH2 = QHBoxLayout()

        self.lblScaleFactor = QLabel("Px-to-mm: ")
        self.lblScaleFactor.setFixedWidth(TEXT_SPACE)
        self.lblScaleFactor.setAlignment(Qt.AlignRight)
        self.editScaleFactor = QLineEdit("1.0")
        self.editScaleFactor.setMinimumWidth(150)
        self.editScaleFactor.setStyleSheet(
            "background-color: rgb(55,55,55); border: 1px solid rgb(90,90,90)")

        layoutH2.setAlignment(Qt.AlignLeft)
        layoutH2.addWidget(self.lblScaleFactor)
        layoutH2.addWidget(self.editScaleFactor)
        layoutH2.addStretch()

        ###########################################################

        layoutH3 = QHBoxLayout()

        self.btnCancel = QPushButton("Cancel")
        self.btnCancel.clicked.connect(self.close)
        self.btnApply = QPushButton("Apply")

        layoutH3.setAlignment(Qt.AlignRight)
        layoutH3.addStretch()
        layoutH3.addWidget(self.btnCancel)
        layoutH3.addWidget(self.btnApply)

        ###########################################################

        layoutV = QVBoxLayout()
        layoutV.addLayout(layoutH0)
        layoutV.addLayout(layoutH1)
        layoutV.addLayout(layoutH2)
        layoutV.addLayout(layoutH3)
        # layoutV.setSpacing(3)
        self.setLayout(layoutV)

        self.setWindowTitle("MAP SETTINGS")
Exemplo n.º 16
0
    def initUI(self):
        mainLayout = QVBoxLayout()

        grid1 = QGridLayout()
        grid1.setSpacing(10)
        
        # 消息框
        self.msgbox = QTextBrowser()
        self.msgbox.setReadOnly(True)
        self.msgbox.append(info)
        grid1.addWidget(self.msgbox, 0, 0, 1, 4)

        # 发送消息框
        self.input = QLineEdit()
        self.send_msg = QPushButton('发送')
        grid1.addWidget(self.input, 1, 0, 1, 3)
        grid1.addWidget(self.send_msg, 1, 3, 1, 1)
        self.send_msg.clicked.connect(self.sendMsg)

        # 消息发送板块
        msgGroupBox = QGroupBox('消息发送')
        msgGroupBox.setLayout(grid1)

        # 文件传输板块
        fileGroupBox = QGroupBox('文件传输')
        grid2 = QGridLayout()
        grid2.setSpacing(10)

        # 选择工作文件夹
        lbw = QLabel('文件夹:')
        self.fpath = QLineEdit('./client_files')
        sel_f = QPushButton('选择文件夹')
        grid2.addWidget(lbw, 2, 0, 1, 1)
        grid2.addWidget(self.fpath, 2, 1, 1, 3)
        grid2.addWidget(sel_f, 2, 4, 1, 1)
        sel_f.clicked.connect(self.showDialog)

        # 展示本机文件列表
        lbcf = QLabel('本机文件:')
        self.cflist = QListView()
        self.cmodel = QStandardItemModel(self.cflist)
        grid2.addWidget(lbcf, 4, 0, 1, 2)
        grid2.addWidget(self.cflist, 5, 0, 8, 2)

        # 展示服务器文件列表
        lbsf = QLabel('服务器文件:')
        self.sflist = QListView()
        self.smodel = QStandardItemModel(self.sflist)
        grid2.addWidget(lbsf, 4, 3, 1, 2)
        grid2.addWidget(self.sflist, 5, 3, 8, 2)

        # 添加操作按钮
        self.bsend = QToolButton()
        self.brec = QToolButton()
        self.bsend.setArrowType(Qt.RightArrow)
        self.brec.setArrowType(Qt.LeftArrow)
        self.brec.setEnabled(False)
        self.bsend.setEnabled(False)
        grid2.addWidget(self.bsend, 7, 2, 1, 1)
        grid2.addWidget(self.brec, 9, 2, 1, 1)
        self.bsend.clicked.connect(lambda : self.getList(self.cmodel, self.clist_num, 'sendf'))
        self.brec.clicked.connect(lambda : self.getList(self.smodel, self.slist_num, 'dwnf'))

        self.cmodel.itemChanged.connect(lambda: self.onChanged(self.clist_num, self.bsend))
        self.smodel.itemChanged.connect(lambda: self.onChanged(self.slist_num, self.brec))

        # 添加进度条
        self.pro = QProgressBar()
        grid2.addWidget(self.pro, 13, 0, 1, 5)

        fileGroupBox.setLayout(grid2)
        
        mainLayout.addWidget(msgGroupBox)
        mainLayout.addWidget(fileGroupBox)

        self.setLayout(mainLayout)

        self.resize(640, 640)
Exemplo n.º 17
0
    def initUI(self):
        # 执行时间标签
        self.time = QLabel('', self)
        self.time.move(100, 80)
        self.time.resize(200, 20)
        # ID标签
        self.sid = QLabel('ID', self)
        self.sid.move(25, 50)
        self.sid.resize(50, 20)
        # ID搜索框
        self.searchBar = QLineEdit(self)
        self.searchBar.move(100, 30)
        self.searchBar.resize(450, 50)
        # 搜索按钮
        self.searchButton = QPushButton("Search", self)
        self.searchButton.move(600, 30)
        self.searchButton.resize(80, 50)
        # 清空按钮
        self.clearButton = QPushButton("Clear", self)
        self.clearButton.move(700, 30)
        self.clearButton.resize(80, 50)
        # cnlabels
        self.cnlabels = QLabel('CNLABELS', self)
        self.cnlabels.move(15, 140)
        self.cnlabels.resize(50, 20)
        self.cnlabelsEdit = QTextEdit(self)
        self.cnlabelsEdit.move(100, 120)
        self.cnlabelsEdit.resize(680, 60)
        # enlabels
        self.enlabels = QLabel('ENLABELS', self)
        self.enlabels.move(15, 200)
        self.enlabels.resize(50, 20)
        self.enlabelsEdit = QTextEdit(self)
        self.enlabelsEdit.move(100, 180)
        self.enlabelsEdit.resize(680, 60)
        # descriptions
        self.descriptions = QLabel('DESCRIPTIONS', self)
        self.descriptions.move(15, 260)
        self.descriptions.resize(80, 20)
        self.descriptionsEdit = QTextEdit(self)
        self.descriptionsEdit.move(100, 240)
        self.descriptionsEdit.resize(680, 60)
        # aliases
        self.aliases = QLabel('ALIASES', self)
        self.aliases.move(15, 320)
        self.aliases.resize(80, 20)
        self.aliasesEdit = QTextEdit(self)
        self.aliasesEdit.move(100, 300)
        self.aliasesEdit.resize(680, 60)
        # properties
        self.properties = QLabel('PROPERTIES', self)
        self.properties.move(15, 380)
        self.properties.resize(80, 20)
        self.propertiesEdit = QTextEdit(self)
        self.propertiesEdit.move(100, 360)
        self.propertiesEdit.resize(680, 60)
        # datavalue
        self.datavalue = QLabel('DATAVALUE', self)
        self.datavalue.move(15, 440)
        self.datavalue.resize(80, 20)
        self.datavalueEdit = QTextEdit(self)
        self.datavalueEdit.move(100, 420)
        self.datavalueEdit.resize(680, 60)
        # qhash
        self.qhash = QLabel('QHASH', self)
        self.qhash.move(15, 500)
        self.qhash.resize(80, 20)
        self.qhashEdit = QTextEdit(self)
        self.qhashEdit.move(100, 480)
        self.qhashEdit.resize(680, 60)
        # qdatavalue
        self.qdatavalue = QLabel('QDATAVALUE', self)
        self.qdatavalue.move(15, 560)
        self.qdatavalue.resize(80, 20)
        self.qdatavalueEdit = QTextEdit(self)
        self.qdatavalueEdit.move(100, 540)
        self.qdatavalueEdit.resize(680, 60)
        # rhash
        self.rhash = QLabel('RHASH', self)
        self.rhash.move(15, 620)
        self.rhash.resize(80, 20)
        self.rhashEdit = QTextEdit(self)
        self.rhashEdit.move(100, 600)
        self.rhashEdit.resize(680, 60)
        # rdatavalue
        self.rdatavalue = QLabel('RDATAVALUE', self)
        self.rdatavalue.move(15, 680)
        self.rdatavalue.resize(80, 20)
        self.rdatavalueEdit = QTextEdit(self)
        self.rdatavalueEdit.move(100, 660)
        self.rdatavalueEdit.resize(680, 60)
        # snakorder
        self.snakorder = QLabel('SNAKORDER', self)
        self.snakorder.move(15, 740)
        self.snakorder.resize(80, 20)
        self.snakorderEdit = QTextEdit(self)
        self.snakorderEdit.move(100, 720)
        self.snakorderEdit.resize(680, 60)

        self.resize(800, 800)
        self.center()
        self.setWindowTitle('WikiData---ID-SEARCH')
        self.setWindowIcon(QIcon('icon.jpg'))
        self.show()
        self.searchButton.clicked.connect(self.fun)
        self.clearButton.clicked.connect(self.clear)
Exemplo n.º 18
0
    def __init__(self):
        self.app = QApplication([])
        visibleGui = QWidget()
        self.ipAddressBox = QLineEdit('opc.tcp://192.168.0.1:4840')
        self.ipAddressBox.setFixedWidth(200)
        self.ipStatusLabel = QLabel('Connection Status:')
        self.ipStatusButton = QPushButton("Not Connected")
        self.ipLabel = QLabel('&IP Address:')
        self.ipLabel.setBuddy(self.ipAddressBox)
        self.ipLabel.setBuddy(self.ipStatusButton)
        self.ipConnectPushButton = QPushButton('Connect')
        self.ipConnectPushButton.clicked.connect(self.tryConnect)

        topLayout = QHBoxLayout()
        topLayout.addWidget(self.ipLabel)
        topLayout.addWidget(self.ipAddressBox)
        topLayout.addWidget(self.ipConnectPushButton)
        topLayout.addStretch(1)
        topLayout.addWidget(self.ipStatusLabel)
        topLayout.addWidget(self.ipStatusButton)

        self.mainControlButtons = []
        self.mainControlButtons.append(QPushButton("External Servo ON"))    #[0] = EXSVON
        self.mainControlButtons.append(QPushButton("Safety Speed Enable"))  #[1] = Safety Speed Enable
        self.mainControlButtons.append(QPushButton("Emergency STOP"))       #[2] = ESTOP
        self.mainControlButtons.append(QPushButton("Play Mode Select"))     #[3] = PlayModeSel
        self.mainControlButtons.append(QPushButton("Master Job Call"))      #[4] = MasterJobCall
        self.mainControlButtons.append(QPushButton("External Start"))       #[5] = ExtStart
        self.mainControlButtons.append(QPushButton("External Hold"))        #[6] = ExtHold
        self.mainControlButtons.append(QPushButton("Start Pour Task"))      #[7] = StartPourTask
        self.mainControlButtons.append(QPushButton("Start Cap Task"))       #[8] = StartCapTask
        self.mainControlButtons.append(QPushButton("Return to Home Position"))      #[9] = ReturnHome

        leftLayout = QVBoxLayout()
        for button in self.mainControlButtons:
            button.setCheckable(True)
            leftLayout.addWidget(button)

        leftGroup = QGroupBox('Main Controls')
        leftGroup.setLayout(leftLayout)


        self.sensorReadouts = ['not a readout']
        for i in range(1,16):
            self.sensorReadouts.append(QPushButton("Sensor {}".format(i)))
        upper8SensorsLayout = QHBoxLayout()
        lower8SensorsLayout = QHBoxLayout()
        for i in range(1,16):
            if i < 9: upper8SensorsLayout.addWidget(self.sensorReadouts[i])
            else: lower8SensorsLayout.addWidget(self.sensorReadouts[i])
        refreshButton = QPushButton("Refresh Values")
        refreshButton.clicked.connect(self.updateValues)

        rightLayout = QGridLayout()
        rightLayout.addLayout(upper8SensorsLayout, 1,0,1,2)
        rightLayout.addLayout(lower8SensorsLayout, 1,0,2,2)
        rightLayout.addWidget(refreshButton)
        rightLayout.setRowStretch(1,1)
        rightLayout.setRowStretch(1,2)

        rightGroup = QGroupBox('Signal Readback')
        rightGroup.setLayout(rightLayout)



        mainLayout = QGridLayout()
        mainLayout.addLayout(topLayout, 0,0,1,2)
        mainLayout.addWidget(leftGroup,1,0)
        mainLayout.addWidget(rightGroup,1,1)
        mainLayout.setRowStretch(1, 1)
        mainLayout.setRowStretch(2, 1)
        mainLayout.setColumnStretch(0,1)
        mainLayout.setColumnStretch(1,1)

        visibleGui.setLayout(mainLayout)
        visibleGui.setWindowTitle('OPCUA Siemens 2019 GUI')
        visibleGui.show()
        self.app.exec_()
Exemplo n.º 19
0
from PyQt5.QtWidgets import QWidget,QApplication,QVBoxLayout,QPushButton
from PyQt5.QtGui import QIcon
import sys

# 创建PyQt程序(sys.argv 固定写法)
app = QApplication(sys.argv)
# 创建窗口
window = QWidget()
# 修改标题
window.setWindowTitle('水平布局')
# 创建布局
layout = QVBoxLayout()
# 设置窗口布局
window.setLayout(layout)
# 创建5个按钮
btn1 = QPushButton('1')
btn2 = QPushButton('2')
btn3 = QPushButton('3')
btn4 = QPushButton('4')
btn5 = QPushButton('5')
# 添加到布局中
layout.addWidget(btn1)
layout.addWidget(btn2)
layout.addWidget(btn3)
layout.addWidget(btn4)
layout.addWidget(btn5)

# 展示窗口
window.show()
# 等待窗口停止,退出操作
sys.exit(app.exec())
Exemplo n.º 20
0
    def __init__(self, parent=None):
        super(QWidget, self).__init__(parent)
        self.asset_dialog = AssetDialog(self)

        self.tool_bar = QToolBar()
        self.btn_add_asset = QPushButton("+")
        self.btn_add_asset.clicked.connect(self.add_symbol)
        self.tool_bar.addWidget(self.btn_add_asset)

        self.tab_layout = QTabWidget()
        vbox = QVBoxLayout()
        vbox.addWidget(self.tool_bar)
        vbox.addWidget(self.tab_layout)

        self.reload_btn, self.account_settings_btn = QToolButton(
        ), QToolButton()
        self.reload_btn.setIcon(QIcon('icons/cil-reload.png'))
        self.reload_btn.setToolTip('Reload the balance')
        self.account_settings_btn.setIcon(QIcon('icons/cil-settings.png'))
        self.account_settings_btn.setToolTip('Open the account settings')
        self.account_balance = QLineEdit('100.000 USD')
        self.account_balance.setFixedWidth(120)
        self.account_balance.setEnabled(False)
        self.balance_label = QLabel('Balance')
        self.balance_label.setFixedWidth(100)
        self.balance_label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        self.trades_count, self.trades_win, self.trades_lost = QLabel(
            '103'), QLabel('75 (72.81%)'), QLabel('28 (27.18%)')
        self.trades_count_label, self.trades_win_label, self.trades_lost_label = QLabel(
            'Trades : '), QLabel('Win : '), QLabel('Lost : ')

        main_layout = QVBoxLayout()
        titlebar_layout = QHBoxLayout()
        hbox1, hbox2, hbox3 = QHBoxLayout(), QHBoxLayout(), QHBoxLayout()

        # Create the trades options Layout
        hbox2.addWidget(self.trades_count_label)
        hbox2.addWidget(self.trades_count)
        hbox2.addWidget(self.trades_win_label)
        hbox2.addWidget(self.trades_win)
        hbox2.addWidget(self.trades_lost_label)
        hbox2.addWidget(self.trades_lost)
        hbox2.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)

        # Create the balance layout
        hbox3.addWidget(self.balance_label)
        hbox3.addWidget(self.account_balance)
        hbox3.addWidget(self.reload_btn)
        hbox3.addWidget(self.account_settings_btn)
        hbox3.setAlignment(Qt.AlignRight | Qt.AlignVCenter)

        self.w_title = QLabel("Trade Room")

        hbox1.addWidget(self.w_title)

        titlebar_layout.addLayout(hbox1, 3)
        titlebar_layout.addLayout(hbox2, 4)
        titlebar_layout.addLayout(hbox3, 3)

        css = open('styles/dark_theme.css', 'r').read()

        self.setStyleSheet(css)
        title_bar = QWidget()
        title_bar.setObjectName("TitleBar")
        title_bar.setLayout(titlebar_layout)

        main_layout.addWidget(title_bar)
        main_layout.addLayout(vbox)

        self.setLayout(main_layout)
Exemplo n.º 21
0
#!/usr/bin/env python
from PyQt5.QtWidgets import QApplication, QLabel, QLineEdit, QPushButton, QWidget, QBoxLayout, QMessageBox

app = QApplication([])
window = QWidget()
layout = QBoxLayout(QBoxLayout.Direction.TopToBottom)

settings_button = QPushButton("Settings")


def on_settings_button_clicked():
    alert = QMessageBox()
    alert.setText("Unimplemented")
    alert.exec_()


settings_button.clicked.connect(on_settings_button_clicked)
layout.addWidget(settings_button)

line_display = QLabel("TYPING LINE GOES HERE")
layout.addWidget(line_display)

typing_line = QLineEdit()
layout.addWidget(typing_line)

typing_speed = QLabel("Typing Speed: ??? Characters per minute")
layout.addWidget(typing_speed)

typing_proficiency = QLabel("Proficiency: 0")
layout.addWidget(typing_proficiency)
Exemplo n.º 22
0
    def setupUi(self, MnWndw_1):
        # Set layout for Mainwindow, including widgets
        # Main window
        MnWndw_1.setObjectName("MnWndw_1")
        MnWndw_1.resize(543, 434)
        self.cntrlWdgt = QWidget(MnWndw_1)
        self.cntrlWdgt.setObjectName("cntrlWdgt")
        self.grdLO_1 = QGridLayout(self.cntrlWdgt)
        self.grdLO_1.setObjectName("grdLO_1")

        # Insert widgets
        # Dialog button box, left down corner
        self.btnBx = QDialogButtonBox(self.cntrlWdgt)
        self.btnBx.setStandardButtons(QDialogButtonBox.Cancel
                                      | QDialogButtonBox.Ok)
        self.btnBx.setObjectName("btnBx")
        self.grdLO_1.addWidget(self.btnBx, 2, 1, 1, 1)
        self.HLO_3 = QHBoxLayout()
        self.HLO_3.setObjectName("HLO_3")
        # Add left push button
        self.pshBtn_2 = QPushButton(self.cntrlWdgt)
        self.pshBtn_2.setObjectName("pshBtn_2")
        self.HLO_3.addWidget(self.pshBtn_2)
        self.verticalLayout_3 = QVBoxLayout()
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.ChkBx = QCheckBox(self.cntrlWdgt)
        self.ChkBx.setObjectName("ChkBx")
        self.verticalLayout_3.addWidget(self.ChkBx)
        self.ChkBx_2 = QCheckBox(self.cntrlWdgt)
        self.ChkBx_2.setObjectName("ChkBx_2")
        self.verticalLayout_3.addWidget(self.ChkBx_2)
        self.ChkBx_3 = QCheckBox(self.cntrlWdgt)
        self.ChkBx_3.setObjectName("ChkBx_3")
        self.verticalLayout_3.addWidget(self.ChkBx_3)
        self.ChkBx_4 = QCheckBox(self.cntrlWdgt)
        self.ChkBx_4.setObjectName("ChkBx_4")
        self.verticalLayout_3.addWidget(self.ChkBx_4)
        self.line = QFrame(self.cntrlWdgt)
        self.line.setFrameShape(QFrame.HLine)
        self.line.setFrameShadow(QFrame.Sunken)
        self.line.setObjectName("line")
        self.verticalLayout_3.addWidget(self.line)
        self.ChkBx_5 = QCheckBox(self.cntrlWdgt)
        self.ChkBx_5.setObjectName("ChkBx_5")
        self.verticalLayout_3.addWidget(self.ChkBx_5)
        self.HLO_3.addLayout(self.verticalLayout_3)
        spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum,
                                 QSizePolicy.Expanding)
        self.HLO_3.addItem(spacerItem)
        self.grdLO_2 = QGridLayout()
        self.grdLO_2.setObjectName("grdLO_2")
        self.RadBtn_5 = QRadioButton(self.cntrlWdgt)
        self.RadBtn_5.setObjectName("RadBtn_5")
        self.grdLO_2.addWidget(self.RadBtn_5, 2, 1, 1, 1)
        self.RadBtn_4 = QRadioButton(self.cntrlWdgt)
        self.RadBtn_4.setObjectName("RadBtn_4")
        self.grdLO_2.addWidget(self.RadBtn_4, 4, 1, 1, 1)
        self.pshBtn = QPushButton(self.cntrlWdgt)
        self.pshBtn.setObjectName("pshBtn")
        self.grdLO_2.addWidget(self.pshBtn, 0, 0, 1, 1)
        self.RadBtn_2 = QRadioButton(self.cntrlWdgt)
        self.RadBtn_2.setObjectName("RadBtn_2")
        self.grdLO_2.addWidget(self.RadBtn_2, 0, 1, 1, 1)
        self.RadBtn_3 = QRadioButton(self.cntrlWdgt)
        self.RadBtn_3.setObjectName("RadBtn_3")
        self.grdLO_2.addWidget(self.RadBtn_3, 1, 1, 1, 1)
        self.RadBtn = QRadioButton(self.cntrlWdgt)
        self.RadBtn.setObjectName("RadBtn")
        self.grdLO_2.addWidget(self.RadBtn, 3, 1, 1, 1)
        self.HLO_3.addLayout(self.grdLO_2)
        self.grdLO_1.addLayout(self.HLO_3, 1, 1, 1, 1)
        self.HLO_4 = QHBoxLayout()
        self.HLO_4.setObjectName("HLO_4")
        self.lbl_2 = QLabel(self.cntrlWdgt)
        self.lbl_2.setObjectName("lbl_2")
        self.HLO_4.addWidget(self.lbl_2)
        self.lbl = QLabel(self.cntrlWdgt)
        self.lbl.setObjectName("lbl")
        self.HLO_4.addWidget(self.lbl)
        self.grdLO_1.addLayout(self.HLO_4, 0, 1, 1, 1)
        self.lineEdit = QLineEdit(self.cntrlWdgt)
        self.lineEdit.setObjectName("lineEdit")
        self.grdLO_1.addWidget(self.lineEdit, 3, 1, 1, 1)
        MnWndw_1.setCentralWidget(self.cntrlWdgt)
        self.menubar = QMenuBar(MnWndw_1)
        self.menubar.setGeometry(QRect(0, 0, 543, 26))
        self.menubar.setObjectName("menubar")
        self.menuFile = QMenu(self.menubar)
        self.menuFile.setObjectName("menuFile")
        MnWndw_1.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(MnWndw_1)
        self.statusbar.setObjectName("statusbar")
        MnWndw_1.setStatusBar(self.statusbar)
        self.actionExit = QAction(MnWndw_1)
        self.actionExit.setObjectName("actionExit")
        self.menuFile.addAction(self.actionExit)
        self.menubar.addAction(self.menuFile.menuAction())

        self.retranslateUi(MnWndw_1)
        self.ChkBx_5.toggled['bool'].connect(self.ChkBx_4.setChecked)
        self.ChkBx_5.toggled['bool'].connect(self.ChkBx_3.setChecked)
        self.ChkBx_5.toggled['bool'].connect(self.ChkBx_2.setChecked)
        self.ChkBx_5.toggled['bool'].connect(self.ChkBx.setChecked)
        self.btnBx.accepted.connect(self.lineEdit.clear)
        QMetaObject.connectSlotsByName(MnWndw_1)
Exemplo n.º 23
0
    def initUI(self):

        ########################################################################
        # ADD MENU ITEMS
        ########################################################################

        # Create the File menu
        self.menuFile = self.menuBar().addMenu("&File")
        self.actionSaveAs = QAction("&Save As", self)
        self.actionSaveAs.triggered.connect(self.saveas)
        self.actionQuit = QAction("&Quit", self)
        self.actionQuit.triggered.connect(self.close)
        self.menuFile.addActions([self.actionSaveAs, self.actionQuit])

        # Create the Help menu
        self.menuHelp = self.menuBar().addMenu("&Help")
        self.actionAbout = QAction("&About", self)
        self.actionAbout.triggered.connect(self.about)
        self.menuHelp.addActions([self.actionAbout])

        ########################################################################
        # CREATE CENTRAL WIDGET
        ########################################################################

        self.widget = QWidget()

        columntitle1 = QLabel('States')
        list1 = QLabel('A')
        list2 = QLabel('B')
        list3 = QLabel('C')
        list4 = QLabel('D')

        columntitle2 = QLabel('     Name')
        self.name1 = QLineEdit()
        self.name2 = QLineEdit()
        self.name3 = QLineEdit()
        self.name4 = QLineEdit()

        grid = QGridLayout()
        grid.setSpacing(5)

        grid.addWidget(columntitle1, 1, 0)
        grid.addWidget(list1, 2, 0)
        grid.addWidget(list2, 3, 0)
        grid.addWidget(list3, 4, 0)
        grid.addWidget(list4, 5, 0)

        grid.addWidget(columntitle2, 1, 1)
        grid.addWidget(self.name1, 2, 1)
        grid.addWidget(self.name2, 3, 1)
        grid.addWidget(self.name3, 4, 1)
        grid.addWidget(self.name4, 5, 1)

        grid.addWidget(QLabel('A'), 1, 2)
        grid.addWidget(QLabel('B'), 1, 3)
        grid.addWidget(QLabel('C'), 1, 4)
        grid.addWidget(QLabel('D'), 1, 5)

        #       Create Checkboxes
        self.cb1 = QCheckBox()
        self.cb2 = QCheckBox()
        self.cb3 = QCheckBox()
        self.cb4 = QCheckBox()
        self.cb5 = QCheckBox()
        self.cb6 = QCheckBox()
        self.cb7 = QCheckBox()
        self.cb8 = QCheckBox()
        self.cb9 = QCheckBox()
        self.cb10 = QCheckBox()
        self.cb11 = QCheckBox()
        self.cb12 = QCheckBox()
        self.cb13 = QCheckBox()
        self.cb14 = QCheckBox()
        self.cb15 = QCheckBox()
        self.cb16 = QCheckBox()

        #       Implement Checkboxes
        #        grid.addWidget(self.cb1, 2, 2)
        grid.addWidget(self.cb2, 2, 3)
        grid.addWidget(self.cb3, 2, 4)
        grid.addWidget(self.cb4, 2, 5)
        grid.addWidget(self.cb5, 3, 2)
        #        grid.addWidget(self.cb6, 3, 3)
        grid.addWidget(self.cb7, 3, 4)
        grid.addWidget(self.cb8, 3, 5)
        grid.addWidget(self.cb9, 4, 2)
        grid.addWidget(self.cb10, 4, 3)
        #        grid.addWidget(self.cb11, 4, 4)
        grid.addWidget(self.cb12, 4, 5)
        grid.addWidget(self.cb13, 5, 2)
        grid.addWidget(self.cb14, 5, 3)
        grid.addWidget(self.cb15, 5, 4)
        #        grid.addWidget(self.cb16, 5, 5)

        #       Create Button to Create Diagram
        self.generate = QPushButton('Generate')
        self.generate.clicked.connect(self.calculate)

        grid.addWidget(self.generate, 6, 8)

        self.widget.setLayout(grid)
        self.setCentralWidget(self.widget)

        self.setGeometry(600, 250, 350, 100)
        self.setWindowTitle('Machine State Diagram Generator')
        self.show()
Exemplo n.º 24
0
    def __init__(self, url, version, parent=0, f=0):
        super(LauncherUpdateDialog, self).__init__(parent, f)

        self.updated = False
        self.url = url

        layout = QGridLayout()

        self.shown = False
        self.qnam = QNetworkAccessManager()
        self.http_reply = None

        progress_label = QLabel()
        progress_label.setText(_('Progress:'))
        layout.addWidget(progress_label, 0, 0, Qt.AlignRight)
        self.progress_label = progress_label

        progress_bar = QProgressBar()
        layout.addWidget(progress_bar, 0, 1)
        self.progress_bar = progress_bar

        url_label = QLabel()
        url_label.setText(_('Url:'))
        layout.addWidget(url_label, 1, 0, Qt.AlignRight)
        self.url_label = url_label

        url_lineedit = QLineEdit()
        url_lineedit.setText(url)
        url_lineedit.setReadOnly(True)
        layout.addWidget(url_lineedit, 1, 1)
        self.url_lineedit = url_lineedit

        size_label = QLabel()
        size_label.setText(_('Size:'))
        layout.addWidget(size_label, 2, 0, Qt.AlignRight)
        self.size_label = size_label

        size_value_label = QLabel()
        layout.addWidget(size_value_label, 2, 1)
        self.size_value_label = size_value_label

        speed_label = QLabel()
        speed_label.setText(_('Speed:'))
        layout.addWidget(speed_label, 3, 0, Qt.AlignRight)
        self.speed_label = speed_label

        speed_value_label = QLabel()
        layout.addWidget(speed_value_label, 3, 1)
        self.speed_value_label = speed_value_label

        cancel_button = QPushButton()
        cancel_button.setText(_('Cancel update'))
        cancel_button.setStyleSheet('font-size: 15px;')
        cancel_button.clicked.connect(self.cancel_update)
        layout.addWidget(cancel_button, 4, 0, 1, 2)
        self.cancel_button = cancel_button

        layout.setColumnStretch(1, 100)

        self.setLayout(layout)
        self.setMinimumSize(300, 0)
        self.setWindowTitle(_('CDDA Game Launcher self-update'))
Exemplo n.º 25
0
    def initUI(self):

        self.now = 0

 
        self.timer = QBasicTimer()

        self.step = 0

 
        grid = QGridLayout()

        grid.setSpacing(10)

 
        self.holes = []

        n, k = 0, 0

        for i in range(9):

            self.holes.append(QPushButton("U",self))

            self.holes[i].setFlat(True)

            self.holes[i].setIcon(QIcon(UNACTIVE))

            self.holes[i].setIconSize(QSize(200,200))

 
            self.holes[i].clicked.connect(self.doAction)

 
            grid.addWidget(self.holes[i], n, k)

            if k < 2:

                k += 1

            else:

                n += 1

                k = 0

 
        self.count = QLabel('0')

        self.time = QLabel(str(TIME))

        self.runBtn = QPushButton("Запуск")

 
        grid.addWidget(self.count, n, 0)

        grid.addWidget(self.time, n, 1)

        grid.addWidget(self.runBtn, n, 2)

 
        self.runBtn.clicked.connect(self.startGame)

 
 
        self.setLayout(grid)

 
 
        self.setWindowTitle("Кроты")

        self.setGeometry(50,50,750,750)

        self.show()
Exemplo n.º 26
0
    def __init__(self, parameters, color, editable=False):
        """
            Init the ShowNewFile.
        """
        super().__init__()
        print(parameters)
        self.editable = editable
        """
            Here is a little hack: in the QTreeWidget (see below), we will add
            some QTreeWidgetItem. Each one of them will be removable. But each
            time we remove a QTreeWidgetItem, the index of the QTreeWidgetItem
            below it will be reindexed. So, we need to remember how many
            QTreeWidgetItem were deleted to calculate the old index.
            This is done throught a list. Each time we add a node, we add its
            id to the list. This way, when we delete the node, we search the
            position of its id in the list, and we delete the node at this
            position.
            The same process is used later for the node of other nodes.
        """
        self.nb_created = 0
        self.correspondence_index_position = []

        self.setMinimumSize(690, 500)
        tabs = QTabWidget()
        tabs.setFocusPolicy(Qt.NoFocus)  # prevent the "horrible orange box effect" on Ubuntu
        # set the style
        tabs.setStyleSheet(tabs.styleSheet() + """
        QTabBar::tab:!selected {
            color: rgb(242, 241, 240);
            background-color: rgb(0, 126, 148);
        }

        QTabBar::tab:selected {
            color: rgb(0, 126, 148);
        }
        """)

        # change the background color
        p = self.palette()
        red, green, blue, alpha = color
        p.setColor(self.backgroundRole(), QColor(red, green, blue, alpha))
        self.setPalette(p)

        # get the equation from the file
        list_data_equation = []
        for key in parameters["equation"]:
            if key == "D":
                first_coef_type = "D_0"
                second_coef_type = "E_D"
            elif key == "S":
                first_coef_type = "S_0"
                second_coef_type = "E_S"
            elif key == "Kr":
                first_coef_type = "Kr_0"
                second_coef_type = "E_r"
            

            sorted_coefficients = []
            sorted_coefficients.append(key)
            sorted_coefficients.append((first_coef_type, parameters["equation"][key][first_coef_type]))
            sorted_coefficients.append((second_coef_type, parameters["equation"][key][second_coef_type]))
            comment = parameters["equation"][key].get("comment", "")
            sorted_coefficients.append(("comment", comment))
            list_data_equation.append(sorted_coefficients)

        self.list_data_equation = list_data_equation
        # create a tab based on this informations
        tabs.addTab(makeWidget.make_scroll(self.make_vbox_from_data_equation(list_data_equation)), "Coefficients values")

        """
        # display a nice name for the area
        adatome_name = parameters["material"]["adatome"]
        adatome_name = str(adatome_name) if adatome_name is not None else "None"
        material_name = parameters["material"]["name"]
        material_name = str(material_name) if material_name is not None else "None"
        name_of_area = QLabel("diffusion of " + adatome_name + " in " + material_name)
        myFont=QFont()
        myFont.setBold(True)
        name_of_area.setFont(myFont)
        """

        material_container = makeWidget.make_vbox()
        material_container.setObjectName("material")
        gb_material = QGroupBox()
        gb_material.setTitle("material")
        gb_material.setObjectName("gb_material")
        grid_material = QGridLayout()
        grid_material.setObjectName("grid_material")
        gb_material.layout = grid_material
        gb_material.setLayout(gb_material.layout)

        gb_adatome = QGroupBox()
        gb_adatome.setTitle("adatome")
        gb_adatome.setObjectName("gb_adatome")
        grid_adatome = QGridLayout()
        grid_adatome.setObjectName("grid_adatome")
        gb_adatome.layout = grid_adatome
        gb_adatome.setLayout(gb_adatome.layout)

        material_container.layout.addWidget(gb_adatome)
        material_container.layout.addWidget(gb_material)

        adatome_counter = 0
        for key in ["adatome", "adatome_atomic_number", "adatome_atomic_symbol"]:
            value = ""
            try:
                value = str(parameters["material"][key])
            except KeyError:
                print("There is no key named", key, "in the file loaded, thus it is not possible to diplay this information.")
                if self.editable:
                    value = "None"
            if value:
                line = QLineEditWidthed(value, editable, "--------------")
                grid_adatome.addWidget(QLabel(key), adatome_counter, 0)
                grid_adatome.addWidget(line, adatome_counter, 1);
                adatome_counter += 1

        
        material_counter = 0
                # "name" : None,
        # "atomic_symbol" : None,
        # "lattice_type" : None,
        # "melting_point" : None,
        # "atomic_number" : None,
        # "mean_lattice_constant" : None,
        # "density" : None,

        # "adatome" : None,
        # "adatome_atomic_number" : None,
        # "adatome_atomic_symbol" : None

        keys = ("name", "atomic_symbol", "lattice_type", "melting_point", "atomic_number", "mean_lattice_constant", "density")
        units = ("", "", "", "K", "", "m", "atoms/m³")
        for key, unit in zip(keys, units):
            value = ""
            try:
                value = str(parameters["material"][key])
            except KeyError:
                print("There is no key named", key, "in the file loaded, thus it is not possible to diplay this information.")
                if self.editable:
                    value = "None"
            if value:
                line = QLineEditWidthed(value, editable, "--------------")
                grid_material.addWidget(QLabel(key), material_counter, 0)
                grid_material.addWidget(QLabel("     "), material_counter, 1)  # todo: find a better way to align Qlabels inside the grid
                grid_material.addWidget(line, material_counter, 2)

                if unit:
                    grid_material.addWidget(QLabel("("+unit+")"), material_counter, 3)
                    if key == "density":
                        eq_density = makeWidget.make_pixmap("ressources/latex_equation_density_resized.png")
                        grid_material.addWidget(eq_density, material_counter, 4)
                    else:
                        grid_material.addWidget(QLabel(""), material_counter, 4)
                material_counter += 1

        tabs.addTab(makeWidget.make_scroll(material_container), "Material")

        gridSource = QWidget()
        gridSource.layout = QGridLayout()
        gridSource.setLayout(gridSource.layout)
        gridSource.setObjectName("source")
        i = 0

        self.list_data_source = parameters["source"]
        # last edit
        prop = "last_edit"
        gridSource.layout.addWidget(QLabel(prop), i, 0)
        value = parameters["source"].get("last_edit", get_today_date())
        gridSource.layout.addWidget(QLineEditWidthed(value, False, "2019-07-01 10:56:89"), i, 1)
        i += 1

        # author_name
        prop = "author_name"
        gridSource.layout.addWidget(QLabel(prop), i, 0)
        value = parameters["source"][prop]
        if value is None:
            value = "None"
        elif type(value) is not str:
            value = "{:.2e}".format(float(value))
        gridSource.layout.addWidget(QLineEditWidthed(value, editable, "-------------------------------"), i, 1)
        i += 1

        # DOI
        prop = "doi"
        gridSource.layout.addWidget(QLabel(prop), i, 0)
        doi_api_success = False
        to_insert = None
        if not self.editable:
            try:
                import signal
                from crossref.restful import Works

                class TimeoutException(Exception):
                    pass

                def deadline(timeout, *args):
                    """
                        "decorator of a decorator" that allow the decorator
                        to accept an argument. If the decorated function didn't
                        finish before 'timeout' seconds, then a
                        TimeoutException is raised.
                    """
                    def decorate(f):
                        """ the decorator creation """
                        def handler(signum, frame):
                            """ the handler for the timeout """
                            raise TimeoutException()
                
                        def new_f(*args):
                            """ the initiation of the handler, 
                            the lauch of the function and the end of it"""
                            signal.signal(signal.SIGALRM, handler)
                            signal.alarm(timeout)
                            res = f(*args)
                            signal.alarm(0)
                            return res
                    
                        new_f.__name__ = f.__name__
                        return new_f
                    return decorate

                @deadline(3)
                def request_doi_api():
                    works = Works()
                    address = parameters["source"][prop]
                    data = works.doi(address)
                    if data:
                        value = data["URL"]
                        to_insert = QLabel("<html><a href=\"" + value + "\">" + value + "</a></html>")
                    else:
                        to_insert = None
                    return to_insert
                
                try:
                    # to_insert = request_doi_api()
                    if to_insert:
                        doi_api_success = True
                except TimeoutException:
                    print("time out")
            except Exception as e:
                print(e)
        if not doi_api_success:
            value = parameters["source"][prop]
            if value is None:
                value = "None"
            elif type(value) is not str:
                value = "{:.2e}".format(float(value))
            to_insert = QLineEditWidthed(value, editable, "https://doi.org/10.1016/j.nme.2018.11.020-------------")
        gridSource.layout.addWidget(to_insert, i, 1)
        i += 1
        # YEAR
        prop = "year"
        gridSource.layout.addWidget(QLabel(prop), i, 0)
        value = parameters["source"][prop]
        if value is None:
            value = "None"
        elif type(value) is not str:
            value = str(int(value))
        gridSource.layout.addWidget(QLineEditWidthed(value, editable, "------"), i, 1)
        i += 1

        tabs.addTab(makeWidget.make_scroll(gridSource), "Source")
        
        tree = QTreeWidget()
        tree.setItemsExpandable(False)
        tabs.setStyleSheet(tabs.styleSheet() + """
        QTreeWidget::item {
            margin: 3px 0;
        }
        """)
        if self.editable:
            tree.setColumnCount(4)
            tree.setHeaderLabels([
                "Density",
                "",
                "energy",
                "",
                "frequence",
                "",
                "Delete this trap",
                "Add data to this trap"
            ])
        else:
            tree.setColumnCount(2)
            tree.setHeaderLabels([
                "Density",
                "",
                "energy",
                "",
                "frequence",
                ""
            ])
        tree.header().resizeSection(0, 120)
        tree.header().resizeSection(1, 50)
        tree.header().resizeSection(2, 100)
        tree.header().resizeSection(3, 35)
        tree.header().resizeSection(4, 100)
        tree.header().resizeSection(5, 35)

        tree.header().resizeSection(6, 115)
        tree.header().resizeSection(7, 145)
        tree.header().setStretchLastSection(False)
        tree.setObjectName("traps")
        
        for trap in parameters["traps"]:
            tree_item_for_this_trap = self.create_subtree_for_a_trap(tree, trap)
            for data in trap["data"]:
                self.addEnergyToATrap(tree, tree_item_for_this_trap, data)
        vbox = makeWidget.make_vbox()
        vbox.layout.addWidget(tree)

        if self.editable:
            bt_add_new_trap = QPushButton("Add a trap")
            vbox.layout.addWidget(bt_add_new_trap)
            empty_trap = {"density":None, "angular_frequency":None, "energy":[]}
            bt_add_new_trap.clicked.connect(partial(self.create_subtree_for_a_trap, tree, empty_trap))
        comment = parameters.get("traps-comment", "")
        textedit = QTextEdit(comment)
        textedit.setReadOnly(not self.editable)
        textedit.setObjectName("traps-comment")
        tabs.addTab(makeWidget.make_vbox(vbox, textedit), "Traps")
        
        layout = QVBoxLayout()  # contient les tabs
        layout.addWidget(tabs)
        self.setLayout(layout)
        self.tabs = tabs
Exemplo n.º 27
0
 def __init__(self):
     super().__init__()
     layout = QBoxLayout(QBoxLayout.Direction.TopToBottom)
     self.backButton = QPushButton('Back')
     layout.addWidget(self.backButton, alignment=Qt.AlignCenter)
     self.setLayout(layout)
Exemplo n.º 28
0
    def __init__(self, map, annotations, blob, x, y, parent=None):
        super(QtCrackWidget, self).__init__(parent)

        self.setStyleSheet("background-color: rgb(60,60,65); color: white")

        self.qimg_cropped = utils.cropQImage(map, blob.bbox)
        arr = utils.qimageToNumpyArray(self.qimg_cropped)
        self.input_arr = rgb2gray(arr) * 255
        self.tolerance = 20
        self.annotations = annotations
        self.blob = blob
        self.xmap = x
        self.ymap = y
        self.qimg_crack = QImage(self.qimg_cropped.width(),
                                 self.qimg_cropped.height(),
                                 QImage.Format_RGB32)
        self.qimg_crack.fill(qRgb(0, 0, 0))

        self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.setFixedWidth(400)
        self.setFixedHeight(400)

        SLIDER_WIDTH = 200
        IMAGEVIEWER_SIZE = 300  # SIZE x SIZE

        self.sliderTolerance = QSlider(Qt.Horizontal)
        self.sliderTolerance.setFocusPolicy(Qt.StrongFocus)
        self.sliderTolerance.setMinimumWidth(SLIDER_WIDTH)
        self.sliderTolerance.setMinimum(1)
        self.sliderTolerance.setMaximum(100)
        self.sliderTolerance.setValue(self.tolerance)
        self.sliderTolerance.setTickInterval(5)
        self.sliderTolerance.setAutoFillBackground(True)
        self.sliderTolerance.valueChanged.connect(self.sliderToleranceChanged)

        self.lblTolerance = QLabel("Tolerance: 20")
        self.lblTolerance.setAutoFillBackground(True)
        str = "Tolerance {}".format(self.tolerance)
        self.lblTolerance.setText(str)

        layoutTolerance = QHBoxLayout()
        layoutTolerance.addWidget(self.lblTolerance)
        layoutTolerance.addWidget(self.sliderTolerance)

        self.viewer = QtImageViewer()
        self.viewer.disableScrollBars()
        self.viewer.setFixedWidth(IMAGEVIEWER_SIZE)
        self.viewer.setFixedHeight(IMAGEVIEWER_SIZE)

        self.btnCancel = QPushButton("Cancel")
        self.btnCancel.setAutoFillBackground(True)

        self.btnApply = QPushButton("Apply")
        self.btnApply.setAutoFillBackground(True)

        layoutButtons = QHBoxLayout()
        layoutButtons.addWidget(self.btnCancel)
        layoutButtons.addWidget(self.btnApply)

        layoutV = QVBoxLayout()
        layoutV.addLayout(layoutTolerance)
        layoutV.addWidget(self.viewer)
        layoutV.addLayout(layoutButtons)
        layoutV.setSpacing(10)
        self.setLayout(layoutV)

        self.viewer.setImg(self.qimg_cropped)
        self.preview()

        self.setAutoFillBackground(True)

        self.setWindowTitle("Create Crack")
        self.setWindowFlags(Qt.Window | Qt.CustomizeWindowHint
                            | Qt.WindowTitleHint)
Exemplo n.º 29
0
    def __init__(self, parent=None):
        super(lineEditDemo, self).__init__(parent)
        self.setWindowTitle('纪委')
        self.resize(1200, 800)

        #全局布局
        wlayout = QVBoxLayout()
        #局部布局 水平布局和 垂直布局
        hlayout1 = QHBoxLayout()
        hlayout2 = QHBoxLayout()
        hlayout3 = QHBoxLayout()
        hlayout4 = QHBoxLayout()
        hlayout5 = QHBoxLayout()
        hlayout6 = QHBoxLayout()
        vlayout = QVBoxLayout()

        #创建4个文本输入框
        self.name = QLineEdit()
        self.gender = QLineEdit()
        self.year = QLineEdit()
        self.id = QLineEdit()

        #添加到表单布局中
        #flo.addRow(文本名称(可以自定义),文本框)
        self.combo = QComboBox(self)
        typeLabel = QLabel("请选择你的人员类型")
        self.combo.addItem("")
        self.combo.addItem("村社干部")
        self.combo.addItem("雇员")
        self.combo.addItem("公务员")

        hlayout4.addWidget(typeLabel)
        hlayout4.addWidget(self.combo)

        self.combo1 = QComboBox(self)
        yearLabel = QLabel("请选择年度")
        self.combo1.addItem("")
        self.combo1.addItem("2020")
        self.combo1.addItem("2021")
        self.combo1.addItem("2022")
        hlayout5.addWidget(yearLabel)
        hlayout5.addWidget(self.combo1)
        #设置setPlaceholderText()文本框浮现的文字
        nameLabel = QLabel("请输入你的姓名")
        self.name.setPlaceholderText('姓名')

        hlayout1.addWidget(nameLabel)
        hlayout1.addWidget(self.name)

        genderLabel = QLabel("请输入你的性别")
        self.gender.setPlaceholderText('性别')

        hlayout2.addWidget(genderLabel)
        hlayout2.addWidget(self.gender)

        idLabel = QLabel("请输入你的身份证号")
        self.id.setPlaceholderText('身份证号')

        hlayout3.addWidget(idLabel)
        hlayout3.addWidget(self.id)

        self.label = QLabel(self)
        self.label.setText("显示图片")
        self.label.setFixedSize(300, 200)
        #self.label.move(400, 400)
        self.label.setStyleSheet(
            "border:2px solid red;font-size:20px;text-align:center;")

        self.btnButton1 = QPushButton('打开图片')
        self.btnButton1.clicked.connect(self.openimage)
        #点击确定校验是否符合规则
        self.btnButton = QPushButton('确定')
        # self.btnButton.clicked.connect(self.buttonClick)
        # self.btnButton.clicked.connect(self.onButtonClick)
        self.btnButton.clicked.connect(self.showsecond)
        #s=SecondWindow()
        #self.btnButton.clicked.connect(s.show)
        #self.btnButton.clicked.connect(self.buttonClick)
        #setEchoMode():设置显示效果

        #QLineEdit.Normal:正常显示所输入的字符,此为默认选项

        layout = QVBoxLayout()
        #设置窗口的布局
        #wlayout.addWidget(hlayout1)
        #wlayout.addWidget(hlayout2)
        #wlayout.addWidget(hlayout3)
        #wlayout.addWidget(hlayout4)
        #wlayout.addWidget(hlayout5)

        wlayout.addWidget(self.name)
        wlayout.addWidget(self.gender)

        wlayout.addWidget(self.id)
        wlayout.addWidget(self.combo)
        wlayout.addWidget(self.combo1)
        wlayout.addWidget(self.btnButton1)
        wlayout.addWidget(self.label)
        wlayout.addWidget(self.btnButton)

        self.setLayout(wlayout)
Exemplo n.º 30
0
 def insertButton(self):
     buttonInsert = QPushButton("Insertar", self)
     buttonInsert.clicked.connect(self.insertData)
     return buttonInsert