def __init__(self, drawSelf):
        super(PhotoWindow, self).__init__()
        self.drawSelf = drawSelf
        self.path = os.path.abspath(os.path.join(os.path.dirname(__file__)))

        ## Update for photo
        self.allpictures = []
        self.allpicturesdates = []
        self.allpicturestimes = []
        self.allpicturesImpath = []
        self.allpicturesAzimuth = []
        for i, f in enumerate(self.drawSelf.layerActive.getFeatures()):
            if 'PATH' in self.drawSelf.fields:
                imPath = f.attributes()[f.fieldNameIndex('Path')]
            elif 'PHOTO' in self.drawSelf.fields:
                imPath = f.attributes()[f.fieldNameIndex('photo')]
            else:
                imPath = ''
            try:
                dateTrue = str(f.attributes()[f.fieldNameIndex(
                    'Date')].toString('yyyy-MM-dd'))
            except:
                dateTrue = str(f.attributes()[f.fieldNameIndex('Date')])
            try:
                timeTrue = str(f.attributes()[f.fieldNameIndex(
                    'Time')].toString('hh:mm:ss'))
            except:
                timeTrue = str(f.attributes()[f.fieldNameIndex('Time')])

            if not os.path.exists(imPath):
                prj = QgsProject.instance()
                if prj.fileName():
                    imPath = QFileInfo(prj.fileName()).absolutePath() + \
                             f.attributes()[f.fieldNameIndex('RelPath')]

            azimuth = f.attributes()[f.fieldNameIndex('Azimuth')]
            self.allpictures.append(f.attributes()[f.fieldNameIndex('Name')])
            self.allpicturesdates.append(dateTrue)
            self.allpicturestimes.append(timeTrue)
            self.allpicturesImpath.append(imPath)
            self.allpicturesAzimuth.append(azimuth)

        self.viewer = PhotosViewer(self)

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

        self.setWindowTitle('Photo')
        #self.setWindowFlags(Qt.WindowStaysOnTopHint)
        self.setWindowIcon(QIcon(self.path + "//icon.png"))

        self.infoPhoto1 = QLabel(self)
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.infoPhoto1.setSizePolicy(sizePolicy)
        self.infoPhoto1.setFrameShape(QFrame.Box)

        self.infoPhoto2 = QLabel(self)
        self.infoPhoto2.setSizePolicy(sizePolicy)
        self.infoPhoto2.setFrameShape(QFrame.Box)

        self.infoPhoto3 = QLabel(self)
        self.infoPhoto3.setSizePolicy(sizePolicy)
        self.infoPhoto3.setFrameShape(QFrame.Box)

        self.extent = QPushButton(self)
        self.extent.setSizePolicy(sizePolicy)
        self.extent.setIcon(
            QIcon(self.path + '//svg//mActionZoomFullExtent.svg'))
        self.extent.clicked.connect(self.extentbutton)

        self.zoom = QPushButton(self)
        self.zoom.setSizePolicy(sizePolicy)
        self.zoom.setIcon(QIcon(self.path + '//svg//method-draw-image.svg'))
        self.zoom.clicked.connect(self.zoombutton)

        self.pan = QPushButton(self)
        self.pan.setSizePolicy(sizePolicy)
        self.pan.setIcon(QIcon(self.path + '//svg//mActionPan.svg'))
        self.pan.clicked.connect(self.panbutton)

        self.zoom_to_select = QPushButton(self)
        self.zoom_to_select.setSizePolicy(sizePolicy)
        self.zoom_to_select.setIcon(
            QIcon(self.path + '//svg//mActionZoomToSelected.svg'))
        self.zoom_to_select.clicked.connect(self.zoom_to_selectbutton)

        self.rotate_option = QPushButton(self)
        self.rotate_option.setSizePolicy(sizePolicy)
        self.rotate_option.setIcon(QIcon(self.path + '//svg//rotate.png'))
        self.rotate_option.clicked.connect(self.rotatebutton)

        self.rotate_azimuth = QPushButton(self)
        self.rotate_azimuth.setSizePolicy(sizePolicy)
        self.rotate_azimuth.setIcon(QIcon(self.path + '//svg//tonorth.png'))
        self.rotate_azimuth.clicked.connect(self.rotate_azimuthbutton)

        self.hide_arrow = QPushButton(self)
        self.hide_arrow.setSizePolicy(sizePolicy)
        self.hide_arrow.setIcon(QIcon(self.path + '//svg//arrowRight.png'))
        self.hide_arrow.clicked.connect(self.hide_arrow_button)
        if len(self.allpictures) > 1:
            self.hide_arrow.setEnabled(True)
        else:
            self.hide_arrow.setEnabled(False)

        # Add tips on buttons
        self.extent.setToolTip('Extent photo')
        self.zoom.setToolTip('Select area to zoom')
        self.pan.setToolTip('Pan')
        self.zoom_to_select.setToolTip('Zoom to selected photo')
        self.rotate_option.setToolTip('Rotate 45°')
        self.rotate_azimuth.setToolTip('Rotate to azimuth')
        self.hide_arrow.setToolTip('Hide arrows')

        # Arrange layout
        VBlayout = QVBoxLayout(self)
        HBlayout = QHBoxLayout()
        HBlayout2 = QHBoxLayout()
        HBlayout2.addWidget(self.viewer)
        HBlayout.setAlignment(Qt.AlignCenter)
        HBlayout.addWidget(self.infoPhoto1)
        HBlayout.addWidget(self.infoPhoto2)
        HBlayout.addWidget(self.infoPhoto3)
        HBlayout.addWidget(self.extent)
        HBlayout.addWidget(self.zoom)
        HBlayout.addWidget(self.pan)
        HBlayout.addWidget(self.rotate_option)
        HBlayout.addWidget(self.rotate_azimuth)
        HBlayout.addWidget(self.zoom_to_select)
        HBlayout.addWidget(self.hide_arrow)

        VBlayout.addLayout(HBlayout2)
        VBlayout.addLayout(HBlayout)
Exemple #2
0
import sys

from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton

# 创建一个 application实例
app = QApplication(sys.argv)
win = QWidget()
win.setWindowTitle('Web页面中的JavaScript与 QWebEngineView交互例子')

# 创建一个垂直布局器
layout = QVBoxLayout()
win.setLayout(layout)

# 创建一个 QWebEngineView 对象
view = QWebEngineView()
view.setHtml('''
 <html>
  <head>
   <title>A Demo Page</title>

   <script language="javascript">

    function completeAndReturnName() {
     var fname = document.getElementById('fname').value;
     var lname = document.getElementById('lname').value;
     var full = fname + '' + lname;

     document.getElementById('fullname').value = full;
     document.getElementById('submit-btn').style.display = 'block';
Exemple #3
0
    def initUI(self):
        self.setGeometry(300, 300, 500, 250)
        self.setWindowTitle('Assignment6')

        vbox = QVBoxLayout()

        hbox1 = QHBoxLayout()
        hbox1.addStretch(1)
        self.lbl1 = QLabel('Name:')
        self.lbl2 = QLineEdit()
        hbox1.addWidget(self.lbl1)
        hbox1.addWidget(self.lbl2)
        self.lbl3 = QLabel('Age:')
        self.lbl4 = QLineEdit()
        hbox1.addWidget(self.lbl3)
        hbox1.addWidget(self.lbl4)
        self.lbl5 = QLabel('Score:')
        self.lbl6 = QLineEdit()
        hbox1.addWidget(self.lbl5)
        hbox1.addWidget(self.lbl6)

        hbox2 = QHBoxLayout()
        hbox2.addStretch(1)
        self.lbl7 = QLabel('Amount:')
        self.lbl8 = QLineEdit()
        hbox2.addWidget(self.lbl7)
        hbox2.addWidget(self.lbl8)
        self.lbl9 = QLabel('Key:')
        self.lbl10 = QComboBox()
        self.lbl10.addItem('Name')
        self.lbl10.addItem('Age')
        self.lbl10.addItem('Score')
        hbox2.addWidget(self.lbl9)
        hbox2.addWidget(self.lbl10)

        hbox3 = QHBoxLayout()
        hbox3.addStretch(1)
        self.lbl11 = QPushButton('Add')
        self.lbl11.clicked.connect(self.Add)
        self.lbl12 = QPushButton('Del')
        self.lbl12.clicked.connect(self.S_Del)
        self.lbl13 = QPushButton('Find')
        self.lbl13.clicked.connect(self.S_Find)
        self.lbl14 = QPushButton('Inc')
        self.lbl14.clicked.connect(self.S_Inc)
        self.lbl15 = QPushButton('Show')
        self.lbl15.clicked.connect(self.Show)
        hbox3.addWidget(self.lbl11)
        hbox3.addWidget(self.lbl12)
        hbox3.addWidget(self.lbl13)
        hbox3.addWidget(self.lbl14)
        hbox3.addWidget(self.lbl15)

        vbox.addLayout(hbox1)
        vbox.addLayout(hbox2)
        vbox.addLayout(hbox3)

        self.lbl16 = QLabel('Result:')

        self.lbl17 = QTextEdit()

        vbox.addWidget(self.lbl16)
        vbox.addWidget(self.lbl17)

        self.setLayout(vbox)
        self.show()
Exemple #4
0
    def initUI(self):
        if self.diplomname == '':
            self.setWindowTitle("Create diplom")
        else:
            self.setWindowTitle("Edit diplom "+self.diplomname)

            #rules = diplom.get_rules(diplom, self.diplomname+".rules")
        self.setGeometry(300, 500, 500, 300)
        #self.setFixedWidth(450)
        #self.setFixedHeight(450)
        self.setWindowIcon(QIcon('logo.png'))
        style = "QWidget{background-color:" + self.settingsDict['background-color'] + "; color:" + self.settingsDict[
            'color'] + ";}"
        styleform = "background :" + self.settingsDict['form-background'] + "; font-weight: bold; color:"+ self.settingsDict['color-table']+";"
        self.setGeometry(int(self.settingsDict['log-form-window-left']), int(self.settingsDict['log-form-window-top']),
                         int(self.settingsDict['log-form-window-width']), int(self.settingsDict['log-form-window-height']))

        self.setStyleSheet(style)
        self.name_layout = QHBoxLayout()
        self.name_label = QLabel("Name diploma:")
        self.name_label.setFixedWidth(150)
        self.name_input = QLineEdit()
        self.name_input.setStyleSheet(styleform)
        self.name_input.setFixedWidth(200)
        self.name_layout.addWidget(self.name_label)
        self.name_layout.addWidget(self.name_input)
        self.name_layout.addStretch(300)
        #








        #
        self.score_layout = QHBoxLayout()
        score_text = QLabel("How many points do you need")
        score_text.setStyleSheet(style)
        self.score_input = QLineEdit()
        self.score_input.setStyleSheet(styleform)
        self.score_input.setText("0")
        self.score_layout.addWidget(score_text)
        self.score_layout.addWidget(self.score_input)
        #
        self.repeat_layout = QHBoxLayout()
        self.text_repeat = QLabel("Repeats:")
        self.repeat_combo = QComboBox()
        self.repeat_combo.setFixedWidth(200)
        self.repeat_combo.addItems(["resolved other bands", "resolved others mod", "resolving other mods and bands", "not resolving"])
        self.repeat_layout.addWidget(self.text_repeat)
        self.repeat_layout.addWidget(self.repeat_combo)
        self.repeat_layout.addStretch(100)
        #
        self.sps_layout = QHBoxLayout()


        self.sps_text = QLabel("Special calls \n or prefix:")
        self.sps_table_widget = QTableWidget()
        self.sps_table_widget.setStyleSheet(styleform)
        self.sps_table_widget.setFixedWidth(240)
        self. sps_table_widget.setFixedHeight(200)
        self.sps_table_widget.setColumnCount(3)
        self.sps_table_widget.setColumnWidth(0, 80)
        self.sps_table_widget.setColumnWidth(1, 50)
        self.sps_table_widget.setColumnWidth(2, 70)
        self.sps_table_widget.setRowCount(10)
        self.sps_table_widget.setHorizontalHeaderLabels(['call', 'score', 'mode'])
        self.sps_table_widget.horizontalHeaderItem(0).setToolTip("Enter special call")
        self.sps_table_widget.horizontalHeaderItem(1).setToolTip("Enter scores for QSO")
        self.sps_table_widget.horizontalHeaderItem(2).setToolTip("Select mode")
        #self.combo_mode = QComboBox()
        #self.combo_mode2 = QComboBox()
        #self.combo_mode.addItems(['SSB', 'CW', 'DIGI'])
        #self.combo_mode2.addItems(['SSB', 'CW', 'DIGI'])
        row_count = self.sps_table_widget.rowCount()
        self.combo_mode_list = []
        if self.diplomname == '':


            for row in range(row_count):
                self.combo_mode_list.append({'combo'+str(row): QComboBox()})
                self.combo_mode_list[row]['combo' + str(row)].addItems(['SSB', 'CW', 'DIGI'])
                self.sps_table_widget.setCellWidget(row, 2, self.combo_mode_list[row]['combo'+str(row)])



        add_row = QPushButton("Add rows")
        add_row.clicked.connect(self.add_row)
        self.prefix_lay = QVBoxLayout()
        #self.prefix_lay.addWidget(self.prefix_check_box)
        self.prefix_lay.addWidget(self.sps_text)
        self.sps_layout.addLayout(self.prefix_lay)
        self.sps_layout.addWidget(self.sps_table_widget)
        self.sps_layout.addWidget(add_row)
        #
        self.button_layout = QHBoxLayout()
        self.cancel_button = QPushButton("Cancel")
        self.cancel_button.clicked.connect(self.close)
        self.ok_button = QPushButton("Create diploma")
        self.ok_button.clicked.connect(self.save_diplom)
        self.button_layout.addWidget(self.cancel_button)
        self.button_layout.addWidget(self.ok_button)
        #
        self.color_label = QLabel()
        self.color_label.setStyleSheet(style)
        self.color_label.setText("Select color for telnet highlight")
        self.color_button = QPushButton()
        #self.color_button.setFixedWidth(100)
        self.color_button.clicked.connect(self.select_color)
        if self.diplomname == '':
            self.color_button.setText("Select color")

        self.color_layout = QHBoxLayout()
        self.color_layout.addWidget(self.color_label)
        self.color_layout.addWidget(self.color_button)
        #
        self.global_layout = QVBoxLayout()
        self.global_layout.addLayout(self.name_layout)
        #self.global_layout.addLayout(self.date_layout)
        #self.spaceItem = QSpacerItem(15, 10)
        #self.global_layout.addSpacerItem(self.spaceItem)
        self.global_layout.addLayout(self.color_layout)
        #self.global_layout.addSpacerItem(self.spaceItem)
        self.global_layout.addLayout(self.score_layout)
        self.global_layout.addLayout(self.repeat_layout)
        self.global_layout.addLayout(self.sps_layout)
        self.global_layout.addLayout(self.button_layout)
        self.setLayout(self.global_layout)
        if self.diplomname != '':
            self.add_info(self.list_data)
Exemple #5
0
 def confirm(self, message, title):
     label = WWLabel(message)
     vbox = QVBoxLayout()
     vbox.addWidget(label)
     self.exec_layout(vbox, title)
Exemple #6
0
    def __init__(self, window, plugin, keystore):
        title = _("{} Settings").format(plugin.device)
        super(CKCCSettingsDialog, self).__init__(window, title)
        self.setMaximumWidth(540)

        # Note: Coldcard may **not** be connected at present time. Keep working!

        devmgr = plugin.device_manager()
        #config = devmgr.config
        #handler = keystore.handler
        self.thread = thread = keystore.thread
        self.keystore = keystore

        def connect_and_doit():
            # Attempt connection to device, or raise.
            device_id = plugin.choose_device(window, keystore)
            if not device_id:
                raise RuntimeError("Device not connected")
            client = devmgr.client_by_id(device_id)
            if not client:
                raise RuntimeError("Device not connected")
            return client

        body = QWidget()
        body_layout = QVBoxLayout(body)
        grid = QGridLayout()
        grid.setColumnStretch(2, 1)

        # see <http://doc.qt.io/archives/qt-4.8/richtext-html-subset.html>
        title = QLabel('''<center>
<span style="font-size: x-large">Coldcard Wallet</span>
<br><span style="font-size: medium">from Coinkite Inc.</span>
<br><a href="https://coldcardwallet.com">coldcardwallet.com</a>''')
        title.setTextInteractionFlags(Qt.LinksAccessibleByMouse)

        grid.addWidget(title, 0, 0, 1, 2, Qt.AlignHCenter)
        y = 3

        rows = [
            ('xfp', _("Master Fingerprint")),
            ('serial', _("USB Serial")),
            ('fw_version', _("Firmware Version")),
            ('fw_built', _("Build Date")),
            ('bl_version', _("Bootloader")),
        ]
        for row_num, (member_name, label) in enumerate(rows):
            # XXX we know xfp already, even if not connected
            widget = QLabel('<tt>000000000000')
            widget.setTextInteractionFlags(Qt.TextSelectableByMouse
                                           | Qt.TextSelectableByKeyboard)

            grid.addWidget(QLabel(label), y, 0, 1, 1, Qt.AlignRight)
            grid.addWidget(widget, y, 1, 1, 1, Qt.AlignLeft)
            setattr(self, member_name, widget)
            y += 1
        body_layout.addLayout(grid)

        upg_btn = QPushButton(_('Upgrade'))

        #upg_btn.setDefault(False)
        def _start_upgrade():
            thread.add(connect_and_doit, on_success=self.start_upgrade)

        upg_btn.clicked.connect(_start_upgrade)

        y += 3
        grid.addWidget(upg_btn, y, 0)
        grid.addWidget(CloseButton(self), y, 1)

        dialog_vbox = QVBoxLayout(self)
        dialog_vbox.addWidget(body)

        # Fetch firmware/versions values and show them.
        thread.add(connect_and_doit,
                   on_success=self.show_values,
                   on_error=self.show_placeholders)
    def edit(self):

        logging.debug('edit() called ExecOp')
        mod_path = os.path.dirname(Pythonic.__file__)

        self.opEditLayout = QVBoxLayout()

        self.op_edit = ElementEditor(self)
        self.op_edit.setWindowTitle(QC.translate('', 'Edit Basic Operation'))

        self.head_info = QLabel()
        self.head_info.setText(
            QC.translate('', 'Enter your Python 3 code below:'))

        self.help_text = QLabel()
        self.help_text.setText(
            QC.translate('', 'Process your own Python 3 code.'))

        self.cmd_line_txt_1 = QLabel()
        self.cmd_line_txt_1.setText(QC.translate('', 'Use custom editor?'))
        self.cmd_line_txt_2 = QLabel()
        self.cmd_line_txt_2.setText(
            QC.translate('',
                         'Use keyword $FILENAME to specify the code file.'))
        self.cmd_line_txt_3 = QLabel()
        self.cmd_line_txt_3.setText(
            QC.translate('', 'Re-open to activate settings.'))

        self.custom_editor_checkbox = QCheckBox()
        self.custom_editor_cmd = QLineEdit()
        self.custom_editor_line = QWidget()
        self.custom_editor_line_layout = QHBoxLayout(self.custom_editor_line)
        self.custom_editor_line_layout.addWidget(self.cmd_line_txt_1)
        self.custom_editor_line_layout.addWidget(self.custom_editor_checkbox)

        self.op_image = QLabel()
        self.op_image.setPixmap(
            QPixmap(os.path.join(mod_path, self.pixmap_path)))

        self.code_input = QTextEdit()
        self.code_input.setMinimumHeight(250)

        # hier logging option einfügen
        self.log_line = QWidget()
        self.ask_for_logging = QLabel()
        self.ask_for_logging.setText(QC.translate('', 'Log output?'))
        self.log_checkbox = QCheckBox()
        self.log_line_layout = QHBoxLayout(self.log_line)
        self.log_line_layout.addWidget(self.ask_for_logging)
        self.log_line_layout.addWidget(self.log_checkbox)
        self.log_line_layout.addStretch(1)

        self.loadLastConfig()

        self.confirm_button = QPushButton(QC.translate('', 'Ok'))

        self.spacer = QSpacerItem(0, 30)
        self.picto_spacer = QSpacerItem(0, 40)

        self.picto_widget = QWidget()
        self.pictogram_layout = QGridLayout(self.picto_widget)
        self.pictogram_layout.addWidget(self.op_image, 0, 0)
        self.pictogram_layout.addItem(self.picto_spacer, 0, 1)
        self.pictogram_layout.addWidget(self.help_text, 0, 2)

        self.opEditLayout.addWidget(self.head_info)
        self.opEditLayout.addWidget(self.code_input)
        self.opEditLayout.addWidget(self.custom_editor_line)
        self.opEditLayout.addWidget(self.custom_editor_cmd)
        self.opEditLayout.addWidget(self.cmd_line_txt_2)
        self.opEditLayout.addWidget(self.cmd_line_txt_3)
        self.opEditLayout.addWidget(self.log_line)
        self.opEditLayout.addSpacerItem(self.spacer)
        self.opEditLayout.addWidget(self.picto_widget)
        self.opEditLayout.addWidget(self.confirm_button)
        self.op_edit.setLayout(self.opEditLayout)

        # signals and slots
        self.custom_editor_checkbox.stateChanged.connect(
            self.toggle_custom_editor)
        self.confirm_button.clicked.connect(self.op_edit.closeEvent)
        self.op_edit.window_closed.connect(self.edit_done)

        self.op_edit.setMinimumHeight(650)
        self.op_edit.show()
    def __init__(self, parent):
        super(MasternodeOutputsTab, self).__init__(parent)
        self.dialog = parent
        self.manager = parent.manager

        include_frozen_checkbox = QCheckBox(_('Include frozen addresses'))
        include_frozen_checkbox.setChecked(False)
        self.scan_outputs_button = QPushButton(
            _('Scan For Masternode Outputs'))

        def on_scan_outputs():
            """Call scan_for_outputs() with whether to include frozen addresses."""
            self.scan_for_outputs(include_frozen_checkbox.isChecked())

        self.scan_outputs_button.clicked.connect(on_scan_outputs)

        self.status_edit = QLineEdit()
        self.status_edit.setReadOnly(True)
        self.valid_outputs_list = MasternodeOutputsWidget()
        self.valid_outputs_list.outputSelected.connect(self.set_output)

        self.collateral_edit = PrevOutWidget()
        self.collateral_edit.setReadOnly(True)

        self.mapper = QDataWidgetMapper()
        self.mapper.setSubmitPolicy(QDataWidgetMapper.ManualSubmit)
        self.mapper.setModel(self.dialog.masternodes_widget.proxy_model)

        model = self.dialog.masternodes_widget.model
        self.mapper.addMapping(self.collateral_edit, model.VIN, b'string')

        self.save_output_button = QPushButton(_('Save'))
        self.save_output_button.setEnabled(False)
        self.save_output_button.clicked.connect(self.save_output)

        vbox = QVBoxLayout()

        desc = ' '.join([
            'Use this tab to scan for and choose a collateral payment for your masternode.',
            'A valid collateral payment is exactly 1000 DASH.'
        ])
        desc = QLabel(_(desc))
        desc.setWordWrap(True)
        vbox.addWidget(desc)

        status_box = QHBoxLayout()
        status_box.setContentsMargins(0, 0, 0, 0)
        status_box.addWidget(QLabel(_('Status:')))
        status_box.addWidget(self.status_edit, stretch=1)
        vbox.addLayout(status_box)

        valid_outputs_box = QVBoxLayout()
        valid_outputs_box.setContentsMargins(0, 0, 0, 0)
        valid_outputs_box.addWidget(QLabel(_('Masternode Outputs:')))
        valid_outputs_box.addWidget(self.valid_outputs_list)

        vbox.addLayout(
            util.Buttons(include_frozen_checkbox, self.scan_outputs_button))
        vbox.addLayout(valid_outputs_box)

        vbox.addWidget(self.collateral_edit)
        vbox.addLayout(util.Buttons(self.save_output_button))
        self.setLayout(vbox)
Exemple #9
0
	def initialize(self):
		layout = QVBoxLayout()

		# Change Likelihood
		vbox = QVBoxLayout()
		likelihoods = ["Python","C","CUDA"]
		self.rbs = [QRadioButton(rtext) for rtext in likelihoods]
		self.change_ll(True)
		[vbox.addWidget(r) for r in self.rbs]
		frame1 = QGroupBox("Likelihood Function")
		frame1.setLayout(vbox)
		layout.addWidget(frame1)

		# Speed Test
		grid1 = QGridLayout()
		self.spin = [QSpinBox(), QSpinBox()]
		[s.setRange(1,1000000000) for s in self.spin]
		self.btest = QPushButton("Test")
		lrepeats = QLabel("Repeats")
		ldatapoints = QLabel("Datapoints")
		self.lavg = QLabel("")
		grid1.addWidget(lrepeats,0,0)
		grid1.addWidget(ldatapoints,0,1)
		grid1.addWidget(self.lavg,0,2)
		grid1.addWidget(self.spin[0],1,0)
		grid1.addWidget(self.spin[1],1,1)
		grid1.addWidget(self.btest,1,2)
		frame2 = QGroupBox("Speed Test Likelihood Function")
		frame2.setLayout(grid1)
		layout.addWidget(frame2)

		# Options
		frame_options = QGroupBox('Options')
		grid2 = QGridLayout()
		leps = QLabel(u"Numerical Integration Error, ε")
		self.le_eps = QLineEdit()
		self.le_eps.setValidator(QDoubleValidator(1e-300,1e300,100))
		lthreads = QLabel('Number of MCMC Threads')
		self.spin_threads = QSpinBox()
		self.spin_threads.setRange(1,1000000)
		grid2.addWidget(leps,0,0)
		grid2.addWidget(self.le_eps,0,1)
		grid2.addWidget(lthreads,1,0)
		grid2.addWidget(self.spin_threads,1,1)
		frame_options.setLayout(grid2)
		layout.addWidget(frame_options)

		# Reset and Log
		frame3 = QFrame()
		hbox = QHBoxLayout()
		breset = QPushButton("Reset")
		bdumplog = QPushButton("Save Log")
		hbox.addWidget(bdumplog)
		hbox.addWidget(breset)
		frame3.setLayout(hbox)
		layout.addWidget(frame3)

		layout.addStretch(1)
		self.setLayout(layout)

		#Fill Forms
		self.init_forms()

		# Connect Forms & Buttons
		[r.toggled.connect(self.change_ll) for r in self.rbs]
		[s.valueChanged.connect(self.update_speed) for s in self.spin]
		self.btest.clicked.connect(self.test_likelihood)
		#self.le_eps.returnPressed.connect(self.update_eps)
		self.le_eps.editingFinished.connect(self.update_eps)
		self.spin_threads.valueChanged.connect(self.update_threads)
		breset.clicked.connect(self.check_reset)
		bdumplog.clicked.connect(self.save_log)

		self.setWindowTitle('Set Preferences')
		# self.setGeometry(200,200,500,300)
		self.show()
Exemple #10
0
    def setup(self, mode, device_list):
        widget_layout = QVBoxLayout()
        self.setLayout(widget_layout)

        # Check whether esptool is installed, show error if not
        esptool_installed = os.path.exists(MODULE_DIR + "/esptool.py")
        if not esptool_installed:
            error_msg = _(
                "The ESP Firmware flasher requires the esptool' "
                "package to be installed.\n"
                "Select \"Third Party Packages\", add 'esptool' "
                "and click 'OK'"
            )
            error_label = QLabel(error_msg)
            widget_layout.addWidget(error_label)
            return

        # Instructions
        grp_instructions = QGroupBox(
            _("How to flash MicroPython to your device")
        )
        grp_instructions_vbox = QVBoxLayout()
        grp_instructions.setLayout(grp_instructions_vbox)
        # Note: we have to specify the link color here, to something
        # that's suitable for both day/night/contrast themes, as the
        # link color is not configurable in the Qt Stylesheets
        instructions = _(
            "&nbsp;1. Determine the type of device (ESP8266 or ESP32)<br />"
            "&nbsp;2. Download firmware from the "
            '<a href="https://micropython.org/download" '
            'style="color:#039be5;">'
            "https://micropython.org/download</a><br/>"
            "&nbsp;3. Connect your device<br/>"
            "&nbsp;4. Load the .bin file below using the 'Browse' button<br/>"
            "&nbsp;5. Press 'Erase & write firmware'"
            # "<br /><br />Check the current MicroPython version using the "
            # "following commands:<br />"
            # ">>> import sys<br />"
            # ">>> sys.implementation"
        )
        label = QLabel(instructions)
        label.setTextFormat(Qt.RichText)
        label.setTextInteractionFlags(Qt.TextBrowserInteraction)
        label.setOpenExternalLinks(True)
        label.setWordWrap(True)
        grp_instructions_vbox.addWidget(label)
        widget_layout.addWidget(grp_instructions)

        # Device type, firmware path, flash button
        device_selector_label = QLabel("Device:")
        self.device_selector = DeviceSelector(show_label=True, icon_first=True)
        self.device_selector.set_device_list(device_list)
        device_type_label = QLabel("Choose device type:")
        self.device_type = QComboBox(self)
        self.device_type.addItem("ESP8266")
        self.device_type.addItem("ESP32")
        firmware_label = QLabel("Firmware (.bin):")
        self.txtFolder = QLineEdit()
        self.btnFolder = QPushButton(_("Browse"))
        self.btnExec = QPushButton(_("Erase && write firmware"))
        self.btnExec.setEnabled(False)
        form_set = QGridLayout()
        form_set.addWidget(device_selector_label, 0, 0)
        form_set.addWidget(self.device_selector, 0, 1, 1, 3)
        form_set.addWidget(device_type_label, 1, 0)
        form_set.addWidget(self.device_type, 1, 1)
        form_set.addWidget(firmware_label, 2, 0)
        form_set.addWidget(self.txtFolder, 2, 1)
        form_set.addWidget(self.btnFolder, 2, 2)
        form_set.addWidget(self.btnExec, 2, 3)
        widget_layout.addLayout(form_set)

        # Output area
        self.log_text_area = QPlainTextEdit()
        self.log_text_area.setReadOnly(True)
        form_set = QHBoxLayout()
        form_set.addWidget(self.log_text_area)
        widget_layout.addLayout(form_set)
        widget_layout.addStretch()

        # Connect events
        self.txtFolder.textChanged.connect(self.firmware_path_changed)
        self.btnFolder.clicked.connect(self.show_folder_dialog)
        self.btnExec.clicked.connect(self.update_firmware)
        self.device_selector.device_changed.connect(self.toggle_exec_button)

        self.mode = mode
    def setupUi(self, Dialog):
        self.verticalLayout = QVBoxLayout(Dialog)

        self.lcd_reading = QLCDNumber(Dialog)
        self.lcd_reading.setMinimumSize(QtCore.QSize(300, 100))
        self.verticalLayout.addWidget(self.lcd_reading)
Exemple #12
0
    def __init__(self, parent=None, email=None, remember_credentials=True):
        super(Login, self).__init__(parent)

        self.login = None
        self.passwd = None
        self.remember = remember_credentials

        self.linkRegister = QLabel(
            '<small><a href="' + config.register_url + '">' +
            QApplication.translate("Plus", "Register", None) + '</a></small>')
        self.linkRegister.setOpenExternalLinks(True)
        self.linkResetPassword = QLabel(
            '<small><a href="' + config.reset_passwd_url + '">' +
            QApplication.translate("Plus", "Reset Password", None) +
            '</a></small>')
        self.linkResetPassword.setOpenExternalLinks(True)

        self.textName = QLineEdit(self)
        self.textName.setPlaceholderText(
            QApplication.translate("Plus", "Email", None))
        if email is not None:
            self.textName.setText(email)
        self.textName.textChanged.connect(self.textChanged)
        self.textPass = QLineEdit(self)
        self.textPass.setEchoMode(QLineEdit.Password)
        self.textPass.setPlaceholderText(
            QApplication.translate("Plus", "Password", None))
        self.textPass.textChanged.connect(self.textChanged)

        self.rememberCheckbox = QCheckBox(
            QApplication.translate("Plus", "Remember", None))
        self.rememberCheckbox.setChecked(self.remember)
        self.rememberCheckbox.stateChanged.connect(self.rememberCheckChanged)

        self.dialogbuttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal)
        aw = config.app_window
        if aw.locale not in aw.qtbase_locales:
            self.dialogbuttons.button(QDialogButtonBox.Ok).setText(
                QApplication.translate("Button", "OK", None))
            self.dialogbuttons.button(QDialogButtonBox.Cancel).setText(
                QApplication.translate("Button", "Cancel", None))
        self.dialogbuttons.accepted.connect(self.setCredentials)
        self.dialogbuttons.rejected.connect(self.reject)
        self.dialogbuttons.button(QDialogButtonBox.Ok).setEnabled(False)
        self.dialogbuttons.button(QDialogButtonBox.Cancel).setDefault(True)
        # add additional CMD-. shortcut to close the dialog
        self.dialogbuttons.button(QDialogButtonBox.Cancel).setShortcut(
            QKeySequence("Ctrl+."))
        # add additional CMD-W shortcut to close this dialog
        cancelAction = QAction(self, triggered=lambda _: self.reject())
        try:
            cancelAction.setShortcut(QKeySequence.Cancel)
        except:
            pass
        self.dialogbuttons.button(QDialogButtonBox.Cancel).addActions(
            [cancelAction])

        credentialsLayout = QVBoxLayout(self)
        credentialsLayout.addWidget(self.textName)
        credentialsLayout.addWidget(self.textPass)
        credentialsLayout.addWidget(self.rememberCheckbox)

        credentialsGroup = QGroupBox()
        credentialsGroup.setLayout(credentialsLayout)

        buttonLayout = QHBoxLayout()
        buttonLayout.addStretch()
        buttonLayout.addWidget(self.dialogbuttons)
        buttonLayout.addStretch()

        linkLayout = QHBoxLayout()
        linkLayout.addStretch()
        linkLayout.addWidget(self.linkRegister)
        linkLayout.addStretch()
        linkLayout.addWidget(self.linkResetPassword)
        linkLayout.addStretch()

        layout = QVBoxLayout(self)
        layout.addWidget(credentialsGroup)
        layout.addLayout(linkLayout)
        layout.addLayout(buttonLayout)
        layout.setContentsMargins(10, 10, 10, 10)
        layout.setSpacing(5)
Exemple #13
0
    def initUI(self):
        # make button
        addButton = QPushButton("Add", self)
        belButton = QPushButton("Del", self)
        findButton = QPushButton("Find", self)
        incButton = QPushButton("Inc", self)
        showButton = QPushButton("show", self)

        addButton.clicked.connect(self.addAction)
        belButton.clicked.connect(self.delAction)
        findButton.clicked.connect(self.findAction)
        incButton.clicked.connect(self.incAction)
        showButton.clicked.connect(self.showScoreDB)

        # =======================================================
        # make label name
        name = QLabel('Name:')
        age = QLabel('Age:')
        score = QLabel('Score:')
        Amount = QLabel('Amount:')
        Result = QLabel('Result:')
        key = QLabel('Key:')

        # make label box
        self.nameEdit = QLineEdit()
        self.ageEdit = QLineEdit()
        self.scoreEdit = QLineEdit()
        self.AmountEdit = QLineEdit()
        self.ResultEdit = QTextEdit()

        self.keybox = QComboBox()
        # key정하는 박스 만들기
        self.keybox.addItem("Name")
        self.keybox.addItem("Age")
        self.keybox.addItem("Score")

        # ========================================================

        self.hbox1 = QHBoxLayout()
        # 1번째 줄
        self.hbox1.addWidget(name)
        self.hbox1.addWidget(self.nameEdit, 1)
        self.hbox1.addWidget(age)
        self.hbox1.addWidget(self.ageEdit, 1)
        self.hbox1.addWidget(score)
        self.hbox1.addWidget(self.scoreEdit, 1)

        self.hbox2 = QHBoxLayout()
        # 2번째 줄
        self.hbox2.addStretch(1)
        self.hbox2.addStretch(1)
        self.hbox2.addWidget(Amount)
        self.hbox2.addWidget(self.AmountEdit, 1)
        self.hbox2.addWidget(key)
        self.hbox2.addWidget(self.keybox)

        self.hbox3 = QHBoxLayout()
        # 3번째 줄
        self.hbox3.addStretch(1)
        self.hbox3.addWidget(addButton)
        self.hbox3.addWidget(belButton)
        self.hbox3.addWidget(findButton)
        self.hbox3.addWidget(incButton)
        self.hbox3.addWidget(showButton)

        self.hbox4 = QHBoxLayout()
        # 4번째 줄
        self.hbox4.addWidget(Result)
        self.hbox4.addStretch(1)

        self.hbox5 = QHBoxLayout()
        # 5번째 줄
        self.hbox5.addWidget(self.ResultEdit, 5)

        self.vbox = QVBoxLayout()
        # 쌓기
        self.vbox.addLayout(self.hbox1)
        self.vbox.addLayout(self.hbox2)
        self.vbox.addLayout(self.hbox3)
        self.vbox.addLayout(self.hbox4)
        self.vbox.addLayout(self.hbox5)

        self.setLayout(self.vbox)

        self.setGeometry(300, 300, 500, 250)
        self.setWindowTitle('Assignment6')
        self.show()
Exemple #14
0
    def __init__(self, parent=None):
        super(AddressBook, self).__init__(parent)

        self.contacts = SortedDict()
        self.oldName = ''
        self.oldAddress = ''
        self.currentMode = self.NavigationMode

        nameLabel = QLabel("Name:")
        self.nameLine = QLineEdit()
        self.nameLine.setReadOnly(True)

        addressLabel = QLabel("Address:")
        self.addressText = QTextEdit()
        self.addressText.setReadOnly(True)

        self.addButton = QPushButton("&Add")
        self.addButton.show()
        self.editButton = QPushButton("&Edit")
        self.editButton.setEnabled(False)
        self.removeButton = QPushButton("&Remove")
        self.removeButton.setEnabled(False)
        self.findButton = QPushButton("&Find")
        self.findButton.setEnabled(False)
        self.submitButton = QPushButton("&Submit")
        self.submitButton.hide()
        self.cancelButton = QPushButton("&Cancel")
        self.cancelButton.hide()

        self.nextButton = QPushButton("&Next")
        self.nextButton.setEnabled(False)
        self.previousButton = QPushButton("&Previous")
        self.previousButton.setEnabled(False)

        self.dialog = FindDialog()

        self.addButton.clicked.connect(self.addContact)
        self.submitButton.clicked.connect(self.submitContact)
        self.editButton.clicked.connect(self.editContact)
        self.removeButton.clicked.connect(self.removeContact)
        self.findButton.clicked.connect(self.findContact)
        self.cancelButton.clicked.connect(self.cancel)
        self.nextButton.clicked.connect(self.next)
        self.previousButton.clicked.connect(self.previous)

        buttonLayout1 = QVBoxLayout()
        buttonLayout1.addWidget(self.addButton)
        buttonLayout1.addWidget(self.editButton)
        buttonLayout1.addWidget(self.removeButton)
        buttonLayout1.addWidget(self.findButton)
        buttonLayout1.addWidget(self.submitButton)
        buttonLayout1.addWidget(self.cancelButton)
        buttonLayout1.addStretch()

        buttonLayout2 = QHBoxLayout()
        buttonLayout2.addWidget(self.previousButton)
        buttonLayout2.addWidget(self.nextButton)

        mainLayout = QGridLayout()
        mainLayout.addWidget(nameLabel, 0, 0)
        mainLayout.addWidget(self.nameLine, 0, 1)
        mainLayout.addWidget(addressLabel, 1, 0, Qt.AlignTop)
        mainLayout.addWidget(self.addressText, 1, 1)
        mainLayout.addLayout(buttonLayout1, 1, 2)
        mainLayout.addLayout(buttonLayout2, 2, 1)

        self.setLayout(mainLayout)
        self.setWindowTitle("Simple Address Book")
Exemple #15
0
    def initUI(self):
        """
        Creates the user interface and displays it.
        """

        # Create rho slider widget and set min and max values
        self.sld_rho = QSlider(Qt.Horizontal)
        self.sld_rho.setMinimum(0)
        self.sld_rho.setMaximum(100)
        self.sld_rho.setValue(70)

        # Create server slider widget and set min and max values
        self.sld_numservers = QSlider(Qt.Horizontal)
        self.sld_numservers.setMinimum(0)
        self.sld_numservers.setMaximum(100)
        self.sld_numservers.setValue(10)

        # Create labels for sliders and their values
        rho = self.sld_rho.value() / 100
        rho_slider_val = '{:.2f}'.format(rho)
        numservers_slider_val = '{:d}'.format(self.sld_numservers.value())

        lbl_rho = QLabel("Traffic Intensity")
        self.lbl_rho_value = QLabel(rho_slider_val)

        lbl_numservers = QLabel("Number of servers")
        self.lbl_numservers_value = QLabel(numservers_slider_val)

        # Create a label and a label widget to show Erlang B and C value
        self.lbl_erlangb_value = QLabel("0.00")
        lbl_erlangb = QLabel("Erlang B")

        self.lbl_erlangc_value = QLabel("0.00")
        lbl_erlangc = QLabel("Erlang C")

        # Create grid layouts to hold the various widgets. The main layout
        # will contain the traffic and erlang grids.
        grid_main = QVBoxLayout()
        grid_traffic = QVBoxLayout()
        grid_rho = QHBoxLayout()
        grid_numservers = QHBoxLayout()
        grid_traffic.addLayout(grid_rho)
        grid_traffic.addLayout(grid_numservers)
        grid_erlang = QGridLayout()

        # Since grid_traffic and grid_erlang are not top-level layouts,
        # need to add them to parent layout before adding anything to them.
        # See http://doc.qt.io/qt-5/qgridlayout.html#details
        grid_main.addLayout(grid_traffic)
        grid_main.addLayout(grid_erlang)

        # Now add the widgets to their respective grid layouts
        grid_rho.addWidget(lbl_rho)
        grid_rho.addWidget(self.sld_rho)
        grid_rho.addWidget(self.lbl_rho_value)

        grid_numservers.addWidget(lbl_numservers)
        grid_numservers.addWidget(self.sld_numservers)
        grid_numservers.addWidget(self.lbl_numservers_value)

        # Since the erlang grid is a QGridLayout, we specify row
        # and column numbers within which to place the widgets.
        grid_erlang.addWidget(lbl_erlangb, 0, 0)
        grid_erlang.addWidget(self.lbl_erlangb_value, 0, 1)
        grid_erlang.addWidget(lbl_erlangc, 1, 0)
        grid_erlang.addWidget(self.lbl_erlangc_value, 1, 1)

        # Set the layout for the ErlangCalc widget
        self.setLayout(grid_main)

        # Hook up slider to a sliderchange function
        self.sld_rho.valueChanged.connect(self.sliderchange)
        self.sld_numservers.valueChanged.connect(self.sliderchange)

        # Position and size the widget (x, y, width, height)
        self.setGeometry(300, 300, 650, 350)
        # Set window title
        self.setWindowTitle('Erlang Calculator')
        # Display the ErlangCalc widget
        self.show()
Exemple #16
0
    def __init__(self, tx, parent, desc, prompt_if_unsaved):
        '''Transactions in the wallet will show their description.
        Pass desc to give a description for txs not yet in the wallet.
        '''
        # We want to be a top-level window
        QDialog.__init__(self, parent=None)
        # Take a copy; it might get updated in the main window by
        # e.g. the FX plugin.  If this happens during or after a long
        # sign operation the signatures are lost.
        self.tx = tx = copy.deepcopy(tx)
        try:
            self.tx.deserialize()
        except BaseException as e:
            raise SerializationError(e)
        self.main_window = parent
        self.wallet = parent.wallet
        self.prompt_if_unsaved = prompt_if_unsaved
        self.saved = False
        self.desc = desc

        # if the wallet can populate the inputs with more info, do it now.
        # as a result, e.g. we might learn an imported address tx is segwit,
        # in which case it's ok to display txid
        tx.add_inputs_info(self.wallet)

        self.setMinimumWidth(880)
        self.setWindowTitle(_("Transaction"))

        vbox = QVBoxLayout()
        self.setLayout(vbox)

        vbox.addWidget(QLabel(_("Transaction ID:")))
        self.tx_hash_e = ButtonsLineEdit()
        qr_show = lambda: parent.show_qrcode(
            str(self.tx_hash_e.text()), 'Transaction ID', parent=self)
        self.tx_hash_e.addButton("qrcode.png", qr_show, _("Show as QR code"))
        self.tx_hash_e.setReadOnly(True)
        vbox.addWidget(self.tx_hash_e)

        self.add_tx_stats(vbox)
        vbox.addSpacing(10)
        self.add_io(vbox)

        self.sign_button = b = QPushButton(_("Sign"))
        b.clicked.connect(self.sign)

        self.broadcast_button = b = QPushButton(_("Broadcast"))
        b.clicked.connect(self.do_broadcast)

        self.save_button = b = QPushButton(_("Save"))
        save_button_disabled = not tx.is_complete()
        b.setDisabled(save_button_disabled)
        if save_button_disabled:
            b.setToolTip(SAVE_BUTTON_DISABLED_TOOLTIP)
        else:
            b.setToolTip(SAVE_BUTTON_ENABLED_TOOLTIP)
        b.clicked.connect(self.save)

        self.export_button = b = QPushButton(_("Export"))
        b.clicked.connect(self.export)

        self.cancel_button = b = QPushButton(_("Close"))
        b.clicked.connect(self.close)
        b.setDefault(True)

        self.qr_button = b = QPushButton()
        b.setIcon(read_QIcon("qrcode.png"))
        b.clicked.connect(self.show_qr)

        self.copy_button = CopyButton(lambda: str(self.tx), parent.app)

        # Action buttons
        self.buttons = [
            self.sign_button, self.broadcast_button, self.cancel_button
        ]
        # Transaction sharing buttons
        self.sharing_buttons = [
            self.copy_button, self.qr_button, self.export_button,
            self.save_button
        ]

        run_hook('transaction_dialog', self)

        hbox = QHBoxLayout()
        share_btn_layout = Buttons(*self.sharing_buttons)
        hbox.addLayout(share_btn_layout)
        hbox.addStretch(1)
        hbox.addLayout(Buttons(*self.buttons))
        vbox.addLayout(hbox)
        self.update()
Exemple #17
0
    def __init__(self):
        super().__init__()

        arguments = self.parseArguments()

        self.DEBUG = arguments.debug

        os.chdir(os.path.dirname(os.path.realpath(__file__)))

        self.MIN_WIDTH = 600
        self.MIN_HEIGHT = 350

        self.setMinimumWidth(self.MIN_WIDTH)
        self.setMinimumHeight(self.MIN_HEIGHT)

        self.ROOT_FOLDER = os.path.expanduser("~/.florodoro/")

        self.HISTORY_FILE_PATH = self.ROOT_FOLDER + "history" + ("" if not self.DEBUG else "-debug") + ".yaml"
        self.CONFIGURATION_FILE_PATH = self.ROOT_FOLDER + "config" + ("" if not self.DEBUG else "-debug") + ".yaml"

        self.history = History(self.HISTORY_FILE_PATH)

        self.SOUNDS_FOLDER = "sounds/"
        self.PLANTS_FOLDER = "plants/"
        self.IMAGE_FOLDER = "images/"

        self.TEXT_COLOR = self.palette().text().color()
        self.BREAK_COLOR = "#B37700"

        self.APP_NAME = "Florodoro"

        self.STUDY_ICON = qtawesome.icon('fa5s.book', color=self.TEXT_COLOR)
        self.BREAK_ICON = qtawesome.icon('fa5s.coffee', color=self.BREAK_COLOR)
        self.CONTINUE_ICON = qtawesome.icon('fa5s.play', color=self.TEXT_COLOR)
        self.PAUSE_ICON = qtawesome.icon('fa5s.pause', color=self.TEXT_COLOR)
        self.RESET_ICON = qtawesome.icon('fa5s.undo', color=self.TEXT_COLOR)

        self.PLANTS = [GreenTree, DoubleGreenTree, OrangeTree, CircularFlower]
        self.PLANT_NAMES = ["Spruce", "Double spruce", "Maple", "Flower"]

        self.WIDGET_SPACING = 10

        self.MAX_TIME = 180
        self.STEP = 5

        self.INITIAL_TEXT = "Start!"

        self.menuBar = QMenuBar(self)
        self.presets_menu = self.menuBar.addMenu('&Presets')

        self.presets = {
            "Classic": (25, 5, 4),
            "Extended": (45, 12, 2),
            "Sitcomodoro": (65, 25, 1),
        }

        for name in self.presets:
            study_time, break_time, cycles = self.presets[name]

            self.presets_menu.addAction(
                QAction(f"{name} ({study_time} : {break_time} : {cycles})", self,
                        triggered=partial(self.load_preset, study_time, break_time, cycles)))

        self.DEFAULT_PRESET = "Classic"

        self.options_menu = self.menuBar.addMenu('&Options')

        self.notify_menu = self.options_menu.addMenu("&Notify")

        self.sound_action = QAction("&Sound", self, checkable=True, checked=not self.DEBUG,
                                    triggered=lambda _: self.volume_slider.setDisabled(
                                        not self.sound_action.isChecked()))

        self.notify_menu.addAction(self.sound_action)

        # Default audio device
        self.audio_device = QAudioDeviceInfo.defaultInputDevice()

        # Create device menu
        self.audio_device_menu = self.notify_menu.addMenu("&Audio Devices")

        # For all sound devices, add a device check box to the device menu
        audio_devices = QAudioDeviceInfo.availableDevices(QAudio.AudioOutput)

        for device in audio_devices:
            device_name = device.deviceName()
            self.device_action = QAction(f"&{device_name}", self, checkable=True, checked=not self.DEBUG, triggered=partial(self.setAudioDevice, device))
            # Create callback of some sort for clicking on the device in the menu
            self.audio_device_menu.addAction(self.device_action)

        self.volume_slider = QSlider(Qt.Horizontal, minimum=0, maximum=100, value=85)
        slider_action = QWidgetAction(self)
        slider_action.setDefaultWidget(SpacedQWidget(self.volume_slider))
        self.notify_menu.addAction(slider_action)

        self.popup_action = QAction("&Pop-up", self, checkable=True, checked=True)
        self.notify_menu.addAction(self.popup_action)

        self.menuBar.addAction(
            QAction(
                "&Statistics",
                self,
                triggered=lambda: self.statistics.show() if self.statistics.isHidden() else self.statistics.hide()
            )
        )

        self.menuBar.addAction(
            QAction(
                "&About",
                self,
                triggered=lambda: QMessageBox.information(
                    self,
                    "About",
                    "This application was created by Tomáš Sláma. It is heavily inspired by the Android app Forest, "
                    "but with all of the plants generated procedurally. It's <a href='https://github.com/xiaoxiae/Florodoro'>open source</a> and licensed "
                    "under MIT, so do as you please with the code and anything else related to the project.",
                ),
            )
        )

        self.plant_menu = self.options_menu.addMenu("&Plants")

        self.overstudy_action = QAction("Overstudy", self, checkable=True)
        self.options_menu.addAction(self.overstudy_action)

        self.plant_images = []
        self.plant_checkboxes = []

        # dynamically create widgets for each plant
        for plant, name in zip(self.PLANTS, self.PLANT_NAMES):
            self.plant_images.append(tempfile.NamedTemporaryFile(suffix=".svg"))
            tmp = plant()
            tmp.set_max_age(1)
            tmp.set_age(1)
            tmp.save(self.plant_images[-1].name, 200, 200)

            setattr(self.__class__, name,
                    QAction(self, icon=QIcon(self.plant_images[-1].name), text=name, checkable=True, checked=True))

            action = getattr(self.__class__, name)

            self.plant_menu.addAction(action)
            self.plant_checkboxes.append(action)

        # the current plant that we're growing
        # if set to none, no plant is growing
        self.plant = None

        self.menuBar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum)

        main_vertical_layout = QVBoxLayout(self)
        main_vertical_layout.setContentsMargins(0, 0, 0, 0)
        main_vertical_layout.setSpacing(0)
        main_vertical_layout.addWidget(self.menuBar)

        self.canvas = Canvas(self)

        self.statistics = Statistics(self.history)

        font = self.font()
        font.setPointSize(100)

        self.main_label = QLabel(self, alignment=Qt.AlignCenter)
        self.main_label.setFont(font)
        self.main_label.setText(self.INITIAL_TEXT)

        font.setPointSize(26)
        self.cycle_label = QLabel(self)
        self.cycle_label.setAlignment(Qt.AlignTop)
        self.cycle_label.setMargin(20)
        self.cycle_label.setFont(font)

        main_horizontal_layout = QHBoxLayout(self)

        self.study_time_spinbox = QSpinBox(self, prefix="Study for: ", suffix="min.", minimum=1, maximum=self.MAX_TIME,
                                           singleStep=self.STEP)

        self.break_time_spinbox = QSpinBox(self, prefix="Break for: ", suffix="min.", minimum=1, maximum=self.MAX_TIME,
                                           singleStep=self.STEP,
                                           styleSheet=f'color:{self.BREAK_COLOR};')

        self.cycles_spinbox = QSpinBox(self, prefix="Cycles: ", minimum=1, value=1)

        # keep track of remaining number of cycles and the starting number of cycles
        self.remaining_cycles = 0
        self.total_cycles = 0

        # whether we're currently studying
        self.is_study_ongoing = False

        # whether we notified the user already during overstudy
        self.already_notified_during_overstudy = False

        stacked_layout = QStackedLayout(self, stackingMode=QStackedLayout.StackAll)
        stacked_layout.addWidget(self.main_label)
        stacked_layout.addWidget(self.cycle_label)
        stacked_layout.addWidget(self.canvas)

        main_vertical_layout.addLayout(stacked_layout)

        self.setStyleSheet("")

        self.study_button = QPushButton(self, clicked=self.start, icon=self.STUDY_ICON)
        self.break_button = QPushButton(self, clicked=self.start_break, icon=self.BREAK_ICON)
        self.pause_button = QPushButton(self, clicked=self.toggle_pause, icon=self.PAUSE_ICON)
        self.reset_button = QPushButton(self, clicked=self.reset, icon=self.RESET_ICON)

        main_horizontal_layout.addWidget(self.study_time_spinbox)
        main_horizontal_layout.addWidget(self.break_time_spinbox)
        main_horizontal_layout.addWidget(self.cycles_spinbox)
        main_horizontal_layout.addWidget(self.study_button)
        main_horizontal_layout.addWidget(self.break_button)
        main_horizontal_layout.addWidget(self.pause_button)
        main_horizontal_layout.addWidget(self.reset_button)

        main_vertical_layout.addLayout(main_horizontal_layout)

        self.setLayout(main_vertical_layout)

        self.study_timer_frequency = 1 / 60 * 1000
        self.study_timer = QTimer(self, interval=int(self.study_timer_frequency), timeout=self.decrease_remaining_time)

        self.player = QMediaPlayer(self)

        self.setWindowIcon(QIcon(self.IMAGE_FOLDER + "icon.svg"))
        self.setWindowTitle(self.APP_NAME)

        # set initial UI state
        self.reset()

        # a list of name, getter and setter things to load/save when the app opens/closes
        # also dynamically get settings for selecting/unselecting plants
        self.CONFIGURATION_ATTRIBUTES = [("study-time", self.study_time_spinbox.value,
                                          self.study_time_spinbox.setValue),
                                         ("break-time", self.break_time_spinbox.value,
                                          self.break_time_spinbox.setValue),
                                         ("cycles", self.cycles_spinbox.value, self.cycles_spinbox.setValue),
                                         ("sound", self.sound_action.isChecked, self.sound_action.setChecked),
                                         ("sound-volume", self.volume_slider.value, self.volume_slider.setValue),
                                         ("pop-ups", self.popup_action.isChecked, self.popup_action.setChecked),
                                         ("overstudy", self.overstudy_action.isChecked,
                                          self.overstudy_action.setChecked)] + \
                                        [(name.lower(), getattr(self.__class__, name).isChecked,
                                          getattr(self.__class__, name).setChecked) for _, name in
                                         zip(self.PLANTS, self.PLANT_NAMES)]
        # load the default preset
        self.load_preset(*self.presets[self.DEFAULT_PRESET])

        self.load_settings()
        self.show()
Exemple #18
0
    def initUI(self):
        self.resize(900, 600)
        self.move(300, 300)
        self.setWindowTitle("sample")

        # count_text
        self.Q_num = QLabel("", self)
        self.font = QFont()
        self.font.setPointSize(32)
        self.Q_num.setFont(self.font)
        self.Q_num.move(265, 50)

        # task_layout
        self.label1 = QLabel(self)
        self.label1.setPixmap(QPixmap("figures/white.jpg"))

        self.label2 = QLabel(self)
        self.label2.setPixmap(QPixmap("figures/white.jpg"))

        self.label3 = QLabel(self)
        self.label3.setPixmap(QPixmap("figures/left.png"))

        self.label4 = QLabel(self)
        self.label4.setPixmap(QPixmap("figures/R.png"))

        # buttonの設定
        img = QPixmap("figures/m.jpg")
        self.button1 = QPushButton("")
        self.button1.setIcon(QIcon(img))
        self.button1.setIconSize(QSize(200, 200))
        self.button1.setShortcut(Qt.Key_Up)
        self.button1.clicked.connect(self.button_do1)

        img = QPixmap("figures/h.jpg")
        self.button2 = QPushButton("")
        self.button2.setIcon(QIcon(img))
        self.button2.setIconSize(QSize(200, 200))
        self.button2.setShortcut(Qt.Key_Down)
        self.button2.clicked.connect(self.button_do2)

        self.btn_save = QPushButton("保存", self)
        self.btn_save.clicked.connect(self.save_csv)
        self.btn_save.setShortcut(Qt.Key_Right)

        self.btn_start = QPushButton("Start", self)
        self.btn_start.clicked.connect(self.start)
        self.btn_start.setShortcut(Qt.Key_Left)

        # レイアウト配置
        self.task1 = QVBoxLayout()
        self.task1.addSpacing(100)
        self.task1.addWidget(self.label1, alignment=(Qt.AlignRight))
        self.task1.addWidget(self.label3,
                             alignment=(Qt.AlignTop | Qt.AlignRight))

        self.task2 = QVBoxLayout()
        self.task2.addSpacing(100)
        self.task2.addWidget(self.label2)
        self.task2.addWidget(self.label4, alignment=(Qt.AlignTop))

        self.layout = QVBoxLayout()
        self.layout.addWidget(self.button1, alignment=(Qt.AlignBottom))
        self.layout.addWidget(self.button2, alignment=(Qt.AlignTop))
        self.layout.addWidget(self.btn_start)
        self.layout.addWidget(self.btn_save)

        self.task_all = QHBoxLayout()
        self.task_all.addLayout(self.task1)
        self.task_all.addLayout(self.task2)
        self.task_all.addLayout(self.layout)
        self.setLayout(self.task_all)

        # 表示
        self.show()
Exemple #19
0
    def make_page(self):
        page = QFrame()
        layout = QVBoxLayout()
        page.setLayout( layout )

        line1 = QFrame()
        layout1 = QHBoxLayout()
        line1.setLayout( layout1 )
        layout.addWidget( line1 )

        line2 = QFrame()
        layout2 = QHBoxLayout()
        line2.setLayout( layout2 )
        layout.addWidget( line2 )

        line3 = QFrame()
        layout3 = QHBoxLayout()
        line3.setLayout( layout3 )
        layout.addWidget( line3 )

        self.edit_start = QComboBoxNoWheel()
        self.edit_start.addItem("-")
        self.edit_start.addItem("1")
        self.edit_start.addItem("2")
        self.edit_start.addItem("3")
        self.edit_start.currentIndexChanged.connect(self.onChange)
        layout1.addWidget(self.edit_start)

        self.edit_end = QComboBoxNoWheel()
        self.edit_end.addItem("-")
        self.edit_end.addItem("1")
        self.edit_end.addItem("2")
        self.edit_end.addItem("3")
        self.edit_end.currentIndexChanged.connect(self.onChange)
        layout1.addWidget(self.edit_end)

        layout1.addStretch(1)

        delete = QPushButton('Delete')
        delete.clicked.connect(self.delete_self)
        layout1.addWidget(delete)
  
        layout2.addWidget( QLabel("<b>Pos:</b> ") )

        self.edit_posref = QComboBoxNoWheel()
        self.edit_posref.addItem("Chord %")
        self.edit_posref.addItem("Rel Front")
        self.edit_posref.addItem("Rel Rear")
        self.edit_posref.addItem("Abs Pos")
        self.edit_posref.currentIndexChanged.connect(self.onChange)
        layout2.addWidget(self.edit_posref)

        self.edit_pos = QLineEdit()
        self.edit_pos.setFixedWidth(50)
        self.edit_pos.textChanged.connect(self.onChange)
        layout2.addWidget( self.edit_pos )

        layout2.addWidget( QLabel("<b>At Station:</b> ") )
        self.edit_atstation = QLineEdit()
        self.edit_atstation.setFixedWidth(50)
        self.edit_atstation.textChanged.connect(self.onChange)
        layout2.addWidget( self.edit_atstation )

        layout2.addWidget( QLabel("<b>Slope:</b> ") )
        self.edit_slope = QLineEdit()
        self.edit_slope.setFixedWidth(50)
        self.edit_slope.textChanged.connect(self.onChange)
        layout2.addWidget( self.edit_slope )

        layout2.addStretch(1)

        layout3.addWidget( QLabel("<b>Edge Stringer W x H:</b> ") )

        self.edit_width = QLineEdit()
        self.edit_width.setFixedWidth(50)
        self.edit_width.textChanged.connect(self.onChange)
        layout3.addWidget( self.edit_width )

        self.edit_height = QLineEdit()
        self.edit_height.setFixedWidth(50)
        self.edit_height.textChanged.connect(self.onChange)
        layout3.addWidget( self.edit_height )

        layout3.addWidget( QLabel("<b>Hinge Cutout Angle:</b> ") )

        self.edit_angle = QLineEdit()
        self.edit_angle.setFixedWidth(50)
        self.edit_angle.textChanged.connect(self.onChange)
        layout3.addWidget( self.edit_angle )

        layout3.addStretch(1)

        return page
Exemple #20
0
    def createBox(self, orientation, typ):
        self.d_wheel = Qwt.QwtWheel()
        self.d_wheel.setValue(80)
        self.d_wheel.setWheelWidth(20)
        self.d_wheel.setMass(1.0)
        self.d_thermo = Qwt.QwtThermo()
        self.d_thermo.setOrientation(orientation)

        if (orientation == Qt.Horizontal):
            self.d_thermo.setScalePosition(Qwt.QwtThermo.LeadingScale)
            self.d_wheel.setOrientation(Qt.Vertical)
        else:
            self.d_thermo.setScalePosition(Qwt.QwtThermo.TrailingScale)
            self.d_wheel.setOrientation(Qt.Horizontal)
        if typ == 0:
            colorMap = Qwt.QwtLinearColorMap()
            colorMap.setColorInterval(Qt.blue, Qt.red)
            self.d_thermo.setColorMap(colorMap)
        elif typ == 1:
            colorMap = Qwt.QwtLinearColorMap()
            colorMap.setMode(Qwt.QwtLinearColorMap.FixedColors)
            idx = 4
            colorMap.setColorInterval(Qt.GlobalColor(idx),
                                      Qt.GlobalColor(idx + 10))
            for i in range(10):
                colorMap.addColorStop(i / 10.0, Qt.GlobalColor(idx + i))
            self.d_thermo.setColorMap(colorMap)
        elif typ == 2:
            self.d_wheel.setRange(10, 1000)
            self.d_wheel.setSingleStep(1.0)
            #self.d_thermo.setScaleEngine( Qwt.QwtLogScaleEngine )
            self.d_thermo.setScaleMaxMinor(10)
            self.d_thermo.setFillBrush(Qt.darkCyan)
            self.d_thermo.setAlarmBrush(Qt.magenta)
            self.d_thermo.setAlarmLevel(500.0)
            self.d_wheel.setValue(800)
        elif typ == 3:
            self.d_wheel.setRange(-1000, 1000)
            self.d_wheel.setSingleStep(1.0)
            #self.d_wheel.setPalette( QColor( "Tan" ) )

            #scaleEngine = Qwt.QwtLinearScaleEngine()
            #scaleEngine.setTransformation( Qwt.QwtPowerTransform( 2 ) )

            self.d_thermo.setScaleMaxMinor(5)
            #self.d_thermo.setScaleEngine( scaleEngine )

            pal = QPalette()
            pal.setColor(QPalette.Base, Qt.darkGray)
            #pal.setColor( QPalette.ButtonText, QColor( "darkKhaki" ) )

            self.d_thermo.setPalette(pal)
        elif typ == 4:
            self.d_wheel.setRange(-100, 300)
            self.d_wheel.setInverted(True)

            colorMap = Qwt.QwtLinearColorMap()
            colorMap.setColorInterval(Qt.darkCyan, Qt.yellow)
            self.d_thermo.setColorMap(colorMap)

            self.d_wheel.setValue(243)
        elif typ == 5:
            self.d_thermo.setFillBrush(Qt.darkCyan)
            self.d_thermo.setAlarmBrush(Qt.magenta)
            self.d_thermo.setAlarmLevel(60.0)
        elif typ == 6:
            self.d_thermo.setOriginMode(Qwt.QwtThermo.OriginMinimum)
            #self.d_thermo.setFillBrush( QBrush( "DarkSlateBlue" ) )
            #self.d_thermo.setAlarmBrush( QBrush( "DarkOrange" ) )
            self.d_thermo.setAlarmLevel(60.0)
        elif typ == 7:
            self.d_wheel.setRange(-100, 100)
            self.d_thermo.setOriginMode(Qwt.QwtThermo.OriginCustom)
            self.d_thermo.setOrigin(0.0)
            self.d_thermo.setFillBrush(Qt.darkBlue)

        dmin = self.d_wheel.minimum()
        dmax = self.d_wheel.maximum()

        #if ( self.d_wheel.isInverted() ):
        #    tmp = dmin
        #    dmin = dmax
        #    dmax = tmp
        #    #swap( dmin, dmax )
        self.d_thermo.setScale(dmin, dmax)
        self.d_thermo.setValue(self.d_wheel.value())
        self.d_wheel.valueChanged['double'].connect(self.d_thermo.setValue)

        box = QWidget()

        layout = None

        if (orientation == Qt.Horizontal):
            layout = QHBoxLayout(box)
        else:
            layout = QVBoxLayout(box)
        layout.addWidget(self.d_thermo, Qt.AlignCenter)
        layout.addWidget(self.d_wheel)
        return box
Exemple #21
0
    def __init__(self, handler, data):
        '''Ask user for 2nd factor authentication. Support text and security card methods.
        Use last method from settings, but support downgrade.
        '''
        QDialog.__init__(self, handler.top_level_window())
        self.handler = handler
        self.txdata = data
        self.idxs = self.txdata['keycardData'] if self.txdata['confirmationType'] > 1 else ''
        self.setMinimumWidth(650)
        self.setWindowTitle(_("Ledger Wallet Authentication"))
        self.cfg = copy.deepcopy(self.handler.win.wallet.get_keystore().cfg)
        self.dongle = self.handler.win.wallet.get_keystore().get_client().dongle
        self.pin = ''
        
        self.devmode = self.getDevice2FAMode()
        if self.devmode == 0x11 or self.txdata['confirmationType'] == 1:
            self.cfg['mode'] = 0
        
        vbox = QVBoxLayout()
        self.setLayout(vbox)
        
        def on_change_mode(idx):
            self.cfg['mode'] = 0 if self.devmode == 0x11 else idx if idx > 0 else 1
            if self.cfg['mode'] > 0:
                self.handler.win.wallet.get_keystore().cfg = self.cfg
                self.handler.win.wallet.save_keystore()
            self.update_dlg()
        def return_pin():
            self.pin = self.pintxt.text() if self.txdata['confirmationType'] == 1 else self.cardtxt.text() 
            if self.cfg['mode'] == 1:
                self.pin = ''.join(chr(int(str(i),16)) for i in self.pin)
            self.accept()
        
        self.modebox = QWidget()
        modelayout = QHBoxLayout()
        self.modebox.setLayout(modelayout)
        modelayout.addWidget(QLabel(_("Method:")))
        self.modes = QComboBox()
        modelayout.addWidget(self.modes, 2)
        modelayout.addStretch(1)
        self.modebox.setMaximumHeight(50)
        vbox.addWidget(self.modebox)
        
        self.populate_modes()
        self.modes.currentIndexChanged.connect(on_change_mode)

        self.helpmsg = QTextEdit()
        self.helpmsg.setStyleSheet("QTextEdit { color:black; background-color: lightgray; }")
        self.helpmsg.setReadOnly(True)
        vbox.addWidget(self.helpmsg)
        
        self.pinbox = QWidget()
        pinlayout = QHBoxLayout()
        self.pinbox.setLayout(pinlayout)
        self.pintxt = PasswordLineEdit()
        self.pintxt.setMaxLength(4)
        self.pintxt.returnPressed.connect(return_pin)
        pinlayout.addWidget(QLabel(_("Enter PIN:")))
        pinlayout.addWidget(self.pintxt)
        pinlayout.addWidget(QLabel(_("NOT DEVICE PIN - see above")))
        pinlayout.addStretch(1)
        self.pinbox.setVisible(self.cfg['mode'] == 0)
        vbox.addWidget(self.pinbox)
                    
        self.cardbox = QWidget()
        card = QVBoxLayout()
        self.cardbox.setLayout(card)
        self.addrtext = QTextEdit()
        self.addrtext.setStyleSheet('''
            QTextEdit {
                color:blue; background-color:lightgray; padding:15px 10px; border:none;
                font-size:20pt; font-family: "Courier New", monospace; }
        ''')
        self.addrtext.setReadOnly(True)
        self.addrtext.setMaximumHeight(130)
        card.addWidget(self.addrtext)
        
        def pin_changed(s):
            if len(s) < len(self.idxs):
                i = self.idxs[len(s)]
                addr = self.txdata['address']
                if not constants.net.TESTNET:
                    text = addr[:i] + '<u><b>' + addr[i:i+1] + '</u></b>' + addr[i+1:]
                else:
                    # pin needs to be created from mainnet address
                    addr_mainnet = bitcoin.script_to_address(bitcoin.address_to_script(addr), net=constants.BitcoinMainnet)
                    addr_mainnet = addr_mainnet[:i] + '<u><b>' + addr_mainnet[i:i+1] + '</u></b>' + addr_mainnet[i+1:]
                    text = str(addr) + '\n' + str(addr_mainnet)
                self.addrtext.setHtml(str(text))
            else:
                self.addrtext.setHtml(_("Press Enter"))
                
        pin_changed('')    
        cardpin = QHBoxLayout()
        cardpin.addWidget(QLabel(_("Enter PIN:")))
        self.cardtxt = PasswordLineEdit()
        self.cardtxt.setMaxLength(len(self.idxs))
        self.cardtxt.textChanged.connect(pin_changed)
        self.cardtxt.returnPressed.connect(return_pin)
        cardpin.addWidget(self.cardtxt)
        cardpin.addWidget(QLabel(_("NOT DEVICE PIN - see above")))
        cardpin.addStretch(1)
        card.addLayout(cardpin)
        self.cardbox.setVisible(self.cfg['mode'] == 1)
        vbox.addWidget(self.cardbox)

        self.update_dlg()
Exemple #22
0
    def __init__(self, parent=None):
        super().__init__()
        self.setWindowTitle(self.tr("Welcome Pisi Linux"))
        self.setFixedSize(700, 475)
        self.setWindowIcon(QIcon(":/images/pisilinux-welcome.svg"))
        self.setLayout(QVBoxLayout())
        self.layout().setSpacing(0)
        self.layout().setContentsMargins(0, 0, 0, 0)
        self.setStyleSheet("QPushButton {border: none; text-align: left; color:black;} QLabel {color:black;}")

        x = (QDesktopWidget().width() - self.width()) // 2
        y = (QDesktopWidget().height() - self.height()) // 2
        self.move(x, y)

        # The header code:

        self.headerWidget = QWidget()
        self.headerWidget.setFixedHeight(80)
        self.headerWidget.setLayout(QHBoxLayout())
        self.headerWidget.setStyleSheet("background-image:url(:/images/background.png);")
        self.layout().addWidget(self.headerWidget)

        self.pisiWhiteLogo = QLabel()
        self.pisiWhiteLogo.setFixedSize(64, 64)
        self.pisiWhiteLogo.setScaledContents(True)
        self.pisiWhiteLogo.setPixmap(
            QIcon(":/images/pisi-white.svg").pixmap(self.pisiWhiteLogo.size()))
        self.headerWidget.layout().addWidget(self.pisiWhiteLogo)

        self.pisiTextLabel = QLabel()
        self.pisiTextLabel.setFixedSize(157, 48)
        self.pisiTextLabel.setScaledContents(True)
        self.pisiTextLabel.setPixmap(QPixmap(":/images/pisi-text.png"))
        self.headerWidget.layout().addWidget(self.pisiTextLabel)

        self.headerWidget.layout().addItem(
            QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Expanding))

        self.versionLabel = QLabel()
        font = self.versionLabel.font()
        font.setPointSize(12)
        self.versionLabel.setFont(font)
        self.versionLabel.setText(
            "{} - {}".format(
                QSysInfo.productVersion(), QSysInfo.currentCpuArchitecture()))
        self.versionLabel.setStyleSheet("color: white; font-weight: bold;")
        self.headerWidget.layout().addWidget(self.versionLabel)

        # The middle area code:

        self.contentWidget = QWidget()
        self.contentWidget.setLayout(QVBoxLayout())
        self.contentWidget.setStyleSheet("background-color: white;")
        self.layout().addWidget(self.contentWidget)

        self.meetingLabel = QLabel()
        self.meetingLabel.setText(
            self.tr("Welcome to Pisi Linux!"
                    " Thank you for joining our community!\n\n"
                    "As Pisi GNU/Linux developers,"
                    " we hope you enjoy using Pisi Linux."
                    " The following links will guide you while"
                    " using Pisi Linux. Please do not"
                    " hesitate to inform about your experiences,"
                    " suggestions and errors you have encountered."))

        self.meetingLabel.setWordWrap(True)
        font = self.meetingLabel.font()
        font.setPointSize(10)
        self.meetingLabel.setFont(font)
        self.meetingLabel.setAlignment(Qt.AlignHCenter)
        self.meetingLabel.setStyleSheet("color: black;")
        self.contentWidget.layout().addWidget(self.meetingLabel)

        self.mainLayout = QHBoxLayout()
        self.contentWidget.layout().addLayout(self.mainLayout)

        vlayoutI = QVBoxLayout()

        self.docsHeader = QLabel()
        font = self.docsHeader.font()
        font.setPointSize(14)
        font.setBold(True)
        self.docsHeader.setFont(font)
        self.docsHeader.setAlignment(Qt.AlignHCenter)
        self.docsHeader.setText(self.tr("Documents"))
        vlayoutI.addWidget(self.docsHeader)

        self.installationDocButton = QPushButton()
        self.installationDocButton.setFixedWidth(160)
        self.installationDocButton.setCursor(Qt.PointingHandCursor)
        self.installationDocButton.setText(self.tr("Installation Guide"))
        self.installationDocButton.setIcon(QIcon(':/images/guide.svg'))
        self.installationDocButton.setIconSize(QSize(32, 32))
        vlayoutI.addWidget(self.installationDocButton)

        self.releaseNotesButton = QPushButton()
        self.releaseNotesButton.setFixedWidth(160)
        self.releaseNotesButton.setCursor(Qt.PointingHandCursor)
        self.releaseNotesButton.setText(self.tr("Release Notes"))
        self.releaseNotesButton.setIcon(QIcon(':/images/info.svg'))
        self.releaseNotesButton.setIconSize(QSize(32, 32))
        vlayoutI.addWidget(self.releaseNotesButton)

        self.wikiButton = QPushButton()
        self.wikiButton.setFixedWidth(160)
        self.wikiButton.setCursor(Qt.PointingHandCursor)
        self.wikiButton.setText(self.tr("Pisi Linux Wiki"))
        self.wikiButton.setIcon(QIcon(':/images/wikipedia-logo.svg'))
        self.wikiButton.setIconSize(QSize(32, 32))
        vlayoutI.addWidget(self.wikiButton)

        vlayoutII = QVBoxLayout()

        self.supportHeader = QLabel()
        font = self.supportHeader.font()
        font.setPointSize(14)
        font.setBold(True)
        self.supportHeader.setFont(font)
        self.supportHeader.setAlignment(Qt.AlignHCenter)
        self.supportHeader.setText(self.tr("Support"))
        vlayoutII.addWidget(self.supportHeader)

        self.forumButton = QPushButton()
        self.forumButton.setFixedWidth(160)
        self.forumButton.setCursor(Qt.PointingHandCursor)
        self.forumButton.setText(self.tr("Forum"))
        self.forumButton.setIconSize(QSize(32, 32))
        self.forumButton.setIcon(QIcon(':/images/forum.svg'))
        vlayoutII.addWidget(self.forumButton)

        self.chatButton = QPushButton()
        self.chatButton.setFixedWidth(160)
        self.chatButton.setCursor(Qt.PointingHandCursor)
        self.chatButton.setText(self.tr("PisiLinux Telegram"))
        self.chatButton.setIcon(QIcon(':/images/chat.svg'))
        self.chatButton.setIconSize(QSize(32, 32))
        vlayoutII.addWidget(self.chatButton)

        self.bugsButton = QPushButton()
        self.bugsButton.setFixedWidth(160)
        self.bugsButton.setCursor(Qt.PointingHandCursor)
        self.bugsButton.setText(self.tr("Pisi Linux Bugs"))
        self.bugsButton.setIcon(QIcon(':/images/bug.svg'))
        self.bugsButton.setIconSize(QSize(32, 32))
        vlayoutII.addWidget(self.bugsButton)

        vlayoutIII = QVBoxLayout()

        self.installationHeader = QLabel()
        font = self.installationHeader.font()
        font.setPointSize(14)
        font.setBold(True)
        self.installationHeader.setFont(font)
        self.installationHeader.setAlignment(Qt.AlignHCenter)
        self.installationHeader.setText(self.tr("Installation"))
        vlayoutIII.addWidget(self.installationHeader)

        # TODO: Also for YALI
        self.calamaresButton = QPushButton()
        self.calamaresButton.setFixedWidth(160)
        self.calamaresButton.setCursor(Qt.PointingHandCursor)
        self.calamaresButton.setText(self.tr("Start Installation"))
        self.calamaresButton.setIcon(QIcon(':/images/calamares.svg'))
        self.calamaresButton.setIconSize(QSize(32, 32))
        vlayoutIII.addWidget(self.calamaresButton)

        self.joinUsButton = QPushButton()
        self.joinUsButton.setFixedWidth(160)
        self.joinUsButton.setCursor(Qt.PointingHandCursor)
        self.joinUsButton.setText(self.tr("Join Us"))
        self.joinUsButton.setIcon(QIcon(':/images/join_us.svg'))
        self.joinUsButton.setIconSize(QSize(32, 32))
        vlayoutIII.addWidget(self.joinUsButton)

        self.donateButton = QPushButton()
        self.donateButton.setFixedWidth(160)
        self.donateButton.setCursor(Qt.PointingHandCursor)
        self.donateButton.setText(self.tr("Home"))
        self.donateButton.setIcon(QIcon(':/images/home.svg'))
        self.donateButton.setIconSize(QSize(32, 32))
        vlayoutIII.addWidget(self.donateButton)

        self.mainLayout.addLayout(vlayoutI)
        self.mainLayout.addLayout(vlayoutII)
        self.mainLayout.addLayout(vlayoutIII)

        self.noteLabel = QLabel()
        font = self.noteLabel.font()
        font.setPointSize(12)
        font.setBold(True)
        self.noteLabel.setFont(font)
        self.noteLabel.setText(self.tr("Note: The password is \"live\"."))
        self.noteLabel.setAlignment(Qt.AlignHCenter)
        self.noteLabel.setMinimumSize(250, 50)
        self.noteLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
        self.contentWidget.layout().addWidget(self.noteLabel)

        # The footer code:

        self.footerWidget = QWidget()
        self.footerWidget.setFixedHeight(50)
        self.footerWidget.setLayout(QHBoxLayout())
        self.footerWidget.setStyleSheet(
            "background-image: url(:/images//background.png);")
        self.layout().addWidget(self.footerWidget)

        self.facebookButton = QPushButton()
        self.facebookButton.setFixedSize(36, 36)
        self.facebookButton.setIconSize(QSize(36, 36))
        self.facebookButton.setIcon(QIcon(':/images/facebook.svg'))
        self.facebookButton.setCursor(Qt.PointingHandCursor)
        self.facebookButton.setToolTip(self.tr("Facebook Page"))
        self.footerWidget.layout().addWidget(self.facebookButton)

        self.twitterButton = QPushButton()
        self.twitterButton.setFixedSize(36, 36)
        self.twitterButton.setIconSize(QSize(36, 36))
        self.twitterButton.setIcon(QIcon(':/images/twitter.svg'))
        self.twitterButton.setCursor(Qt.PointingHandCursor)
        self.twitterButton.setToolTip(self.tr("Twitter Page"))
        self.footerWidget.layout().addWidget(self.twitterButton)

        self.instagramButton = QPushButton()
        self.instagramButton.setFixedSize(36, 36)
        self.instagramButton.setIconSize(QSize(36, 36))
        self.instagramButton.setIcon(QIcon(':/images/instagram.svg'))
        self.instagramButton.setCursor(Qt.PointingHandCursor)
        self.instagramButton.setToolTip(self.tr("Instagram Page"))
        self.footerWidget.layout().addWidget(self.instagramButton)

        self.youtubeButton = QPushButton()
        self.youtubeButton.setFixedSize(36, 36)
        self.youtubeButton.setIconSize(QSize(36, 36))
        self.youtubeButton.setIcon(QIcon(':/images/youtube.svg'))
        self.youtubeButton.setCursor(Qt.PointingHandCursor)
        self.youtubeButton.setToolTip(self.tr("YouTube Page"))
        self.footerWidget.layout().addWidget(self.youtubeButton)

        self.githubButton = QPushButton()
        self.githubButton.setFixedSize(36, 36)
        self.githubButton.setIconSize(QSize(36, 36))
        self.githubButton.setIcon(QIcon(':/images/github-logo.svg'))
        self.githubButton.setCursor(Qt.PointingHandCursor)
        self.githubButton.setToolTip(self.tr("Pisi Linux Repositories GitHub Page"))
        self.footerWidget.layout().addWidget(self.githubButton)

        self.github2Button = QPushButton()
        self.github2Button.setFixedSize(36, 36)
        self.github2Button.setIconSize(QSize(36, 36))
        self.github2Button.setIcon(QIcon(':/images/github-logo.svg'))
        self.github2Button.setCursor(Qt.PointingHandCursor)
        self.github2Button.setToolTip(self.tr("Pisi Linux New GitHub Page"))
        self.footerWidget.layout().addWidget(self.github2Button)

        self.github3Button = QPushButton()
        self.github3Button.setFixedSize(36, 36)
        self.github3Button.setIconSize(QSize(36, 36))
        self.github3Button.setIcon(QIcon(':/images/github-logo.svg'))
        self.github3Button.setCursor(Qt.PointingHandCursor)
        self.github3Button.setToolTip(self.tr("forYali GitHub Page"))
        self.footerWidget.layout().addWidget(self.github3Button)

        self.footerWidget.layout().addItem(
            QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Expanding))

        self.startupCheckBox = QCheckBox()
        self.startupCheckBox.setChecked(
            os.path.exists(os.path.join(os.environ["HOME"],
                                        ".config",
                                        "autostart",
                                        "pisilinux-welcome.desktop")))
        font = self.startupCheckBox.font()
        font.setBold(True)
        self.startupCheckBox.setFont(font)
        self.startupCheckBox.setText(self.tr("Show on startup"))
        self.startupCheckBox.setStyleSheet("color: white;")
        self.footerWidget.layout().addWidget(self.startupCheckBox)

        self.facebookButton.clicked.connect(self.facebookPage)
        self.twitterButton.clicked.connect(self.twitterPage)
        self.instagramButton.clicked.connect(self.instagramPage)
        self.youtubeButton.clicked.connect(self.youtubePage)
        self.githubButton.clicked.connect(self.githubPage)
        self.github2Button.clicked.connect(self.github2Page)
        self.github3Button.clicked.connect(self.github3Page)

        self.releaseNotesButton.clicked.connect(self.releaseNotes)
        self.wikiButton.clicked.connect(self.wikiPage)
        self.forumButton.clicked.connect(self.forumPage)
        self.chatButton.clicked.connect(self.chatPages)
        self.joinUsButton.clicked.connect(self.joinUsPage)
        self.donateButton.clicked.connect(self.homePage)
        self.startupCheckBox.clicked.connect(self.startupState)
        self.bugsButton.clicked.connect(self.issuesPage)
Exemple #23
0
    def select_storage(self, path, get_wallet_from_daemon) -> Tuple[str, Optional[WalletStorage]]:

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

        msg_label = WWLabel('')
        vbox.addWidget(msg_label)
        hbox2 = QHBoxLayout()
        pw_e = PasswordLineEdit('', self)
        pw_e.setFixedWidth(17 * char_width_in_lineedit())
        pw_label = QLabel(_('Password') + ':')
        hbox2.addWidget(pw_label)
        hbox2.addWidget(pw_e)
        hbox2.addStretch()
        vbox.addLayout(hbox2)

        vbox.addSpacing(50)
        vbox_create_new = QVBoxLayout()
        vbox_create_new.addWidget(QLabel(_('Alternatively') + ':'), alignment=Qt.AlignLeft)
        button_create_new = QPushButton(_('Create New Wallet'))
        button_create_new.setMinimumWidth(120)
        vbox_create_new.addWidget(button_create_new, alignment=Qt.AlignLeft)
        widget_create_new = QWidget()
        widget_create_new.setLayout(vbox_create_new)
        vbox_create_new.setContentsMargins(0, 0, 0, 0)
        vbox.addWidget(widget_create_new)

        self.set_layout(vbox, title=_('Electrum wallet'))

        temp_storage = None  # type: Optional[WalletStorage]
        wallet_folder = os.path.dirname(path)

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

        def on_filename(filename):
            # FIXME? "filename" might contain ".." (etc) and hence sketchy path traversals are possible
            nonlocal temp_storage
            temp_storage = None
            msg = None
            path = os.path.join(wallet_folder, filename)
            wallet_from_memory = get_wallet_from_daemon(path)
            try:
                if wallet_from_memory:
                    temp_storage = wallet_from_memory.storage  # type: Optional[WalletStorage]
                else:
                    temp_storage = WalletStorage(path)
            except (StorageReadWriteError, WalletFileException) as e:
                msg = _('Cannot read file') + f'\n{repr(e)}'
            except Exception as e:
                self.logger.exception('')
                msg = _('Cannot read file') + f'\n{repr(e)}'
            self.next_button.setEnabled(temp_storage is not None)
            user_needs_to_enter_password = False
            if temp_storage:
                if not temp_storage.file_exists():
                    msg =_("This file does not exist.") + '\n' \
                          + _("Press 'Next' to create this wallet, or choose another file.")
                elif not wallet_from_memory:
                    if temp_storage.is_encrypted_with_user_pw():
                        msg = _("This file is encrypted with a password.") + '\n' \
                              + _('Enter your password or choose another file.')
                        user_needs_to_enter_password = True
                    elif temp_storage.is_encrypted_with_hw_device():
                        msg = _("This file is encrypted using a hardware device.") + '\n' \
                              + _("Press 'Next' to choose device to decrypt.")
                    else:
                        msg = _("Press 'Next' to open this wallet.")
                else:
                    msg = _("This file is already open in memory.") + "\n" \
                        + _("Press 'Next' to create/focus window.")
            if msg is None:
                msg = _('Cannot read file')
            msg_label.setText(msg)
            widget_create_new.setVisible(bool(temp_storage and temp_storage.file_exists()))
            if user_needs_to_enter_password:
                pw_label.show()
                pw_e.show()
                pw_e.setFocus()
            else:
                pw_label.hide()
                pw_e.hide()

        button.clicked.connect(on_choose)
        button_create_new.clicked.connect(
            partial(
                name_e.setText,
                get_new_wallet_name(wallet_folder)))
        name_e.textChanged.connect(on_filename)
        name_e.setText(os.path.basename(path))

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

        try:
            run_user_interaction_loop()
        finally:
            try:
                pw_e.clear()
            except RuntimeError:  # wrapped C/C++ object has been deleted.
                pass              # happens when decrypting with hw device

        return temp_storage.path, (temp_storage if temp_storage.file_exists() else None)
    def handle_import_clicked():
        dialog = ImportDialog.init(window, AmDatEntry.fields(),
                                   AmDatEntry.fields())
        dialog.import_accepted.connect(handle_import_accepted)
        dialog.show()

    def handle_export_clicked():
        export_data = Foo(id=1,
                          num_gem_slots=3,
                          gem_slot1_lvl=3,
                          gem_slot2_lvl=2,
                          gem_slot3_lvl=1)
        dialog = ExportDialog.init(window, export_data, AmDatEntry.fields(),
                                   AmDatEntry.fields())
        dialog.open()

    import_button = QPushButton("Import data ...")
    import_button.clicked.connect(handle_import_clicked)

    export_button = QPushButton("Export data ...")
    export_button.clicked.connect(handle_export_clicked)

    box = QWidget()
    box.setLayout(QVBoxLayout())
    box.layout().addWidget(import_button)
    box.layout().addWidget(export_button)
    window.setCentralWidget(box)
    window.show()
    sys.exit(app.exec_())
    def __init__(self, initialTriggerChannel, initialTriggerPolarity, initialTriggerBuffer, initialPostTrigger, initialSaveTriggerChannel, parent):
        super().__init__(parent)

        self.setWindowTitle("Episodic Triggered Recording Control")

        label1 = QLabel(
            "Digital or analog inputs lines may be used to trigger recording.  If an analog input line is selected, the threshold between logic high and logic low is 1.65 V.")
        label1.setWordWrap(True)

        digitalInputComboBox = QComboBox()
        digitalInputComboBox.addItem("Digital Input 0")
        digitalInputComboBox.addItem("Digital Input 1")
        digitalInputComboBox.addItem("Digital Input 2")
        digitalInputComboBox.addItem("Digital Input 3")
        digitalInputComboBox.addItem("Digital Input 4")
        digitalInputComboBox.addItem("Digital Input 5")
        digitalInputComboBox.addItem("Digital Input 6")
        digitalInputComboBox.addItem("Digital Input 7")
        digitalInputComboBox.addItem("Digital Input 8")
        digitalInputComboBox.addItem("Digital Input 9")
        digitalInputComboBox.addItem("Digital Input 10")
        digitalInputComboBox.addItem("Digital Input 11")
        digitalInputComboBox.addItem("Digital Input 12")
        digitalInputComboBox.addItem("Digital Input 13")
        digitalInputComboBox.addItem("Digital Input 14")
        digitalInputComboBox.addItem("Digital Input 15")
        digitalInputComboBox.addItem("Analog Input 1")
        digitalInputComboBox.addItem("Analog Input 2")
        digitalInputComboBox.addItem("Analog Input 3")
        digitalInputComboBox.addItem("Analog Input 4")
        digitalInputComboBox.addItem("Analog Input 5")
        digitalInputComboBox.addItem("Analog Input 6")
        digitalInputComboBox.addItem("Analog Input 7")
        digitalInputComboBox.addItem("Analog Input 8")
        digitalInputComboBox.setCurrentIndex(initialTriggerChannel)

        digitalInputComboBox.currentIndexChanged.connect(self.setDigitalInput)

        triggerPolarityComboBox = QComboBox()
        triggerPolarityComboBox.addItem("Trigger on Logic High")
        triggerPolarityComboBox.addItem("Trigger on Logic Low")
        triggerPolarityComboBox.setCurrentIndex(initialTriggerPolarity)

        triggerPolarityComboBox.currentIndexChanged.connect(
            self.setTriggerPolarity)

        self.saveTriggerChannelCheckBox = QCheckBox(
            "Automatically Save Trigger Channel")
        self.saveTriggerChannelCheckBox.setChecked(initialSaveTriggerChannel)

        triggerControls = QVBoxLayout()
        triggerControls.addWidget(digitalInputComboBox)
        triggerControls.addWidget(triggerPolarityComboBox)
        triggerControls.addWidget(self.saveTriggerChannelCheckBox)

        triggerHBox = QHBoxLayout()
        triggerHBox.addLayout(triggerControls)
        triggerHBox.addStretch(1)

        triggerLayout = QVBoxLayout()
        triggerLayout.addWidget(label1)
        triggerLayout.addLayout(triggerHBox)

        triggerGroupBox = QGroupBox("Trigger Source")
        triggerGroupBox.setLayout(triggerLayout)

        triggerHLayout = QHBoxLayout()
        triggerHLayout.addWidget(triggerGroupBox)

        recordBufferSpinBox = QSpinBox()
        recordBufferSpinBox.setRange(1, 30)
        recordBufferSpinBox.setValue(initialTriggerBuffer)

        recordBufferSpinBox.valueChanged.connect(self.recordBufferSeconds)

        bufferSpinBoxLayout = QHBoxLayout()
        bufferSpinBoxLayout.addWidget(recordBufferSpinBox)
        bufferSpinBoxLayout.addWidget(QLabel("seconds"))
        bufferSpinBoxLayout.addStretch(1)

        label2 = QLabel("If a pretrigger buffer size of N seconds is selected, "
                        "slightly more than N seconds of pretrigger data will be "
                        "saved to disk when a trigger is detected, assuming that "
                        "data acquisition has been running for at least N seconds.")
        label2.setWordWrap(True)

        bufferSelectLayout = QVBoxLayout()
        bufferSelectLayout.addWidget(
            QLabel("Pretrigger data saved (range: 1-30 seconds):"))
        bufferSelectLayout.addLayout(bufferSpinBoxLayout)
        bufferSelectLayout.addWidget(label2)

        bufferGroupBox = QGroupBox("Pretrigger Buffer")
        bufferGroupBox.setLayout(bufferSelectLayout)

        bufferHLayout = QHBoxLayout()
        bufferHLayout.addWidget(bufferGroupBox)
    #    bufferHLayout.addStretch(1)

        postTriggerSpinBox = QSpinBox()
        postTriggerSpinBox.setRange(1, 9999)
        postTriggerSpinBox.setValue(initialPostTrigger)

        postTriggerSpinBox.valueChanged.connect(self.postTriggerSeconds)

        postTriggerSpinBoxLayout = QHBoxLayout()
        postTriggerSpinBoxLayout.addWidget(postTriggerSpinBox)
        postTriggerSpinBoxLayout.addWidget(QLabel("seconds"))
        postTriggerSpinBoxLayout.addStretch(1)

        label4 = QLabel("If a posttrigger time of M seconds is selected, "
                        "slightly more than M seconds of data will be "
                        "saved to disk after the trigger is de-asserted.")
        label4.setWordWrap(True)

        postTriggerSelectLayout = QVBoxLayout()
        postTriggerSelectLayout.addWidget(
            QLabel("Posttrigger data saved (range: 1-9999 seconds):"))
        postTriggerSelectLayout.addLayout(postTriggerSpinBoxLayout)
        postTriggerSelectLayout.addWidget(label4)

        postTriggerGroupBox = QGroupBox("Posttrigger Buffer")
        postTriggerGroupBox.setLayout(postTriggerSelectLayout)

        postTriggerHLayout = QHBoxLayout()
        postTriggerHLayout.addWidget(postTriggerGroupBox)
    #    postTriggerHLayout.addStretch(1)

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

        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)

        label3 = QLabel("Press OK to start triggered recording with selected settings.  "
                        "Waveforms will be displayed in real time, but recording will "
                        "not start until the trigger is detected.  A tone will indicate "
                        "when the trigger has been detected.  A different tone indicates "
                        "that recording has stopped after a trigger has been de-asserted.  "
                        "Successive trigger events will create saved data files.  "
                        "Press the Stop button to exit triggered recording mode.")
        label3.setWordWrap(True)

        mainLayout = QVBoxLayout()
        mainLayout.addLayout(triggerHLayout)
        mainLayout.addLayout(bufferHLayout)
        mainLayout.addLayout(postTriggerHLayout)
        mainLayout.addWidget(label3)
        mainLayout.addWidget(self.buttonBox)

        self.setLayout(mainLayout)

        self.setDigitalInput(digitalInputComboBox.currentIndex())
        self.setTriggerPolarity(triggerPolarityComboBox.currentIndex())
        self.recordBufferSeconds(recordBufferSpinBox.value())
        self.postTriggerSeconds(postTriggerSpinBox.value())
Exemple #26
0
    def __init__(self,
                 *,
                 parent: 'ElectrumWindow',
                 desc,
                 prompt_if_unsaved,
                 finalized: bool,
                 external_keypairs=None):
        '''Transactions in the wallet will show their description.
        Pass desc to give a description for txs not yet in the wallet.
        '''
        # We want to be a top-level window
        QDialog.__init__(self, parent=None)
        self.tx = None  # type: Optional[Transaction]
        self.external_keypairs = external_keypairs
        self.finalized = finalized
        self.main_window = parent
        self.config = parent.config
        self.wallet = parent.wallet
        self.prompt_if_unsaved = prompt_if_unsaved
        self.saved = False
        self.desc = desc
        self.setMinimumWidth(640)
        self.resize(1200, 600)
        self.set_title()

        self.psbt_only_widgets = []  # type: List[QWidget]

        vbox = QVBoxLayout()
        self.setLayout(vbox)

        vbox.addWidget(QLabel(_("Transaction ID:")))
        self.tx_hash_e = ButtonsLineEdit()
        qr_show = lambda: parent.show_qrcode(
            str(self.tx_hash_e.text()), 'Transaction ID', parent=self)
        qr_icon = "qrcode_white.png" if ColorScheme.dark_scheme else "qrcode.png"
        self.tx_hash_e.addButton(qr_icon, qr_show, _("Show as QR code"))
        self.tx_hash_e.setReadOnly(True)
        vbox.addWidget(self.tx_hash_e)

        self.add_tx_stats(vbox)

        vbox.addSpacing(10)

        self.inputs_header = QLabel()
        vbox.addWidget(self.inputs_header)
        self.inputs_textedit = QTextEditWithDefaultSize()
        vbox.addWidget(self.inputs_textedit)

        self.txo_color_recv = TxOutputColoring(
            legend=_("Receiving Address"),
            color=ColorScheme.GREEN,
            tooltip=_("Wallet receive address"))
        self.txo_color_change = TxOutputColoring(
            legend=_("Change Address"),
            color=ColorScheme.YELLOW,
            tooltip=_("Wallet change address"))
        self.txo_color_2fa = TxOutputColoring(
            legend=_("TrustedCoin (2FA) batch fee"),
            color=ColorScheme.BLUE,
            tooltip=_(
                "TrustedCoin (2FA) fee for the next batch of transactions"))

        outheader_hbox = QHBoxLayout()
        outheader_hbox.setContentsMargins(0, 0, 0, 0)
        vbox.addLayout(outheader_hbox)
        self.outputs_header = QLabel()
        outheader_hbox.addWidget(self.outputs_header)
        outheader_hbox.addStretch(2)
        outheader_hbox.addWidget(self.txo_color_recv.legend_label)
        outheader_hbox.addWidget(self.txo_color_change.legend_label)
        outheader_hbox.addWidget(self.txo_color_2fa.legend_label)

        self.outputs_textedit = QTextEditWithDefaultSize()
        vbox.addWidget(self.outputs_textedit)

        self.sign_button = b = QPushButton(_("Sign"))
        b.clicked.connect(self.sign)

        self.broadcast_button = b = QPushButton(_("Broadcast"))
        b.clicked.connect(self.do_broadcast)

        self.save_button = b = QPushButton(_("Save"))
        b.clicked.connect(self.save)

        self.cancel_button = b = QPushButton(_("Close"))
        b.clicked.connect(self.close)
        b.setDefault(True)

        self.export_actions_menu = export_actions_menu = QMenu()
        self.add_export_actions_to_menu(export_actions_menu)
        export_actions_menu.addSeparator()
        export_submenu = export_actions_menu.addMenu(
            _("For CoinJoin; strip privates"))
        self.add_export_actions_to_menu(export_submenu,
                                        gettx=self._gettx_for_coinjoin)
        self.psbt_only_widgets.append(export_submenu)
        export_submenu = export_actions_menu.addMenu(
            _("For hardware device; include xpubs"))
        self.add_export_actions_to_menu(export_submenu,
                                        gettx=self._gettx_for_hardware_device)
        self.psbt_only_widgets.append(export_submenu)

        self.export_actions_button = QToolButton()
        self.export_actions_button.setText(_("Export"))
        self.export_actions_button.setMenu(export_actions_menu)
        self.export_actions_button.setPopupMode(QToolButton.InstantPopup)

        self.finalize_button = QPushButton(_('Finalize'))
        self.finalize_button.clicked.connect(self.on_finalize)

        partial_tx_actions_menu = QMenu()
        ptx_merge_sigs_action = QAction(_("Merge signatures from"), self)
        ptx_merge_sigs_action.triggered.connect(self.merge_sigs)
        partial_tx_actions_menu.addAction(ptx_merge_sigs_action)
        self._ptx_join_txs_action = QAction(_("Join inputs/outputs"), self)
        self._ptx_join_txs_action.triggered.connect(self.join_tx_with_another)
        partial_tx_actions_menu.addAction(self._ptx_join_txs_action)
        self.partial_tx_actions_button = QToolButton()
        self.partial_tx_actions_button.setText(_("Combine"))
        self.partial_tx_actions_button.setMenu(partial_tx_actions_menu)
        self.partial_tx_actions_button.setPopupMode(QToolButton.InstantPopup)
        self.psbt_only_widgets.append(self.partial_tx_actions_button)

        # Action buttons
        self.buttons = [
            self.partial_tx_actions_button, self.sign_button,
            self.broadcast_button, self.cancel_button
        ]
        # Transaction sharing buttons
        self.sharing_buttons = [
            self.finalize_button, self.export_actions_button, self.save_button
        ]
        run_hook('transaction_dialog', self)
        if not self.finalized:
            self.create_fee_controls()
            vbox.addWidget(self.feecontrol_fields)
        self.hbox = hbox = QHBoxLayout()
        hbox.addLayout(Buttons(*self.sharing_buttons))
        hbox.addStretch(1)
        hbox.addLayout(Buttons(*self.buttons))
        vbox.addLayout(hbox)
        self.set_buttons_visibility()

        dialogs.append(self)
    def __init__(self):
        super(SpoilerReaderGUI, self).__init__()
        self.filename = self.loadSpoilerData()
        self.spoilerData = SpoilerData(self.filename)

        # Set the window properties
        self.setWindowTitle('OoTR Spoiler Log Reader')
        self.setWindowIcon(QIcon('assets/Ocarina of Time.png'))
        self.setMinimumWidth(1600)

        # Create the central widget
        self._centralWidget = QWidget(self)
        self.setCentralWidget(self._centralWidget)

        # Create the general layout. This is a VBox, with file dialog, browse button, and hash on top,
        # and the item view on the bottom
        self.generalLayout = QVBoxLayout()
        self._centralWidget.setLayout(self.generalLayout)

        # Create the file dialog on the top of the general layout
        # self._createFileDialogLayout()
        self.createTopMatter()

        # Now create an HBox to act as the "overall" item view. Sections will include WOTH items,
        # dungeons and songs, and a tabbed item/entrance viewer
        self.itemLayout = QHBoxLayout()
        self.generalLayout.addLayout(self.itemLayout)

        # Create the scroll area for the WOTH items
        self.wothScroll = self.createScrollArea()
        wothLayout = QFormLayout()
        if self.spoilerData.isTriforceHunt:
            wothHeader = self.createHeaderLabel('Path of Gold')
        else:
            wothHeader = self.createHeaderLabel('Way of the Hero')
        wothLayout.addRow(wothHeader)
        for location in self.spoilerData.locations.values():
            if location.isWOTH:
                itemLabel, locationBox = location.createGUIElements()
                wothLayout.addRow(itemLabel, locationBox)
        wothWidget = QWidget()
        wothWidget.setLayout(wothLayout)
        self.wothScroll.setWidget(wothWidget)

        # Create the scroll area for the dungeons and songs
        self.dungeonsAndSongsScroll = self.createScrollArea()
        dungeonAndSongsLayout = QFormLayout()
        dungeonHeader = self.createHeaderLabel('Dungeons')
        dungeonAndSongsLayout.addRow(dungeonHeader)
        for locationList in self.spoilerData.tabs['Dungeon Prizes'].values():
            for location in locationList:
                itemLabel = location.item.createItemLabel()
                regionBox = location.region.createRegionBox()
                dungeonAndSongsLayout.addRow(itemLabel, regionBox)
        if self.spoilerData.isMQDungeons:
            for region in self.spoilerData.regions.values():
                if region.dungeonType == 'Minor':
                    itemLabel = self.spoilerData.items[
                        region.name].createItemLabel()
                    regionBox = region.createRegionBox()
                    dungeonAndSongsLayout.addRow(itemLabel, regionBox)

        songHeader = self.createHeaderLabel('Songs')
        dungeonAndSongsLayout.addRow(songHeader)
        for locationList in self.spoilerData.tabs['Songs'].values():
            for location in locationList:
                itemLabel, locationBox = location.createGUIElements()
                dungeonAndSongsLayout.addRow(itemLabel, locationBox)
        dungeonsAndSongsWidget = QWidget()
        dungeonsAndSongsWidget.setLayout(dungeonAndSongsLayout)
        self.dungeonsAndSongsScroll.setWidget(dungeonsAndSongsWidget)

        # Create the tab widget and tabs
        self.tabWidget = QTabWidget()
        for tab in self.spoilerData.tabs:
            isTab = tabDictionary[tab]['isTab']
            byRegion = tabDictionary[tab]['byRegion']
            if isTab:
                if tab == 'Dungeon Items':
                    tabScroll = self.createDungeonItemsTab()
                else:
                    tabScroll = self.createGenericTab(tab, byRegion)
                if tabScroll is not None:
                    self.tabWidget.addTab(tabScroll, tab)

        # Check for shopsanity to add shops tab
        if self.spoilerData.isShopsanity:
            self.createShopsTab()

        # Check for entrance randomizer to add entrances and exits
        if self.spoilerData.isEntranceRandomzier:
            self.createEntrancesTab()

        # Add all of the widgets to the layout
        self.itemLayout.addWidget(self.dungeonsAndSongsScroll, 2)
        self.itemLayout.addWidget(self.wothScroll, 2)
        self.itemLayout.addWidget(self.tabWidget, 3)
Exemple #28
0
    def add_tx_stats(self, vbox):
        hbox_stats = QHBoxLayout()

        # left column
        vbox_left = QVBoxLayout()
        self.tx_desc = TxDetailLabel(word_wrap=True)
        vbox_left.addWidget(self.tx_desc)
        self.status_label = TxDetailLabel()
        vbox_left.addWidget(self.status_label)
        self.date_label = TxDetailLabel()
        vbox_left.addWidget(self.date_label)
        self.amount_label = TxDetailLabel()
        vbox_left.addWidget(self.amount_label)
        self.ln_amount_label = TxDetailLabel()
        vbox_left.addWidget(self.ln_amount_label)

        fee_hbox = QHBoxLayout()
        self.fee_label = TxDetailLabel()
        fee_hbox.addWidget(self.fee_label)
        self.fee_warning_icon = QLabel()
        pixmap = QPixmap(icon_path("warning"))
        pixmap_size = round(2 * char_width_in_lineedit())
        pixmap = pixmap.scaled(pixmap_size, pixmap_size, Qt.KeepAspectRatio,
                               Qt.SmoothTransformation)
        self.fee_warning_icon.setPixmap(pixmap)
        self.fee_warning_icon.setVisible(False)
        fee_hbox.addWidget(self.fee_warning_icon)
        fee_hbox.addStretch(1)
        vbox_left.addLayout(fee_hbox)

        vbox_left.addStretch(1)
        hbox_stats.addLayout(vbox_left, 50)

        # vertical line separator
        line_separator = QFrame()
        line_separator.setFrameShape(QFrame.VLine)
        line_separator.setFrameShadow(QFrame.Sunken)
        line_separator.setLineWidth(1)
        hbox_stats.addWidget(line_separator)

        # right column
        vbox_right = QVBoxLayout()
        self.size_label = TxDetailLabel()
        vbox_right.addWidget(self.size_label)
        self.rbf_label = TxDetailLabel()
        vbox_right.addWidget(self.rbf_label)
        self.rbf_cb = QCheckBox(_('Replace by fee'))
        self.rbf_cb.setChecked(bool(self.config.get('use_rbf', True)))
        vbox_right.addWidget(self.rbf_cb)

        self.locktime_final_label = TxDetailLabel()
        vbox_right.addWidget(self.locktime_final_label)

        locktime_setter_hbox = QHBoxLayout()
        locktime_setter_hbox.setContentsMargins(0, 0, 0, 0)
        locktime_setter_hbox.setSpacing(0)
        locktime_setter_label = TxDetailLabel()
        locktime_setter_label.setText("LockTime: ")
        self.locktime_e = LockTimeEdit(self)
        locktime_setter_hbox.addWidget(locktime_setter_label)
        locktime_setter_hbox.addWidget(self.locktime_e)
        locktime_setter_hbox.addStretch(1)
        self.locktime_setter_widget = QWidget()
        self.locktime_setter_widget.setLayout(locktime_setter_hbox)
        vbox_right.addWidget(self.locktime_setter_widget)

        self.block_height_label = TxDetailLabel()
        vbox_right.addWidget(self.block_height_label)
        vbox_right.addStretch(1)
        hbox_stats.addLayout(vbox_right, 50)

        vbox.addLayout(hbox_stats)

        # below columns
        self.block_hash_label = TxDetailLabel(word_wrap=True)
        vbox.addWidget(self.block_hash_label)

        # set visibility after parenting can be determined by Qt
        self.rbf_label.setVisible(self.finalized)
        self.rbf_cb.setVisible(not self.finalized)
        self.locktime_final_label.setVisible(self.finalized)
        self.locktime_setter_widget.setVisible(not self.finalized)
Exemple #29
0
    def initGUI(self, desktop):
        """
        Главный метод инициализации всего графического интерфейса
        """
        self.setGeometry(
            desktop.width() * 0.1,
            desktop.height() * 0.1,
            desktop.width() * 0.8,
            desktop.height() * 0.8
        )

        # Кнопки
        self.action_button = QPushButton('Поиск')
        self.action_button.clicked.connect(self.act)

        self.clear_button = QPushButton('Очистить')
        self.clear_button.clicked.connect(self.clear_forms)

        self.new_button = QPushButton('Создать')
        self.new_button.clicked.connect(self.new)

        self.delete_button = QPushButton('Удалить')
        self.delete_button.clicked.connect(self.delete)

        # Компоновщики
        panel = QGridLayout()
        left_side = QVBoxLayout()
        grid = QGridLayout()

        fields = License.fields

        # Инициализируем список баз
        list_label = QLabel("Лицензии")
        list_label.setAlignment(Qt.AlignCenter)

        self.list_view = QListWidget()
        self.update_list(self.list_view)
        self.list_view.setFixedWidth(desktop.width() * 0.15)
        self.list_view.currentItemChanged.connect(self.fill)
        self.list_view.itemClicked.connect(self.fill)

        # создаем формы для ввода данных
        i = 1
        for field in fields:
            label = QLabel(field.rus)
            if field.type == str:
                self.input_forms[field.eng] = QLineEdit()
                if 'лицензионный ключ' in field.rus.lower():
                    self.input_forms[field.eng].setInputMask('>NNNNN-NNNNN-NNNNN-NNNNN-NNNNN;_')
                elif 'ip' in field.rus:
                    self.input_forms[field.eng].setInputMask('000.000.000.000')

            elif field.type == int:
                self.input_forms[field.eng] = QLineEdit()
                self.input_forms[field.eng].setValidator(QIntValidator())
                if 'год' in field.rus.lower():
                    self.input_forms[field.eng].setValidator(QIntValidator(1900, 2016))
                    self.input_forms[field.eng].setMaxLength(4)
            elif field.type == date:
                self.input_forms[field.eng] = QDateEdit()
                self.input_forms[field.eng].setCalendarPopup(True)
                self.input_forms[field.eng].setMinimumDate(self.MIN_DATE)
                self.input_forms[field.eng].setDate(self.MIN_DATE)

            self.input_forms[field.eng].setEnabled(False)

            grid.addWidget(label, i, 0)
            grid.addWidget(self.input_forms[field.eng], i, 1)
            i += 1

        left_side.addWidget(list_label)
        left_side.addWidget(self.list_view)
        left_side.setSpacing(10)

        panel.addLayout(left_side, 1, 1)
        panel.addLayout(grid, 1, 2, 1, 3)
        panel.addWidget(self.new_button, 2, 1)
        panel.addWidget(self.action_button, 2, 2)
        panel.addWidget(self.clear_button, 2, 3)
        panel.addWidget(self.delete_button, 2, 4)
        self.setLayout(panel)
Exemple #30
0
    def __init__(self, parent, event_classification, lock_status):
        super(QFrame, self).__init__(parent)
        self.setFixedWidth(850)
        self.setFrameStyle(QFrame.Box)
        if event_classification.focus:
            self.setLineWidth(3)

        self.setStyleSheet('background-color: white')

        self.layout = QGridLayout(self)
        self.layout.setAlignment(Qt.AlignTop)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setSpacing(0)

        self.__text_layout = QVBoxLayout()
        self.__text_layout.setSpacing(5)
        self.__text_layout.setContentsMargins(5, 5, 5, 5)
        self.__button_layout = QHBoxLayout()
        self.__button_layout.setSpacing(4)
        self.__button_layout.setContentsMargins(5, 5, 5, 5)

        self.__event_classification = event_classification
        event = self.__event_classification.getEvent()

        self.__id_label = QLabel('ID: {0} - {1}'.format(event.event_id, event.waveform_h[0].getWaveformFileName()))
        self.__id_label.setContentsMargins(5, 5, 5, 5)
        self.__id_label.setStyleSheet('background-color: rgb({0}, {1}, {2}); border-bottom: 1px solid black'.format(*CLASSIFICATION_COLOR_DICT[event_classification.classification]))

        if event.getOriginTime() is None:
            origin_time = "-"
        else:
            origin_time = event.getOriginTime().val.strftime("%H:%M:%S")

        self.__event_values_text = QLabel('Time: {0}    Latitude: {1}    Longitude: {2}    Magnitude: {3}'.format(
            origin_time,
            event.getLatitude().val,
            event.getLongitude().val,
            event.getMagnitude().val,)
            , self)
        self.__event_values_text.setFixedHeight(20)

        category_string = "Event Classification: {0}    ".format(self.__event_classification.classification)
        if self.__event_classification.eqex is not None:
            category_string += 'EQ/EX: {0}    '.format(self.__event_classification.eqex)
        if self.__event_classification.certainty is not None:
            category_string += 'Certainty: {0}'.format(self.__event_classification.certainty)

        self.__event_categorization_text = QLabel(category_string, self)
        self.__event_categorization_text.setFixedHeight(20)

        self.__remove_priority_button = QPushButton('', self)
        self.__remove_priority_button.setIcon(QIcon('{0}/resources/icons/remove.png'.format(PROJECT_FILE_PATH)))
        self.__remove_priority_button.setFixedSize(25, 25)
        self.__remove_priority_button.clicked.connect(self.removePriority)

        if (self.__event_classification.priority < 0 or self.__event_classification.priority > 9999):
            self.__remove_priority_button.hide()

        self.__push_to_top_button = QPushButton('', self)
        self.__push_to_top_button.setIcon(QIcon('{0}/resources/icons/push_to_top.png'.format(PROJECT_FILE_PATH)))
        self.__push_to_top_button.setFixedSize(25, 25)
        self.__push_to_top_button.clicked.connect(self.pushToTopPressed)

        self.__set_as_important_button = QPushButton('', self)
        if self.__event_classification.priority > 9999:
            self.__set_as_important_button.setIcon(QIcon('{0}/resources/icons/set_as_unimportant.png'.format(PROJECT_FILE_PATH)))
        else:
            self.__set_as_important_button.setIcon(QIcon('{0}/resources/icons/set_as_important.png'.format(PROJECT_FILE_PATH)))
        self.__set_as_important_button.setFixedSize(25, 25)
        self.__set_as_important_button.clicked.connect(self.setAsImportantPressed)

        self.__text_layout.addWidget(self.__event_values_text)
        self.__text_layout.addWidget(self.__event_categorization_text)

        self.__button_layout.addWidget(self.__remove_priority_button, 0, Qt.AlignTop)
        self.__button_layout.addWidget(self.__push_to_top_button, 0, Qt.AlignTop)
        self.__button_layout.addWidget(self.__set_as_important_button, 0, Qt.AlignTop)

        self.layout.addWidget(self.__id_label, 0, 0, 1, 2)
        self.layout.addLayout(self.__text_layout, 1, 0)
        self.layout.addLayout(self.__button_layout, 1, 1)

        if lock_status:
            self.unlockEventBox()
        else:
            self.lockEventBox()