Exemplo n.º 1
0
 def __init__(self, width, height):
     super().__init__()
     self.SettingsChanged = False
     self.setWindowTitle('Settings')
     self.setGeometry(QRect(round((width - 400) / 2), round((height - 200) / 2), 400, 100))
     hBox1 = QHBoxLayout()
     self.lbPath = QLabel(self)
     self.lbPath.setText('File path:')
     self.lnEdit = QLineEdit(self)
     self.lnEdit.setText(output_path)
     self.lnEdit.setToolTip('Edit path')
     self.btnOpen = QPushButton(self)
     self.btnOpen.setIcon(QIcon(':/folder-icon'))
     self.btnOpen.setIconSize(QSize(24, 24))
     self.btnOpen.setToolTip('Choose folder to save downloaded files')
     self.btnOpen.clicked.connect(self.onOpenClicked)
     hBox1.addWidget(self.lbPath, 0)
     hBox1.addWidget(self.lnEdit, 1)
     hBox1.addWidget(self.btnOpen, 0)
     gbStream = QGroupBox(self)
     gbStream.setTitle('Stream type:')
     hBox2 = QHBoxLayout()
     self.btnProgressive = QRadioButton(self)
     self.btnProgressive.setText('progressive')
     self.btnProgressive.setToolTip('Streams with both audio and video tracks')
     self.btnProgressive.toggled.connect(lambda: self.onStreamType(self.btnProgressive.text()))
     self.btnAdaptive = QRadioButton(self)
     self.btnAdaptive.setText('adaptive')
     self.btnAdaptive.setToolTip('Streams with only audio or video track')
     self.btnAdaptive.toggled.connect(lambda: self.onStreamType(self.btnAdaptive.text()))
     self.btnAllStream = QRadioButton(self)
     self.btnAllStream.setText('all')
     self.btnAllStream.setToolTip('Lists all available downloads')
     self.btnAllStream.toggled.connect(lambda: self.onStreamType(self.btnAllStream.text()))
     if stream_type == 'progressive':
         self.btnProgressive.setChecked(True)
     elif stream_type == 'adaptive':
         self.btnAdaptive.setChecked(True)
     else:
         self.btnAllStream.setChecked(True)
     hBox2.addWidget(self.btnProgressive)
     hBox2.addWidget(self.btnAdaptive)
     hBox2.addWidget(self.btnAllStream)
     gbStream.setLayout(hBox2)
     gbSubtype = QGroupBox(self)
     gbSubtype.setTitle('Subtype')
     hBox3 = QHBoxLayout()
     self.btn3Gpp = QRadioButton(self)
     self.btn3Gpp.setText('3gpp')
     self.btn3Gpp.toggled.connect(lambda: self.onSubType(self.btn3Gpp.text()))
     self.btnMp4 = QRadioButton(self)
     self.btnMp4.setText('mp4')
     self.btnMp4.toggled.connect(lambda: self.onSubType(self.btnMp4.text()))
     self.btnWebm = QRadioButton(self)
     self.btnWebm.setText('webm')
     self.btnWebm.toggled.connect(lambda: self.onSubType(self.btnWebm.text()))
     hBox3.addWidget(self.btn3Gpp)
     hBox3.addWidget(self.btnMp4)
     hBox3.addWidget(self.btnWebm)
     gbSubtype.setLayout(hBox3)
     if subtype == '3gpp':
         self.btn3Gpp.setChecked(True)
     if subtype == 'webm':
         self.btnWebm.setChecked(True)
     else:
         self.btnMp4.setChecked(True)
     self.chbDlCap = QCheckBox(self)
     self.chbDlCap.setText('Download a caption if available')
     self.chbDlCap.setChecked(dl_cap)
     vBox = QVBoxLayout()
     vBox.addLayout(hBox1)
     vBox.addWidget(gbStream)
     vBox.addWidget(gbSubtype)
     vBox.addWidget(self.chbDlCap)
     self.btnBox = QDialogButtonBox(self)
     sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
     sizePolicy.setHorizontalStretch(0)
     sizePolicy.setVerticalStretch(0)
     sizePolicy.setHeightForWidth(self.btnBox.sizePolicy().hasHeightForWidth())
     self.btnBox.setSizePolicy(sizePolicy)
     self.btnBox.setOrientation(Qt.Horizontal)
     self.btnBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
     self.btnBox.accepted.connect(self.onOk)
     self.btnBox.rejected.connect(self.onCancel)
     vBox.addWidget(self.btnBox)
     self.setLayout(vBox)
Exemplo n.º 2
0
    def __init__(self,
                 standard_volume_names,
                 standard_organ_names,
                 rtss,
                 roi_id,
                 roi_name,
                 rename_signal,
                 suggested_text="",
                 *args,
                 **kwargs):
        super(RenameROIWindow, self).__init__(*args, **kwargs)

        if platform.system() == 'Darwin':
            self.stylesheet_path = "src/res/stylesheet.qss"
        else:
            self.stylesheet_path = "src/res/stylesheet-win-linux.qss"
        stylesheet = open(resource_path(self.stylesheet_path)).read()
        self.setStyleSheet(stylesheet)

        self.standard_volume_names = standard_volume_names
        self.standard_organ_names = standard_organ_names
        self.rtss = rtss
        self.roi_id = roi_id
        self.roi_name = roi_name
        self.rename_signal = rename_signal
        self.suggested_text = suggested_text

        self.setWindowTitle("Rename Region of Interest")
        self.setMinimumSize(300, 90)

        self.icon = QtGui.QIcon()
        self.icon.addPixmap(
            QtGui.QPixmap(resource_path("src/res/images/icon.ico")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)  # adding icon
        self.setWindowIcon(self.icon)

        self.explanation_text = QLabel("Enter a new name:")

        self.input_field = QLineEdit()
        self.input_field.setText(self.suggested_text)
        self.input_field.textChanged.connect(self.on_text_edited)

        self.feedback_text = QLabel()

        self.button_area = QWidget()
        self.cancel_button = QPushButton("Cancel")
        self.cancel_button.clicked.connect(self.close)
        self.rename_button = QPushButton("Rename")
        self.rename_button.clicked.connect(self.on_rename_clicked)

        self.button_layout = QHBoxLayout()
        self.button_layout.addWidget(self.cancel_button)
        self.button_layout.addWidget(self.rename_button)
        self.button_area.setLayout(self.button_layout)

        self.list_label = QLabel()
        self.list_label.setText("List of Standard Region of Interests")

        # Populating the table of ROIs
        self.list_of_ROIs = QListWidget()
        self.list_of_ROIs.addItem(
            "------------Standard Organ Names------------")
        for organ in self.standard_organ_names:
            self.list_of_ROIs.addItem(organ)

        self.list_of_ROIs.addItem(
            "------------Standard Volume Names------------")
        for volume in self.standard_volume_names:
            self.list_of_ROIs.addItem(volume)

        self.list_of_ROIs.clicked.connect(self.on_ROI_clicked)

        self.layout = QVBoxLayout()
        self.layout.addWidget(self.explanation_text)
        self.layout.addWidget(self.input_field)
        self.layout.addWidget(self.feedback_text)
        self.layout.addWidget(self.button_area)
        self.layout.addWidget(self.list_label)
        self.layout.addWidget(self.list_of_ROIs)
        self.setLayout(self.layout)
Exemplo n.º 3
0
	def to_pics(self,path):
		d_raw = QPixmap(path)
		d = QLabel()
		d.setPixmap(d_raw.scaledToHeight(100))
		return d
Exemplo n.º 4
0
 def _status_bar_add_label(self, value, stretch=0):
     widget = QLabel(value)
     self.status_bar.layout().addWidget(widget, stretch)
     return widget
Exemplo n.º 5
0
    def __init__(self, columns, condition):
        super().__init__()

        self.columns = columns

        # Strip df part
        condition = condition.replace('self.parent().df', '')

        # Strip brackets and quotes
        condition = condition.replace('["', '')
        condition = condition.replace('"]', '')
        condition = condition.replace('[\'', '')
        condition = condition.replace('\'[', '')

        self.layout = QGridLayout(self)

        line = QFrame()
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)

        self.condition_le = QLineEdit(condition)

        self.layout.addWidget(QLabel('Pandas-like condition string'), 0, 0)
        self.layout.addWidget(self.condition_le, 0, 1, 1, 3)
        self.layout.addWidget(line, 1, 0, 1, 4)

        # ----- Labels -----
        self.layout.addWidget(QLabel('Column:'), 2, 0)
        self.layout.addWidget(QLabel('Math operation (optional):'), 2, 1)
        self.layout.addWidget(QLabel('Operator:'), 2, 2)
        self.layout.addWidget(QLabel('Condition value:'), 2, 3)

        # Rolldown column selector
        column_box = QComboBox(self)
        for col in self.columns:
            column_box.addItem(col)
        self.layout.addWidget(column_box, 3, 0)

        # Optional mathematical operation on column
        self.layout.addWidget(QLineEdit(), 3, 1)

        # Rolldown comparison oeprators
        operator_box = QComboBox(self)
        operator_box.addItem('<')
        operator_box.addItem('>')
        operator_box.addItem('==')
        operator_box.addItem('!=')
        self.layout.addWidget(operator_box, 3, 2)

        # Editline value input
        self.layout.addWidget(QLineEdit(), 3, 3)

        # OK / cancel button
        self.button_layout = QHBoxLayout()
        ok_btn = QPushButton('OK')
        ok_btn.clicked.connect(self.construct_condition_string)
        ok_btn.clicked.connect(self.accept)

        clc_btn = QPushButton('Cancel')
        clc_btn.clicked.connect(self.reject)

        self.button_layout.addWidget(ok_btn)
        self.button_layout.addWidget(clc_btn)

        self.layout.addLayout(self.button_layout, 4, 0, 1, 4)

        self.setLayout(self.layout)
Exemplo n.º 6
0
    def create_template_build_widgets(self):
        # 输入模板名
        tip_name_text = QLabel("请在以下文本框中输入模板名")
        tip_name_hbox = QHBoxLayout()
        tip_name_hbox.addWidget(tip_name_text)
        template_name_text = QLabel("模板名")
        self.template_name_edit = QLineEdit()
        template_name_hbox = QHBoxLayout()
        template_name_hbox.addWidget(template_name_text)
        template_name_hbox.addWidget(self.template_name_edit)

        # 输入问句条件词
        tip_fq_condition_text = QLabel("输入问句条件词(英文名称在前且唯一,后面可跟多个中文解释)如:\n"
                                       "school 学校 高校")
        tip_fq_condition_hbox = QHBoxLayout()
        tip_fq_condition_hbox.addWidget(tip_fq_condition_text)
        fq_condition_text = QLabel("问句条件词")
        self.fq_condition_edit = QTextEdit()
        fq_condition_hbox = QHBoxLayout()
        fq_condition_hbox.addWidget(fq_condition_text)
        fq_condition_hbox.addWidget(self.fq_condition_edit)

        # 输入问句目标词
        tip_fq_target_text = QLabel("输入问句目标词(英文名称在前且唯一,后面可跟多个中文解释)如:\n"
                                    "numbers 招生人数 招生计划 招多少人 招生计划是多少 招生人数是多少")
        tip_fq_target_hbox = QHBoxLayout()
        tip_fq_target_hbox.addWidget(tip_fq_target_text)
        fq_target_text = QLabel("问句目标词")
        self.fq_target_edit = QTextEdit()
        fq_target_hbox = QHBoxLayout()
        fq_target_hbox.addWidget(fq_target_text)
        fq_target_hbox.addWidget(self.fq_target_edit)

        # 输入问句模板及对应的答句模板
        tip_template_sentence_text = QLabel("每行输入完整的模板句示例及对应的答案句模板,如:\n"
                                            "(school)(year)(major)(district)(classy)(numbers)\n"
                                            "(school)(year)(major)(district)(classy)招收(numbers)人")
        tip_template_sentence_hbox = QHBoxLayout()
        tip_template_sentence_hbox.addWidget(tip_template_sentence_text)
        template_sentence_text = QLabel("模板字段")
        self.template_sentence_edit = QTextEdit()
        template_sentence_hbox = QHBoxLayout()
        template_sentence_hbox.addWidget(template_sentence_text)
        template_sentence_hbox.addWidget(self.template_sentence_edit)

        self.input_btn = QPushButton("输入以上信息")
        self.input_btn.clicked.connect(self.analysis_input)
        input_btn_hbox = QHBoxLayout()
        input_btn_hbox.addWidget(self.input_btn)

        # 分析字段并返回给用户
        analysis_result_text = QLabel("字段分析结果")
        self.analysis_result = QTextEdit()
        analysis_result_hbox = QHBoxLayout()
        analysis_result_hbox.addWidget(analysis_result_text)
        analysis_result_hbox.addWidget(self.analysis_result)

        # 字段确认,进入模板构造阶段
        self.build_template_btn = QPushButton("模板构造")
        self.build_template_btn.clicked.connect(self.build_template)
        build_template_btn_hbox = QHBoxLayout()
        build_template_btn_hbox.addWidget(self.build_template_btn)

        # 构造模板显示
        template_build_result_text = QLabel("构造模板")
        self.template_build_result_edit = QTextEdit()
        template_build_result_hbox = QHBoxLayout()
        template_build_result_hbox.addWidget(template_build_result_text)
        template_build_result_hbox.addWidget(self.template_build_result_edit)

        main_vbox = QVBoxLayout()
        main_vbox.addLayout(tip_name_hbox)
        main_vbox.addLayout(template_name_hbox)
        main_vbox.addLayout(tip_fq_condition_hbox)
        main_vbox.addLayout(fq_condition_hbox)
        main_vbox.addLayout(tip_fq_target_hbox)
        main_vbox.addLayout(fq_target_hbox)
        main_vbox.addLayout(tip_template_sentence_hbox)
        main_vbox.addLayout(template_sentence_hbox)
        main_vbox.addLayout(input_btn_hbox)
        main_vbox.addLayout(analysis_result_hbox)
        main_vbox.addLayout(build_template_btn_hbox)
        main_vbox.addLayout(template_build_result_hbox)
        self.setLayout(main_vbox)
Exemplo n.º 7
0
    def initUI(self):
        # 执行时间标签
        self.time=QLabel('',self)
        self.time.move(100,80)
        self.time.resize(200, 20)
        # NMAE标签
        self.sid = QLabel('NAME', 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)

        # entity_id
        self.entity_id = QLabel('ENTITY_ID', self)
        self.entity_id.move(15, 140)
        self.entity_id.resize(50, 20)
        self.entity_idEdit=QTextEdit(self)
        self.entity_idEdit.move(100, 120)
        self.entity_idEdit.resize(680,60)

        # type
        self.type = QLabel('TYPE', self)
        self.type.move(15, 200)
        self.type.resize(50, 20)
        self.typeEdit = QTextEdit(self)
        self.typeEdit.move(100, 180)
        self.typeEdit.resize(680, 60)

        #len
        self.len = QLabel('LEN', self)
        self.len.move(15, 260)
        self.len.resize(80, 20)
        self.lenEdit = QTextEdit(self)
        self.lenEdit.move(100, 240)
        self.lenEdit.resize(680, 60)

        # lable
        self.lable = QLabel('LABLE', self)
        self.lable.move(15, 320)
        self.lable.resize(80, 20)
        self.lableEdit = QTextEdit(self)
        self.lableEdit.move(100, 300)
        self.lableEdit.resize(680, 160)

        #description
        self.description = QLabel('DESCRIPTION', self)
        self.description.move(15, 380)
        self.description.resize(80, 20)
        self.descriptionEdit = QTextEdit(self)
        self.descriptionEdit.move(100, 360)
        self.descriptionEdit.resize(680, 60)

        # alise
        self.aliases = QLabel('ALISE', self)
        self.aliases.move(15, 440)
        self.aliases.resize(80, 20)
        self.aliasesEdit = QTextEdit(self)
        self.aliasesEdit.move(100, 400)
        self.aliasesEdit.resize(680, 60)

        # site
        self.site = QLabel('SITE', self)
        self.site.move(15, 500)
        self.site.resize(80, 20)
        self.siteEdit = QTextEdit(self)
        self.siteEdit.move(100, 460)
        self.siteEdit.resize(680, 60)

        # title
        self.title = QLabel('TITLE', self)
        self.title.move(15, 560)
        self.title.resize(80, 20)
        self.titleEdit = QTextEdit(self)
        self.titleEdit.move(100, 520)
        self.titleEdit.resize(680, 60)

        self.resize( 800, 650)
        self.center()
        self.setWindowTitle('WikiData---Qs1 ID-Search')
        self.setWindowIcon(QIcon('icon.jpg'))
        self.show()
        self.searchButton.clicked.connect(self.fun)
        self.clearButton.clicked.connect(self.clear)
Exemplo n.º 8
0
    def init_UI(self):
        # Add core elements for the window
        self.lbl_tittle1 = QLabel("Batalla ", self)
        self.lbl_tittle1.setStyleSheet("font-weight: bold; color: white; font-family: century gothic; font-size: 29px")
        self.lbl_tittle1.move(450, 50)
        self.img_logo = QLabel(self)
        pixmap = QPixmap("Clases/images/imgTitle.png")
        self.img_logo.setPixmap(pixmap)
        self.img_logo.move(550, 5)
        self.img_logo.setMinimumSize(100, 100)
        self.lbl_tittle2 = QLabel("Naval ", self)
        self.lbl_tittle2.setStyleSheet("font-weight: bold; color: white; font-family: century gothic; font-size: 29px")
        self.lbl_tittle2.move(650, 50)

        # Button score
        self.btn_score = QPushButton('Ver puntuación', self)
        self.btn_score.resize(350, 60)
        self.btn_score.move(370, 250)
        self.btn_score.setStyleSheet(
            "background-color: #08AE9E; font-weight: bold; color: White; font-family: century gothic; font-size: 18px")

        # Button Log out
        self.btn_logout = QPushButton('Cerrar Sesión', self)
        self.btn_logout.resize(350, 60)
        self.btn_logout.move(370, 450)
        self.btn_logout.setStyleSheet(
            "background-color: #08AE9E; font-weight: bold; color: White; font-family: century gothic; font-size: 18px")
        self.btn_logout.clicked.connect(self.logout_clicked)

        # Button Send
        self.btn_send = QPushButton("Enviar", self)
        self.btn_send.resize(165, 35)
        self.btn_send.move(900, 580)
        self.btn_send.setStyleSheet(
            "background-color: #08AE9E; font-weight: bold; color: White; font-family: century gothic; font-size: 16px")
        self.btn_send.clicked.connect(self.play_clicked)

        # LabeL username
        self.lbl_username = QLabel(self.username, self)
        self.lbl_username.setStyleSheet("font-weight: bold; color: white; font-family: century gothic; font-size: 17px")
        self.lbl_username.move(1130, 95)

        # Label FRIENDS
        self.lbl_friends = QLabel("Amigos", self)
        self.lbl_friends.setStyleSheet("font-weight: bold; color: white; font-family: century gothic; font-size: 18px")
        self.lbl_friends.move(900, 133)

        # ListWidget list friends
        self.list_friends = QListWidget(self)
        self.list_friends.move(900, 170)
        self.list_friends.setMinimumSize(250, 400)
        self.list_friends.setStyleSheet(
            "background-color: #0277bd; font-weight: bold; color: White; font-family: century gothic; font-size: 15px")
        # "background-color: WHITE; font-weight: bold; color: BLACK; font-family: century gothic; font-size: 15px")

        # This window
        self.setFixedSize(1200, 650)
        self.center()
        self.setWindowTitle('Batalla Naval')
        self.setWindowIcon(QtGui.QIcon('Clases/images/b6.ico'))

        # Set the baackground image
        palette = QPalette()
        palette.setBrush(QPalette.Background, QBrush(QPixmap("Clases/images/fondo.png")))
        self.setPalette(palette)
        # self.timer = QTimer(self)
        # self.timer.timeout.connect(self.update_list)
        # self.timer.start(3000)
        self.windowGame = WindowBattle(self.selected_lenguage)
        self.windowGame.hide()
        self.show()
 def initUI(self):
     # ---  --- #
     self.layout      = QVBoxLayout(self)
     self.initView()
     # --- button widget --- #
     self.button_startstop = QPushButton('Start/Stop')
     self.button_startstop.setStyleSheet("background-color: red")
     self.button_nextFrame = QPushButton('Next frame')
     # ---  --- #
     self.fps_input     = QSpinBox()
     self.fps_input.setRange(1, 48)
     self.fps_input.setValue(self.fps)
     self.exposure      = QDoubleSpinBox()
     self.exposure.setSingleStep(0.01)
     self.cam_framerate = QDoubleSpinBox()
     self.exposure.setSingleStep(0.01)
     self.pixelclock    = QDoubleSpinBox()
     self.which_camera  = QComboBox()
     self.which_camera.addItem('USB camera')
     self.which_camera.addItem('From Image Dir.')
     # --- set default --- #
     self.exposure.setRange(0.10, 99.0)
     self.exposure.setValue(12.5)
     self.cam_framerate.setRange(1.00, 15.0)
     self.cam_framerate.setValue( 10.0 )
     self.pixelclock.setRange(5, 30)
     self.pixelclock.setValue(20)
     # --- connections --- #
     self.button_startstop.clicked.connect(self.startStop_continuous_view)
     self.fps_input.valueChanged.connect(self.setFPS)
     self.button_nextFrame.clicked.connect( self.nextFrame )
     self.exposure.valueChanged.connect( self.update_exposure )
     self.cam_framerate.valueChanged.connect( self.update_camFPS )
     self.pixelclock.valueChanged.connect( self.update_pixelClock )
     self.which_camera.currentIndexChanged.connect( self.changeCameraStyle )
     # --- layout --- #
     label_1 = QLabel('fps :')
     label_1.setWordWrap(True)
     label_2 = QLabel('value max:') 
     label_2.setWordWrap(True)
     label_3 = QLabel('Which camera')
     label_3.setWordWrap(True)
     label_4 = QLabel('Exposure (ms):')
     label_4.setWordWrap(True)
     label_5 = QLabel('Camera fps:')
     label_5.setWordWrap(True)
     label_6 = QLabel('Pixel clock (MHz):')
     label_6.setWordWrap(True)
     grid = QGridLayout()
     grid.addWidget( self.button_startstop, 0,0)
     grid.addWidget( self.button_nextFrame, 0,1)
     grid.addWidget( label_1              , 0,2)
     grid.addWidget( self.fps_input       , 0,3)
     grid.addWidget( label_2              , 0,4)
     grid.addWidget( self.qlabl_max       , 0,5)
     grid.addWidget(QVLine()              , 0,6 , 2,1)
     grid.addWidget(label_3               , 0,7)
     grid.addWidget( self.which_camera    , 1,7 , 2,1)
     grid.addWidget(label_4               , 1,0)
     grid.addWidget( self.exposure        , 1,1)
     grid.addWidget(label_5               , 1,2)
     grid.addWidget( self.cam_framerate   , 1,3)
     grid.addWidget(label_6               , 1,4)
     grid.addWidget( self.pixelclock      , 1,5)
     self.layout.addLayout(grid)
     self.layout.addWidget(self.image_view)
     self.setLayout(self.layout)
Exemplo n.º 10
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

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

        # word count
        gb = QGroupBox()
        hbox1 = QHBoxLayout()
        gb.setLayout(hbox1)
        vbox.addWidget(gb)
        gb.setTitle(_("Select your seed length:"))
        bg_numwords = QButtonGroup()
        word_counts = (12, 18, 24)
        for i, count in enumerate(word_counts):
            rb = QRadioButton(gb)
            rb.setText(_("{:d} words").format(count))
            bg_numwords.addButton(rb)
            bg_numwords.setId(rb, i)
            hbox1.addWidget(rb)
            rb.setChecked(True)

        # 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)
        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 not model == 'T':
            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, RECOVERY_TYPE_SCRAMBLED_WORDS)
            hbox_rectype.addWidget(rb1)
            rb1.setChecked(True)

            rb2 = QRadioButton(gb_rectype)
            rb2.setText(_('Matrix'))
            bg_rectype.addButton(rb2)
            bg_rectype.setId(rb2, RECOVERY_TYPE_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=word_counts[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,
            no_backup=cb_no_backup.isChecked() if cb_no_backup else False,
        )
Exemplo n.º 11
0
    def __init__(self, window, plugin, keystore, device_id):
        title = _("{} Settings").format(plugin.device)
        super(SettingsDialog, self).__init__(window, title)
        self.setMaximumWidth(540)

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

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

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

            thread.add(task, on_success=update)

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

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

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

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

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

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

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

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

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

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

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

        def wipe_device():
            wallet = window.wallet
            if wallet and sum(wallet.get_balance()):
                title = _("Confirm Device Wipe")
                msg = _("Are you SURE you want to wipe the device?\n"
                        "Your wallet still has Navcoins 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 Navcoins if they obtain physical "
                           "access to your {}.").format(plugin.device))
        pin_msg.setWordWrap(True)
        pin_msg.setStyleSheet("color: red")
        settings_glayout.addWidget(pin_msg, 3, 1, 1, -1)

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

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

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

        # Advanced tab - clear PIN
        clear_pin_button = QPushButton(_("Disable PIN"))
        clear_pin_button.clicked.connect(clear_pin)
        clear_pin_warning = QLabel(
            _("If you disable your PIN, anyone with physical access to your "
              "{} device can spend your Navcoins.").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 Navcoins "
              "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.º 12
0
    def __init__(self, mainGui):
        QDialog.__init__(self, mainGui)

        logger.debug("Initialising GuiWritingStats ...")
        self.setObjectName("GuiWritingStats")

        self.mainConf   = novelwriter.CONFIG
        self.mainGui    = mainGui
        self.mainTheme  = mainGui.mainTheme
        self.theProject = mainGui.theProject

        self.logData    = []
        self.filterData = []
        self.timeFilter = 0.0
        self.wordOffset = 0

        pOptions = self.theProject.options

        self.setWindowTitle(self.tr("Writing Statistics"))
        self.setMinimumWidth(self.mainConf.pxInt(420))
        self.setMinimumHeight(self.mainConf.pxInt(400))
        self.resize(
            self.mainConf.pxInt(pOptions.getInt("GuiWritingStats", "winWidth",  550)),
            self.mainConf.pxInt(pOptions.getInt("GuiWritingStats", "winHeight", 500))
        )

        # List Box
        wCol0 = self.mainConf.pxInt(
            pOptions.getInt("GuiWritingStats", "widthCol0", 180)
        )
        wCol1 = self.mainConf.pxInt(
            pOptions.getInt("GuiWritingStats", "widthCol1", 80)
        )
        wCol2 = self.mainConf.pxInt(
            pOptions.getInt("GuiWritingStats", "widthCol2", 80)
        )
        wCol3 = self.mainConf.pxInt(
            pOptions.getInt("GuiWritingStats", "widthCol3", 80)
        )

        self.listBox = QTreeWidget()
        self.listBox.setHeaderLabels([
            self.tr("Session Start"),
            self.tr("Length"),
            self.tr("Idle"),
            self.tr("Words"),
            self.tr("Histogram"),
        ])
        self.listBox.setIndentation(0)
        self.listBox.setColumnWidth(self.C_TIME, wCol0)
        self.listBox.setColumnWidth(self.C_LENGTH, wCol1)
        self.listBox.setColumnWidth(self.C_IDLE, wCol2)
        self.listBox.setColumnWidth(self.C_COUNT, wCol3)

        hHeader = self.listBox.headerItem()
        hHeader.setTextAlignment(self.C_LENGTH, Qt.AlignRight)
        hHeader.setTextAlignment(self.C_IDLE, Qt.AlignRight)
        hHeader.setTextAlignment(self.C_COUNT, Qt.AlignRight)

        sortCol = checkIntRange(pOptions.getInt("GuiWritingStats", "sortCol", 0), 0, 2, 0)
        sortOrder = checkIntTuple(
            pOptions.getInt("GuiWritingStats", "sortOrder", Qt.DescendingOrder),
            (Qt.AscendingOrder, Qt.DescendingOrder), Qt.DescendingOrder
        )
        self.listBox.sortByColumn(sortCol, sortOrder)
        self.listBox.setSortingEnabled(True)

        # Word Bar
        self.barHeight = int(round(0.5*self.mainTheme.fontPixelSize))
        self.barWidth = self.mainConf.pxInt(200)
        self.barImage = QPixmap(self.barHeight, self.barHeight)
        self.barImage.fill(self.palette().highlight().color())

        # Session Info
        self.infoBox = QGroupBox(self.tr("Sum Totals"), self)
        self.infoForm = QGridLayout(self)
        self.infoBox.setLayout(self.infoForm)

        self.labelTotal = QLabel(formatTime(0))
        self.labelTotal.setFont(self.mainTheme.guiFontFixed)
        self.labelTotal.setAlignment(Qt.AlignVCenter | Qt.AlignRight)

        self.labelIdleT = QLabel(formatTime(0))
        self.labelIdleT.setFont(self.mainTheme.guiFontFixed)
        self.labelIdleT.setAlignment(Qt.AlignVCenter | Qt.AlignRight)

        self.labelFilter = QLabel(formatTime(0))
        self.labelFilter.setFont(self.mainTheme.guiFontFixed)
        self.labelFilter.setAlignment(Qt.AlignVCenter | Qt.AlignRight)

        self.novelWords = QLabel("0")
        self.novelWords.setFont(self.mainTheme.guiFontFixed)
        self.novelWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)

        self.notesWords = QLabel("0")
        self.notesWords.setFont(self.mainTheme.guiFontFixed)
        self.notesWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)

        self.totalWords = QLabel("0")
        self.totalWords.setFont(self.mainTheme.guiFontFixed)
        self.totalWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)

        lblTTime   = QLabel(self.tr("Total Time:"))
        lblITime   = QLabel(self.tr("Idle Time:"))
        lblFTime   = QLabel(self.tr("Filtered Time:"))
        lblNvCount = QLabel(self.tr("Novel Word Count:"))
        lblNtCount = QLabel(self.tr("Notes Word Count:"))
        lblTtCount = QLabel(self.tr("Total Word Count:"))

        self.infoForm.addWidget(lblTTime,   0, 0)
        self.infoForm.addWidget(lblITime,   1, 0)
        self.infoForm.addWidget(lblFTime,   2, 0)
        self.infoForm.addWidget(lblNvCount, 3, 0)
        self.infoForm.addWidget(lblNtCount, 4, 0)
        self.infoForm.addWidget(lblTtCount, 5, 0)

        self.infoForm.addWidget(self.labelTotal,  0, 1)
        self.infoForm.addWidget(self.labelIdleT,  1, 1)
        self.infoForm.addWidget(self.labelFilter, 2, 1)
        self.infoForm.addWidget(self.novelWords,  3, 1)
        self.infoForm.addWidget(self.notesWords,  4, 1)
        self.infoForm.addWidget(self.totalWords,  5, 1)

        self.infoForm.setRowStretch(6, 1)

        # Filter Options
        sPx = self.mainTheme.baseIconSize

        self.filterBox = QGroupBox(self.tr("Filters"), self)
        self.filterForm = QGridLayout(self)
        self.filterBox.setLayout(self.filterForm)

        self.incNovel = QSwitch(width=2*sPx, height=sPx)
        self.incNovel.setChecked(
            pOptions.getBool("GuiWritingStats", "incNovel", True)
        )
        self.incNovel.clicked.connect(self._updateListBox)

        self.incNotes = QSwitch(width=2*sPx, height=sPx)
        self.incNotes.setChecked(
            pOptions.getBool("GuiWritingStats", "incNotes", True)
        )
        self.incNotes.clicked.connect(self._updateListBox)

        self.hideZeros = QSwitch(width=2*sPx, height=sPx)
        self.hideZeros.setChecked(
            pOptions.getBool("GuiWritingStats", "hideZeros", True)
        )
        self.hideZeros.clicked.connect(self._updateListBox)

        self.hideNegative = QSwitch(width=2*sPx, height=sPx)
        self.hideNegative.setChecked(
            pOptions.getBool("GuiWritingStats", "hideNegative", False)
        )
        self.hideNegative.clicked.connect(self._updateListBox)

        self.groupByDay = QSwitch(width=2*sPx, height=sPx)
        self.groupByDay.setChecked(
            pOptions.getBool("GuiWritingStats", "groupByDay", False)
        )
        self.groupByDay.clicked.connect(self._updateListBox)

        self.showIdleTime = QSwitch(width=2*sPx, height=sPx)
        self.showIdleTime.setChecked(
            pOptions.getBool("GuiWritingStats", "showIdleTime", False)
        )
        self.showIdleTime.clicked.connect(self._updateListBox)

        self.filterForm.addWidget(QLabel(self.tr("Count novel files")),        0, 0)
        self.filterForm.addWidget(QLabel(self.tr("Count note files")),         1, 0)
        self.filterForm.addWidget(QLabel(self.tr("Hide zero word count")),     2, 0)
        self.filterForm.addWidget(QLabel(self.tr("Hide negative word count")), 3, 0)
        self.filterForm.addWidget(QLabel(self.tr("Group entries by day")),     4, 0)
        self.filterForm.addWidget(QLabel(self.tr("Show idle time")),           5, 0)
        self.filterForm.addWidget(self.incNovel,     0, 1)
        self.filterForm.addWidget(self.incNotes,     1, 1)
        self.filterForm.addWidget(self.hideZeros,    2, 1)
        self.filterForm.addWidget(self.hideNegative, 3, 1)
        self.filterForm.addWidget(self.groupByDay,   4, 1)
        self.filterForm.addWidget(self.showIdleTime, 5, 1)
        self.filterForm.setRowStretch(6, 1)

        # Settings
        self.histMax = QSpinBox(self)
        self.histMax.setMinimum(100)
        self.histMax.setMaximum(100000)
        self.histMax.setSingleStep(100)
        self.histMax.setValue(
            pOptions.getInt("GuiWritingStats", "histMax", 2000)
        )
        self.histMax.valueChanged.connect(self._updateListBox)

        self.optsBox = QHBoxLayout()
        self.optsBox.addStretch(1)
        self.optsBox.addWidget(QLabel(self.tr("Word count cap for the histogram")), 0)
        self.optsBox.addWidget(self.histMax, 0)

        # Buttons
        self.buttonBox = QDialogButtonBox()
        self.buttonBox.rejected.connect(self._doClose)

        self.btnClose = self.buttonBox.addButton(QDialogButtonBox.Close)
        self.btnClose.setAutoDefault(False)

        self.btnSave = self.buttonBox.addButton(self.tr("Save As"), QDialogButtonBox.ActionRole)
        self.btnSave.setAutoDefault(False)

        self.saveMenu = QMenu(self)
        self.btnSave.setMenu(self.saveMenu)

        self.saveJSON = QAction(self.tr("JSON Data File (.json)"), self)
        self.saveJSON.triggered.connect(lambda: self._saveData(self.FMT_JSON))
        self.saveMenu.addAction(self.saveJSON)

        self.saveCSV = QAction(self.tr("CSV Data File (.csv)"), self)
        self.saveCSV.triggered.connect(lambda: self._saveData(self.FMT_CSV))
        self.saveMenu.addAction(self.saveCSV)

        # Assemble
        self.outerBox = QGridLayout()
        self.outerBox.addWidget(self.listBox,   0, 0, 1, 2)
        self.outerBox.addLayout(self.optsBox,   1, 0, 1, 2)
        self.outerBox.addWidget(self.infoBox,   2, 0)
        self.outerBox.addWidget(self.filterBox, 2, 1)
        self.outerBox.addWidget(self.buttonBox, 3, 0, 1, 2)
        self.outerBox.setRowStretch(0, 1)

        self.setLayout(self.outerBox)

        logger.debug("GuiWritingStats initialisation complete")

        return
Exemplo n.º 13
0
    def initUI(self):
        pg.setConfigOption('background', 'w')
        self.setWindowTitle('Cut Signal')
        self.setWindowIcon(QIcon("Icons\cut.png"))
        self.resize(1225, 700)
        #################################################################
        ##     Definición de variables globales
        #################################################################
        self.nombreSenial = ''
        self.y = []
        self.aux = 0
        self.aux2 = False
        #################################################################
        ##     Definición de elementos contenedores
        #################################################################
        contain = QSplitter(Qt.Horizontal)
        graficos = QVBoxLayout()
        botones = QVBoxLayout()
        results2 = QFormLayout()
        results3 = QFormLayout()
        results = QFormLayout()
        #################################################################
        ##     Elementos del layout botones
        #################################################################
        #Region for segment in signal
        self.lr = pg.LinearRegionItem([0, 6000])

        btnLoadSig = QPushButton('Load signal')
        btnLoadSig.clicked.connect(self.cargarSenial)
        btnLoadSig.setStyleSheet("font-size: 18px")

        self.btnIniciar = QPushButton('Start segmentation')
        self.btnIniciar.clicked.connect(self.enabledButtons)
        self.btnIniciar.setEnabled(False)
        self.btnIniciar.setStyleSheet("font-size: 18px")

        self.btnAdd = QPushButton('Add segment')
        self.btnAdd.clicked.connect(self.addInterval)
        self.btnAdd.setEnabled(False)
        self.btnAdd.setStyleSheet("font-size: 18px")

        txtnumseg = QLabel("Segment num:")
        txtnumseg.setStyleSheet("font-size: 18px")

        validator = QIntValidator()
        validator.setRange(100, 999)

        self.txtns = QLineEdit()
        self.txtns.setValidator(validator)
        self.txtns.setEnabled(False)

        lbl_umbral = QLabel('Upper threshold:')
        lbl_umbral.setStyleSheet("font-size: 18px")
        self.txt_umbral = QLineEdit()

        lbl_basal = QLabel('Lower threshold')
        lbl_basal.setStyleSheet("font-size: 18px")
        self.txt_basal = QLineEdit()

        lbl_ancho = QLabel('Segment width ')
        lbl_ancho.setStyleSheet("font-size: 18px")
        self.txt_ancho = QLineEdit()

        lbl_separacion = QLabel('Distance:')
        lbl_separacion.setStyleSheet("font-size: 18px")
        self.txt_separacion = QLineEdit()

        self.btnauto = QPushButton('Start auto-segmentation')
        self.btnauto.clicked.connect(self.autoseg)
        self.btnauto.setStyleSheet("font-size: 18px")
        self.btnauto.setEnabled(False)

        lbl_total = QLabel('# of segments:')
        lbl_total.setStyleSheet('font-size: 18px')

        self.txt_total = QLabel()
        self.txt_total.setStyleSheet('font-size: 18px')

        lbl_file = QLabel('Segment: ')
        lbl_file.setStyleSheet("font-size: 18px")
        self.seg_pos = QComboBox()
        self.seg_pos.currentIndexChanged.connect(self.localizacion)

        self.lbl_inicio = QLabel()
        self.lbl_inicio.setStyleSheet("font-size: 18px")
        self.lbl_final = QLabel()
        self.lbl_final.setStyleSheet("font-size: 18px")

        self.btn_loc = QPushButton('Find segment')
        self.btn_loc.setStyleSheet("font-size: 18px")
        self.btn_loc.clicked.connect(self.colocar)
        self.btn_loc.setEnabled(False)

        lbl_autoseg = QLabel("Auto-Segmentation")
        lbl_autoseg.setStyleSheet("font-size: 20px")
        #################################################################
        ##     Elementos del layout graficos
        #################################################################
        self.plot1 = pg.PlotWidget()
        self.plot1.setLabel('bottom', color='k', **{'font-size': '16pt'})
        self.plot1.getAxis('bottom').setPen(pg.mkPen(color='k', width=1))
        self.plot1.setLabel('left', color='k', **{'font-size': '16pt'})
        self.plot1.getAxis('left').setPen(pg.mkPen(color='k', width=1))
        self.plot1.showGrid(1, 1, 0.2)
        graficos.addWidget(self.plot1)
        #################################################################
        ##     Colocar elementos en layout botones
        #################################################################
        botones.addWidget(btnLoadSig)
        botones.addWidget(self.btnIniciar)
        results.addRow(txtnumseg, self.txtns)
        results.addRow(self.btnAdd)
        botones.addLayout(results)

        results2.addRow(lbl_autoseg)
        results2.addRow(lbl_umbral, self.txt_umbral)
        results2.addRow(lbl_basal, self.txt_basal)
        results2.addRow(lbl_ancho, self.txt_ancho)
        results2.addRow(lbl_separacion, self.txt_separacion)
        botones.addLayout(results2)
        botones.addWidget(self.btnauto)
        results3.addRow(lbl_total, self.txt_total)
        results3.addRow(lbl_file, self.seg_pos)
        results3.addRow(self.lbl_inicio, self.lbl_final)
        results3.addRow(self.btn_loc)
        botones.addLayout(results3)
        #################################################################
        ##     Colocar elementos en la ventana
        #################################################################
        bot = QWidget()
        bot.setLayout(botones)
        gra = QWidget()
        gra.setLayout(graficos)

        contain.addWidget(gra)
        contain.addWidget(bot)
        self.setCentralWidget(contain)
Exemplo n.º 14
0
    def initUI(self):
        #define all labels
        suchwort = QLabel('Suchwort:')
        dLoad = QLabel('Download:')
        ord = QLabel('Ordnen:')
        output = QLabel('Output:')
        result = QLabel('')
        #suchfenster
        self.suchwortedit = QLineEdit()
        #use a sublayout to keep it cleaner
        subSuch = QVBoxLayout()
        subSuch.addWidget(suchwort)
        subSuch.addWidget(self.suchwortedit)

        #define the parameters
        tituLabel = QLabel('Titeltiefe:')
        houptLabel = QLabel('Haupttiefe:')
        azau = QLabel('Anzahl Ketten:')

        self.tituCombo = QComboBox(self)
        self.houptCombo = QComboBox(self)
        self.azauCombo = QComboBox(self)
        #get the boxes range 1 to 8
        for i in range(1, 8):
            self.tituCombo.addItem(str(i))
            self.houptCombo.addItem(str(i))
            self.azauCombo.addItem(str(i))

        #make sublayouts for every parameter
        subTitu = QHBoxLayout()
        subTitu.addWidget(tituLabel)
        subTitu.addWidget(self.tituCombo)

        subHoupt = QHBoxLayout()
        subHoupt.addWidget(houptLabel)
        subHoupt.addWidget(self.houptCombo)

        subAzau = QHBoxLayout()
        subAzau.addWidget(azau)
        subAzau.addWidget(self.azauCombo)

        #define the buttons for the different modes
        subButton = QHBoxLayout()
        naiveButton = QPushButton('Naive', self)
        posButton = QPushButton('PoS', self)
        naiveButton.clicked.connect(self.naiveGo)
        posButton.clicked.connect(self.posGo)
        subButton.addWidget(naiveButton)
        subButton.addWidget(posButton)
        #define the progressbars
        self.dLoadProgress = QProgressBar(self)
        self.dLoadProgress.setGeometry(30, 40, 280, 25)

        self.orderProgress = QProgressBar(self)
        self.orderProgress.setGeometry(30, 40, 280, 25)

        #put the output in a scrollingarea to read all
        self.resultArea = QScrollArea()
        self.resultArea.setWidget(result)

        #define the gridlayout
        grid = QGridLayout()
        grid.addLayout(subSuch, 0, 0, 1, 6)
        grid.addLayout(subTitu, 2, 0, 1, 2)
        grid.addLayout(subHoupt, 2, 2, 1, 2)
        grid.addLayout(subAzau, 2, 4, 1, 2)
        grid.addLayout(subButton, 3, 0, 1, 6)
        grid.addWidget(dLoad, 4, 0)
        grid.addWidget(self.dLoadProgress, 5, 0, 1, 6)
        grid.addWidget(ord, 6, 0)
        grid.addWidget(self.orderProgress, 7, 0, 1, 6)
        grid.addWidget(output, 8, 0)
        grid.addWidget(self.resultArea, 9, 0, 4, 6)

        self.setLayout(grid)

        self.setGeometry(300, 300, 300, 300)
        self.setWindowTitle('NLZMarkov')
        self.show()
Exemplo n.º 15
0
    def __init__(self):
        super().__init__()
        self.wait_times = [10, 30, 60]
        self.push_wait = []  # list of wait buttons
        self.displaystat_hdr = []  # TODO replace with OrderedDict?
        self.displaystat_val = []
        self.statlabels = OrderedDict()  # statname: (namelabel, vallabel)
        # create widgets
        w = QWidget(self)
        self.central_widget = w
        self.time_lbl = QLabel(w)
        self.date_lbl = QLabel(w)
        self.location_lbl = QLabel(w)
        self.energy_bar = QProgressBar(w)
        self.arousal_bar = QProgressBar(w)
        self.widget_stack = QStackedWidget(self)
        self.location_view = LocationView(self)
        self.school_management = SchoolManagement(self)

        # create layout
        self.retranslateUi()
        grid = QGridLayout(self.central_widget)
        grid.setContentsMargins(0, 0, 0, 0)
        grid.addWidget(self.time_lbl, 0, 5, 1, 2)
        grid.addWidget(self.date_lbl, 0, 3, 1, 2)
        grid.addWidget(self.energy_bar, 0, 7, 1, 5)
        grid.addWidget(self.arousal_bar, 1, 7, 1, 5)
        grid.addWidget(self.location_lbl, 2, 0, 2, 3)

        for i, stat in enumerate(self.displaystat_hdr):
            val = self.displaystat_val[i]
            statlabel = QLabel(stat, w)
            vallabel = QLabel(val, w)
            self.statlabels[stat] = (statlabel, vallabel)
            grid.addWidget(statlabel, 2, 3 + i, 1, 1)
            grid.addWidget(vallabel, 3, 3 + i, 1, 1)
            # TODO: style
#            displaystat_hdr[i].setPalette(HHStyle::hdr_text);
#            displaystat_hdr[i].setAlignment(Qt::AlignCenter);
#            displaystat_val[i].setPalette(HHStyle::white_text);
#            displaystat_val[i].setAlignment(Qt::AlignCenter);

        self.widget_stack.addWidget(self.location_view)
        self.widget_stack.addWidget(self.school_management)

        grid.addWidget(self.widget_stack, 4, 0, 50, 12)

        self.setCentralWidget(w)

        # configure window
        self.setWindowTitle("pyprinciple")
        geom = QDesktopWidget().availableGeometry()
        self.setGeometry(100, 50, 800, 600)

        # configure widgets
        w.setContentsMargins(0, 0, 0, 0)
        w.setObjectName("central_widget")

        geom.setHeight(geom.height() * 0.98)

        self.time_lbl.setObjectName("text")  # use text style from style sheet
        self.time_lbl.setFont(style.big_font)
        self.time_lbl.setAlignment(Qt.AlignCenter)
        self.date_lbl.setObjectName("text")
        self.date_lbl.setFont(style.big_font)
        self.date_lbl.setAlignment(Qt.AlignRight)
        self.location_lbl.setObjectName("text")
        self.location_lbl.setFont(style.location_font)

        #        self.gridW.setContentsMargins(0, 0, 0, 0)
        #        gridW.setGeometry(geom)
        self.energy_bar.setValue(60)
        self.energy_bar.setObjectName("energy")
        self.arousal_bar.setValue(48)
        self.arousal_bar.setObjectName("arousal")

        geom.setHeight(geom.height() * 10 / 11)  # removes space for header
        self.location_lbl.setGeometry(geom)
        self.school_management.setGeometry(geom)

        self.widget_stack.setCurrentIndex(0)

        # TODO only shown if window contains locationview
        for i in range(0, len(self.wait_times)):
            pw = QPushButton("Wait %d min" % self.wait_times[i])
            self.push_wait.append(pw)
            grid.addWidget(pw, 0, i, 2, 1)

        for name in world.peopleAt("Your Home"):
            self.location_view.addPerson(Person(name))

        self.retranslateUi()

        self.show()
Exemplo n.º 16
0
def widgets(P, W):
    if not P.convSettingsChanged:
        #widgets
        W.ctLabel = QLabel(_translate('Conversational', 'CUT TYPE'))
        W.ctGroup = QButtonGroup(W)
        W.cExt = QRadioButton(_translate('Conversational', 'EXTERNAL'))
        W.cExt.setChecked(True)
        W.ctGroup.addButton(W.cExt)
        W.cInt = QRadioButton(_translate('Conversational', 'INTERNAL'))
        W.ctGroup.addButton(W.cInt)
        W.koLabel = QLabel(_translate('Conversational', 'KERF'))
        W.kOffset = QPushButton(_translate('Conversational', 'OFFSET'))
        W.kOffset.setCheckable(True)
        W.spLabel = QLabel(_translate('Conversational', 'START'))
        W.spGroup = QButtonGroup(W)
        W.center = QRadioButton(_translate('Conversational', 'CENTER'))
        W.spGroup.addButton(W.center)
        W.bLeft = QRadioButton(_translate('Conversational', 'BTM LEFT'))
        W.spGroup.addButton(W.bLeft)
        text = _translate('Conversational', 'ORIGIN')
        W.xsLabel = QLabel(_translate('Conversational', 'X {}'.format(text)))
        W.xsEntry = QLineEdit(str(P.xSaved), objectName='xsEntry')
        W.ysLabel = QLabel(_translate('Conversational', 'Y {}'.format(text)))
        W.ysEntry = QLineEdit(str(P.ySaved), objectName='ysEntry')
        W.liLabel = QLabel(_translate('Conversational', 'LEAD IN'))
        W.liEntry = QLineEdit(str(P.leadIn), objectName='liEntry')
        W.loLabel = QLabel(_translate('Conversational', 'LEAD OUT'))
        W.loEntry = QLineEdit(str(P.leadOut), objectName='loEntry')
        W.lLabel = QLabel(_translate('Conversational', 'LENGTH'))
        W.lEntry = QLineEdit()
        W.wLabel = QLabel(_translate('Conversational', 'WIDTH'))
        W.wEntry = QLineEdit()
        W.aLabel = QLabel(_translate('Conversational', 'ANGLE'))
        W.aEntry = QLineEdit('0.0', objectName='aEntry')
        W.add = QPushButton(_translate('Conversational', 'ADD'))
        W.lDesc = QLabel(_translate('Conversational', 'CREATING SLOT'))
        W.iLabel = QLabel()
        pixmap = QPixmap('{}conv_slot_l.png'.format(
            P.IMAGES)).scaledToWidth(196)
        W.iLabel.setPixmap(pixmap)
        #alignment and size
        rightAlign = ['ctLabel', 'koLabel', 'spLabel', 'xsLabel', 'xsEntry', 'ysLabel', \
                      'ysEntry', 'liLabel', 'liEntry', 'loLabel', 'loEntry', 'lLabel', \
                      'lEntry', 'wLabel', 'wEntry', 'aLabel', 'aEntry']
        centerAlign = ['lDesc']
        rButton = ['cExt', 'cInt', 'center', 'bLeft']
        pButton = ['preview', 'add', 'undo', 'kOffset']
        for widget in rightAlign:
            W[widget].setAlignment(Qt.AlignRight | Qt.AlignVCenter)
            W[widget].setFixedWidth(80)
            W[widget].setFixedHeight(24)
        for widget in centerAlign:
            W[widget].setAlignment(Qt.AlignCenter | Qt.AlignBottom)
            W[widget].setFixedWidth(240)
            W[widget].setFixedHeight(24)
        for widget in rButton:
            W[widget].setFixedWidth(80)
            W[widget].setFixedHeight(24)
        for widget in pButton:
            W[widget].setFixedWidth(80)
            W[widget].setFixedHeight(24)
        #starting parameters
        W.add.setEnabled(False)
        if P.oSaved:
            W.center.setChecked(True)
        else:
            W.bLeft.setChecked(True)
        if not W.liEntry.text() or float(W.liEntry.text()) == 0:
            W.kOffset.setChecked(False)
            W.kOffset.setEnabled(False)
    #connections
    W.preview.pressed.disconnect()
    W.undo.pressed.disconnect()
    W.conv_material.currentTextChanged.connect(lambda: auto_preview(P, W))
    W.cExt.toggled.connect(lambda: auto_preview(P, W))
    W.kOffset.toggled.connect(lambda: auto_preview(P, W))
    W.center.toggled.connect(lambda: auto_preview(P, W))
    W.preview.pressed.connect(lambda: preview(P, W))
    W.add.pressed.connect(lambda: P.conv_add_shape_to_file())
    W.undo.pressed.connect(lambda: P.conv_undo_shape())
    entries = ['xsEntry', 'ysEntry', 'liEntry', 'loEntry', \
               'lEntry', 'wEntry', 'aEntry']
    for entry in entries:
        W[entry].textChanged.connect(lambda: entry_changed(P, W, W.sender()))
        W[entry].returnPressed.connect(lambda: preview(P, W))
    #add to layout
    if P.landscape:
        W.entries.addWidget(W.ctLabel, 0, 0)
        W.entries.addWidget(W.cExt, 0, 1)
        W.entries.addWidget(W.cInt, 0, 2)
        W.entries.addWidget(W.koLabel, 0, 3)
        W.entries.addWidget(W.kOffset, 0, 4)
        W.entries.addWidget(W.spLabel, 1, 0)
        W.entries.addWidget(W.center, 1, 1)
        W.entries.addWidget(W.bLeft, 1, 2)
        W.entries.addWidget(W.xsLabel, 2, 0)
        W.entries.addWidget(W.xsEntry, 2, 1)
        W.entries.addWidget(W.ysLabel, 3, 0)
        W.entries.addWidget(W.ysEntry, 3, 1)
        W.entries.addWidget(W.liLabel, 4, 0)
        W.entries.addWidget(W.liEntry, 4, 1)
        W.entries.addWidget(W.loLabel, 5, 0)
        W.entries.addWidget(W.loEntry, 5, 1)
        W.entries.addWidget(W.lLabel, 6, 0)
        W.entries.addWidget(W.lEntry, 6, 1)
        W.entries.addWidget(W.wLabel, 7, 0)
        W.entries.addWidget(W.wEntry, 7, 1)
        W.entries.addWidget(W.aLabel, 8, 0)
        W.entries.addWidget(W.aEntry, 8, 1)
        for r in [9, 10, 11]:
            W['s{}'.format(r)] = QLabel('')
            W['s{}'.format(r)].setFixedHeight(24)
            W.entries.addWidget(W['s{}'.format(r)], r, 0)
        W.entries.addWidget(W.preview, 12, 0)
        W.entries.addWidget(W.add, 12, 2)
        W.entries.addWidget(W.undo, 12, 4)
        W.entries.addWidget(W.lDesc, 13, 1, 1, 3)
        W.entries.addWidget(W.iLabel, 2, 2, 7, 3)
    else:
        W.entries.addWidget(W.conv_material, 0, 0, 1, 5)
        W.entries.addWidget(W.ctLabel, 1, 0)
        W.entries.addWidget(W.cExt, 1, 1)
        W.entries.addWidget(W.cInt, 1, 2)
        W.entries.addWidget(W.koLabel, 1, 3)
        W.entries.addWidget(W.kOffset, 1, 4)
        W.entries.addWidget(W.spLabel, 2, 0)
        W.entries.addWidget(W.center, 2, 1)
        W.entries.addWidget(W.bLeft, 2, 2)
        W.entries.addWidget(W.xsLabel, 3, 0)
        W.entries.addWidget(W.xsEntry, 3, 1)
        W.entries.addWidget(W.ysLabel, 3, 2)
        W.entries.addWidget(W.ysEntry, 3, 3)
        W.entries.addWidget(W.liLabel, 4, 0)
        W.entries.addWidget(W.liEntry, 4, 1)
        W.entries.addWidget(W.loLabel, 4, 2)
        W.entries.addWidget(W.loEntry, 4, 3)
        W.entries.addWidget(W.lLabel, 5, 0)
        W.entries.addWidget(W.lEntry, 5, 1)
        W.entries.addWidget(W.wLabel, 6, 0)
        W.entries.addWidget(W.wEntry, 6, 1)
        W.entries.addWidget(W.aLabel, 7, 0)
        W.entries.addWidget(W.aEntry, 7, 1)
        for r in [8]:
            W['s{}'.format(r)] = QLabel('')
            W['s{}'.format(r)].setFixedHeight(24)
            W.entries.addWidget(W['s{}'.format(r)], r, 0)
        W.entries.addWidget(W.preview, 9, 0)
        W.entries.addWidget(W.add, 9, 2)
        W.entries.addWidget(W.undo, 9, 4)
        W.entries.addWidget(W.lDesc, 10, 1, 1, 3)
        W.entries.addWidget(W.iLabel, 0, 5, 7, 3)
    W.lEntry.setFocus()
    P.convSettingsChanged = False
Exemplo n.º 17
0
    def create_mysql_widgets(self):
        table = QLabel("表类型")
        school = QLabel("学校")
        province = QLabel("地区")
        year = QLabel("年份")
        major = QLabel("专业")
        batch = QLabel("批次")
        classy = QLabel("科别")

        self.table_combo = QComboBox()
        table_names = ["计划招生", "专业分数", "地区分数"]
        self.table_combo.addItems(table_names)
        self.table_combo.activated[str].connect(self.table_combo_activated)

        self.school_combo = QComboBox()
        self.school_combo.activated[str].connect(self.school_combo_activated)

        self.district_combo = QComboBox()
        self.district_combo.activated[str].connect(self.district_combo_activated)

        self.year_combo = QComboBox()
        self.year_combo.activated[str].connect(self.year_combo_activated)
        self.major_combo = QComboBox()
        self.major_combo.activated[str].connect(self.major_combo_activated)
        self.batch_combo = QComboBox()
        self.classy_combo = QComboBox()
        self.classy_combo.activated[str].connect(self.classy_combo_activated)

        select_hbox = QHBoxLayout()
        select_hbox.addWidget(table)
        select_hbox.addWidget(self.table_combo)
        select_hbox.addWidget(school)
        select_hbox.addWidget(self.school_combo)
        select_hbox.addWidget(province)
        select_hbox.addWidget(self.district_combo)
        select_hbox.addWidget(year)
        select_hbox.addWidget(self.year_combo)
        select_hbox.addWidget(major)
        select_hbox.addWidget(self.major_combo)
        select_hbox.addWidget(batch)
        select_hbox.addWidget(self.batch_combo)
        select_hbox.addWidget(classy)
        select_hbox.addWidget(self.classy_combo)

        sql = QLabel("SQL语句")
        self.SQL_edit = QLineEdit()
        sql_hbox = QHBoxLayout()
        sql_hbox.addWidget(sql)
        sql_hbox.addWidget(self.SQL_edit)

        result = QLabel("查询结果")
        self.result_edit = QTextEdit()
        result_hbox = QHBoxLayout()
        result_hbox.addWidget(result)
        result_hbox.addWidget(self.result_edit)

        self.query_btn = QPushButton("查询")

        btn_hbox = QHBoxLayout()
        btn_hbox.addWidget(self.query_btn)
        self.query_btn.clicked.connect(self.mysql_query)

        main_vbox = QVBoxLayout()
        main_vbox.addLayout(select_hbox)
        main_vbox.addLayout(sql_hbox)
        main_vbox.addLayout(result_hbox)
        main_vbox.addLayout(btn_hbox)
        self.setLayout(main_vbox)
Exemplo n.º 18
0
    def __init__(self,
                 seed=None,
                 title=None,
                 icon=True,
                 msg=None,
                 options=None,
                 is_seed=None,
                 passphrase=None,
                 parent=None,
                 for_seed_words=True):
        QVBoxLayout.__init__(self)
        self.parent = parent
        self.options = options
        if title:
            self.addWidget(WWLabel(title))
        if seed:  # "read only", we already have the text
            if for_seed_words:
                self.seed_e = ButtonsTextEdit()
            else:  # e.g. xpub
                self.seed_e = ShowQRTextEdit()
            self.seed_e.setReadOnly(True)
            self.seed_e.setText(seed)
        else:  # we expect user to enter text
            assert for_seed_words
            self.seed_e = CompletionTextEdit()
            self.seed_e.setTabChangesFocus(False)  # so that tab auto-completes
            self.is_seed = is_seed
            self.saved_is_seed = self.is_seed
            self.seed_e.textChanged.connect(self.on_edit)
            self.initialize_completer()

        self.seed_e.setMaximumHeight(75)
        hbox = QHBoxLayout()
        if icon:
            logo = QLabel()
            logo.setPixmap(
                QPixmap(icon_path("seed.png")).scaledToWidth(
                    64, mode=Qt.SmoothTransformation))
            logo.setMaximumWidth(60)
            hbox.addWidget(logo)
        hbox.addWidget(self.seed_e)
        self.addLayout(hbox)
        hbox = QHBoxLayout()
        hbox.addStretch(1)
        self.seed_type_label = QLabel('')
        hbox.addWidget(self.seed_type_label)

        # options
        self.is_bip39 = False
        self.is_ext = False
        if options:
            opt_button = EnterButton(_('Options'), self.seed_options)
            hbox.addWidget(opt_button)
            self.addLayout(hbox)
        if passphrase:
            hbox = QHBoxLayout()
            passphrase_e = QLineEdit()
            passphrase_e.setText(passphrase)
            passphrase_e.setReadOnly(True)
            hbox.addWidget(QLabel(_("Your seed extension is") + ':'))
            hbox.addWidget(passphrase_e)
            self.addLayout(hbox)
        self.addStretch(1)
        self.seed_warning = WWLabel('')
        if msg:
            self.seed_warning.setText(seed_warning_msg(seed))
        self.addWidget(self.seed_warning)
Exemplo n.º 19
0
default_index = 6
try:
    exercise = int(sys.argv[1])
except IndexError:
    exercise = default_index
    print(f"Need to specify exercise number (1-5). Defaulting to: {exercise}")

app = QApplication(sys.argv)

if exercise == 1:
    window = QWidget()
    window.setWindowTitle('PyQT5 App')
    name = sys.argv[2]
    window.setGeometry(100, 100, 200, 80)
    window.move(60, 15)
    helloMsg = QLabel(f'<h1>Hello {name}!</h1>', parent=window)
    helloMsg.move(10, 15)
    window.show()

elif exercise == 2:
    window = QWidget()
    window.setWindowTitle('PyQT5 App')
    layout = QHBoxLayout()
    layout.addWidget(QPushButton('Left'))
    layout.addWidget(QPushButton('Center'))
    layout.addWidget(QPushButton('Right'))
    window.setLayout(layout)
    window.show()

elif exercise == 3:
    window = QWidget()
Exemplo n.º 20
0
    def __init__(self, parent=None):
        super(MainForm, self).__init__(parent)

        #设置数据库日志文件
        db = get_db(database)
        cur = db.cursor()
        cur.execute('set global general_log = on')
        db.commit()
        cur.execute('set global log_output = \'file\'')
        db.commit()
        cur.execute('set global general_log_file=' + '\'' + logpath + '\'')
        db.commit()
        db.close()

        self.Receive_Email = None
        self.m = None
        self.n = None

        self.filename = ""
        self.copiedItem = QByteArray()
        self.pasteOffset = 5
        self.prevPoint = QPoint()
        self.addOffset = 5
        self.borders = []

        self.printer = QPrinter(QPrinter.HighResolution)
        self.printer.setPageSize(QPrinter.Letter)

        self.view = GraphicsView()
        self.scene = QGraphicsScene(self)
        self.scene.setSceneRect(0, 0, PageSize[0], PageSize[1])
        self.view.setScene(self.scene)

        #设置地图文件
        pixmap = QPixmap("Bin_Map_25%_59%.png")
        self.scene.addPixmap(pixmap)

        self.wrapped = []  # Needed to keep wrappers alive
        buttonLayout = QVBoxLayout()
        #添加输入Email label和输入框
        eml = QLabel('TO Email Address', self)
        self.lineEdit1 = QLineEdit(self)
        buttonLayout.addWidget(eml)
        buttonLayout.addWidget(self.lineEdit1)

        #添加输入RPO label和输入框
        rpo = QLabel('RPO#', self)
        self.lineEdit = QLineEdit(self)
        buttonLayout.addWidget(rpo)
        buttonLayout.addWidget(self.lineEdit)

        #添加Button 和对应的功能
        for text, slot in (("Send Email", self.sendEmail),
                           ("Add Box", self.addBox), ("Clear", self.clear),
                           ("Summary", self.Summary), ("Quit", self.accept)):
            button = QPushButton(text)
            if not MAC:
                button.setFocusPolicy(Qt.NoFocus)
            if slot is not None:
                button.clicked.connect(slot)
            if text == "Quit":
                buttonLayout.addStretch(1)
            buttonLayout.addWidget(button)
        buttonLayout.addStretch()

        #设置接收Pick结果邮箱地址
        rcv = QLabel('Receive Email Address', self)
        self.lineEdit2 = QLineEdit(self)
        self.Confirm = QPushButton("Confirm")

        self.Confirm.clicked.connect(self.setRec)
        buttonLayout.addWidget(rcv)
        buttonLayout.addWidget(self.lineEdit2)
        buttonLayout.addWidget(self.Confirm)

        layout = QHBoxLayout()
        layout.addLayout(buttonLayout)
        layout.addWidget(self.view, 1)

        self.setLayout(layout)
        #MyArrow(self.scene)
        fm = QFontMetrics(self.font())
        self.resize(self.scene.width() + fm.width(" Delete... ") + 50,
                    self.scene.height() + 50)
        self.setWindowTitle("DWI")
Exemplo n.º 21
0
def simpleLabel(content):
    label = QLabel()
    label.setText(content)
    return label
Exemplo n.º 22
0
    def _wallet_widgets(self, wallet: Wallet, tab: QWidget) -> None:
        use_change_addresses_cb = QCheckBox(_('Use change addresses'))
        use_change_addresses_cb.setChecked(
            wallet.get_boolean_setting(WalletSettings.USE_CHANGE, True))
        use_change_addresses_cb.setEnabled(
            app_state.config.is_modifiable(WalletSettings.USE_CHANGE))
        use_change_addresses_cb.setToolTip(
            _('Using a different change key each time improves your privacy by '
              'making it more difficult for others to analyze your transactions.')
        )
        def on_usechange(state: int):
            should_enable = state == Qt.Checked
            if wallet.get_boolean_setting(WalletSettings.USE_CHANGE, True) != should_enable:
                wallet.set_boolean_setting(WalletSettings.USE_CHANGE, should_enable)
                multiple_change_cb.setEnabled(should_enable)
        use_change_addresses_cb.stateChanged.connect(on_usechange)

        multiple_change_cb = QCheckBox(_('Use multiple change addresses'))
        multiple_change_cb.setChecked(
            wallet.get_boolean_setting(WalletSettings.MULTIPLE_CHANGE, True))
        multiple_change_cb.setEnabled(wallet.get_boolean_setting(WalletSettings.USE_CHANGE, True))
        multiple_change_cb.setToolTip('\n'.join([
            _('In some cases, use up to 3 change keys in order to break '
              'up large coin amounts and obfuscate the recipient key.'),
            _('This may result in higher transactions fees.')
        ]))
        def on_multiple_change_toggled(state: int) -> None:
            multiple = state == Qt.Checked
            if wallet.get_boolean_setting(WalletSettings.MULTIPLE_CHANGE, True) != multiple:
                wallet.set_boolean_setting(WalletSettings.MULTIPLE_CHANGE, multiple)
        multiple_change_cb.stateChanged.connect(on_multiple_change_toggled)

        coinsplitting_option_cb = QCheckBox(_('Show coin-splitting option on the Send tab'))
        coinsplitting_option_cb.setChecked(wallet.get_boolean_setting(WalletSettings.ADD_SV_OUTPUT))
        coinsplitting_option_cb.setEnabled(
            app_state.config.is_modifiable(WalletSettings.ADD_SV_OUTPUT))
        coinsplitting_option_cb.setToolTip(
            _('Whether to feature the the option to add Bitcoin SV only data to the transaction '
              'on the Send tab. Will only be shown for compatible account types.')
        )
        def on_coinsplitting_option_cb(state: int):
            should_enable = state == Qt.Checked
            if wallet.get_boolean_setting(WalletSettings.ADD_SV_OUTPUT) != should_enable:
                wallet.set_boolean_setting(WalletSettings.ADD_SV_OUTPUT, should_enable)
        coinsplitting_option_cb.stateChanged.connect(on_coinsplitting_option_cb)

        options_box = QGroupBox()
        options_vbox = QVBoxLayout()
        options_box.setLayout(options_vbox)
        options_vbox.addWidget(use_change_addresses_cb)
        options_vbox.addWidget(multiple_change_cb)
        options_vbox.addWidget(coinsplitting_option_cb)

        multiple_accounts_cb = QCheckBox(_('Enable multiple accounts'))
        multiple_accounts_cb.setChecked(
            wallet.get_boolean_setting(WalletSettings.MULTIPLE_ACCOUNTS))
        multiple_accounts_cb.setToolTip('\n'.join([
            _('Multiple accounts are to a large degree ready for use, but not tested to the level '
              'where they are enabled for general use. Users who may wish to use these are warned '
              'that they are in the experimental section for a reason.')
        ]))
        def on_multiple_accounts_toggled(state: int) -> None:
            should_enable = state == Qt.Checked
            is_enabled = wallet.get_boolean_setting(WalletSettings.MULTIPLE_ACCOUNTS)
            if should_enable != is_enabled:
                wallet.set_boolean_setting(WalletSettings.MULTIPLE_ACCOUNTS, should_enable)
        multiple_accounts_cb.stateChanged.connect(on_multiple_accounts_toggled)

        experimental_box = QGroupBox()
        experimental_vbox = QVBoxLayout()
        experimental_box.setLayout(experimental_vbox)
        experimental_vbox.addWidget(multiple_accounts_cb)

        # Todo - add ability here to toggle deactivation of used keys - AustEcon
        transaction_cache_size = wallet.get_cache_size_for_tx_bytedata()
        # nz_label = HelpLabel(_('Transaction Cache Size (MB)') + ':',
        #     _("This allows setting a per-wallet limit on the amount of transaction data cached "
        #     "in memory. A value of 0 will disable the cache, and setting low values can cause "
        #     "wallet slowness due to continual fetching of transaction data from the database."))
        nz_modifiable = app_state.config.is_modifiable('tx_bytedata_cache_size')
        nz = QSpinBox()
        nz.setAlignment(Qt.AlignRight)
        nz.setMinimum(MINIMUM_TXDATA_CACHE_SIZE_MB)
        nz.setMaximum(MAXIMUM_TXDATA_CACHE_SIZE_MB)
        nz.setValue(transaction_cache_size)
        nz.setEnabled(nz_modifiable)
        def on_nz():
            value = nz.value()
            # This will not resize the cache, as we do not want to be doing it with every
            # change and some changes may be bad to actually put in place.
            wallet.set_cache_size_for_tx_bytedata(value)
        nz.valueChanged.connect(on_nz)

        tx_cache_layout = QHBoxLayout()
        tx_cache_layout.setSpacing(15)
        tx_cache_layout.addWidget(nz)
        tx_cache_layout.addWidget(QLabel(_("MiB")))

        form = FormSectionWidget(minimum_label_width=120)
        form.add_row(_('General options'), options_box, True)
        form.add_row(_('Experimental options'), experimental_box, True)
        form.add_row(_('Transaction Cache Size'), tx_cache_layout)

        vbox = QVBoxLayout()
        vbox.addWidget(form)
        vbox.addStretch(1)
        tab.setLayout(vbox)
Exemplo n.º 23
0
    def __init__(self, parent=None):
        super(emailWidget,self).__init__(parent)
        print("[INFO - EMAIL_WIDGET ] : EMAIL WIDGET INITIALIZATION CALLED")

        self.finished_status = False
               
        grid = QGridLayout()

        self.emailBox=QGroupBox("EMAIL SECTION")
        self.title = QLabel("LOADING")
        self.mainContent = QLabel("LOADING")
        self.opt_1 = QLabel("SMILE FOR 5 SEC TO OPEN EMAILS")
        self.opt_2 = QLabel("CLOSE BOTH EYES FOR 5 SEC TO BACK")
        self.opt_debug = QLabel("STATUS : LOADING")
        self.opt_debug.setWordWrap(True)

        self.title.setStyleSheet("color: white")
        self.title.setAlignment(Qt.AlignCenter)
        self.mainContent.setStyleSheet("color: white ; font: bold 20px")
        self.mainContent.setAlignment(Qt.AlignCenter)
        self.opt_1.setStyleSheet("color: white ;font: bold 12px")
        self.opt_1.setAlignment(Qt.AlignLeft)
        self.opt_2.setStyleSheet("color: white ;font: bold 12px")
        self.opt_2.setAlignment(Qt.AlignLeft)
        self.opt_debug.setStyleSheet("color: white ;font: bold 12px")
        self.opt_debug.setAlignment(Qt.AlignLeft)

        self.verticalLayout = QVBoxLayout()
        self.verticalLayout_Option = QVBoxLayout()
        
        self.combiner = QVBoxLayout()
        
        self.verticalLayout.addWidget(self.title)
        self.verticalLayout.addWidget(self.mainContent)
        self.verticalLayout_Option.addWidget(self.opt_debug)
        self.verticalLayout_Option.addWidget(self.opt_1)
        self.verticalLayout_Option.addWidget(self.opt_2)
        

        self.verticalLayout.addStretch(1)
        self.verticalLayout_Option.addStretch(1)
        
        
        self.combiner.addLayout(self.verticalLayout)
        self.combiner.addLayout(self.verticalLayout_Option)
        self.combiner.addStretch(0)
        self.emailBox.setLayout(self.combiner)
        
        grid.addWidget(self.emailBox,1,1)


        self.emailWorker = EMAIL_BACKEND()
        self.emailthread = QThread()
        self.emailWorker.signal_Email_Name.connect(self.updateDate)
        self.emailWorker.signal_Email_Notifications_Num.connect(self.updateNotification)
        self.emailWorker.emailLoader_finished.connect(self._finished)
        self.emailWorker.moveToThread(self.emailthread)
        self.emailthread.started.connect(self.emailWorker.emailExtractor)

        QApplication.processEvents()
        self.setLayout(grid)
        self.setWindowTitle("EMAIL MODULE")
  
        self.setAutoFillBackground(True)
        p = self.palette()
        p.setColor(self.backgroundRole(), Qt.black)
        self.setPalette(p)
        self.resize(600,300)
Exemplo n.º 24
0
    def setItem(self):
        #发消息按钮
        self.button = QPushButton(self)
        self.button.setText("发消息")
        self.button.setStyleSheet('''background-color:rgb(30,180,255);color:rgb(255,255,255);border: 0px solid;
        border-radius: 10px;''')
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        font.setPointSize(12)
        font.setBold(True)
        font.setWeight(75)
        self.button.setFont(font)
        self.button.setGeometry(260,500,180,50)
        #好友昵称Label
        self.name_label = QLabel(self)
        self.name_label.setText(self.info_list[1])
        font = QtGui.QFont()
        font.setFamily("Microsoft YaHei UI")
        font.setPointSize(18)
        font.setWeight(75)
        self.name_label.setFont(font)
        self.name_label.setGeometry(100,60,250,60)
        #好友性别Label
        pwd = os.getcwd()
        path = pwd + '\\images\\03-20.png'
        self.gender_label = QLabel(self)
        self.gender_label.setGeometry(330,80,30,30)
        self.gender_label.setPixmap(QtGui.QPixmap(path))
        self.gender_label.setScaledContents(True)
        #好友签名Label
        self.sign_label = QLabel(self)
        self.sign_label.setGeometry(100,130,400,30)
        self.sign_label.setText("这个家伙很懒,没有设置签名")
        self.sign_label.setStyleSheet("color:grey;")
        #好友头像Label
        self.head_label = QLabel(self)
        self.head_label.setGeometry(510,70,90,90)
        self.head_label.setPixmap(QtGui.QPixmap(self.info_list[2]))
        self.head_label.setScaledContents(True)

        #分割线
        self.devision_line = QLabel(self)
        self.devision_line.setGeometry(100,200,500,2)
        self.devision_line.setStyleSheet("border:0.5px solid rgb(240,240,240);")
        #备注label
        self.remark = QLabel(self)
        self.remark.setGeometry(100,240,100,40)
        self.remark.setText("备 注")
        self.remark.setStyleSheet("color:grey;")
        #修改备注Button
        self.remark_btn = QPushButton(self)
        self.remark_btn.setText("点击添加备注")
        self.remark_btn.setGeometry(160,240,200,40)
        self.remark_btn.setStyleSheet("background-color:transparent;border:0px;")

        #修改备注LineEdit
        self.remark_lineEdit = QLineEdit(self)
        self.remark_lineEdit.setGeometry(215,240,200,30)
        self.remark_lineEdit.hide()
        #生日Label
        self.birth = QLabel(self)
        self.birth.setGeometry(100,300,100,40)
        self.birth.setText("生 日")
        self.birth.setStyleSheet("color:grey;")
        #出生日期
        self.birthday = QLabel(self)
        self.birthday.setGeometry(215,300,100,40)
        self.birthday.setText("1999-10-01")
        #星座
        self.constellation = QLabel(self)
        self.constellation.setGeometry(350,300,100,40)
        self.constellation.setText("天秤座")
        #Top账号
        self.top_count = QLabel(self)
        self.top_count.setGeometry(100,360,100,40)
        self.top_count.setText("Top账号")
        self.top_count.setStyleSheet("color:grey;")
        #账号
        self.count = QLabel(self)
        self.count.setGeometry(215,360,100,40)
        self.count.setText(self.info_list[0])
        #分割线
        self.devision_line1 = QLabel(self)
        self.devision_line1.setGeometry(100,450,500,2)
        self.devision_line1.setStyleSheet("border:0.5px solid rgb(240,240,240);")
Exemplo n.º 25
0
 def __init__(self):
     super(Widget, self).__init__()
 
     self.setWindowTitle("Artikelen wijzigen")
     self.setWindowIcon(QIcon('./images/logos/logo.jpg'))
                 
     self.setFont(QFont('Arial', 10))
                
     self.Artikelnummer = QLabel()
     q1Edit = QLineEdit(str(rpartikel[0]))
     q1Edit.setFixedWidth(100)
     q1Edit.setDisabled(True)
     q1Edit.setFont(QFont("Arial",10))
     q1Edit.textChanged.connect(self.q1Changed)
 
     self.Artikelomschrijving = QLabel()
     q2Edit = QLineEdit(str(rpartikel[1]))
     q2Edit.setFixedWidth(400)
     q2Edit.setFont(QFont("Arial",10))
     q2Edit.textChanged.connect(self.q2Changed)
     
     self.Artikelprijs = QLabel()
     q3Edit = QLineEdit(str(rpartikel[2]))
     q3Edit.setFixedWidth(100)
     q3Edit.setFont(QFont("Arial",10))
     q3Edit.textChanged.connect(self.q3Changed)
     reg_ex = QRegExp('^[0-9]{1,10}[.0-9]{0,3}$')
     input_validator = QRegExpValidator(reg_ex, q3Edit)
     q3Edit.setValidator(input_validator)
                    
     self.Artikelvoorraad = QLabel()
     q4Edit = QLineEdit(str(rpartikel[3]))
     q4Edit.setFixedWidth(100)
     q4Edit.setFont(QFont("Arial",10))
     q4Edit.setDisabled(True)
     q4Edit.textChanged.connect(self.q4Changed)
     reg_ex = QRegExp('^[0-9]{0,10}[.0-9]{0,3}$')
     input_validator = QRegExpValidator(reg_ex, q4Edit)
     q4Edit.setValidator(input_validator)
     
     self.Artikeleenheid = QLabel()
     q5Edit = QComboBox()
     q5Edit.setFixedWidth(140)
     q5Edit.setFont(QFont("Arial",10))
     q5Edit.setStyleSheet("color: black;  background-color: gainsboro")
     q5Edit.addItem(' Maak uw keuze')
     q5Edit.addItem('stuk')
     q5Edit.addItem('100')
     q5Edit.addItem('meter')
     q5Edit.addItem('kg')
     q5Edit.addItem('liter')
     q5Edit.addItem('m²')
     q5Edit.addItem('m³')
     q5Edit.activated[str].connect(self.q5Changed)        
             
     self.Minimumvoorraad = QLabel()
     q6Edit = QLineEdit(str(rpartikel[5]))
     q6Edit.setFixedWidth(100)
     q6Edit.setFont(QFont("Arial",10))
     q6Edit.textChanged.connect(self.q6Changed)
     reg_ex = QRegExp('^[0-9]{1,10}[.0-9]{0,3}$')
     input_validator = QRegExpValidator(reg_ex, q6Edit)
     q6Edit.setValidator(input_validator)
   
     self.Bestelgrootte = QLabel()
     q7Edit = QLineEdit(str(rpartikel[6]))
     q7Edit.setFixedWidth(100)
     q7Edit.setFont(QFont("Arial",10))
     q7Edit.textChanged.connect(self.q7Changed)
     reg_ex = QRegExp('^[0-9]{1,10}[.0-9]{0,3}$')
     input_validator = QRegExpValidator(reg_ex, q7Edit)
     q7Edit.setValidator(input_validator)
                  
     self.Magazijnlocatie = QLabel()
     q8Edit = QLineEdit(str(rpartikel[7]))
     q8Edit.setFixedWidth(100)
     q8Edit.setFont(QFont("Arial",10))
     q8Edit.textChanged.connect(self.q8Changed)
     
     self.Artikelgroep = QLabel()
     q9Edit = QLineEdit(str(rpartikel[8]))
     q9Edit.setFixedWidth(200)
     q9Edit.setFont(QFont("Arial",10))
     q9Edit.textChanged.connect(self.q9Changed)
     
     self.Barcode = QLabel()
     q10Edit = QLineEdit(str(rpartikel[9]))
     q10Edit.setFixedWidth(100)
     q10Edit.setFont(QFont("Arial",10))
     q10Edit.textChanged.connect(self.q10Changed)
     reg_ex = QRegExp('^[1-9]{1,13}$')
     input_validator = QRegExpValidator(reg_ex, q10Edit)
     q10Edit.setValidator(input_validator)
 
     self.Artikelthumbnail = QLabel()
     q11Edit = QLineEdit(str(rpartikel[10]))
     q11Edit.setFixedWidth(400)
     q11Edit.setFont(QFont("Arial",10))
     q11Edit.textChanged.connect(self.q11Changed)
             
     self.Artikelfoto = QLabel()
     q12Edit = QLineEdit(str(rpartikel[11]))
     q12Edit.setFixedWidth(400)
     q12Edit.setFont(QFont("Arial",10))
     q12Edit.textChanged.connect(self.q12Changed)
  
     self.Categorie = QLabel()
     q13Edit = QComboBox()
     q13Edit.setFixedWidth(270)
     q13Edit.setFont(QFont("Arial",10))
     q13Edit.setStyleSheet("color: black;  background-color: gainsboro")
     q13Edit.addItem('             Maak uw keuze')
     q13Edit.addItem('1. Voorraadgestuurd prijs < 5')
     q13Edit.addItem('2. Voorraadgestuurd prijs < 20')
     q13Edit.addItem('3. Voorraadgestuurd prijs < 500')
     q13Edit.addItem('4. Voorraadgestuurd prijs > 500')
     q13Edit.addItem('5. Reserveringgestuurd prijs < 5')
     q13Edit.addItem('6. Reserveringgestuurd prijs < 20')
     q13Edit.addItem('7. Reserveringgestuurd prijs < 500')
     q13Edit.addItem('8. Reserveringgestuurd prijs > 500')            
     q13Edit.activated[str].connect(self.q13Changed)        
             
     grid = QGridLayout()
     grid.setSpacing(20)
 
     lbl = QLabel()
     pixmap = QPixmap('./images/logos/verbinding.jpg')
     lbl.setPixmap(pixmap)
     grid.addWidget(lbl , 0, 0)
 
     logo = QLabel()
     pixmap = QPixmap('./images/logos/logo.jpg')
     logo.setPixmap(pixmap)
     grid.addWidget(logo , 0, 2, 1, 1, Qt.AlignRight) 
 
     self.setFont(QFont('Arial', 10))
     grid.addWidget(QLabel('Wijzigen artikel'), 1, 1)
 
     grid.addWidget(QLabel('                                *'), 2, 0)
     grid.addWidget(QLabel('Verplichte velden'), 2, 1)
 
     grid.addWidget(QLabel('Artikelnummer'), 3, 0)
     grid.addWidget(q1Edit, 3, 1)
 
     grid.addWidget(QLabel('Artikelomschrijving     *'), 4, 0)
     grid.addWidget(q2Edit, 4, 1)
 
     grid.addWidget(QLabel('Artikelprijs                 *'), 5, 0)
     grid.addWidget(q3Edit, 5 , 1) 
 
     grid.addWidget(QLabel('Artikelvoorraad'), 6, 0)
     grid.addWidget(q4Edit, 6, 1)
   
     grid.addWidget(QLabel('                                            '+str(rpartikel[4])), 7, 0)
     grid.addWidget(QLabel('Eenheid                    *'), 7, 0)
     grid.addWidget(q5Edit, 7, 1)
 
     grid.addWidget(QLabel('Minimumvoorraad      *'), 8, 0)
     grid.addWidget(q6Edit, 8, 1)
 
     grid.addWidget(QLabel('Bestelgrootte             *'), 9, 0)
     grid.addWidget(q7Edit, 9, 1)
 
     grid.addWidget(QLabel('Magazijnlocatie         *'), 10, 0)
     grid.addWidget(q8Edit, 10, 1)
 
     grid.addWidget(QLabel('Artikelgroep              *'), 11, 0)
     grid.addWidget(q9Edit, 11, 1) 
 
     grid.addWidget(QLabel('Barcode'), 12, 0)
     grid.addWidget(q10Edit, 12, 1)
 
     grid.addWidget(QLabel('Artikelthumbnail'), 13, 0)
     grid.addWidget(q11Edit, 13, 1)
 
     grid.addWidget(QLabel('Artikelfoto'), 14, 0)
     grid.addWidget(q12Edit, 14, 1)
     
     grid.addWidget(QLabel('                                            '+str(rpartikel[12])), 15, 0)
     grid.addWidget(QLabel('Categorie                   *'),15,0)
     grid.addWidget(q13Edit, 15, 1)
 
     grid.addWidget(QLabel('\u00A9 2017 all rights reserved [email protected]'), 16, 1)
         
     applyBtn = QPushButton('Wijzigen')
     applyBtn.clicked.connect(self.accept)
 
     grid.addWidget(applyBtn, 15, 2)
     applyBtn.setFont(QFont("Arial",10))
     applyBtn.setFixedWidth(100)
     applyBtn.setStyleSheet("color: black;  background-color: gainsboro")
     
     cancelBtn = QPushButton('Sluiten')
     cancelBtn.clicked.connect(lambda: wijzSluit(self, m_email))
 
     grid.addWidget(cancelBtn, 14, 2)
     cancelBtn.setFont(QFont("Arial",10))
     cancelBtn.setFixedWidth(100)
     cancelBtn.setStyleSheet("color: black;  background-color: gainsboro")
                                   
     self.setLayout(grid)
     self.setGeometry(500, 100, 350, 300)
Exemplo n.º 26
0
    def initUI(self):
        # Создание кнопок
        self.ok_button = QPushButton("Готово")
        self.cancel_button = QPushButton("Закрыть")

        # Создаем пространство
        self.qspacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)

        # Создание меток для ввода языка и степени изучения
        self.label_language = QLabel("Введите язык: ")
        self.label_level = QLabel("Введите степень изучения: ")

        # Создание полей для ввода языка и степени изучения
        self.line_edit_language = QLineEdit()
        self.line_edit_level = QLineEdit()

        # Создание диалогового окна
        self.dialog = QMessageBox()
        self.table = QTableWidget()
        self.table.setRowCount(10)
        self.table.setColumnCount(2)
        self.table.setHorizontalHeaderLabels(('Язык', 'Степень изучения'))
        self.data = [
            ['Python', 'Да'],
            ['Java', 'Да'],
            ['SQL', 'Да']
        ]
        row = 0
        for tup in self.data:
            col = 0

            for item in tup:
                cellinfo = QTableWidgetItem(item)
                self.table.setItem(row, col, cellinfo)
                col += 1
            row += 1



        # Привязываем кнопки к функциям
        self.ok_button.clicked.connect(self.press_button)
        self.cancel_button.clicked.connect(self.close)

        # Создаем горизонтальный виджет и добавляем кнопки
        hbox = QHBoxLayout()
        hbox.addStretch(4)
        hbox.addWidget(self.ok_button)
        hbox.addWidget(self.cancel_button)
        hbox.addItem(self.qspacer)

        # Создаем горизонтальный виджет и добавляем метку и поле для ввода логина
        hbox2 = QHBoxLayout()
        hbox2.addStretch(1)
        hbox2.addWidget(self.table)
        hbox2.addItem(QSpacerItem(200, 500, QSizePolicy.Minimum, QSizePolicy.Expanding))

        # Создаем горизонтальный виджет добавляем метку и поле для ввода пароля
        hbox3 = QHBoxLayout()
        hbox3.addStretch(3)
        hbox3.addWidget(self.label_language)
        hbox3.addWidget(self.line_edit_language)
        hbox3.addItem(QSpacerItem(200, 500, QSizePolicy.Minimum, QSizePolicy.Expanding))

        hbox4 = QHBoxLayout()
        hbox3.addStretch(2)
        hbox3.addWidget(self.label_level)
        hbox3.addWidget(self.line_edit_level)
        hbox3.addItem(QSpacerItem(100, 500, QSizePolicy.Minimum, QSizePolicy.Expanding))

        # Создаем вертикальный виджет
        vbox = QVBoxLayout()
        vbox.addStretch(1)
        vbox.addLayout(hbox4)
        vbox.addLayout(hbox2)
        vbox.addLayout(hbox3)
        vbox.addLayout(hbox)

        # Добавляем все боксы в основное окно
        self.setLayout(vbox)
        self.setGeometry(500, 300, 500, 300)
        self.setWindowTitle('Графический интерфейс')
        self.show()
Exemplo n.º 27
0
    def __init__(self):
        super(ImageWindow, self).__init__()

        self.imagelabel = QLabel()
        self.imagelabel.resize(500, 400)
Exemplo n.º 28
0
    def add_options_panel(self):
        # Prepare the sliders
        options_layout = QVBoxLayout()

        options_layout.addStretch()  # Centralize the sliders
        sliders_layout = QVBoxLayout()
        max_label_width = -1
        for i in range(self.model.nbDof()):
            slider_layout = QHBoxLayout()
            sliders_layout.addLayout(slider_layout)

            # Add a name
            name_label = QLabel()
            name = f"{self.model.nameDof()[i]}"
            name_label.setText(name)
            name_label.setPalette(self.palette_active)
            label_width = name_label.fontMetrics().boundingRect(name_label.text()).width()
            if label_width > max_label_width:
                max_label_width = label_width
            slider_layout.addWidget(name_label)

            # Add the slider
            slider = QSlider(Qt.Horizontal)
            slider.setMinimum(-np.pi*self.double_factor)
            slider.setMaximum(np.pi*self.double_factor)
            slider.setPageStep(self.double_factor)
            slider.setValue(0)
            slider.valueChanged.connect(self.__move_avatar_from_sliders)
            slider.sliderReleased.connect(partial(self.__update_muscle_analyses_graphs, False, False, False, False))
            slider_layout.addWidget(slider)

            # Add the value
            value_label = QLabel()
            value_label.setText(f"{0:.2f}")
            value_label.setPalette(self.palette_active)
            slider_layout.addWidget(value_label)

            # Add to the main sliders
            self.sliders.append((name_label, slider, value_label))
        # Adjust the size of the names
        for name_label, _, _ in self.sliders:
            name_label.setFixedWidth(max_label_width + 1)

        # Put the sliders in a scrollable area
        sliders_widget = QWidget()
        sliders_widget.setLayout(sliders_layout)
        sliders_scroll = QScrollArea()
        sliders_scroll.setFrameShape(0)
        sliders_scroll.setWidgetResizable(True)
        sliders_scroll.setWidget(sliders_widget)
        options_layout.addWidget(sliders_scroll)

        # Add reset button
        button_layout = QHBoxLayout()
        options_layout.addLayout(button_layout)
        reset_push_button = QPushButton("Reset")
        reset_push_button.setPalette(self.palette_active)
        reset_push_button.released.connect(self.reset_q)
        button_layout.addWidget(reset_push_button)

        # Add the radio button for analyses
        option_analyses_group = QGroupBox()
        option_analyses_layout = QVBoxLayout()
        # Add text
        analyse_text = QLabel()
        analyse_text.setPalette(self.palette_active)
        analyse_text.setText("Analyses")
        option_analyses_layout.addWidget(analyse_text)
        # Add the no analyses
        radio_none = QRadioButton()
        radio_none.setPalette(self.palette_active)
        radio_none.setChecked(True)
        radio_none.toggled.connect(lambda: self.__select_analyses_panel(radio_none, 0))
        radio_none.setText("None")
        option_analyses_layout.addWidget(radio_none)
        # Add the muscles analyses
        radio_muscle = QRadioButton()
        radio_muscle.setPalette(self.palette_active)
        radio_muscle.toggled.connect(lambda: self.__select_analyses_panel(radio_muscle, 1))
        radio_muscle.setText("Muscles")
        option_analyses_layout.addWidget(radio_muscle)
        # Add the layout to the interface
        option_analyses_group.setLayout(option_analyses_layout)
        options_layout.addWidget(option_analyses_group)

        # Finalize the options panel
        options_layout.addStretch()  # Centralize the sliders

        # Animation panel
        animation_layout = QVBoxLayout()
        animation_layout.addWidget(self.vtk_window.avatar_widget)

        # Add the animation slider
        animation_slider_layout = QHBoxLayout()
        animation_layout.addLayout(animation_slider_layout)
        load_push_button = QPushButton("Load movement")
        load_push_button.setPalette(self.palette_active)
        load_push_button.released.connect(self.__load_movement_from_button)
        animation_slider_layout.addWidget(load_push_button)

        # Controllers
        self.play_stop_push_button = QPushButton()
        self.play_stop_push_button.setIcon(self.start_icon)
        self.play_stop_push_button.setPalette(self.palette_active)
        self.play_stop_push_button.setEnabled(False)
        self.play_stop_push_button.released.connect(self.__start_stop_animation)
        animation_slider_layout.addWidget(self.play_stop_push_button)

        slider = QSlider(Qt.Horizontal)
        slider.setMinimum(0)
        slider.setMaximum(100)
        slider.setValue(0)
        slider.setEnabled(False)
        slider.valueChanged.connect(self.__animate_from_slider)
        animation_slider_layout.addWidget(slider)

        # Add the frame count
        frame_label = QLabel()
        frame_label.setText(f"{0}")
        frame_label.setPalette(self.palette_inactive)
        animation_slider_layout.addWidget(frame_label)

        self.movement_slider = (slider, frame_label)

        # Global placement of the window
        self.vtk_window.main_layout.addLayout(options_layout, 0, 0)
        self.vtk_window.main_layout.addLayout(animation_layout, 0, 1)
        self.vtk_window.main_layout.setColumnStretch(0, 1)
        self.vtk_window.main_layout.setColumnStretch(1, 2)

        # Change the size of the window to account for the new sliders
        self.vtk_window.resize(self.vtk_window.size().width() * 2, self.vtk_window.size().height())

        # Prepare all the analyses panel
        self.muscle_analyses = MuscleAnalyses(self.analyses_muscle_widget, self)
        if self.model.nbMuscleTotal() == 0:
            radio_muscle.setEnabled(False)
        self.__select_analyses_panel(radio_muscle, 1)
Exemplo n.º 29
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()

        grid = QGridLayout()
        self.test_name_label = QLabel()
        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)

        v_layout = QVBoxLayout()
        v_layout.addLayout(grid, 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)

        preview_mask_button = QPushButton()
        preview_mask_button.setText('Preview New Mask')
        preview_mask_button.pressed.connect(self.preview_mask)

        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)
Exemplo n.º 30
0
    def initUI(self):

        sizeLabel = QLabel("< Picture Max Size >", self)
        sizeLabel.setFont(QFont("SansSerif", 13))
        sizeLabel.resize(230, 30)
        sizeLabel.move(40, 60)

        widthLabel = QLabel("width :", self)
        widthLabel.setFont(QFont("SansSerif", 13))
        widthLabel.move(30, 100)

        heightLabel = QLabel("height :", self)
        heightLabel.setFont(QFont("SansSerif", 13))
        heightLabel.move(240, 100)

        self.widthEdit = QLineEdit("1920", self)
        self.widthEdit.resize(90, 27)
        self.widthEdit.move(110, 105)

        self.heightEdit = QLineEdit("1080", self)
        self.heightEdit.resize(90, 27)
        self.heightEdit.move(330, 105)

        self.inputLabel = QLabel("< Folder Path >", self)
        self.inputLabel.setFont(QFont("SansSerif", 13))
        self.inputLabel.resize(200, 30)
        self.inputLabel.move(40, 160)

        self.inputEdit = QLineEdit(None, self)
        self.inputEdit.resize(350, 25)
        self.inputEdit.move(20, 200)

        button_01 = QPushButton("Reference", self)
        button_01.clicked.connect(self.inputDialog)
        button_01.setFont(QFont("SansSerif", 11))
        button_01.resize(100, 35)
        button_01.move(380, 195)

        outputLabel = QLabel("< Output Directory >", self)
        outputLabel.setFont(QFont("SansSerif", 13))
        outputLabel.resize(200, 30)
        outputLabel.move(40, 250)

        self.outputEdit = QLineEdit(None, self)
        self.outputEdit.resize(350, 25)
        self.outputEdit.move(20, 290)

        button_02 = QPushButton("Reference", self)
        button_02.clicked.connect(self.outputDialog)
        button_02.setFont(QFont("SansSerif", 11))
        button_02.resize(100, 35)
        button_02.move(380, 285)

        button_03 = QPushButton("Resize", self)
        button_03.clicked.connect(self.fileResize)
        button_03.setFont(QFont("SansSerif", 14))
        button_03.resize(120, 45)
        button_03.move(170, 340)

        self.statusBar()

        openWindow = QAction(QIcon(""), "Open", self)
        openWindow.setShortcut("Ctrl+O")
        openWindow.setStatusTip("Open New Window")
        openWindow.triggered.connect(self.Open)

        closeWindow = QAction(QIcon(""), "Exit", self)
        closeWindow.setShortcut("Ctrl+Q")
        closeWindow.setStatusTip("Close this Window")
        closeWindow.triggered.connect(self.Exit)

        choiceFile = QAction(QIcon(""), "File", self)
        choiceFile.setShortcut("Alt+F")
        choiceFile.setStatusTip("Choose from File")
        choiceFile.triggered.connect(self.fromFile)

        choiceFolder = QAction(QIcon(""), "Folder", self)
        choiceFolder.setShortcut("Ctrl+F")
        choiceFolder.setStatusTip("Choose from Folder")
        choiceFolder.triggered.connect(self.fromFolder)

        menubar = self.menuBar()

        windowMenu = menubar.addMenu("&Window")
        choiceMenu = menubar.addMenu("&Choice")
        windowMenu.addAction(openWindow)
        windowMenu.addAction(closeWindow)
        choiceMenu.addAction(choiceFile)
        choiceMenu.addAction(choiceFolder)
        self.setGeometry(300, 300, 500, 420)
        self.setMinimumHeight(420)
        self.setMinimumWidth(500)
        self.setMaximumHeight(420)
        self.setMaximumWidth(500)
        self.setWindowTitle("Resizer")
        self.show()