Exemple #1
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.resize(800, 480)
        self.setWindowTitle('PySide GUI')
        #self.setWindowFlags(PySide.QtCore.Qt.FramelessWindowHint)

         
        self.wgHome, self.dcHome = self.createHomePage()

        
        # serial page
        self.wgSerial = QWidget(self)
        gridLayout = QGridLayout(self.wgSerial)
        self.lb1 = QLabel('serial page')
        self.lb2 = QLabel('label 2')
        self.lb3 = QLabel('label 3')
        
        gridLayout.addWidget(self.lb1, 0, 0)
        gridLayout.addWidget(self.lb2, 1, 0)
        gridLayout.addWidget(self.lb3, 2, 0)
        

        self.sw = QStackedWidget(self)
        self.sw.addWidget(self.wgHome)
        self.sw.addWidget(self.wgSerial)
        self.setCentralWidget(self.sw)
        
        
        menubar = QMenuBar(self)
        menubar.setGeometry(QRect(0, 0, 731, 29))
        menu_File = QMenu(menubar)
        self.setMenuBar(menubar)
        statusbar = QStatusBar(self)
        self.setStatusBar(statusbar)
        

        actionHome = QAction(self)
        actionHome.setIcon(QIcon("icon/Home-50.png"))
        actionHome.setStatusTip("Home content")
        actionHome.triggered.connect(
            lambda: self.sw.setCurrentWidget(self.wgHome))

        actionSerial = QAction(self)
        actionSerial.setIcon(QIcon("icon/Unicast-50.png"))
        actionSerial.setStatusTip("Serial polling task status")
        actionSerial.triggered.connect(
            lambda: self.sw.setCurrentWidget(self.wgSerial))

        actionLogging = QAction(self)
        actionLogging.setIcon(QIcon("icon/Database-50.png"))
        actionLogging.setStatusTip("Logging task status")
        actionLogging.triggered.connect(
            lambda: self.sw.setCurrentWidget(self.wgLogging))  

        actionUpload = QAction(self)
        actionUpload.setIcon(QIcon("icon/Upload to Cloud-50.png"))
        actionUpload.setStatusTip("Uploading task status")
        actionUpload.triggered.connect(
            lambda: self.sw.setCurrentWidget(self.wgLogging))  

        actionDebug = QAction(self)
        actionDebug.setIcon(QIcon("icon/Bug-50.png"))
        actionDebug.setStatusTip("debug")
        actionDebug.triggered.connect(self.debug)  


        actionAbout = QAction(self)
        actionAbout.triggered.connect(self.about)
        actionAbout.setIcon(QIcon("icon/Info-50.png"))
        actionAbout.setStatusTip("Pop up the About dialog.")

        actionSetting = QAction(self)
        actionSetting.setCheckable(False)
        actionSetting.setObjectName('action_clear')
        actionSetting.setIcon(QIcon("icon/Settings-50.png"))
        

        actionLeft = QAction(self)
        actionLeft.setIcon(QIcon("icon/Left-50.png"))
        actionLeft.setStatusTip("Left page")
        actionLeft.triggered.connect(self.switchLeftWidget)

        actionRight = QAction(self)
        actionRight.setIcon(QIcon("icon/Right-50.png"))
        actionRight.setStatusTip("Right page")
        actionRight.triggered.connect(self.switchRightWidget)
        

        actionClose = QAction(self)
        actionClose.setCheckable(False)
        actionClose.setObjectName("action_Close")        
        actionClose.setIcon(QIcon("icon/Delete-50.png"))
        actionClose.setStatusTip("Close the program.")
        actionClose.triggered.connect(self.close)        

#------------------------------------------------------
        menu_File.addAction(actionHome)
        menu_File.addAction(actionAbout)
        menu_File.addAction(actionClose)
        menu_File.addAction(actionSetting)
        menubar.addAction(menu_File.menuAction())


        iconToolBar = self.addToolBar("iconBar.png")
        iconToolBar.addAction(actionHome)
        
        iconToolBar.addAction(actionSerial)
        iconToolBar.addAction(actionLogging)
        iconToolBar.addAction(actionUpload)

        iconToolBar.addAction(actionDebug)
        
        iconToolBar.addAction(actionAbout)
        iconToolBar.addAction(actionSetting)
        iconToolBar.addAction(actionLeft)
        iconToolBar.addAction(actionRight)
        iconToolBar.addAction(actionClose)
Exemple #2
0
 def setup(self):
     
     self.dirty = False
     
     self.def_cfg = copy.deepcopy(self.config)
     self.config.update_from_user_file()
     self.base_cfg = copy.deepcopy(self.config)
     
     self.categories = QListWidget()
     #self.categories.setSizePolicy(QSizePolicy.Fixed,QSizePolicy.Expanding)
     self.settings = QStackedWidget()
     #self.categories.setSizePolicy(QSizePolicy.MinimumExpanding,QSizePolicy.Expanding)
     
     QObject.connect(self.categories, SIGNAL('itemSelectionChanged()'), self.category_selected)
     
     self.widget_list = {}
     for cat in self.config.get_categories():
         self.widget_list[cat] = {}
     longest_cat = 0
     for cat in self.config.get_categories():
         if len(cat) > longest_cat:
             longest_cat = len(cat)
         self.categories.addItem(cat)
         settings_layout = QGridLayout()
         r = 0
         c = 0
         for setting in self.config.get_settings(cat):
             info = self.config.get_setting(cat, setting, True)
             s = QWidget()
             s.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Fixed)
             sl = QVBoxLayout()
             label = QLabel()
             if info.has_key('alias'):
                 label.setText(info['alias'])
             else:
                 label.setText(setting)
             if info.has_key('about'):
                 label.setToolTip(info['about'])
             sl.addWidget(label)
             if info['type'] == constants.CT_LINEEDIT:
                 w = LineEdit(self, self.config,cat,setting,info)
             elif info['type'] == constants.CT_CHECKBOX:
                 w = CheckBox(self, self.config,cat,setting,info)
             elif info['type'] == constants.CT_SPINBOX:
                 w = SpinBox(self, self.config,cat,setting,info)
             elif info['type'] == constants.CT_DBLSPINBOX:
                 w = DoubleSpinBox(self, self.config,cat,setting,info)
             elif info['type'] == constants.CT_COMBO:
                 w = ComboBox(self, self.config,cat,setting,info)
             w.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Fixed)
             self.widget_list[cat][setting] = w
             sl.addWidget(w)
             s.setLayout(sl)
             c = self.config.config[cat].index(setting) % 2
             settings_layout.addWidget(s, r, c)
             if c == 1:
                 r += 1
         settings = QWidget()
         settings.setLayout(settings_layout)
         settings_scroller = QScrollArea()
         settings_scroller.setWidget(settings)
         settings_scroller.setWidgetResizable(True)
         self.settings.addWidget(settings_scroller)
         
     font = self.categories.font()
     fm = QFontMetrics(font)
     self.categories.setMaximumWidth(fm.widthChar('X')*(longest_cat+4))
     
     self.main = QWidget()
     self.main_layout = QVBoxLayout()
     
     self.config_layout = QHBoxLayout()
     self.config_layout.addWidget(self.categories)
     self.config_layout.addWidget(self.settings)
     
     self.mainButtons = QDialogButtonBox(QDialogButtonBox.RestoreDefaults | QDialogButtonBox.Reset | QDialogButtonBox.Apply)
     self.main_apply = self.mainButtons.button(QDialogButtonBox.StandardButton.Apply)
     self.main_reset = self.mainButtons.button(QDialogButtonBox.StandardButton.Reset)
     self.main_defaults = self.mainButtons.button(QDialogButtonBox.StandardButton.LastButton)
     QObject.connect(self.mainButtons, SIGNAL('clicked(QAbstractButton *)'), self.mainbutton_clicked)
     
     self.dirty_check()
     
     self.main_layout.addLayout(self.config_layout)
     self.main_layout.addWidget(self.mainButtons)
     
     self.main.setLayout(self.main_layout)
     
     self.setCentralWidget(self.main)
     self.setWindowTitle(self.title)
     self.setUnifiedTitleAndToolBarOnMac(True)
     
     self.categories.setCurrentItem(self.categories.item(0))
     
     self.menuBar = QMenuBar()
     self.filemenu = QMenu('&File')
     self.quitAction = QAction(self)
     self.quitAction.setText('&Quit')
     if platform.system() != 'Darwin':
         self.quitAction.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q))
     QObject.connect(self.quitAction, SIGNAL('triggered()'), self.quitApp)
     self.filemenu.addAction(self.quitAction)
     self.menuBar.addMenu(self.filemenu)
     self.setMenuBar(self.menuBar)
     
     self.show()
     self.activateWindow()
     self.raise_()
     
     self.setMinimumWidth(self.geometry().width()*1.2)
     
     screen = QDesktopWidget().screenGeometry()
     size = self.geometry()
     self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2)
    def createMainWidget(self):
        """
        TOWRITE

        :return: TOWRITE
        :rtype: QScrollArea
        """
        widget = QWidget(self)

        # Misc
        groupBoxMisc = QGroupBox(self.tr("General Information"), widget)

        labelStitchesTotal = QLabel(self.tr("Total Stitches:"), self)
        labelStitchesReal = QLabel(self.tr("Real Stitches:"), self)
        labelStitchesJump = QLabel(self.tr("Jump Stitches:"), self)
        labelStitchesTrim = QLabel(self.tr("Trim Stitches:"), self)
        labelColorTotal = QLabel(self.tr("Total Colors:"), self)
        labelColorChanges = QLabel(self.tr("Color Changes:"), self)
        labelRectLeft = QLabel(self.tr("Left:"), self)
        labelRectTop = QLabel(self.tr("Top:"), self)
        labelRectRight = QLabel(self.tr("Right:"), self)
        labelRectBottom = QLabel(self.tr("Bottom:"), self)
        labelRectWidth = QLabel(self.tr("Width:"), self)
        labelRectHeight = QLabel(self.tr("Height:"), self)

        fieldStitchesTotal = QLabel(u'%s' % (self.stitchesTotal), self)
        fieldStitchesReal = QLabel(u'%s' % (self.stitchesReal), self)
        fieldStitchesJump = QLabel(u'%s' % (self.stitchesJump), self)
        fieldStitchesTrim = QLabel(u'%s' % (self.stitchesTrim), self)
        fieldColorTotal = QLabel(u'%s' % (self.colorTotal), self)
        fieldColorChanges = QLabel(u'%s' % (self.colorChanges), self)
        fieldRectLeft = QLabel(u'%s' % (str(self.boundingRect.left()) + " mm"),
                               self)
        fieldRectTop = QLabel(u'%s' % (str(self.boundingRect.top()) + " mm"),
                              self)
        fieldRectRight = QLabel(
            u'%s' % (str(self.boundingRect.right()) + " mm"), self)
        fieldRectBottom = QLabel(
            u'%s' % (str(self.boundingRect.bottom()) + " mm"), self)
        fieldRectWidth = QLabel(
            u'%s' % (str(self.boundingRect.width()) + " mm"), self)
        fieldRectHeight = QLabel(
            u'%s' % (str(self.boundingRect.height()) + " mm"), self)

        gridLayoutMisc = QGridLayout(groupBoxMisc)
        gridLayoutMisc.addWidget(labelStitchesTotal, 0, 0, Qt.AlignLeft)
        gridLayoutMisc.addWidget(labelStitchesReal, 1, 0, Qt.AlignLeft)
        gridLayoutMisc.addWidget(labelStitchesJump, 2, 0, Qt.AlignLeft)
        gridLayoutMisc.addWidget(labelStitchesTrim, 3, 0, Qt.AlignLeft)
        gridLayoutMisc.addWidget(labelColorTotal, 4, 0, Qt.AlignLeft)
        gridLayoutMisc.addWidget(labelColorChanges, 5, 0, Qt.AlignLeft)
        gridLayoutMisc.addWidget(labelRectLeft, 6, 0, Qt.AlignLeft)
        gridLayoutMisc.addWidget(labelRectTop, 7, 0, Qt.AlignLeft)
        gridLayoutMisc.addWidget(labelRectRight, 8, 0, Qt.AlignLeft)
        gridLayoutMisc.addWidget(labelRectBottom, 9, 0, Qt.AlignLeft)
        gridLayoutMisc.addWidget(labelRectWidth, 10, 0, Qt.AlignLeft)
        gridLayoutMisc.addWidget(labelRectHeight, 11, 0, Qt.AlignLeft)
        gridLayoutMisc.addWidget(fieldStitchesTotal, 0, 1, Qt.AlignLeft)
        gridLayoutMisc.addWidget(fieldStitchesReal, 1, 1, Qt.AlignLeft)
        gridLayoutMisc.addWidget(fieldStitchesJump, 2, 1, Qt.AlignLeft)
        gridLayoutMisc.addWidget(fieldStitchesTrim, 3, 1, Qt.AlignLeft)
        gridLayoutMisc.addWidget(fieldColorTotal, 4, 1, Qt.AlignLeft)
        gridLayoutMisc.addWidget(fieldColorChanges, 5, 1, Qt.AlignLeft)
        gridLayoutMisc.addWidget(fieldRectLeft, 6, 1, Qt.AlignLeft)
        gridLayoutMisc.addWidget(fieldRectTop, 7, 1, Qt.AlignLeft)
        gridLayoutMisc.addWidget(fieldRectRight, 8, 1, Qt.AlignLeft)
        gridLayoutMisc.addWidget(fieldRectBottom, 9, 1, Qt.AlignLeft)
        gridLayoutMisc.addWidget(fieldRectWidth, 10, 1, Qt.AlignLeft)
        gridLayoutMisc.addWidget(fieldRectHeight, 11, 1, Qt.AlignLeft)
        gridLayoutMisc.setColumnStretch(1, 1)
        groupBoxMisc.setLayout(gridLayoutMisc)

        # TODO: Color Histogram

        # Stitch Distribution
        # groupBoxDist = QGroupBox(self.tr("Stitch Distribution"), widget)

        # TODO: Stitch Distribution Histogram

        # Widget Layout
        vboxLayoutMain = QVBoxLayout(widget)
        vboxLayoutMain.addWidget(groupBoxMisc)
        # vboxLayoutMain.addWidget(groupBoxDist)
        vboxLayoutMain.addStretch(1)
        widget.setLayout(vboxLayoutMain)

        scrollArea = QScrollArea(self)
        scrollArea.setWidgetResizable(True)
        scrollArea.setWidget(widget)
        return scrollArea
Exemple #4
0
    def initUI(self):

        # textEdit = QTextEdit()
        # self.setCentralWidget(textEdit)

        # self.setStyleSheet("QGroupBox {  border: 1px solid gray; padding: 5px;}");

        # Action to quit program
        exitAction = QAction(QIcon(None), 'Quit', self)
        exitAction.setShortcut('Ctrl+Q')
        exitAction.setStatusTip('Exit application')
        exitAction.triggered.connect(self.close)

        # # Action to update device list
        # self.refreshAction = QAction(QIcon('img/reload.png'), 'Refresh', self)
        # self.refreshAction.setShortcut('F5')
        # self.refreshAction.setStatusTip('Refresh list of connected devices.')
        # self.refreshAction.triggered.connect(self.updateDeviceList)

        # Action to show program information
        helpAction = QAction(QIcon(None), 'Help', self)
        helpAction.setShortcut('F1')
        helpAction.triggered.connect(self.showHelpDialog)

        # Action to help
        aboutAction = QAction(QIcon(None), 'About', self)
        aboutAction.triggered.connect(self.showAboutDialog)

        self.statusBar()

        # Add the file menu
        menubar = self.menuBar()
        fileMenu = menubar.addMenu('&File')
        # fileMenu.addAction(self.refreshAction)
        fileMenu.addAction(exitAction)
        fileMenu = menubar.addMenu('&Help')
        fileMenu.addAction(helpAction)
        fileMenu.addAction(aboutAction)

        # # Add the toolbar
        # toolbar = self.addToolBar('Exit')
        # # toolbar.addAction(self.refreshAction)
        # toolbar.setMovable(False)

        # Add the main windows widgets
        self.deviceListWidget = DeviceList(self.programDeviceHandler,
                                           self.infoDeviceHandler,
                                           self.resetDeviceHandler)
        self.fileSelectorWidget = FileSelector()

        self.setStyleSheet("""
            QStatusBar {
                border-top: 1px solid #CCC;
            }
            QToolBar {
                border-top: 1px solid #DDD;
                border-bottom: 1px solid #CCC;
            }
        """)

        gbox = QGroupBox("Connected USB devices:")
        gboxLayout = QVBoxLayout()
        gboxLayout.addWidget(self.deviceListWidget)
        gbox.setLayout(gboxLayout)

        self.refreshEvent = QTimer()
        self.refreshEvent.setInterval(1250)
        self.refreshEvent.timeout.connect(self.USBUpdate)
        self.refreshEvent.start()

        layout = QVBoxLayout()
        layout.addWidget(self.fileSelectorWidget)
        layout.addWidget(gbox)
        self.setCentralWidget(QWidget())
        self.centralWidget().setLayout(layout)

        self.setMinimumSize(620, 700)
        self.setMaximumWidth(620)
        self.setWindowFlags(Qt.Window | Qt.WindowMinimizeButtonHint
                            | Qt.WindowCloseButtonHint)

        self.setGeometry(300, 300, 350, 250)
        self.setWindowTitle('keyplus layout and firmware loader')
        self.show()
Exemple #5
0
import sys
import utils
from PySide.QtGui import QApplication, QWidget

if __name__ == '__main__':
	with QApplication(sys.argv) as app:
		with QWidget() as window:
			window.show()
		sys.exit(app.exec_())
    def getWidget(self):
        widget = QWidget()
        widget.setLayout(self.layout)

        return widget
 def getParameterWidget(self):
     return QWidget()
 def testVBoxReference(self):
     #QVBoxLayout.addWidget reference count
     w = QWidget()
     self.checkLayoutReference(QVBoxLayout(w))
 def testGridReference(self):
     #QGridLayout.addWidget reference count
     w = QWidget()
     self.checkLayoutReference(QGridLayout(w))
Exemple #10
0
 def setUp(self):
     super(WidgetPySignal, self).setUp()
     self.obj = Dummy()
     self.widget = QWidget()
Exemple #11
0
    def __init__(self, *args, **kwargs):

        self.minimum = 1
        self.maximum = 100
        self.lineEditMaximum = 10000

        QMainWindow.__init__(self, *args, **kwargs)
        self.installEventFilter(self)
        #self.setWindowFlags( QtCore.Qt.Drawer )
        self.setWindowTitle(Window_global.title)

        widgetMain = QWidget()
        layoutVertical = QVBoxLayout(widgetMain)
        self.setCentralWidget(widgetMain)

        layoutSlider = QHBoxLayout()
        lineEdit = QLineEdit()
        lineEdit.setFixedWidth(100)
        lineEdit.setText(str(1))
        validator = QIntValidator(self.minimum, self.lineEditMaximum, self)
        lineEdit.setValidator(validator)
        slider = QSlider()
        slider.setOrientation(QtCore.Qt.Horizontal)
        slider.setMinimum(self.minimum)
        slider.setMaximum(self.maximum)
        layoutSlider.addWidget(lineEdit)
        layoutSlider.addWidget(slider)
        layoutAngle = QVBoxLayout()
        checkBox = QCheckBox('Connect Angle By Tangent')
        layoutVector = QHBoxLayout()
        leVx = QLineEdit()
        leVx.setText(str(1.000))
        leVx.setEnabled(False)
        leVx.setValidator(QDoubleValidator(-100, 100, 5, self))
        leVy = QLineEdit()
        leVy.setText(str(0.000))
        leVy.setEnabled(False)
        leVy.setValidator(QDoubleValidator(-100, 100, 5, self))
        leVz = QLineEdit()
        leVz.setText(str(0.000))
        leVz.setEnabled(False)
        leVz.setValidator(QDoubleValidator(-100, 100, 5, self))
        layoutAngle.addWidget(checkBox)
        layoutAngle.addLayout(layoutVector)
        layoutVector.addWidget(leVx)
        layoutVector.addWidget(leVy)
        layoutVector.addWidget(leVz)
        button = QPushButton('Create')

        layoutVertical.addLayout(layoutSlider)
        layoutVertical.addLayout(layoutAngle)
        layoutVertical.addWidget(button)

        QtCore.QObject.connect(slider, QtCore.SIGNAL('valueChanged(int)'),
                               self.sliderValueChanged)
        QtCore.QObject.connect(lineEdit, QtCore.SIGNAL('textEdited(QString)'),
                               self.lineEditValueChanged)
        QtCore.QObject.connect(button, QtCore.SIGNAL('clicked()'),
                               Functions.createPointOnCurve)
        QtCore.QObject.connect(checkBox, QtCore.SIGNAL('clicked()'),
                               Functions.setAngleEnabled)
        self.slider = slider
        self.lineEdit = lineEdit

        Window_global.slider = slider
        Window_global.button = button
        Window_global.checkBox = checkBox
        Window_global.leVx = leVx
        Window_global.leVy = leVy
        Window_global.leVz = leVz
Exemple #12
0
 def __init__(self):
     super(MainWindow, self).__init__()
     self.setWindowTitle("Cobaya input generator for Cosmology")
     self.setGeometry(0, 0, 1500, 1000)
     self.move(
         QApplication.desktop().screen().rect().center() - self.rect().center())
     self.show()
     # Main layout
     self.layout = QHBoxLayout()
     self.setLayout(self.layout)
     self.layout_left = QVBoxLayout()
     self.layout.addLayout(self.layout_left)
     self.layout_output = QVBoxLayout()
     self.layout.addLayout(self.layout_output)
     # LEFT: Options
     self.options = QWidget()
     self.layout_options = QVBoxLayout()
     self.options.setLayout(self.layout_options)
     self.options_scroll = QScrollArea()
     self.options_scroll.setWidget(self.options)
     self.options_scroll.setWidgetResizable(True)
     self.layout_left.addWidget(self.options_scroll)
     self.atoms = odict()
     titles = odict([
         ["preset", "Presets"],
         ["theory", "Theory code"],
         ["primordial", "Primordial perturbations"],
         ["geometry", "Geometry"],
         ["hubble", "Constaint on hubble parameter"],
         ["baryons", "Baryon sector"],
         ["dark_matter", "Dark matter"],
         ["dark_energy", "Lambda / Dark energy"],
         ["neutrinos", "Neutrinos and other extra matter"],
         ["bbn", "BBN"],
         ["reionization", "Reionization history"],
         ["cmb_lensing", "CMB lensing"],
         ["cmb", "CMB experiments"],
         ["sampler", "Samplers"]])
     for a in titles:
         self.atoms[a] = {
             "group": QGroupBox(titles[a]),
             "combo": QComboBox()}
         self.layout_options.addWidget(self.atoms[a]["group"])
         self.atoms[a]["layout"] = QVBoxLayout(self.atoms[a]["group"])
         self.atoms[a]["layout"].addWidget(self.atoms[a]["combo"])
         self.atoms[a]["combo"].addItems(
             [text(k,v) for k,v in getattr(input_database, a).items()])
     # Connect to refreshers -- needs to be after adding all elements
     for a in self.atoms:
         if a == "preset":
             self.atoms["preset"]["combo"].currentIndexChanged.connect(
                 self.refresh_preset)
             continue
         self.atoms[a]["combo"].currentIndexChanged.connect(self.refresh)
     # Add Planck-naming checkbox and connect to refresher too
     self.planck_names = QCheckBox("Keep common names")
     self.atoms["theory"]["layout"].addWidget(self.planck_names)
     self.planck_names.stateChanged.connect(self.refresh)
     # RIGHT: Output + buttons
     self.display_tabs = QTabWidget()
     self.display = {}
     for k in ["yaml", "python"]:
         self.display[k] = QTextEdit()
         self.display[k].setLineWrapMode(QTextEdit.NoWrap)
         self.display[k].setFontFamily("mono")
         self.display[k].setCursorWidth(0)
         self.display[k].setReadOnly(True)
         self.display_tabs.addTab(self.display[k], k)
     self.layout_output.addWidget(self.display_tabs)
     # Buttons
     self.buttons = QHBoxLayout()
     self.save_button = QPushButton('Save', self)
     self.copy_button = QPushButton('Copy to clipboard', self)
     self.buttons.addWidget(self.save_button)
     self.buttons.addWidget(self.copy_button)
     self.save_button.released.connect(self.save_file)
     self.copy_button.released.connect(self.copy_clipb)
     self.layout_output.addLayout(self.buttons)
     self.save_dialog = QFileDialog()
     self.save_dialog.setFileMode(QFileDialog.AnyFile)
     self.save_dialog.setAcceptMode(QFileDialog.AcceptSave)
    def __init__(self):
        super(DataInspector, self).__init__()

        self.slider_width = +300

        self.main_widget = QWidget(self)
        self.setCentralWidget(self.main_widget)
        self.render_widget = RenderWidget()

        # Create interface actions
        self.action_load_data = QAction('Load data set',
                                        self,
                                        shortcut='Ctrl+O')
        self.action_load_data.setIcon(QIcon("images/AddButton.png"))
        self.action_load_data.triggered.connect(self.load_file)
        self.action_show_simple = QAction('Switch to simple rendering',
                                          self,
                                          shortcut='Ctrl+1')
        self.action_show_simple.setText("Simple")
        self.action_show_simple.triggered.connect(self.switch_to_simple)
        self.action_show_ct = QAction('Switch to CT rendering',
                                      self,
                                      shortcut='Ctrl+2')
        self.action_show_ct.setText("CT")
        self.action_show_ct.triggered.connect(self.switch_to_ct)
        self.action_show_mip = QAction('Switch to MIP rendering',
                                       self,
                                       shortcut='Ctrl+3')
        self.action_show_mip.setText("MIP")
        self.action_show_mip.triggered.connect(self.switch_to_mip)

        # Align the dock buttons to the right with a spacer widget
        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        # Add buttons to container on top
        self.toolbar = self.addToolBar('Main tools')
        self.toolbar.addAction(self.action_show_simple)
        self.toolbar.addAction(self.action_show_ct)
        self.toolbar.addAction(self.action_show_mip)

        self.toolbar.addWidget(spacer)
        self.toolbar.addAction(self.action_load_data)
        self.setUnifiedTitleAndToolBarOnMac(True)

        # Slider for simple visualization
        self.sliders_simple_widget = QSlider(Qt.Horizontal)
        self.sliders_simple_widget.setMinimumWidth(self.slider_width)
        self.sliders_simple_widget.setMaximumWidth(self.slider_width)
        self.sliders_simple_widget.setMinimum(0)
        self.sliders_simple_widget.setMaximum(1000)
        self.sliders_simple_widget.valueChanged.connect(
            self.simple_slider_value_changed)
        self.sliders_simple_widget.setHidden(True)

        # Create sliders for CT transfer function
        sliders_layout = QVBoxLayout()
        sliders_layout.setContentsMargins(0, 0, 0, 0)
        sliders_layout.setSpacing(0)
        self.sliders = []
        for _ in range(0, 7):
            slider = QSlider(Qt.Horizontal)
            slider.setMinimum(0)
            slider.setMaximum(1000)
            slider.valueChanged.connect(self.ct_slider_value_changed)
            self.sliders.append(slider)
            sliders_layout.addWidget(slider)

        self.sliders_ct_widget = QWidget()
        self.sliders_ct_widget.setMinimumWidth(self.slider_width)
        self.sliders_ct_widget.setMaximumWidth(self.slider_width)
        self.sliders_ct_widget.setLayout(sliders_layout)
        self.sliders_ct_widget.setHidden(True)

        self.min_slider = QSlider(Qt.Horizontal)
        self.min_slider.setMinimum(0)
        self.min_slider.setMaximum(1000)
        self.min_slider.valueChanged.connect(self.mip_slider_value_changed)

        self.max_slider = QSlider(Qt.Horizontal)
        self.max_slider.setMinimum(0)
        self.max_slider.setMaximum(1000)
        self.max_slider.setValue(1000)
        self.max_slider.valueChanged.connect(self.mip_slider_value_changed)

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        layout.addWidget(self.min_slider)
        layout.addWidget(self.max_slider)

        self.sliders_mip_widget = QWidget()
        self.sliders_mip_widget.setMinimumWidth(self.slider_width)
        self.sliders_mip_widget.setMaximumWidth(self.slider_width)
        self.sliders_mip_widget.setLayout(layout)
        self.sliders_mip_widget.setHidden(True)

        layout = QHBoxLayout(self.main_widget)
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.render_widget)
        layout.addWidget(self.sliders_mip_widget)
        layout.addWidget(self.sliders_ct_widget)
        layout.addWidget(self.sliders_simple_widget)
        self.main_widget.setLayout(layout)

        self.resize(800, 500)
Exemple #14
0
 def test_set_layout_succeeding(self):
     parent = QWidget()
     ChildAdder.add(QHBoxLayout(), 'fred', parent)
     self.assertTrue(isinstance(parent.layout(), QHBoxLayout))
Exemple #15
0
 def testAddItemWithIcon(self):
     index = self.toolbox.addItem(QWidget(), QIcon(), 'item')
     item = self.toolbox.widget(index)
     self.assert_(isinstance(item, QWidget))
Exemple #16
0
 def testFormReference(self):
     #QFormLayout.addWidget reference count
     w = QWidget()
     self.checkLayoutReference(QFormLayout(w))
Exemple #17
0
    def __init__(self):

        url = QLineEdit()
        urlLabel = QLabel('Url')
        messages = QTextEdit()
        messagesLabel = QLabel('Messages')
        links = QTableWidget(0, 2)
        linksLabel = QLabel('Links')
        clearMessages = QPushButton('Clear Messages')
        checkIfOnline = QPushButton('Check If Online')
        addSelectedLink = QPushButton('Add Link')
        removeSelectedLink = QPushButton('Remove Selected Link')

        messages.setReadOnly(True)

        links.setHorizontalHeaderLabels(['Url', 'Status'])
        links.horizontalHeader().setResizeMode(QHeaderView.Stretch)
        links.horizontalHeader().setResizeMode(1, QHeaderView.Fixed)

        # set the events

        url.returnPressed.connect(self.select_stream_from_entry)
        links.itemDoubleClicked.connect(self.select_stream_from_link)
        clearMessages.clicked.connect(self.clear_messages)
        checkIfOnline.clicked.connect(self.check_if_online)
        addSelectedLink.clicked.connect(self.add_selected_link)
        removeSelectedLink.clicked.connect(self.remove_selected_link)

        # set the layouts

        mainLayout = QGridLayout()

        # first row
        mainLayout.addWidget(urlLabel, 0, 0, 1, 2)  # spans 2 columns
        mainLayout.addWidget(linksLabel, 0, 2, 1, 3)  # spans 3 columns

        # second row  (links widget occupies 2 rows and 2 columns)
        mainLayout.addWidget(url, 1, 0, 1, 2)  # spans 2 columns
        mainLayout.addWidget(links, 1, 2, 2, 3)  # spans 3 columns

        # third row (messages widget occupies 2 columns)
        mainLayout.addWidget(messages, 2, 0, 1, 2)

        # fourth row
        mainLayout.addWidget(messagesLabel, 3, 0)
        mainLayout.addWidget(clearMessages, 3, 1)
        mainLayout.addWidget(checkIfOnline, 3, 2)
        mainLayout.addWidget(addSelectedLink, 3, 3)
        mainLayout.addWidget(removeSelectedLink, 3, 4)

        window = QWidget()

        window.setLayout(mainLayout)
        window.setWindowTitle('Live Streamer')
        window.resize(700, 350)
        window.show()

        self.url_ui = url
        self.messages_ui = messages
        self.links_ui = links
        self.window_ui = window

        self.links = set()
Exemple #18
0
 def testStackedReference(self):
     #QStackedLayout.addWidget reference count
     w = QWidget()
     self.checkLayoutReference(QStackedLayout(w))
    def SetLayout(self):
        qWidget = QWidget()
        gridLayout = QGridLayout(qWidget)
        row = 0
        self.setCentralWidget(qWidget)

        row += 1
        ssidLabel = QLabel("SSID: ")
        self.ssId = QLineEdit()
        self.ssId.setText("ZodiacWX_24GHz")
        gridLayout.addWidget(ssidLabel, row, 0)
        gridLayout.addWidget(self.ssId, row, 1)

        row += 1
        passwordLabel = QLabel("Password: "******"66666666")
        gridLayout.addWidget(passwordLabel, row, 0)
        gridLayout.addWidget(self.password, row, 1)

        row += 1
        mudServerLabel = QLabel("MUD Server")
        self.mudServerAddress = QLineEdit()
        self.mudServerAddress.setText("203.0.113.7")
        #self.uploadMudUrlCheckbox = QCheckBox()
        #self.uploadMudUrlCheckbox.setToolTip(QToolTip("Send MUD URL to MUD Server?"))
        gridLayout.addWidget(mudServerLabel, row, 0)
        gridLayout.addWidget(self.mudServerAddress, row, 1)

        row += 1
        dppUriLabel = QLabel("DPP URI: ")
        self.dppUri = QLineEdit()
        scanPushButton = QPushButton("Scan", self)
        scanPushButton.clicked.connect(self.doScanQrCode)
        readQrCodePushButton = QPushButton("Select", self)
        readQrCodePushButton.clicked.connect(self.doSelectQrCodeImage)
        gridLayout.addWidget(dppUriLabel, row, 0)
        gridLayout.addWidget(self.dppUri, row, 1)
        gridLayout.addWidget(readQrCodePushButton, row, 2)
        gridLayout.addWidget(scanPushButton, row, 3)

        row += 1
        caCertLabel = QLabel("CA Cert")
        self.caCertPath = QLineEdit()
        self.caCertPath.setText(
            os.environ.get("PROJECT_HOME") +
            "/testcerts/ca/certs/root.cert.pem")
        certPathButton = QPushButton("Select")
        certPathButton.clicked.connect(self.doSelectCaCertPath)
        gridLayout.addWidget(caCertLabel, row, 0)
        gridLayout.addWidget(self.caCertPath, row, 1)
        gridLayout.addWidget(certPathButton, row, 2)

        row += 1
        onboardButton = QPushButton("Onboard Supplicant", self)
        onboardButton.setIcon(QIcon("duck.png"))
        onboardButton.setIconSize(QSize(100, 100))
        onboardButton.clicked.connect(self.doOnboard)

        viewCertButton = QPushButton("View CA Certificate", self)
        viewCertButton.clicked.connect(self.doViewCertificate)

        viewDevCertButton = QPushButton("View Device Certificate", self)
        viewDevCertButton.clicked.connect(self.doViewDeviceCertificate)

        outputCommand = QPushButton("Show Command")
        outputCommand.clicked.connect(self.doViewCommand)

        quitButton = QPushButton("Quit")
        quitButton.clicked.connect(self.doQuit)

        gridLayout.addWidget(onboardButton, row, 0)
        gridLayout.addWidget(viewCertButton, row, 1)
        gridLayout.addWidget(viewDevCertButton, row, 2)
        gridLayout.addWidget(outputCommand, row, 3)
        gridLayout.addWidget(quitButton, row, 4)

        self.myStatusBar = QStatusBar()
        self.setStatusBar(self.myStatusBar)
        self.myStatusBar.showMessage(
            "Note: start wpa_supplicant using start_wpas.sh")
Exemple #20
0
 def setUp(self):
     #Acquire resources
     super(MultipleAdd, self).setUp()
     self.widget = QPushButton('click me')
     self.win = QWidget()
     self.layout = QHBoxLayout(self.win)
Exemple #21
0
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(598, 450)
        self.icon = QIcon(":/icons/uglytheme/48x48/polibeepsync.png")
        Form.setWindowIcon(self.icon)
        Form.setLocale(QLocale(QLocale.English, QLocale.UnitedStates))
        self.verticalLayout = QVBoxLayout(Form)
        self.verticalLayout.setObjectName("verticalLayout")

        self.tabWidget = QTabWidget(Form)
        self.tabWidget.setObjectName("tabWidget")

        # Tab General Settings
        self.tab = QWidget()
        self.tab.setObjectName("tab")
        self.horizontalLayout = QHBoxLayout(self.tab)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.verticalLayout_2 = QVBoxLayout()
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.gridLayout = QGridLayout()
        self.gridLayout.setObjectName("gridLayout")
        self.label_2 = QLabel(self.tab)
        self.label_2.setObjectName("label_2")
        self.gridLayout.addWidget(self.label_2, 3, 0, 1, 1)
        self.label = QLabel(self.tab)
        self.label.setObjectName("label")
        self.gridLayout.addWidget(self.label, 1, 0, 1, 1)
        self.password = QLineEdit(self.tab)
        self.password.setMaximumSize(QSize(139, 16777215))
        self.password.setEchoMode(QLineEdit.Password)
        self.password.setObjectName("password")
        self.gridLayout.addWidget(self.password, 3, 1, 1, 1)
        self.userCode = QLineEdit(self.tab)
        self.userCode.setMaximumSize(QSize(139, 16777215))
        self.userCode.setText("")
        self.userCode.setObjectName("userCode")
        self.gridLayout.addWidget(self.userCode, 1, 1, 1, 1)
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        self.gridLayout.addItem(spacerItem, 1, 2, 1, 1)
        self.verticalLayout_2.addLayout(self.gridLayout)
        self.trylogin = QPushButton(self.tab)
        self.trylogin.setMaximumSize(QSize(154, 16777215))
        self.trylogin.setObjectName("trylogin")
        self.verticalLayout_2.addWidget(self.trylogin)
        self.login_attempt = QLabel(self.tab)
        self.login_attempt.setText("Logging in, please wait.")
        self.login_attempt.setStyleSheet("color: rgba(0, 0, 0, 0);")
        self.login_attempt.setObjectName("login_attempt")
        self.verticalLayout_2.addWidget(self.login_attempt)
        spacerItem1 = QSpacerItem(20, 40, QSizePolicy.Minimum,
                                  QSizePolicy.Expanding)
        self.verticalLayout_2.addItem(spacerItem1)
        self.horizontalLayout_3 = QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.label_4 = QLabel(self.tab)
        self.label_4.setObjectName("label_4")
        self.horizontalLayout_3.addWidget(self.label_4)
        self.rootfolder = QLineEdit(self.tab)
        self.rootfolder.setMinimumSize(QSize(335, 0))
        self.rootfolder.setMaximumSize(QSize(335, 16777215))
        self.rootfolder.setInputMask("")
        self.rootfolder.setReadOnly(True)
        self.rootfolder.setObjectName("rootfolder")
        self.horizontalLayout_3.addWidget(self.rootfolder)
        self.changeRootFolder = QPushButton(self.tab)
        self.changeRootFolder.setObjectName("changeRootFolder")
        self.horizontalLayout_3.addWidget(self.changeRootFolder)
        spacerItem2 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                  QSizePolicy.Minimum)
        self.horizontalLayout_3.addItem(spacerItem2)
        self.verticalLayout_2.addLayout(self.horizontalLayout_3)
        self.horizontalLayout_5 = QHBoxLayout()
        self.horizontalLayout_5.setObjectName("horizontalLayout_5")
        self.label_5 = QLabel(self.tab)
        self.label_5.setObjectName("label_5")
        self.horizontalLayout_5.addWidget(self.label_5)
        self.timerMinutes = QSpinBox(self.tab)
        self.timerMinutes.setObjectName("timerMinutes")
        self.horizontalLayout_5.addWidget(self.timerMinutes)
        self.label_6 = QLabel(self.tab)
        self.label_6.setObjectName("label_6")
        self.horizontalLayout_5.addWidget(self.label_6)
        self.syncNow = QPushButton(self.tab)
        self.syncNow.setObjectName("syncNow")
        self.horizontalLayout_5.addWidget(self.syncNow)
        spacerItem3 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                  QSizePolicy.Minimum)
        self.horizontalLayout_5.addItem(spacerItem3)
        self.verticalLayout_2.addLayout(self.horizontalLayout_5)
        self.addSyncNewCourses = QCheckBox(self.tab)
        self.addSyncNewCourses.setObjectName("addSyncNewCourses")
        self.verticalLayout_2.addWidget(self.addSyncNewCourses)
        self.horizontalLayout.addLayout(self.verticalLayout_2)
        self.tabWidget.addTab(self.tab, "")

        # Tab Courses
        self.tab_2 = QWidget()
        self.tab_2.setObjectName("tab_2")
        self.horizontalLayout_2 = QHBoxLayout(self.tab_2)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.verticalLayout_3 = QVBoxLayout()
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.horizontalLayout_6 = QHBoxLayout()
        self.horizontalLayout_6.setObjectName("horizontalLayout_6")
        self.refreshCourses = QPushButton(self.tab_2)
        self.refreshCourses.setObjectName("refreshCourses")
        self.horizontalLayout_6.addWidget(self.refreshCourses)
        spacerItem4 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                  QSizePolicy.Minimum)
        self.horizontalLayout_6.addItem(spacerItem4)
        self.verticalLayout_3.addLayout(self.horizontalLayout_6)
        self.coursesView = CoursesListView(self.tab_2)
        self.coursesView.setObjectName("coursesView")
        self.verticalLayout_3.addWidget(self.coursesView)
        self.horizontalLayout_2.addLayout(self.verticalLayout_3)
        self.tabWidget.addTab(self.tab_2, "")

        # Tab Status
        self.tab_3 = QWidget()
        self.tab_3.setObjectName("tab_3")
        self.horizontalLayout_7 = QHBoxLayout(self.tab_3)
        self.horizontalLayout_7.setObjectName("horizontalLayout_7")
        self.verticalLayout_4 = QVBoxLayout()
        self.verticalLayout_4.setObjectName("verticalLayout_4")
        self.horizontalLayout_8 = QHBoxLayout()
        self.horizontalLayout_8.setObjectName("horizontalLayout_8")
        self.about = QPushButton(self.tab_3)
        self.about.setObjectName("about")
        self.horizontalLayout_8.addWidget(self.about)
        spacerItem5 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                  QSizePolicy.Minimum)
        self.horizontalLayout_8.addItem(spacerItem5)
        self.verticalLayout_4.addLayout(self.horizontalLayout_8)
        self.status = QTextEdit(self.tab_3)
        self.status.setTextInteractionFlags(Qt.TextSelectableByKeyboard
                                            | Qt.TextSelectableByMouse)
        self.status.setObjectName("status")
        self.verticalLayout_4.addWidget(self.status)
        self.horizontalLayout_7.addLayout(self.verticalLayout_4)
        self.tabWidget.addTab(self.tab_3, "")

        self.tab_4 = QWidget()
        self.tab_4.setObjectName("tab_4")
        self.verticalLayout.addWidget(self.tabWidget)

        self.okButton = QDialogButtonBox(Form)
        self.okButton.setStandardButtons(QDialogButtonBox.Ok)
        self.okButton.setObjectName("okButton")
        self.okButton.clicked.connect(self.hide)
        self.verticalLayout.addWidget(self.okButton)

        self.statusLabel = QLabel(Form)
        self.statusLabel.setObjectName("statusLabel")
        self.verticalLayout.addWidget(self.statusLabel)

        self.retranslateUi(Form)
        self.tabWidget.setCurrentIndex(0)
        QMetaObject.connectSlotsByName(Form)
Exemple #22
0
    toolButtonLeft1 = CreateFlatButton(QAction(icon, "Left", mainWindow))
    toolButtonLeft2 = CreateFlatButton(QAction(icon, "2nd left", mainWindow))
    toolButtonRight = CreateFlatButton(QAction(icon, "Right", mainWindow))

    toolButtonCenter = QPushButton()
    toolButtonCenter.setIcon(QIcon(basePath + "LandmarkTransformButton.png"))
    toolButtonCenter.setText("Center")
    toolButtonCenter.setMinimumWidth(200)

    barWidget = ToolbarWidget()

    barWidget.addLeftItem(toolButtonLeft1)
    barWidget.addLeftItem(toolButtonLeft2)
    barWidget.addCenterItem(toolButtonCenter)
    barWidget.addRightItem(toolButtonRight)
    toolbar.addWidget(barWidget)

    layout = QVBoxLayout()
    layout.setSpacing(0)
    layout.setContentsMargins(0, 0, 0, 0)
    layout.setAlignment(Qt.AlignVCenter | Qt.AlignHCenter)
    layout.addWidget(QLabel("Test toolbar widget"))

    widget = QWidget()
    widget.setLayout(layout)

    mainWindow.setCentralWidget(widget)
    mainWindow.setGeometry(100, 100, 500, 300)
    mainWindow.show()
    app.exec_()
Exemple #23
0
    def __init__(self, *args, **kwargs):

        QMainWindow.__init__(self, *args, **kwargs)
        self.installEventFilter(self)
        self.setObjectName(Window.objectName)
        self.setWindowTitle(Window.title)

        #-----------ui setting-----------------
        baseWidget = QWidget()
        self.setCentralWidget(baseWidget)
        vLayout = QVBoxLayout(baseWidget)

        layout_labels = QHBoxLayout()
        label_src = QLabel("Copy Target")
        label_dst = QLabel("Past Target")
        label_src.setAlignment(QtCore.Qt.AlignCenter)
        label_dst.setAlignment(QtCore.Qt.AlignCenter)
        layout_labels.addWidget(label_src)
        layout_labels.addWidget(label_dst)

        layout_lineEdits = QHBoxLayout()
        lineEdit_src = QLineEdit()
        lineEdit_dst = QLineEdit()
        layout_lineEdits.addWidget(lineEdit_src)
        layout_lineEdits.addWidget(lineEdit_dst)

        separator = QFrame()
        separator.setFrameShape(QFrame.HLine)

        layout_buttons = QHBoxLayout()
        button_copyAndPast = QPushButton("Copy And Past")
        button_close = QPushButton("Close")
        layout_buttons.addWidget(button_copyAndPast)
        layout_buttons.addWidget(button_close)

        layout_labelsSecond = QHBoxLayout()
        label_src = QLabel("Source transforms from copy target")
        label_dst = QLabel("Source transforms from cast target")
        label_src.setAlignment(QtCore.Qt.AlignCenter)
        label_dst.setAlignment(QtCore.Qt.AlignCenter)
        layout_labelsSecond.addWidget(label_src)
        layout_labelsSecond.addWidget(label_dst)

        layout_lineEditsSecond = QHBoxLayout()
        lineEdit_srcSecond = QLineEdit()
        lineEdit_dstSecond = QLineEdit()
        layout_lineEditsSecond.addWidget(lineEdit_srcSecond)
        layout_lineEditsSecond.addWidget(lineEdit_dstSecond)

        vLayout.addLayout(layout_labels)
        vLayout.addLayout(layout_lineEdits)
        vLayout.addWidget(separator)
        vLayout.addLayout(layout_labelsSecond)
        vLayout.addLayout(layout_lineEditsSecond)
        vLayout.addLayout(layout_buttons)

        #---------- Connect to self------------------
        self.lineEdit_src = lineEdit_src
        self.lineEdit_dst = lineEdit_dst
        self.lineEdit_srcSecond = lineEdit_srcSecond
        self.lineEdit_dstSecond = lineEdit_dstSecond

        #------------Connect context menu---------------
        ContextMenu(lineEdit_src)
        ContextMenu(lineEdit_dst)
        ContextMenu(lineEdit_srcSecond, loadTypes='multi')
        ContextMenu(lineEdit_dstSecond, loadTypes='multi')

        #-----------Connect Command------------------
        QtCore.QObject.connect(button_copyAndPast, QtCore.SIGNAL('clicked()'),
                               self.cmd_copyAndPast)
        QtCore.QObject.connect(button_close, QtCore.SIGNAL('clicked()'),
                               self.cmd_close)
Exemple #24
0
 def testBasic(self):
     # Also related to bug #244, on existence of setVisible'''
     widget = QWidget()
     self.assert_(not widget.isVisible())
     widget.setVisible(True)
     self.assert_(widget.isVisible())
Exemple #25
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        # Set window Icon
        self.setWindowTitle(__appname__)
        iconImage = QImage(iconByteArray)
        iconPixmap = QPixmap(iconImage)
        self.setWindowIcon(QIcon(iconPixmap))

        # Set up private key format widgets
        privateKeyFormatLayout = QHBoxLayout()
        privateKeyFormatLabel = QLabel('Select Key Format: ')
        self.privateKeyTypeCombobox = QComboBox()
        self.privateKeyTypeCombobox.addItems(privateKeyFormats)
        self.privateKeyLengthLabel = QLabel('0')
        privateKeyFormatLayout.addWidget(privateKeyFormatLabel)
        privateKeyFormatLayout.addWidget(self.privateKeyTypeCombobox)
        privateKeyFormatLayout.addWidget(self.privateKeyLengthLabel)

        # Set up private key text widgets
        privateKeyLayout = QVBoxLayout()
        privateKeyButtonsLayout = QHBoxLayout()
        generatePrivateKeyButton = QPushButton('Generate Key')
        generatePrivateKeyButton.clicked.connect(self.get_private_key)
        self.copyPrivateKeyButton = QPushButton('Copy Key')
        self.copyPrivateKeyButton.setDisabled(True)
        self.copyPrivateKeyButton.clicked.connect(self.copy_private_key)
        privateKeyButtonsLayout.addWidget(generatePrivateKeyButton)
        privateKeyButtonsLayout.addWidget(self.copyPrivateKeyButton)
        self.privateKeyEdit = GrowingTextEdit()
        self.privateKeyEdit.setFont(QFont('Courier'))
        self.privateKeyEdit.textChanged.connect(
            self.private_key_or_code_changed)
        privateKeyLayout.addLayout(privateKeyButtonsLayout)
        privateKeyLayout.addWidget(self.privateKeyEdit)

        # Set up cypher code widgets
        codeLayout = QHBoxLayout()
        codeLabel = QLabel('Select Cypher Code: ')
        self.codeSelect = QSpinBox()
        self.codeSelect.setValue(10)
        self.codeSelect.setMinimum(2)
        self.codeSelect.setDisabled(True)
        self.codeSelect.valueChanged.connect(self.private_key_or_code_changed)
        codeLayout.addWidget(codeLabel)
        codeLayout.addWidget(self.codeSelect)

        # Set up cypher text widgets
        cypherLayout = QVBoxLayout()
        cypherButtonsLayout = QHBoxLayout()
        cardButtonsLayout = QHBoxLayout()
        self.generateCypherButton = QPushButton('Generate Cypher')
        self.generateCypherButton.clicked.connect(self.get_cypher)
        self.generateCypherButton.setDisabled(True)
        self.copyCypherButton = QPushButton('Copy Cypher')
        self.copyCypherButton.setDisabled(True)
        self.copyCypherButton.clicked.connect(self.copy_cypher)
        cypherButtonsLayout.addWidget(self.generateCypherButton)
        cypherButtonsLayout.addWidget(self.copyCypherButton)
        self.cypherEdit = GrowingTextEdit()
        self.cypherEdit.setFont(QFont('Courier'))
        self.cypherEdit.setReadOnly(True)
        self.cypherEdit.setVisible(False)
        self.cypherEdit.textChanged.connect(self.resize_window)
        self.cypherPreviewLabel = QLabel('-CYPHER PREVIEW-')
        self.cypherPreviewLabel.setAlignment(Qt.AlignCenter)
        self.cypherPreviewLabel.setVisible(False)
        self.cypherPreview = GrowingTextEdit()
        self.cypherPreview.setFont(QFont('Courier'))
        self.cypherPreview.setAlignment(Qt.AlignHCenter)
        self.cypherPreview.setWordWrapMode(QTextOption.NoWrap)
        self.cypherPreview.setReadOnly(True)
        self.cypherPreview.setVisible(False)
        self.cypherCardsPrintButton = QPushButton('Print Cypher Cards')
        self.cypherCardsPrintButton.setVisible(False)
        self.cypherCardsPrintButton.clicked.connect(partial(self.cards, True))
        self.cypherCardsCopyButton = QPushButton('Copy Cypher Cards')
        self.cypherCardsCopyButton.setVisible(False)
        self.cypherCardsCopyButton.clicked.connect(partial(self.cards, False))
        cardButtonsLayout.addWidget(self.cypherCardsPrintButton)
        cardButtonsLayout.addWidget(self.cypherCardsCopyButton)
        cypherLayout.addLayout(cypherButtonsLayout)
        cypherLayout.addWidget(self.cypherEdit)
        cypherLayout.addWidget(self.cypherPreviewLabel)
        cypherLayout.addWidget(self.cypherPreview)
        cypherLayout.addLayout(cardButtonsLayout)

        # Set up donation widgets
        donationsLayout = QVBoxLayout()
        separater = QFrame()
        separater.setFrameShape(QFrame.HLine)
        self.donationButton = QPushButton('Donate')
        self.donationButton.setVisible(False)
        self.donationButton.clicked.connect(self.donate)
        self.copyEthAddressButton = QPushButton('ETH: Copy Address')
        self.copyEthAddressButton.clicked.connect(
            self.copy_eth_donation_address)
        self.copyEthAddressButton.setVisible(False)
        self.copyBtcAddressButton = QPushButton('BTC: Copy Address')
        self.copyBtcAddressButton.clicked.connect(
            self.copy_btc_donation_address)
        self.copyBtcAddressButton.setVisible(False)
        donationsLayout.addWidget(separater)
        donationsLayout.addWidget(self.donationButton)
        donationsLayout.addWidget(self.copyEthAddressButton)
        donationsLayout.addWidget(self.copyBtcAddressButton)

        # Add all widgets and sub-layouts to the master layout
        self.master_layout = QVBoxLayout()
        self.master_layout.addLayout(privateKeyFormatLayout)
        self.master_layout.addLayout(privateKeyLayout)
        self.master_layout.addLayout(codeLayout)
        self.master_layout.addLayout(cypherLayout)
        self.master_layout.addLayout(donationsLayout)
        self.master_widget = QWidget()
        self.master_widget.setLayout(self.master_layout)
        self.setCentralWidget(self.master_widget)

        # Start and connect the window resizing thread
        self.worker = Worker()
        self.worker.updateWindowSize.connect(self.resize_window)
Exemple #26
0
    def __init__(self):
        QMainWindow.__init__(self)
        self.resize(800, 600)
        self.setWindowTitle('PDF Merger')

        about = QAction('About', self)
        self.connect(about, SIGNAL('triggered()'), self.show_about)
        exit = QAction('Exit', self)
        exit.setShortcut('Ctrl+Q')
        self.connect(exit, SIGNAL('triggered()'), SLOT('close()'))

        self.statusBar()
        menubar = self.menuBar()
        file = menubar.addMenu('File')
        file.addAction(about)
        file.addAction(exit)

        self.main_widget = QWidget(self)
        self.setCentralWidget(self.main_widget)
        self.up_down_widget = QWidget(self)
        self.options_widget = QWidget(self)

        input_files_label = QLabel(
            "Input PDFs\nThis is the order in which the files will be merged too"
        )
        self.files_list = QListWidget()
        self.files_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
        add_button = QPushButton("Add PDF(s) to merge...")
        add_button.clicked.connect(self.clicked_add)
        up_button = QPushButton("Up")
        up_button.clicked.connect(self.move_file_up)
        down_button = QPushButton("Down")
        down_button.clicked.connect(self.move_file_down)
        remove_button = QPushButton("Remove PDF")
        remove_button.clicked.connect(self.remove_file)
        select_path_label = QLabel("Output PDF")
        self.dest_path_edit = QLineEdit()
        self.dest_path_edit.setReadOnly(True)
        select_path = QPushButton("Select...")
        select_path.clicked.connect(self.select_save_path)
        start = QPushButton("Start")
        start.clicked.connect(self.merge_pdf)

        up_down_vbox = QVBoxLayout(self.up_down_widget)
        up_down_vbox.addWidget(up_button)
        up_down_vbox.addWidget(down_button)
        up_down_vbox.addWidget(remove_button)
        self.up_down_widget.setLayout(up_down_vbox)

        group_input = QGroupBox()
        grid_input = QGridLayout()
        grid_input.addWidget(add_button, 0, 0)
        grid_input.addWidget(input_files_label, 1, 0)
        grid_input.addWidget(self.files_list, 2, 0)
        grid_input.addWidget(self.up_down_widget, 2, 1)
        group_input.setLayout(grid_input)

        group_output = QGroupBox()
        grid_output = QGridLayout()
        grid_output.addWidget(select_path_label, 0, 0)
        grid_output.addWidget(self.dest_path_edit, 1, 0)
        grid_output.addWidget(select_path, 1, 1)
        group_output.setLayout(grid_output)

        vbox_options = QVBoxLayout(self.options_widget)
        vbox_options.addWidget(group_input)
        vbox_options.addWidget(group_output)
        vbox_options.addWidget(start)
        self.options_widget.setLayout(vbox_options)

        splitter_filelist = QSplitter()
        splitter_filelist.setOrientation(Qt.Vertical)
        splitter_filelist.addWidget(self.options_widget)
        vbox_main = QVBoxLayout(self.main_widget)
        vbox_main.addWidget(splitter_filelist)
        vbox_main.setContentsMargins(0, 0, 0, 0)
Exemple #27
0
 def initLayout(self):
     layout = QGridLayout()
     centralWidget = QWidget()
     centralWidget.setLayout(layout)
     self.setCentralWidget(centralWidget)
Exemple #28
0
 def testAddItem(self):
     # Was losing ownership of the widget.
     index = self.toolbox.addItem(QWidget(), 'item')
     item = self.toolbox.widget(index)
     self.assert_(isinstance(item, QWidget))
Exemple #29
0
 def setUp(self):
    super(QStandardItemModelTest, self).setUp()
    self.window = QWidget()
    self.model = QStandardItemModel(0, 3, self.window)
Exemple #30
0
    def createHomePage(self):
        WIDTH_LEFT = 3
        WIDTH_RIGHT = 7
        dc = dict()
        wg = QWidget(self)
        gridLayout = QGridLayout(wg)

        row = 0
        gridLayout.addWidget(QLabel('Home'), row, 0)

        row = 1
        gridLayout.addWidget(QLabel('Tx'), row, 0, 1, WIDTH_LEFT)
        lbtx = QLabel('tx data')
        lbtx.setMinimumWidth(400)
        dc['pvtx_label'] = lbtx
        gridLayout.addWidget(lbtx, row, 1, 1, WIDTH_RIGHT)

        row = 2
        gridLayout.addWidget(QLabel('Rx'), row, 0, 1, WIDTH_LEFT)
        lbrx = QLabel('rx data')
        dc['pvrx_label'] = lbrx
        gridLayout.addWidget(lbrx, row, 1, 1, WIDTH_RIGHT)

        row = 3
        gridLayout.addWidget(QLabel('Serial485'), row, 0, 1, WIDTH_LEFT)
        ser_label = QLabel('serial 485')
        dc['ser_label'] = ser_label
        gridLayout.addWidget(ser_label, row, 1, 1, WIDTH_RIGHT)

        row = 4
        gridLayout.addWidget(QLabel('Log'), row, 0, 1, WIDTH_LEFT)
        elogging_label = QLabel('event logging')
        dc['elogging_label'] = elogging_label
        gridLayout.addWidget(elogging_label, row+0, 1, 1, WIDTH_RIGHT)

        mlogging_label = QLabel('minute logging')
        dc['mlogging_label'] = mlogging_label
        gridLayout.addWidget(mlogging_label, row+1, 1, 1, WIDTH_RIGHT)

        hlogging_label = QLabel('hour logging')
        dc['hlogging_label'] = hlogging_label
        gridLayout.addWidget(hlogging_label, row+2, 1, 1, WIDTH_RIGHT)

        row = 7
        gridLayout.addWidget(QLabel('Upload'), row, 0, 1, WIDTH_LEFT)
        eupload_label = QLabel('event uploading')
        dc['eupload_label'] = eupload_label
        gridLayout.addWidget(eupload_label, row+0, 1, 1, WIDTH_RIGHT)

        mupload_label = QLabel('minute uploading')
        dc['mupload_label'] = mupload_label
        gridLayout.addWidget(mupload_label, row+1, 1, 1, WIDTH_RIGHT)
        
        hupload_label = QLabel('hour uploading')
        dc['hupload_label'] = hupload_label
        gridLayout.addWidget(hupload_label, row+2, 1, 1, WIDTH_RIGHT)
        
        row = 10
        gridLayout.addWidget(QLabel('Main'), row, 0, 1, WIDTH_LEFT)
        mainthread_label = QLabel('main thread')
        dc['mainthread_label'] = mainthread_label
        gridLayout.addWidget(mainthread_label, row+0, 1, 1, WIDTH_RIGHT)



        return wg, dc