示例#1
0
    def makeContent(self):
        layout = QHBoxLayout()

        layout.addLayout(self._welcomeAreaControls())
        layout.addLayout(self._modeControls())

        return layout
示例#2
0
    def __init__(self, parent=None):

        QWidget.__init__(self)

        # Create the QVBoxLayout that lays out the whole form
        self.main_panel = QHBoxLayout()
        self.lpanel = QHBoxLayout()
        self.rpanel = QVBoxLayout()
        self.plot_box = QHBoxLayout()
        self.summary_box = QHBoxLayout()

        # Control widget
        self.control = psim_control.ControlLayout()
        self.control.sim_button.clicked.connect(self.button_pressed)

        # Plot Widget
        self.graph = psim_plot.MatplotlibWidget()

        # Summary Widget
        self.summary = psim_summary.SummaryLayout()

        # Adding plot to left panel and control widget to right panel
        self.lpanel.addWidget(self.control)
        self.rpanel.addWidget(self.graph)
        self.rpanel.addWidget(self.summary)
        
        # Adding lpanel and rpanel widget to the main MainWindow
        self.main_panel.addLayout(self.lpanel)
        self.main_panel.addLayout(self.rpanel)
        # self.main_panel.addStretch(1)
        self.setLayout(self.main_panel)

        self.df = None
示例#3
0
 def __init__(self, text, minValue, maxValue, defaultValue ):
     
     QWidget.__init__( self )
     
     validator = QDoubleValidator(minValue, maxValue, 2, self )
     mainLayout = QHBoxLayout( self )
     
     checkBox = QCheckBox()
     checkBox.setFixedWidth( 115 )
     checkBox.setText( text )
     
     lineEdit = QLineEdit()
     lineEdit.setValidator( validator )
     lineEdit.setText( str(defaultValue) )
     
     slider = QSlider( QtCore.Qt.Horizontal )
     slider.setMinimum( minValue*100 )
     slider.setMaximum( maxValue*100 )
     slider.setValue( defaultValue )
     
     mainLayout.addWidget( checkBox )
     mainLayout.addWidget( lineEdit )
     mainLayout.addWidget( slider )
     
     QtCore.QObject.connect( slider, QtCore.SIGNAL( 'valueChanged(int)' ), self.syncWidthLineEdit )
     QtCore.QObject.connect( lineEdit, QtCore.SIGNAL( 'textChanged(QString)' ), self.syncWidthSlider )
     QtCore.QObject.connect( checkBox, QtCore.SIGNAL( "clicked()" ), self.updateEnabled )
     
     self.checkBox = checkBox
     self.slider = slider
     self.lineEdit = lineEdit
     
     self.updateEnabled()
示例#4
0
 def __init__(self, *args, **kwargs ):
     
     QWidget.__init__( self, *args )
     
     title = ""
     if kwargs.has_key( 'title' ):
         title = kwargs['title']
         
     self.infoPath = cmds.about(pd=True) + "/sg/fingerWeightCopy/Widget_LoadVertex_%s.txt" % title
     sgCmds.makeFile( self.infoPath )
     
     vLayout = QVBoxLayout( self ); vLayout.setContentsMargins(0,0,0,0)
     
     groupBox = QGroupBox( title )
     groupBox.setAlignment( QtCore.Qt.AlignCenter )
     vLayout.addWidget( groupBox )
     
     hLayout = QHBoxLayout()
     lineEdit = QLineEdit()
     button   = QPushButton("Load"); button.setFixedWidth( 50 )
     hLayout.addWidget( lineEdit )
     hLayout.addWidget( button )
     
     groupBox.setLayout( hLayout )
     
     self.lineEdit = lineEdit
     
     QtCore.QObject.connect( button, QtCore.SIGNAL( "clicked()" ), self.loadVertex )
     self.loadInfo()
示例#5
0
    def _setup_ui(self):
        self._btn_pick_1.setFixedWidth(25)
        self._btn_pick_1.setToolTip('Pick first sequence.')
        self._btn_pick_2.setFixedWidth(25)
        self._btn_pick_2.setToolTip('Pick second sequence.')
        self._btn_compare.setToolTip('Compare sequences.')
        self._progress_bar.setFixedHeight(10)

        lyt_seq1 = QHBoxLayout()
        lyt_seq1.addWidget(self._ledit1)
        lyt_seq1.addWidget(self._btn_pick_1)

        lyt_seq2 = QHBoxLayout()
        lyt_seq2.addWidget(self._ledit2)
        lyt_seq2.addWidget(self._btn_pick_2)

        lyt_main = QVBoxLayout()
        lyt_main.addLayout(lyt_seq1)
        lyt_main.addLayout(lyt_seq2)
        lyt_main.addWidget(self._btn_compare)

        main_widget = QWidget()
        main_widget.setLayout(lyt_main)

        self.setCentralWidget(main_widget)
示例#6
0
 def addTab(self, label ):
     
     layoutWidget = QWidget()
     vLayout = QVBoxLayout(layoutWidget)
     vLayout.setContentsMargins(5,5,5,5)
     
     setFolderLayout = QHBoxLayout()
     listWidget = QListWidget()
     listWidget.setSelectionMode( QAbstractItemView.ExtendedSelection )
     vLayout.addLayout( setFolderLayout )
     vLayout.addWidget( listWidget )
     
     lineEdit = QLineEdit()
     setFolderButton = QPushButton( 'Set Folder' )
     
     setFolderLayout.addWidget( lineEdit )
     setFolderLayout.addWidget( setFolderButton )
     
     QtCore.QObject.connect( setFolderButton, QtCore.SIGNAL( 'clicked()' ),  Functions.setFolder )
     QtCore.QObject.connect( listWidget, QtCore.SIGNAL( 'itemSelectionChanged()' ),  Functions.loadImagePathArea )
     QtCore.QObject.connect( lineEdit, QtCore.SIGNAL( 'textChanged()' ), Functions.lineEdited )
     
     listWidget.setObjectName( Window_global.listWidgetObjectName )
     lineEdit.setContextMenuPolicy( QtCore.Qt.NoContextMenu )
     lineEdit.setObjectName( Window_global.lineEditObjectName )
     
     lineEdit.returnPressed.connect( Functions.lineEdited )
     
     super( Tab, self ).addTab( layoutWidget, label )
    def __init__(self, parent,silhouette,completeness,homogeneity,v_score,AMI,ARS):
        QDialog.__init__( self, parent )
        layout = QVBoxLayout()

        viewLayout = QFormLayout()
        viewLayout.addRow(QLabel('Silhouette score: '),QLabel(silhouette))
        viewLayout.addRow(QLabel('Completeness: '),QLabel(completeness))
        viewLayout.addRow(QLabel('Homogeneity: '),QLabel(homogeneity))
        viewLayout.addRow(QLabel('V score: '),QLabel(v_score))
        viewLayout.addRow(QLabel('Adjusted mutual information: '),QLabel(AMI))
        viewLayout.addRow(QLabel('Adjusted Rand score: '),QLabel(ARS))

        viewWidget = QGroupBox()
        viewWidget.setLayout(viewLayout)

        layout.addWidget(viewWidget)

        #Accept cancel
        self.acceptButton = QPushButton('Ok')
        self.cancelButton = QPushButton('Cancel')

        self.acceptButton.clicked.connect(self.accept)
        self.cancelButton.clicked.connect(self.reject)

        hbox = QHBoxLayout()
        hbox.addWidget(self.acceptButton)
        hbox.addWidget(self.cancelButton)
        ac = QWidget()
        ac.setLayout(hbox)
        layout.addWidget(ac)
        self.setLayout(layout)
示例#8
0
 def createGUI(self):
     self.mainWidget = QWidget()
     self._createMenus()
     
     hLayout = QHBoxLayout()
     vLayout = QVBoxLayout()
     innerVLayout = QVBoxLayout()
     
     self.profileBox = Profile(self.athlete)
     self.addPushupBtn = QPushButton("Add Pushup")
     self.addPushupBtn.setMaximumWidth(100)
     
     self.pushupsListWidget = PushupList(self.pushups) 
     
     self.graphWidget = GraphWidget()
     #self.graphWidget.setMaximumSize(400, 300)
             
     vLayout.addWidget(self.profileBox)
     
     hLayout.addWidget(self.pushupsListWidget)
     innerVLayout.addWidget(self.graphWidget)
     hLayout.addLayout(innerVLayout)
     
     vLayout.addLayout(hLayout)
     
     vLayout.addWidget(self.addPushupBtn)
     
     self.mainWidget.setLayout(vLayout)
     self.setCentralWidget(self.mainWidget)
示例#9
0
 def __init__(self, parent=None):
     super(MainWindow, self).__init__(parent)
     self.setWindowTitle('Tiny BLE Monitor')
     self.resize(800, 500)
     self.cwidget = QWidget()
     self.setCentralWidget(self.cwidget)
     layout = QHBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     self.cwidget.setLayout(layout)
     self.pwidget = pg.PlotWidget()
     layout.addWidget(self.pwidget)
     
     self.pwidget.setTitle(title="press 'space' to freeze/resume")
     self.pwidget.setLabel('left', 'I', units='mA')
     self.pwidget.setLabel('bottom', 't')
     self.pwidget.showButtons()
     self.pwidget.setXRange(0, 3000)
     self.pwidget.setYRange(0, 16)
     # self.pwidget.enableAutoRange(axis=pg.ViewBox.YAxis)
     line = pg.InfiniteLine(pos=1.0, angle=0, movable=True, bounds=[0, 200])
     self.pwidget.addItem(line)
     self.pwidget.showGrid(x=True, y=True, alpha=0.5)
     self.plot = self.pwidget.plot()
     self.plot.setPen((0, 255, 0))
     
     # plotitem = self.pwidget.getPlotItem()
     # plotitem.setLimits(xMin=-1, yMin=-1, minXRange=-1, minYRange=-1) # require pyqtgraph 0.9.9+
     
     self.thread = SerialThread()
     self.thread.error.connect(self.handle_error)
     self.thread.start()
     self.freeze = False
     self.timer = pg.QtCore.QTimer()
     self.timer.timeout.connect(self.update)
     self.timer.start(50)
示例#10
0
    def __init__(self, editor, layout=None, *args, **kw):
        super(_FilterTableView, self).__init__(editor, *args, **kw)

        # vlayout = QVBoxLayout()
        # layout.setSpacing(2)
        # self.table = table = _myFilterTableView(parent)
        # self.table = table = _TableView(parent)

        # table.setSizePolicy(QSizePolicy.Fixed,
        # QSizePolicy.Fixed)
        # table.setMinimumHeight(100)
        # table.setMaximumHeight(50)
        # table.setFixedHeight(50)
        # table.setFixedWidth(50)

        hl = QHBoxLayout()
        self.button = button = QPushButton()
        button.setIcon(icon('delete').create_icon())
        button.setEnabled(False)
        button.setFlat(True)
        button.setSizePolicy(QSizePolicy.Fixed,
                             QSizePolicy.Fixed)

        button.setFixedWidth(15)
        button.setFixedHeight(15)

        self.text = text = QLineEdit()
        hl.addWidget(text)
        hl.addWidget(button)
        # vlayout.addLayout(hl)

        layout.addLayout(hl)
示例#11
0
    def _initUI(self):
        # Variable
        settings = get_settings()

        # Widgets
        self._checkboxes = {}
        for program in settings.get_programs():
            self._checkboxes[program] = QCheckBox(program.name)

        btn_selectall = QPushButton('Select all')
        btn_deselectall = QPushButton('Deselect all')

        # Layouts
        layout = _OptionsWizardPage._initUI(self)
        for program in sorted(self._checkboxes.keys() , key=attrgetter('name')):
            layout.addRow(self._checkboxes[program])

        spacer = QSpacerItem(0, 1000, QSizePolicy.Expanding, QSizePolicy.Expanding)
        layout.addItem(spacer)

        sublayout = QHBoxLayout()
        sublayout.addWidget(btn_selectall)
        sublayout.addWidget(btn_deselectall)
        layout.addRow(sublayout)

        # Signals
        btn_selectall.released.connect(self._onSelectAll)
        btn_deselectall.released.connect(self._onDeselectAll)

        return layout
示例#12
0
文件: axaui.py 项目: axatrikx/Axaclip
 def _putBody(self):
     self._centralWidget = QWidget()
     _hlayout = QHBoxLayout()
     _hlayout.addWidget(self._putSideBar())
     _hlayout.addWidget(self._putTextArea())
     self._centralWidget.setLayout(_hlayout)
     self.setCentralWidget(self._centralWidget)
示例#13
0
    def init ( self, parent ):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        # The control is a vertical layout.
        self.control = layout = QVBoxLayout()
        layout.setSpacing( 5 )
        layout.setMargin( 0 )

        # Add the standard font control:
        self._font = font = QLineEdit( self.str_value )
        QObject.connect( font, SIGNAL( 'editingFinished()' ),
                         self.update_object )
        self.control.addWidget( font )

        # Add all of the font choice controls:
        layout2 = QHBoxLayout()

        self._facename = control = QFontComboBox()
        control.setEditable( False )
        QObject.connect( control, SIGNAL( 'currentFontChanged(QFont)' ),
                         self.update_object_parts )
        layout2.addWidget( control )

        self._point_size = control = QComboBox()
        control.addItems( PointSizes )
        QObject.connect( control, SIGNAL( 'currentIndexChanged(int)' ),
                         self.update_object_parts )
        layout2.addWidget( control )

        # These don't have explicit controls.
        self._bold = self._italic = False

        self.control.addLayout( layout2 )
示例#14
0
 def __init__(self ):
     
     QWidget.__init__( self )
     layout = QVBoxLayout( self )
     
     label = QLabel()
     listWidget = QListWidget()
     listWidget.setSelectionMode( QAbstractItemView.ExtendedSelection )
     hLayout = QHBoxLayout()
     buttonLoad   = QPushButton( "LOAD")
     buttonRemove = QPushButton( "REMOVE")
     hLayout.addWidget( buttonLoad )
     hLayout.addWidget( buttonRemove )
     
     layout.addWidget( label )
     layout.addWidget( listWidget )
     layout.addLayout( hLayout )
     
     self.label = label
     self.listWidget = listWidget
     self.buttonLoad = buttonLoad
     self.buttonRemove = buttonRemove
     
     QtCore.QObject.connect( self.buttonLoad, QtCore.SIGNAL( 'clicked()' ), self.loadCommand )
     QtCore.QObject.connect( self.buttonRemove, QtCore.SIGNAL( 'clicked()' ), self.removeCommand )
示例#15
0
    def __init__(self, fig):
        QDialog.__init__(self)
        self.fig = fig
        main_layout = QVBoxLayout()
        self.setLayout(main_layout)
        top_widget = QWidget()
        bottom_widget = QWidget()
        main_layout.addWidget(top_widget)
        main_layout.addWidget(bottom_widget)
        top_layout = QHBoxLayout()
        bottom_layout = QHBoxLayout()
        top_widget.setLayout(top_layout)
        bottom_widget.setLayout(bottom_layout)

        self.atext = qHotField("annotation", unicode, "the_text")
        top_layout.addWidget(self.atext)
        self.segment_number = qHotField("Segment", int, 1)
        top_layout.addWidget(self.segment_number)
        qmy_button(top_layout, self.annotate_it, "annotate")
        self.over = qHotField("over", int, -70)
        bottom_layout.addWidget(self.over)
        self.up = qHotField('up', int, 30)
        bottom_layout.addWidget(self.up)
        qmy_button(bottom_layout, self.remove_annotations, "remove all")
        qmy_button(bottom_layout, self.remove_last_annotation, "remove last")
        self.annotations = []
示例#16
0
    def _initUI(self):
        '''Sets up the layout of the window'''

        # Define a central widget and a layout for the window
        self.setCentralWidget(QWidget())
        self.mainLayout = QHBoxLayout()
        self.setWindowTitle('Spectral Exchange')

        # Make a layout for all the parameter views
        params = QVBoxLayout()
        params.addWidget(self.rate)
        params.addWidget(self.exchange)
        params.addWidget(self.peak)

        # Add the parameter dialog
        self.mainLayout.addLayout(params)

        # Add the plot 
        plot_lim = QVBoxLayout()
        plot_lim.addWidget(self.plot)
        lim_clear = QHBoxLayout()
        lim_clear.addWidget(self.scale)
        lim_clear.addWidget(self.clear)
        plot_lim.addLayout(lim_clear)
        self.mainLayout.addLayout(plot_lim)

        # Add the widgets to the central widget
        self.centralWidget().setLayout(self.mainLayout)
示例#17
0
 def deleteTab(self):
     
     dialog = QDialog( self )
     dialog.setWindowTitle( "Remove Tab" )
     dialog.resize( 300, 50 )
     
     mainLayout = QVBoxLayout(dialog)
     
     description = QLabel( "'%s' ���� �����Ͻð� ���ϱ�?".decode('utf-8') % self.tabText( self.currentIndex() ) )
     layoutButtons = QHBoxLayout()
     buttonDelete = QPushButton( "�����".decode('utf-8') )
     buttonCancel = QPushButton( "���".decode('utf-8') )
     
     layoutButtons.addWidget( buttonDelete )
     layoutButtons.addWidget( buttonCancel )
     
     mainLayout.addWidget( description )
     mainLayout.addLayout( layoutButtons )
     
     dialog.show()
     
     def cmd_delete():
         self.removeTab( self.indexOf( self.currentWidget() ) )
         dialog.close()
     
     def cmd_cancel():
         dialog.close()
         
     QtCore.QObject.connect( buttonDelete, QtCore.SIGNAL('clicked()'), cmd_delete )
     QtCore.QObject.connect( buttonCancel, QtCore.SIGNAL('clicked()'), cmd_cancel )
示例#18
0
    def __init__(self, *args, **kwargs ):
        
        QMainWindow.__init__( self, *args, **kwargs )
        self.installEventFilter( self )
        self.setObjectName( Window.objectName )
        self.setWindowTitle( Window.title )
        
        mainWidget = QWidget(); self.setCentralWidget( mainWidget )
        mainLayout = QVBoxLayout( mainWidget )
        
        addButtonsLayout = QHBoxLayout()
        buttonAddTab = QPushButton( 'Add Tab' )
        buttonAddLine = QPushButton( 'Add Line' )
        addButtonsLayout.addWidget( buttonAddTab )
        addButtonsLayout.addWidget( buttonAddLine )
        
        tabWidget = TabWidget()
        self.tabWidget = tabWidget
        
        buttonLayout = QHBoxLayout()
        buttonCreate = QPushButton( "Create" )
        buttonClose = QPushButton( "Close" )
        buttonLayout.addWidget( buttonCreate )
        buttonLayout.addWidget( buttonClose )

        mainLayout.addLayout( addButtonsLayout )
        mainLayout.addWidget( tabWidget )
        mainLayout.addLayout( buttonLayout )
    
        QtCore.QObject.connect( buttonAddTab, QtCore.SIGNAL( 'clicked()' ), partial( self.addTab ) )
        QtCore.QObject.connect( buttonAddLine, QtCore.SIGNAL( "clicked()" ), partial( tabWidget.addLine ) )
        QtCore.QObject.connect( buttonCreate, QtCore.SIGNAL( "clicked()" ), self.cmd_create )
        QtCore.QObject.connect( buttonClose, QtCore.SIGNAL( "clicked()" ), self.cmd_close )
示例#19
0
    def makeContent(self):
        layout = QHBoxLayout()

        prefs = PreferencesWidget(self.controller, self.transition)
        layout.addWidget(prefs, 1)

        rhs = QVBoxLayout()

        lblVersion = QLabel()
        lblVersion.setText("av-control version {0} (avx version {1})".format(_ui_version, _avx_version))
        rhs.addWidget(lblVersion)

        self.lv = LogViewer(self.controller, self.mainWindow)

        log = ExpandingButton()
        log.setText("Log")
        log.clicked.connect(self.showLog)
        rhs.addWidget(log)

        btnQuit = ExpandingButton()
        btnQuit.setText("Exit AV Control")
        btnQuit.clicked.connect(self.mainWindow.close)
        rhs.addWidget(btnQuit)

        layout.addLayout(rhs, 1)

        return layout
示例#20
0
        def createLayout():
            label = QLabel()
            layout = QHBoxLayout()
            layout.addWidget(label)

            widget = QWidget()
            widget.setLayout(layout)
            return (layout, widget)
示例#21
0
class UI_AttributeName( QWidget ):
    
    def __init__(self, *args, **kwargs ):
        QWidget.__init__( self, *args, **kwargs )
        self.installEventFilter( self )
        
        self.layout = QHBoxLayout( self )
        self.layout.setContentsMargins( 0,0,0,0 )
示例#22
0
def foo(parent):

    vbox = QHBoxLayout()

    vbox.addWidget( QLabel('this is the label of component', parent) )
    vbox.addWidget( QPushButton(parent, 'button') )

    return vbox
示例#23
0
    def _footer(self):
        hbox2 = QHBoxLayout()
        self.layout.addLayout(hbox2)

        cancelbut = QtGui.QPushButton("Close")
        cancelbut.released.connect(self.close)
        hbox2.addStretch(1)
        hbox2.addWidget(cancelbut)
示例#24
0
	def settings(self):
		if self.settings_window is None:
			window = QDialog(self)
			self.settings_window = window
		else: window = self.settings_window
		window = self.settings_window
		window.setWindowTitle('Settings')
		
		window.notelabel = QLabel("Currently these settings are only guaranteed to work prior to loading the first MIDI!\nYou'll have to restart ADLMIDI pyGui to change them again if they stop working. \n\nSorry! This will be fixed soon!")
		window.notelabel.setWordWrap(True)
		window.notelabel.setStyleSheet("font-size: 8pt; border-style: dotted; border-width: 1px; padding: 12px;")
		window.banklabel = QLabel("<B>Choose Instrument Bank</B>")
		window.space     = QLabel("")
		window.optlabel  = QLabel("<B>Options</B>")
		
		window.combo = QComboBox()
		window.combo.addItems(self.banks)
		#window.combo.setMaximumWidth(350)
		window.combo.setMaxVisibleItems(12)
		window.combo.setStyleSheet("combobox-popup: 0;")
		window.combo.setCurrentIndex(int(self.progset.value("sound/bank", 1)))
		window.combo.currentIndexChanged.connect(self.saveSettings)
		
		window.perc		= QCheckBox("Adlib Percussion Instrument Mode")
		#window.perc.stateChanged.connect(self.checkOpts)
		window.tremamp  = QCheckBox("Tremolo Amplification Mode")
		#window.tremamp.stateChanged.connect(self.checkOpts)
		window.vibamp   = QCheckBox("Vibrato Amplification Mode")
		#window.vibamp.stateChanged.connect(self.checkOpts)
		window.modscale = QCheckBox("Scaling of Modulator Volume")
		#window.modscale.stateChanged.connect(self.checkOpts)
		
		window.okButton = QPushButton('OK')
		window.okButton.clicked.connect(window.hide)
		
		vbox = QVBoxLayout()
		vbox.addWidget(window.space)
		vbox.addWidget(window.banklabel)
		vbox.addWidget(window.combo)
		vbox.addWidget(window.space)
		vbox.addWidget(window.optlabel)
		vbox.addWidget(window.perc)
		vbox.addWidget(window.tremamp)
		vbox.addWidget(window.vibamp)
		vbox.addWidget(window.modscale)
		vbox.addWidget(window.notelabel)
		
		hbox = QHBoxLayout()
		hbox.addStretch(1)
		hbox.addWidget(window.okButton)
		
		vbox.addLayout(hbox)
		window.setLayout(vbox) 
		
		window.setFixedSize(530, 369)
		window.show()
		window.activateWindow()
		window.raise_()
    def setupLayout(self):
        """ Setup the Layout on the Statistics Panel """
        layout = QHBoxLayout()
        self.pieChart = CategoryPieChart(self.categoryStatistics)
        self.categoryList = CategoryList(self.categoryStatistics)

        layout.addWidget(self.pieChart)
        layout.addWidget(self.categoryList)
        self.setLayout(layout)
示例#26
0
    def _welcomeAreaControls(self):
        def onOff(presetString):
            @handlePyroErrors
            def inner(isOn):
                if isOn:
                    self.lights.activate(presetString)
                else:
                    self.lights.deactivate(presetString)
            return inner

        layout = QHBoxLayout()

        gallery_ext = QVBoxLayout()

        gallery_ext.addWidget(TitleLabel("Gallery and External"))

        gallery = ExpandingButton()
        gallery.setText("Gallery")
        gallery.setCheckable(True)
        gallery.toggled.connect(onOff("St Aldate's.Welcome Area.gall on"))
        gallery_ext.addWidget(gallery)

        external = ExpandingButton()
        external.setText("External Lights")
        external.setCheckable(True)
        external.toggled.connect(onOff("EXTERIOR.Section Zero.ENTRA ONLY ON"))
        gallery_ext.addWidget(external)

        layout.addLayout(gallery_ext)

        welcomeArea = QVBoxLayout()

        welcomeArea.addWidget(TitleLabel("Welcome Area"))

        full = OptionButton()
        full.setText("100%")
        _safelyConnect(full.clicked, lambda: self.lights.activate("St Aldate's.Welcome Area.Welcome100%"))
        welcomeArea.addWidget(full)

        std = OptionButton()
        std.setText("70%")
        _safelyConnect(std.clicked, lambda: self.lights.activate("St Aldate's.Welcome Area.Welcome70%"))
        welcomeArea.addWidget(std)

        off = OptionButton()
        off.setText("Off")
        _safelyConnect(off.clicked, lambda: self.lights.activate("St Aldate's.Welcome Area.Ent&GalOFF"))
        welcomeArea.addWidget(off)

        self.welcomeArea = QButtonGroup()
        self.welcomeArea.addButton(full, 1)
        self.welcomeArea.addButton(std, 2)
        self.welcomeArea.addButton(off, 3)

        layout.addLayout(welcomeArea)

        return layout
 def __init__(self, parent=None):
   super(StackSizeCompound, self).__init__(parent)
   self.setTitle("Stack size")
   self.spinbox_stacksize = QSpinBox()
   self.spinbox_stacksize.setMaximum(9999)
   self.spinbox_stacksize.setMinimumWidth(100)
   layout = QHBoxLayout()
   layout.addWidget(self.spinbox_stacksize)
   self.setLayout(layout)
示例#28
0
    def testMoveLayout(self):
        l = QHBoxLayout()
        self.assertEqual(getrefcount(self.widget1), 2)
        l.addWidget(self.widget1)
        self.assertEqual(getrefcount(self.widget1), 3)

        w = QWidget()
        w.setLayout(l)
        self.assertEqual(getrefcount(self.widget1), 3)
 def _getTopOrBottomArrowLayout(self, arrow_alignment):
     self._arrow_layout = QHBoxLayout()
     self._arrow_layout.setAlignment(Qt.AlignLeft)
     self._arrow_layout.setContentsMargins(arrow_alignment, 0, 0, 0)
     return self._arrow_layout
示例#30
0
class Ui_MainView(QMainWindow):

    gui_methods_sig = Signal(int, )

    def __init__(self, ):
        super(Ui_MainView, self).__init__()

        self.output_folder = os.getcwd()
        self.usr = ''
        self.psw = ''

        self.save_username_checked = False

        self.right_base_layout_v = QtGui.QVBoxLayout()
        self.msgBox = QtGui.QMessageBox()

        self.validations = validate_inputs.validate_controls(
            self
        )  # instance for input validations  and we are passing self to validate class for model updations

    def gifUI(self, gui_slate):

        self.gui = gui_slate
        self.gif_widget = QWidget()
        self.gif_layout = QVBoxLayout()

        self.movie_screen = QLabel()
        self.movie_screen.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                        QtGui.QSizePolicy.Expanding)
        self.movie_screen.setAlignment(QtCore.Qt.AlignCenter)
        self.gif_layout.addWidget(self.movie_screen)

        ag_file = "GIF-180704_103026.gif"

        self.movie = QtGui.QMovie(ag_file, QtCore.QByteArray(),
                                  self.gif_widget)
        self.movie.setCacheMode(QtGui.QMovie.CacheAll)
        self.movie.setSpeed(75)
        self.movie_screen.setMovie(self.movie)
        #         self.movie_screen.setFixedWidth(500)

        self.gif_widget.setLayout(self.gif_layout)
        self.gui.setCentralWidget(self.gif_widget)
        #         self.gui.addDockWidget(self.gif_widget)
        self.movie.start()
        #         self.movie.setPaused(True)
        self.gif_widget.show()
#         time.sleep(2)
#         self.movie.stop()

    def setupUi(self, gui_slate):

        self.gui = gui_slate
        self.gui.get_option_selected = False
        self.gui.push_option_selected = False
        self.gui.extract_opt_selected = False
        self.gui.compare_opt_selected = False

        #Outer most Main Layout

        self.widget = QWidget()
        self.widget.setMinimumSize(850, 600)

        self.main_layout_h = QHBoxLayout()
        self.main_layout_h.setAlignment(QtCore.Qt.AlignTop)

        self.widget.setLayout(self.main_layout_h)

        self.gui.setCentralWidget(self.widget)

        self.left_base_widget = QWidget()
        #         self.left_base_widget.setMaximumWidth(600)
        #         self.left_base_widget.setMinimumWidth(450)
        #         self.left_base_widget.setMaximumHeight(700)

        self.right_base_widget = QWidget()

        #3 Sub main Layouts

        self.left_base_layout_v = QVBoxLayout()
        #         self.right_base_layout_v = QVBoxLayout()
        self.corner_logo_layout_v = QVBoxLayout()
        self.left_base_layout_v.setAlignment(QtCore.Qt.AlignTop)

        self.right_base_layout_v.setAlignment(QtCore.Qt.AlignTop)

        #Added Widgets and layouts to the outermost layout

        self.main_layout_h.addWidget(self.left_base_widget)
        self.main_layout_h.addWidget(self.right_base_widget)
        self.main_layout_h.addLayout(self.corner_logo_layout_v)

        #         , QtGui.QFont.Normal
        self.grp_heading_font = QtGui.QFont("Verdana", 10)
        self.grp_heading_font.setItalic(True)

        #Radio buttons layout

        self.radio_groupBox = QtGui.QGroupBox()
        self.radio_option_layout_lb_h = QHBoxLayout()

        self.radio_groupBox.setLayout(self.radio_option_layout_lb_h)

        self.radio_groupBox.setMinimumWidth(450)
        self.left_base_layout_v.addWidget(self.radio_groupBox)

        #Credentials layouts

        self.credentials_groupbox = QtGui.QGroupBox("GTAC Credentials")
        self.credentials_groupbox.setFont(self.grp_heading_font)
        self.credentials_layout_lb_v = QVBoxLayout()

        self.username_layout_lb_h = QHBoxLayout()
        self.password_layout_lb_h = QHBoxLayout()
        self.cr_layout_lb_h = QHBoxLayout()
        self.password_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft)
        self.credentials_layout_lb_v.addLayout(self.username_layout_lb_h)
        self.credentials_layout_lb_v.addLayout(self.password_layout_lb_h)
        self.credentials_layout_lb_v.addLayout(self.cr_layout_lb_h)

        self.credentials_groupbox.setLayout(self.credentials_layout_lb_v)
        self.left_base_layout_v.addWidget(self.credentials_groupbox)
        self.credentials_groupbox.setAlignment(QtCore.Qt.AlignLeft)
        self.credentials_groupbox.hide()

        #IP group box layouts

        self.IP_groupBox = QtGui.QGroupBox("IP Inputs")
        self.IP_groupBox.setFont(self.grp_heading_font)
        self.ip_file_layout_lb_v = QVBoxLayout()

        self.ip_file_select_layout_lb_h = QHBoxLayout()
        self.ip_file_select_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft)
        self.ip_file_layout_lb_v.addLayout(self.ip_file_select_layout_lb_h)

        self.IP_groupBox.setMaximumHeight(135)
        self.IP_groupBox.setLayout(self.ip_file_layout_lb_v)
        self.left_base_layout_v.addWidget(self.IP_groupBox)

        self.IP_groupBox.hide()

        # Commands  group box selection

        self.Commands_groupBox = QtGui.QGroupBox("Commands Inputs")
        self.Commands_groupBox.setFont(self.grp_heading_font)
        self.commands_label_layout_lb_v = QVBoxLayout()

        self.default_chkbx_layout_lb_h = QHBoxLayout()
        self.commands_file_layout_lb_h = QHBoxLayout()
        self.commands_file_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft)
        self.commands_custom_box_layout_lb_h = QHBoxLayout()
        self.none_radio_btn_layout_lb_h = QHBoxLayout()

        self.commands_label_layout_lb_v.addLayout(
            self.default_chkbx_layout_lb_h)
        self.commands_label_layout_lb_v.addLayout(
            self.commands_file_layout_lb_h)
        self.commands_label_layout_lb_v.addLayout(
            self.commands_custom_box_layout_lb_h)
        self.commands_label_layout_lb_v.addLayout(
            self.none_radio_btn_layout_lb_h)

        self.Commands_groupBox.setMaximumHeight(225)
        self.Commands_groupBox.setAlignment(QtCore.Qt.AlignLeft)
        self.Commands_groupBox.setLayout(self.commands_label_layout_lb_v)
        self.left_base_layout_v.addWidget(self.Commands_groupBox)

        self.Commands_groupBox.hide()

        # results group box

        self.results_groupBox = QtGui.QGroupBox("Results")
        self.results_groupBox.setFont(self.grp_heading_font)
        self.results_layout_lb_v = QVBoxLayout()

        self.output_layout_lb_h = QHBoxLayout()
        self.output_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft)

        self.results_layout_lb_v.addLayout(self.output_layout_lb_h)

        self.results_groupBox.setLayout(self.results_layout_lb_v)
        self.left_base_layout_v.addWidget(self.results_groupBox)

        self.results_groupBox.hide()

        # Go Button

        self.go_btn_layout_lb_h = QHBoxLayout()
        self.left_base_layout_v.addLayout(self.go_btn_layout_lb_h)

        # Right and Left Widget on individual layouts

        self.left_base_widget.setLayout(self.left_base_layout_v)
        self.right_base_widget.setLayout(self.right_base_layout_v)

        #### just to see right base layout

        self.right_base = QtGui.QTextEdit(self.gui)
        self.right_base.setStyleSheet(
            """QToolTip { background-color: #00bfff; color: black; border: black solid 2px  }"""
        )
        self.right_base.setObjectName("IP_Address")
        self.right_base_layout_v.addWidget(self.right_base)
        #         self.right_base.setMaximumHeight(500)
        self.right_base.hide()

        self.snap_gif = QtGui.QLabel(self.gui)
        self.snap_gif.setText("")
        self.snap_gif.setStyleSheet("background-color: None")
        self.snap_gif.setPixmap(QtGui.QPixmap("Capture.png"))
        self.snap_gif.setObjectName("logo_corner")
        self.right_base_layout_v.addWidget(self.snap_gif)

        ######

        self.gui.setWindowTitle('SPEED +  3.0')
        self.gui.setWindowIcon(QtGui.QIcon(":/logo/Wind_icon.png"))
        self.gui.setAutoFillBackground(True)

        self.corner_logolabel = QtGui.QLabel(self.gui)
        self.corner_logolabel.setText("")
        self.corner_logolabel.setStyleSheet("background-color: None")
        self.corner_logolabel.setPixmap(QtGui.QPixmap(":/logo/ATT-LOGO-2.png"))
        self.corner_logolabel.setObjectName("logo_corner")
        #         self.corner_logo_layout_v.setAlignment(QtCore.Qt.AlignTop)
        self.corner_logo_layout_v.setAlignment(
            int(QtCore.Qt.AlignTop | QtCore.Qt.AlignRight))
        self.corner_logo_layout_v.addWidget(self.corner_logolabel)

        self.msgBox.setWindowIcon(QtGui.QIcon(":/logo/Wind_icon.png"))
        self.msgBox.setFont(QtGui.QFont("Verdana", 8, QtGui.QFont.Normal))
        self.make_menu()
        ## gif at&t logo
        #         self.movie_screen = QLabel()
        #         self.movie_screen.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
        #         self.movie_screen.setAlignment(QtCore.Qt.AlignCenter)
        #         self.right_base_layout_v.addWidget(self.movie_screen)
        #
        #         ag_file = "C:/Users/rg012f/eclipse-workspace/poojan_try/giphy.gif"
        #         self.movie = QtGui.QMovie(ag_file, QtCore.QByteArray(), None)
        #         self.movie.setCacheMode(QtGui.QMovie.CacheAll)
        #         self.movie.setSpeed(75)
        #         self.movie_screen.setMovie(self.movie)
        #
        #
        #         self.movie.setPaused(True)
        #         self.movie.start()
        #         self.right_base_widget.show()
        #         time.sleep(2)

        ######################### order of the below funtion calls is importnant change them wisely#####################
        self.check_save_username()
        self.create_views()
        self.left_radio_controls()
        self.connect_child_views()

    def make_menu(self):
        self.myMenu = self.gui.menuBar()

        self.file = self.myMenu.addMenu('&File')

        self.file.addAction("&Select Output Folder...",
                            self.select_destination, "Ctrl+O")
        self.file.addAction("&Exit", self.closewindow, "Ctrl+X")

        self.file = self.myMenu.addMenu('&Help')

        self.file.addAction("&About...", self.about_tool, "Ctrl+H")

    def check_save_username(self):
        print("Yo reached save username")
        try:
            f = open('Username.txt', 'r')
            lines = f.readlines()
            if len(lines):
                self.save_username_checked = True
            else:
                self.save_username_checked = False
        except Exception as ex:
            print(ex)

    def select_destination(self, ):

        fld = QtGui.QFileDialog.getExistingDirectory(self.gui,
                                                     'Select Output Folder')
        self.output_folder = str(fld)

    def closewindow(self):
        self.gui.close()

    def about_tool(self):
        abouttool = "Speed + v3.0 \n\nThis tool is useful to fetch, push, extract, compare device configs \n"

        self.msgBox.setText(abouttool)
        self.msgBox.setWindowTitle("About Speed +")
        self.msgBox.show()

    def left_radio_controls(self):

        # ============================    main radio options selection :
        radio_font = QtGui.QFont("Verdana", 10, QtGui.QFont.Normal)

        self.get_radio_option = QtGui.QRadioButton(self.gui)
        self.get_radio_option.setFont(radio_font)
        self.get_radio_option.setText("Get")
        self.radio_option_layout_lb_h.addWidget(self.get_radio_option)

        self.push_radio_option = QtGui.QRadioButton(self.gui)
        self.push_radio_option.setFont(radio_font)
        self.push_radio_option.setText("Push")
        self.radio_option_layout_lb_h.addWidget(self.push_radio_option)

        self.extract_radio_option = QtGui.QRadioButton(self.gui)
        self.extract_radio_option.setFont(radio_font)
        self.extract_radio_option.setText("Extract")
        self.radio_option_layout_lb_h.addWidget(self.extract_radio_option)

        self.compare_radio_option = QtGui.QRadioButton(self.gui)
        self.compare_radio_option.setFont(radio_font)
        self.compare_radio_option.setText("Compare")
        self.radio_option_layout_lb_h.addWidget(self.compare_radio_option)

    def disp_get_options(self):

        self.snap_gif.show()
        self.push_view.hide_push()
        self.excel_view.userOptionextract.hide()
        self.compare_view.main_widget.hide()
        self.get_view.display_get()

    def disp_push_options(self):

        self.snap_gif.show()
        self.get_view.hide_get()
        self.excel_view.userOptionextract.hide()
        self.compare_view.main_widget.hide()
        self.push_view.display_push()
        self.validations.hide_right_common()

    def disp_ext_options(self):

        self.get_view.hide_get()
        self.push_view.hide_push()
        self.compare_view.main_widget.hide()
        self.excel_view.display_excel_portion()
        self.validations.hide_right_common()

    def disp_comp_options(self):

        self.get_view.hide_get()
        self.push_view.hide_push()
        self.excel_view.userOptionextract.hide()
        self.compare_view.display_comapre_portion()
        self.validations.hide_right_common()

    def connect_child_views(self):

        self.get_radio_option.clicked.connect(self.disp_get_options)
        self.push_radio_option.clicked.connect(self.disp_push_options)
        self.extract_radio_option.clicked.connect(self.disp_ext_options)
        self.compare_radio_option.clicked.connect(self.disp_comp_options)

        self.base_left.go_button.clicked.connect(self.connect_validate_option)

    def connect_validate_option(self):

        self.validations.validate_user_inputs(
        )  # passing self to validation class method , other end this self is last_parent

    def create_views(self):

        self.base_left = left_base(
            self
        )  # we are passing main GUI and also local self as 'last_parent' to left base view to update variables

        self.get_view = get_controls(self.gui, self.base_left)
        self.push_view = push_controls(self.gui, self.base_left)
        self.excel_view = extract_excel(self.gui, self.base_left)
        self.compare_view = compare_op_results(self)

    def show_gif_right_base(self, path, layout):
        print("ui parent view show_gif_right_base line 394")
        self.movie_screen = QLabel()
        self.movie_screen.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                        QtGui.QSizePolicy.Expanding)
        self.movie_screen.setAlignment(QtCore.Qt.AlignCenter)
        layout.addWidget(self.movie_screen)

        ag_file = path
        self.movie = QtGui.QMovie(ag_file, QtCore.QByteArray(), None)
        self.movie.setCacheMode(QtGui.QMovie.CacheAll)
        self.movie.setSpeed(75)
        self.movie_screen.setMovie(self.movie)

        #"C:/Users/rg012f/eclipse-workspace/poojan_try/giphy.gif"
        self.movie.setPaused(True)
        self.movie.start()
#         self.right_base_widget.setLayout(layout)
#         self.right_base_widget.show()

    def hide_gif_right_base(self):
        self.movie_screen.hide()
示例#31
0
class RobocompDslGui(QMainWindow):
    def __init__(self, parent=None):
        super(RobocompDslGui, self).__init__(parent)
        self.setWindowTitle("Create new component")
        # self._idsl_paths = []
        self._communications = {
            "implements": [],
            "requires": [],
            "subscribesTo": [],
            "publishes": []
        }
        self._interfaces = {}
        self._cdsl_doc = CDSLDocument()
        self._command_process = QProcess()

        self._main_widget = QWidget()
        self._main_layout = QVBoxLayout()
        self.setCentralWidget(self._main_widget)

        self._name_layout = QHBoxLayout()
        self._name_line_edit = QLineEdit()
        self._name_line_edit.textEdited.connect(self.update_component_name)
        self._name_line_edit.setPlaceholderText("New component name")
        self._name_layout.addWidget(self._name_line_edit)
        self._name_layout.addStretch()

        # DIRECTORY SELECTION
        self._dir_line_edit = QLineEdit()
        # self._dir_line_edit.textEdited.connect(self.update_completer)
        self._dir_completer = QCompleter()
        self._dir_completer_model = QFileSystemModel()
        if os.path.isdir(ROBOCOMP_COMP_DIR):
            self._dir_line_edit.setText(ROBOCOMP_COMP_DIR)
            self._dir_completer_model.setRootPath(ROBOCOMP_COMP_DIR)
        self._dir_completer.setModel(self._dir_completer_model)
        self._dir_line_edit.setCompleter(self._dir_completer)

        self._dir_button = QPushButton("Select directory")
        self._dir_button.clicked.connect(self.set_output_directory)
        self._dir_layout = QHBoxLayout()
        self._dir_layout.addWidget(self._dir_line_edit)
        self._dir_layout.addWidget(self._dir_button)

        # LIST OF ROBOCOMP INTERFACES
        self._interface_list = QListWidget()
        self._interface_list.setSelectionMode(
            QAbstractItemView.ExtendedSelection)
        self._interface_list.itemSelectionChanged.connect(
            self.set_comunication)

        # LIST OF CONNECTION TyPES
        self._type_combo_box = QComboBox()
        self._type_combo_box.addItems(
            ["publishes", "implements", "subscribesTo", "requires"])
        self._type_combo_box.currentIndexChanged.connect(
            self.reselect_existing)

        # BUTTON TO ADD A NEW CONNECTION
        # self._add_connection_button = QPushButton("Add")
        # self._add_connection_button.clicked.connect(self.add_new_comunication)
        self._add_connection_layout = QHBoxLayout()
        # self._add_connection_layout.addWidget(self._add_connection_button)
        self._language_combo_box = QComboBox()
        self._language_combo_box.addItems(["Python", "Cpp", "Cpp11"])
        self._language_combo_box.currentIndexChanged.connect(
            self.update_language)
        self._add_connection_layout.addWidget(self._language_combo_box)
        self._add_connection_layout.addStretch()
        self._gui_check_box = QCheckBox()
        self._gui_check_box.stateChanged.connect(self.update_gui_selection)
        self._gui_label = QLabel("Use Qt GUI")
        self._add_connection_layout.addWidget(self._gui_label)
        self._add_connection_layout.addWidget(self._gui_check_box)

        # WIDGET CONTAINING INTERFACES AND TYPES
        self._selection_layout = QVBoxLayout()
        self._selection_layout.addWidget(self._type_combo_box)
        self._selection_layout.addWidget(self._interface_list)
        self._selection_layout.addLayout(self._add_connection_layout)
        self._selection_widget = QWidget()
        self._selection_widget.setLayout(self._selection_layout)

        # TEXT EDITOR WITH THE RESULTING CDSL CODE
        self._editor = QTextEdit(self)
        self._editor.setHtml("")

        self._document = self._editor.document()
        self._component_directory = None

        # SPLITTER WITH THE SELECTION AND THE CODE
        self._body_splitter = QSplitter(Qt.Horizontal)
        self._body_splitter.addWidget(self._selection_widget)
        self._body_splitter.addWidget(self._editor)
        self._body_splitter.setStretchFactor(0, 2)
        self._body_splitter.setStretchFactor(1, 9)

        # CREATION BUTTONS
        self._create_button = QPushButton("Create .cdsl")
        self._create_button.clicked.connect(self.write_cdsl_file)
        self._creation_layout = QHBoxLayout()
        self._creation_layout.addStretch()
        self._creation_layout.addWidget(self._create_button)

        self._console = QConsole()
        self._command_process.readyReadStandardOutput.connect(
            self._console.standard_output)
        self._command_process.readyReadStandardError.connect(
            self._console.error_output)

        # ADDING WIDGETS TO MAIN LAYOUT
        self._main_widget.setLayout(self._main_layout)
        self._main_layout.addLayout(self._name_layout)
        self._main_layout.addLayout(self._dir_layout)
        self._main_layout.addWidget(self._body_splitter)
        self._main_layout.addLayout(self._creation_layout)
        self._main_layout.addWidget(self._console)
        self.setMinimumSize(800, 500)
        self._editor.setText(self._cdsl_doc.generate_doc())

    # self.editor->show();

    # def update_completer(self, path):
    # 	print "update_completer %s"%path
    # 	info = QFileInfo(path)
    # 	if info.exists() and info.isDir():
    # 			if not path.endswith(os.path.pathsep):
    # 				new_path = os.path.join(path, os.sep)
    # 				# self._dir_line_edit.setText(new_path)
    # 			all_dirs_output = [dI for dI in os.listdir(path) if os.path.isdir(os.path.join(path, dI))]
    # 			print all_dirs_output
    # 			self._dir_completer.complete()

    def load_idsl_files(self, fullpath=None):
        if fullpath is None:
            fullpath = ROBOCOMP_INTERFACES
        idsls_dir = os.path.join(ROBOCOMP_INTERFACES, "IDSLs")
        if os.path.isdir(idsls_dir):
            for full_filename in os.listdir(idsls_dir):
                file_name, file_extension = os.path.splitext(full_filename)
                if "idsl" in file_extension.lower():
                    full_idsl_path = os.path.join(idsls_dir, full_filename)
                    # self._idsl_paths.append(os.path.join(idsls_dir,full_filename))
                    self.parse_idsl_file(full_idsl_path)
        self._interface_list.addItems(self._interfaces.keys())

    def parse_idsl_file(self, fullpath):

        with open(fullpath, 'r') as fin:
            interface_name = None
            for line in fin:
                result = re.findall(r'^\s*interface\s+(\w+)\s*\{?\s*$',
                                    line,
                                    flags=re.MULTILINE)
                if len(result) > 0:
                    interface_name = result[0]
            print("%s for idsl %s" % (interface_name, fullpath))
            if interface_name is not None:
                self._interfaces[interface_name] = fullpath

    def add_new_comunication(self):
        interface_names = self._interface_list.selectedItems()
        com_type = str(self._type_combo_box.currentText())
        for iface_name_item in interface_names:
            iface_name = str(iface_name_item.text())
            self._communications[com_type].append(iface_name)
            idsl_full_path = self._interfaces[iface_name]
            idsl_full_filename = os.path.basename(idsl_full_path)
            self._cdsl_doc.add_comunication(com_type, iface_name)
            self._cdsl_doc.add_import(idsl_full_filename)
        self.update_editor()

    def set_comunication(self):
        interface_names = self._interface_list.selectedItems()
        com_type = str(self._type_combo_box.currentText())
        self._communications[com_type] = []
        self._cdsl_doc.clear_comunication(com_type)
        for iface_name_item in interface_names:
            iface_name = str(iface_name_item.text())
            self._communications[com_type].append(iface_name)
            self._cdsl_doc.add_comunication(com_type, iface_name)
        self.update_imports()
        self.update_editor()

    def update_imports(self):
        self._cdsl_doc.clear_imports()
        for com_type in self._communications:
            for iface_name in self._communications[com_type]:
                idsl_full_path = self._interfaces[iface_name]
                idsl_full_filename = os.path.basename(idsl_full_path)
                self._cdsl_doc.add_import(idsl_full_filename)

    def update_language(self):
        language = self._language_combo_box.currentText()
        self._cdsl_doc.set_language(str(language))
        self.update_editor()

    def update_gui_selection(self):
        checked = self._gui_check_box.isChecked()
        if checked:
            self._cdsl_doc.set_qui(True)
        else:
            self._cdsl_doc.set_qui(False)
        self.update_editor()

    def update_component_name(self, name):
        self._cdsl_doc.set_name(name)
        self.update_editor()

    def update_editor(self):
        self._editor.setText(self._cdsl_doc.generate_doc())

    def set_output_directory(self):
        dir_set = False
        while not dir_set:
            dir = QFileDialog.getExistingDirectory(
                self, "Select Directory", ROBOCOMP_COMP_DIR,
                QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks)
            if self.check_dir_is_empty(str(dir)):
                self._dir_line_edit.setText(dir)
                dir_set = True

    def write_cdsl_file(self):
        component_dir = str(self._dir_line_edit.text())
        text = self._cdsl_doc.generate_doc()
        if not self._name_line_edit.text():
            component_name, ok = QInputDialog.getText(self,
                                                      'No component name set',
                                                      'Enter component name:')
            if ok:
                self.update_component_name(component_name)
                self._name_line_edit.setText(component_name)
            else:
                return False

        if not os.path.exists(component_dir):
            if QMessageBox.Yes == QMessageBox.question(
                    self, "Directory doesn't exist.",
                    "Do you want create the directory %s?" % component_dir,
                    QMessageBox.Yes | QMessageBox.No):
                os.makedirs(component_dir)
            else:
                QMessageBox.question(
                    self, "Directory not exist",
                    "Can't create a component witout a valid directory")
                return False

        file_path = os.path.join(component_dir,
                                 str(self._name_line_edit.text()) + ".cdsl")
        if os.path.exists(file_path):
            if QMessageBox.No == QMessageBox.question(
                    self, "File already exists", "Do you want to overwrite?",
                    QMessageBox.Yes | QMessageBox.No):
                return False

        with open(file_path, 'w') as the_file:
            the_file.write(text)
        self.execute_robocomp_cdsl()
        return True

    def execute_robocomp_cdsl(self):
        cdsl_file_path = os.path.join(
            str(self._dir_line_edit.text()),
            str(self._name_line_edit.text()) + ".cdsl")
        command = "python -u %s/robocompdsl.py %s %s" % (
            ROBOCOMPDSL_DIR, cdsl_file_path,
            os.path.join(str(self._dir_line_edit.text())))
        self._console.append_custom_text("%s\n" % command)
        self._command_process.start(command,
                                    QProcess.Unbuffered | QProcess.ReadWrite)

    def reselect_existing(self):
        com_type = self._type_combo_box.currentText()
        selected = self._communications[com_type]
        self._interface_list.clearSelection()
        for iface in selected:
            items = self._interface_list.findItems(iface,
                                                   Qt.MatchFlag.MatchExactly)
            if len(items) > 0:
                item = items[0]
                item.setSelected(True)

    def check_dir_is_empty(self, dir_path):
        if len(os.listdir(dir_path)) > 0:
            msgBox = QMessageBox()
            msgBox.setWindowTitle("Directory not empty")
            msgBox.setText(
                "The selected directory is not empty.\n"
                "For a new Component you usually want a new directory.\n"
                "Do you want to use this directory anyway?")
            msgBox.setStandardButtons(QMessageBox.Yes)
            msgBox.addButton(QMessageBox.No)
            msgBox.setDefaultButton(QMessageBox.No)
            if msgBox.exec_() == QMessageBox.Yes:
                return True
            else:
                return False
        else:
            return True
示例#32
0
 def layoutWidgets(self):
     layout = QHBoxLayout()
     layout.addWidget(self.listWidget)
     layout.addLayout(self.buttonLayout)
     self.setLayout(layout)
示例#33
0
    def _initGUI(self):
        topHLayout = QHBoxLayout()
        hLayout = QHBoxLayout()
        vLayout = QVBoxLayout()
        
        # Label
        greeterText = QLabel("Welcome to <b>Pushup app</b>." + \
                             "<br><br> Select a profile:")
        vLayout.addWidget(greeterText)        
            
        # List 
        self.list = QListWidget()
        self.list.setMinimumWidth(150)
        self.list.setSelectionMode(QAbstractItemView.SingleSelection)
        # SingleSelection is the default value, but I prefer to be sure
        self.list.itemSelectionChanged.connect(self._activateButtons) 
        
        for athlete in self.athletesList:
            iconW = QIcon.fromTheme("user-available")
            # doens't work on Mac and Windows
            # http://qt-project.org/doc/qt-4.8/qicon.html#fromTheme
            
            listW = QListWidgetItem(iconW, athlete._name)
            listW.setData(Qt.UserRole, athlete)
            
            self.list.addItem(listW)
        
        topHLayout.addWidget(self.list)
        self.profileWidget = ProfileFormWidget()
        self.profileWidget.hide()
        
        topHLayout.addWidget(self.profileWidget)    
       
        vLayout.addLayout(topHLayout)        
        vLayout.addLayout(hLayout)
        
        # Buttons
        self.okBtn = QPushButton("Ok")
        self.okBtn.setDisabled(True)
        self.okBtn.setDefault(True)
        self.okBtn.clicked.connect(self._okButtonSlot)
        self.list.itemDoubleClicked.connect(self._okButtonSlot)
                
        cancelBtn = QPushButton("Cancel")      
        cancelBtn.clicked.connect(self._cancelButtonSlot)
        
        self.editBtn = QPushButton("Edit")
        self.editBtn.setDisabled(True)
        self.editBtn.setCheckable(True)
        self.editBtn.clicked.connect(self._toggleProfileEdit)
        
        self.saveBtn = QPushButton("Save changes") # Saves the changes made on the profile 
        self.saveBtn.hide()
        self.saveBtn.clicked.connect(self._saveButtonSlot)
    
        self.removeProfileBtn = QPushButton("Remove Profile")
        self.removeProfileBtn.setDisabled(True)
        self.removeProfileBtn.clicked.connect(self._removeProfile_Dialog)
        
        hLayout.addWidget(self.editBtn)
        hLayout.addWidget(self.removeProfileBtn)
        hLayout.addWidget(cancelBtn)
        hLayout.addWidget(self.okBtn)
        hLayout.addWidget(self.saveBtn)

        self.setLayout(vLayout)
示例#34
0
class ui(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.setupUI()
        self.id = 1
        self.lines = []
        self.editable = True
        self.des_sort = True
        self.faker = Factory.create()
        self.btn_add.clicked.connect(self.add_line)
        self.btn_del.clicked.connect(self.del_line)
        self.btn_modify.clicked.connect(self.modify_line)
        self.btn_select_line.clicked.connect(self.select_line)
        self.btn_select_single.clicked.connect(self.deny_muti_line)
        self.btn_sort.clicked.connect(self.sortItem)
        self.btn_set_header.clicked.connect(self.setheader)
        self.btn_set_middle.clicked.connect(self.middle)
        self.table.cellChanged.connect(self.cellchange)
        self.btn_noframe.clicked.connect(self.noframe)


#     # Sess = sessionmaker(bind = engine)

    def setupUI(self):
        self.setWindowTitle(windowTital)
        self.resize(640, 480)
        self.table = QTableWidget(self)
        self.btn_add = QPushButton(u'增加')
        self.btn_del = QPushButton(u'删除')
        self.btn_modify = QPushButton(u'可以编辑')
        self.btn_select_line = QPushButton(u'选择整行')
        self.btn_select_single = QPushButton(u'禁止选多行')
        self.btn_sort = QPushButton(u'以分数排序')
        self.btn_set_header = QPushButton(u'标头设置')
        self.btn_set_middle = QPushButton(u'文字居中加颜色')
        self.btn_noframe = QPushButton(u'取消边框颜色交替')
        self.spacerItem = QSpacerItem(20, 20, QSizePolicy.Minimum,
                                      QSizePolicy.Expanding)
        self.vbox = QVBoxLayout()
        self.vbox.addWidget(self.btn_add)
        self.vbox.addWidget(self.btn_del)
        self.vbox.addWidget(self.btn_modify)
        self.vbox.addWidget(self.btn_select_line)
        self.vbox.addWidget(self.btn_select_single)
        self.vbox.addWidget(self.btn_sort)
        self.vbox.addWidget(self.btn_set_header)
        self.vbox.addWidget(self.btn_set_middle)
        self.vbox.addWidget(self.btn_noframe)
        self.vbox.addSpacerItem(
            self.spacerItem)  #可以用addItem也可以用addSpacerItem方法添加,没看出哪里不一样
        self.txt = QLabel()
        self.txt.setMinimumHeight(50)
        self.vbox2 = QVBoxLayout()
        self.vbox2.addWidget(self.table)
        self.vbox2.addWidget(self.txt)
        self.hbox = QHBoxLayout()
        self.hbox.addLayout(self.vbox2)
        self.hbox.addLayout(self.vbox)
        self.setLayout(self.hbox)
        self.table.setColumnCount(4)  ##设置列数
        self.headers = [u'id', u'选择', u'姓名', u'成绩', u'住址']
        self.table.setHorizontalHeaderLabels(self.headers)
        self.show()

    def add_line(self):
        self.table.cellChanged.disconnect()
        row = self.table.rowCount()
        self.table.setRowCount(row + 1)
        id = str(self.id)
        ck = QCheckBox()
        h = QHBoxLayout()
        h.setAlignment(Qt.AlignCenter)
        h.addWidget(ck)
        w = QWidget()
        w.setLayout(h)
        name = self.faker.name()
        score = str(random.randint(50, 99))
        add = self.faker.address()
        self.table.setItem(row, 0, QTableWidgetItem(id))
        self.table.setCellWidget(row, 1, w)
        self.table.setItem(row, 2, QTableWidgetItem(name))
        self.table.setItem(row, 3, QTableWidgetItem(score))
        self.table.setItem(row, 4, QTableWidgetItem(add))
        self.id += 1
        self.lines.append([id, ck, name, score, add])
        self.settext(u'自动生成随机一行数据!,checkbox设置为居中显示')
        self.table.cellChanged.connect(self.cellchange)

    def del_line(self):
        removeline = []
        for line in self.lines:
            if line[1].isChecked():
                row = self.table.rowCount()
                for x in range(row, 0, -1):
                    if line[0] == self.table.item(x - 1, 0).text():
                        self.table.removeRow(x - 1)
                        removeline.append(line)
        for line in removeline:
            self.lines.remove(line)
        self.settext(u'删除在左边checkbox中选中的行,使用了一个笨办法取得行号\n,不知道有没有其他可以直接取得行号的方法!')

    def modify_line(self):
        if self.editable == True:
            self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)
            self.btn_modify.setText(u'禁止编辑')
            self.editable = False
        else:
            self.table.setEditTriggers(QAbstractItemView.AllEditTriggers)
            self.btn_modify.setText(u'可以编辑')
            self.editable = True
        self.settext(u'设置,是否可以编辑整个表格')

    def select_line(self):
        if self.table.selectionBehavior() == 0:
            self.table.setSelectionBehavior(1)
            self.btn_select_line.setStyleSheet('background-color:lightblue')
        else:
            self.table.setSelectionBehavior(0)
            self.btn_select_line.setStyleSheet('')
        self.settext(u'默认时,点击单元格,只可选择一个格,此处设置为可选择整行')

    def deny_muti_line(self):
        if self.table.selectionMode() in [2, 3]:
            self.table.setSelectionMode(QAbstractItemView.SingleSelection)
            self.btn_select_single.setStyleSheet('background-color:lightblue')
        else:
            self.table.setSelectionMode(QAbstractItemView.ExtendedSelection)
            self.btn_select_single.setStyleSheet('')
        self.settext(u'点击时会轮换以多行或单行选择,默认是可以同时选择多行')

    def sortItem(self):
        if self.des_sort == True:
            self.table.sortItems(3, Qt.DescendingOrder)
            self.des_sort = False
            self.btn_sort.setStyleSheet('background-color:lightblue')
            self.table.setSortingEnabled(True)  # 设置表头可以自动排序
        else:
            self.table.sortItems(3, Qt.AscendingOrder)
            self.des_sort = True
            self.btn_sort.setStyleSheet('background-color:lightblue')
            self.table.setSortingEnabled(False)
        self.settext(u'点击时会轮换以升序降序排列,但排序时,会使自动列宽失效!')

    def setheader(self):
        font = QFont(u'微软雅黑', 12)
        font.setBold(True)
        self.table.horizontalHeader().setFont(font)  # 设置表头字体
        self.table.setColumnWidth(0, 50)
        self.table.setColumnWidth(1, 50)
        self.table.setColumnWidth(3, 100)
        self.table.horizontalHeader().setSectionResizeMode(
            2, QHeaderView.Stretch)
        self.table.horizontalHeader().setStyleSheet(
            'QHeaderView::section{background:gray}')
        self.table.horizontalHeader().setFixedHeight(50)
        self.table.setColumnHidden(0, True)
        self.btn_set_header.setStyleSheet('background-color:lightblue')
        self.settext(
            u'设置标头字体及字号,隐藏ID列,设置标头除姓名外全部为固定宽度\n,设置姓名列自动扩展宽度,设置标头行高,设置标头背景色')

    def middle(self):
        self.btn_set_middle.setStyleSheet('background-color:lightblue')
        self.table.setStyleSheet('color:green;')
        row = self.table.rowCount()
        for x in range(row):
            for y in range(4):
                if y != 1:
                    item = self.table.item(x, y)
                    item.setTextAlignment(Qt.AlignCenter)
                else:
                    pass
        self.btn_set_middle.setStyleSheet('background-color:lightblue')
        self.settext(u'将文字居中显示,设置文字颜色')

    def cellchange(self, row, col):
        item = self.table.item(row, col)
        txt = item.text()
        self.settext(u'第%s行,第%s列 , 数据改变为:%s' % (row, col, txt))

    def noframe(self):
        self.table.setAlternatingRowColors(True)
        self.table.setFrameStyle(QFrame.NoFrame)
        self.table.setStyleSheet('color:green;'
                                 'gridline-color:white;'
                                 'border:0px solid gray')
        self.settext(u'取消表的框线,\n 取消表格内框')

    def settext(self, txt):
        font = QFont(u'微软雅黑', 10)
        self.txt.setFont(font)
        self.txt.setText(txt)
示例#35
0
    def __init__(self, parent, find_order_action_slot):
        super(PresenceOverviewWidget, self).__init__(parent)

        self.set_panel_title(_("Presence overview"))
        self.base_date = date.today()

        headers = QStandardItemModel(1, 31 + 3)
        self._table_model = QStandardItemModel(1, 31 + 3, None)

        self.headers_view = QHeaderView(Qt.Orientation.Horizontal, self)
        self.header_model = headers
        self.headers_view.setResizeMode(QHeaderView.ResizeToContents)
        self.headers_view.setModel(
            self.header_model)  # qt's doc : The view does *not* take ownership

        self.table_view = TableViewSignaledEvents(None)
        self.table_view.setModel(self._table_model)

        self.table_view.setHorizontalHeader(self.headers_view)
        self.table_view.verticalHeader().hide()
        self.table_view.setAlternatingRowColors(True)
        self.table_view.setEditTriggers(QAbstractItemView.NoEditTriggers)

        self.table_view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.table_view.customContextMenuRequested.connect(
            self.popup_context_menu)

        self.copy_action = QAction(_("Copy order parts"), self.table_view)
        self.copy_action.triggered.connect(self.copy_slot)
        self.copy_action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_C))
        self.copy_action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
        self.table_view.addAction(self.copy_action)

        self.select_all_action = QAction(_("Select all"), self.table_view)
        self.select_all_action.triggered.connect(self.select_all_slot)
        self.select_all_action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_A))
        self.select_all_action.setShortcutContext(
            Qt.WidgetWithChildrenShortcut)
        self.table_view.addAction(self.select_all_action)

        # self.table_view.setSelectionBehavior(QAbstractItemView.SelectItems)
        # self.table_view.setSelectionMode(QAbstractItemView.SingleSelection)

        navbar = NavBar(self, [(_("Month before"), self.month_before),
                               (_("Today"), self.month_today),
                               (_("Action"), self.show_actions),
                               (_("Month after"), self.month_after),
                               (_("Find"), find_order_action_slot)])

        self.action_menu = QMenu(navbar.buttons[2])
        navbar.buttons[2].setObjectName("specialMenuButton")
        navbar.buttons[4].setObjectName("specialMenuButton")

        self._make_days_off_menu_and_action_group()

        list_actions = [  # (_("Edit"),self.edit_tars, None, None),
            (_("Edit"), self.edit_timetrack_no_ndx, None, None),
            (_("Month correction"), self.edit_month_correction, None,
             [RoleType.modify_monthly_time_track_correction]),
            (self.days_off_menu, None), (self.copy_action, None),
            (self.select_all_action, None)
        ]

        # (_("Insert holidays"),self.create_holidays, None, None),
        # (_("Delete holidays"),self.delete_holidays, None, None) ]

        populate_menu(self.action_menu, self, list_actions)

        # mainlog.debug("tile widget")
        self.title_box = TitleWidget(_("Presence Overview"), self, navbar)
        self.vlayout = QVBoxLayout(self)
        self.vlayout.setObjectName("Vlayout")
        self.vlayout.addWidget(self.title_box)

        self.hours_per_pers_subframe = SubFrame(_("Overview"), self.table_view,
                                                self)
        self.vlayout.addWidget(self.hours_per_pers_subframe)

        self.time_report_view = TimeReportView(self)

        self.days_off_panel = self._make_total_days_off_panel()
        vbox = QVBoxLayout()
        vbox.addWidget(self.days_off_panel)
        vbox.addStretch()
        vbox.setStretch(0, 0)
        vbox.setStretch(1, 1)

        hlayout = QHBoxLayout()
        hlayout.addWidget(self.time_report_view)
        hlayout.addLayout(vbox)
        hlayout.setStretch(0, 1)
        self.detail_subframe = SubFrame(_("Day"), hlayout, self)

        self.vlayout.addWidget(self.detail_subframe)

        self.setLayout(self.vlayout)

        # dbox = QVBoxLayout()
        # dbox.addWidget(QLabel("kjkljkj"))

        # self.total_active_hours = LabeledValue(_("Total activity"))
        # dbox.addWidget(self.total_active_hours)

        # hbox = QHBoxLayout()
        # hbox.addWidget(self.table_view)
        # hbox.addLayout(dbox)

        # self.selection_model = self.table_view.selectionModel()
        # mainlog.debug(m)
        #sm = QItemSelectionModel(self.table_view.model())
        #sm.setModel(self.table_view.model())
        # self.table_view.setSelectionModel(self.selection_model)

        self.table_view.selectionModel().currentChanged.connect(
            self.cell_entered)

        self.table_view.doubleClickedCell.connect(self.edit_timetrack)
示例#36
0
    def __init__(self, parent, dao):
        super(ReprintDeliverySlipDialog, self).__init__(parent)
        self.dao = dao

        title = _("Print a delivery slip")
        self.setWindowTitle(title)
        top_layout = QVBoxLayout()
        self.title_widget = TitleWidget(title, None)

        self.buttons = QDialogButtonBox()
        self.buttons.addButton(QDialogButtonBox.StandardButton.Cancel)
        self.buttons.addButton(QDialogButtonBox.Ok)

        hlayout = QHBoxLayout()
        hlayout.addWidget(QLabel(_("Slip number")))
        self.slip_number = QLineEdit()
        hlayout.addWidget(self.slip_number)
        hlayout.addStretch()

        self.search_results_view = QTableView()
        self.search_results_model = QStandardItemModel()
        self.search_results_model.setHorizontalHeaderLabels(
            [_("Slip Nr"), _("Date"),
             _("Customer"), _("Order")])

        self.search_results_view.setModel(self.search_results_model)
        # self.search_results_view.setHorizontalHeader(self.headers_view)
        self.search_results_view.setEditTriggers(
            QAbstractItemView.NoEditTriggers)

        self.search_results_view.horizontalHeader().setResizeMode(
            1, QHeaderView.ResizeToContents)
        self.search_results_view.horizontalHeader().setResizeMode(
            2, QHeaderView.Stretch)
        self.search_results_view.verticalHeader().hide()

        self.slip_part_view = DeliverySlipViewWidget(self)

        hlayout_results = QHBoxLayout()
        hlayout_results.addWidget(self.search_results_view)
        hlayout_results.addWidget(self.slip_part_view)

        self.search_results_model.removeRows(
            0, self.search_results_model.rowCount())
        delivery_slips = self.dao.delivery_slip_part_dao.find_recent()
        for slip in delivery_slips:
            self.search_results_model.appendRow([
                QStandardItem(str(slip[0])),
                QStandardItem(date_to_dmy(slip[1])),
                QStandardItem(slip[2]),
                QStandardItem(slip[3])
            ])

        top_layout.addWidget(self.title_widget)
        top_layout.addLayout(hlayout)
        top_layout.addLayout(hlayout_results)
        top_layout.addWidget(self.buttons)
        top_layout.setStretch(2, 100)
        self.setLayout(top_layout)

        self.search_results_view.setSelectionBehavior(
            QAbstractItemView.SelectRows)
        self.search_results_view.setSelectionMode(
            QAbstractItemView.SingleSelection)

        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)
        self.search_results_view.activated.connect(self.row_activated)
        self.search_results_view.selectionModel().currentRowChanged.connect(
            self.row_selected)
class MainWindow(QWidget):
    """Class that contains the main window
    Includes two panels: 
    left panel -> control
    right panel -> plot and summary
    """
    def __init__(self, parent=None):

        QWidget.__init__(self)

        # Create the QVBoxLayout that lays out the whole form
        self.main_panel = QHBoxLayout()
        self.lpanel = QHBoxLayout()
        self.rpanel = QVBoxLayout()
        self.plot_box = QHBoxLayout()
        self.summary_box = QHBoxLayout()

        # Control widget
        self.control = psim_control.ControlLayout()
        self.control.sim_button.clicked.connect(self.button_pressed)

        # Plot Widget
        self.graph = psim_plot.MatplotlibWidget()

        # Summary Widget
        self.summary = psim_summary.SummaryLayout()

        # Adding plot to left panel and control widget to right panel
        self.lpanel.addWidget(self.control)
        self.rpanel.addWidget(self.graph)
        self.rpanel.addWidget(self.summary)

        # Adding lpanel and rpanel widget to the main MainWindow
        self.main_panel.addLayout(self.lpanel)
        self.main_panel.addLayout(self.rpanel)
        # self.main_panel.addStretch(1)
        self.setLayout(self.main_panel)

        self.df = None

    @Slot()
    def button_pressed(self):
        """Actions when sim button is pressed"""
        policy_name = self.control.policy.currentText()

        pam1 = int(self.control.p1.text())
        pam2 = int(self.control.p2.text())
        periods = int(self.control.periods.text())

        product = Product(
            name="Product_A",
            #demand_dist=make_distribution(constant, 192),
            #lead_time_dist=make_distribution(constant, 0),
            demand_dist=make_distribution(np.random.normal, 192, 30),
            lead_time_dist=make_distribution(np.random.triangular, 0, 1, 2),
            initial_inventory=500,
            price=8)

        if policy_name == 'Qs':
            policy = {'method': 'Qs', 'arguments': {'Q': pam1, 's': pam2}}
        elif policy_name == 'Ss':
            policy = {'method': 'Ss', 'arguments': {'S': pam1, 's': pam2}}
        elif policy_name == 'RS':
            policy = {'method': 'RS', 'arguments': {'R': pam1, 'S': pam2}}
        elif policy_name == 'RSs':
            pam3 = int(self.control.p3.text())
            policy = {
                'method': 'RSs',
                'arguments': {
                    'R': pam1,
                    'S': pam2,
                    's': pam3
                }
            }

        self.df = make_data(product, policy, periods)

        # Update summary
        K = 2  # cost of one order
        I = 0.02
        ordering_cost = sum([i > 0 for i in self.df['order']]) * K
        purchasing_cost = (product.initial_inventory +
                           sum(self.df['order'])) * product.price
        holding_cost = sum(self.df['avg_inv']) * (
            (product.price * I) / float(periods))
        shortage_cost = sum(self.df['lost_sales']) * product.price
        total_cost = ordering_cost + purchasing_cost + holding_cost + shortage_cost
        service = 1 - (sum(self.df['lost_sales']) / sum(self.df['demand']))
        print("purchasing_cost: ", purchasing_cost)
        print("ordering cost: ", ordering_cost)
        print("holding_cost: ", holding_cost)
        print("shortage_cost: ", shortage_cost)

        self.summary.inventory_cost.setText("{:,.2f}".format(total_cost))
        self.summary.service_level.setText("{:.2%}".format(service))
        self.graph.Plot(self.df, policy, periods)
        self.graph.draw()
示例#38
0
class LoggingOptions(QGroupBox):
    def __init__(self, parent=None):
        super(LoggingOptions, self).__init__()

        self.setTitle('Logging Options')

        self.layout = QVBoxLayout(self)

        self.chbox_include_timestamps = QCheckBox('Include timestamps')
        self.layout.addWidget(self.chbox_include_timestamps)

        self.chbox_equal_lines = QCheckBox(("Ignore if timestamps and values "
                                            "don't change"))
        self.layout.addWidget(self.chbox_equal_lines)

        self.hbox_bad_quality = QHBoxLayout(self)
        self.label_bad_quality = QLabel(('Value to log if reading '
                                         'quality is bad'), self)
        self.hbox_bad_quality.addWidget(self.label_bad_quality)
        self.le_bad_quality = QLineEdit(self)
        self.le_bad_quality.setText('bad')
        regex = QRegExp('[a-zA-Z0-9]+')
        validator = QRegExpValidator(regex)
        self.le_bad_quality.setValidator(validator)
        self.hbox_bad_quality.addWidget(self.le_bad_quality)
        self.layout.addLayout(self.hbox_bad_quality)

        self.hbox_separator = QHBoxLayout(self)
        self.label_separator = QLabel('CSV separator', self)
        self.hbox_separator.addWidget(self.label_separator)
        self.le_separator = QLineEdit(self)
        self.le_separator.setText(';')
        self.hbox_separator.addWidget(self.le_separator)
        self.layout.addLayout(self.hbox_separator)

        self.chbox_print_exceptions = QCheckBox(('Print exceptions as '
                                                 'comment'))
        self.layout.addWidget(self.chbox_print_exceptions)

        self.hbox_comment_char = QHBoxLayout(self)
        self.label_comment_char = QLabel('Comment escape character', self)
        self.hbox_comment_char.addWidget(self.label_comment_char)
        self.le_comment_char = QLineEdit(self)
        self.le_comment_char.setText("'")
        self.hbox_comment_char.addWidget(self.le_comment_char)
        self.layout.addLayout(self.hbox_comment_char)

        self.setLayout(self.layout)
示例#39
0
class TagSelecion(QGroupBox):
    def __init__(self, parent=None, opc=None):
        super(TagSelecion, self).__init__()

        self.opc = opc

        self.setTitle('Tag Selection')

        self.layout = QVBoxLayout(self)

        self.button_refresh = QPushButton('Refresh', self)
        self.button_refresh.clicked.connect(self._refresh)
        self.layout.addWidget(self.button_refresh)

        self.button_all = QPushButton('Select All', self)
        self.button_all.clicked.connect(self._select_all)
        self.layout.addWidget(self.button_all)

        self.button_none = QPushButton('Select None', self)
        self.button_none.clicked.connect(self._select_none)
        self.layout.addWidget(self.button_none)

        self.hbox_pattern = QHBoxLayout(self)
        self.button_pattern = QPushButton('Toggle Pattern', self)
        self.button_pattern.clicked.connect(self._toggle_pattern)
        self._next_toggle = 'select'
        self.hbox_pattern.addWidget(self.button_pattern)
        self.le_pattern = QLineEdit(self)
        self.le_pattern.setPlaceholderText('Pattern')
        self.hbox_pattern.addWidget(self.le_pattern)
        self.layout.addLayout(self.hbox_pattern)

        self.label = QLabel('Select Tags', self)
        self.layout.addWidget(self.label)

        self.listw_tags = QListWidget(self)
        self.listw_tags.setSelectionMode(QAbstractItemView.MultiSelection)
        self.layout.addWidget(self.listw_tags)

        self.setLayout(self.layout)

    def selected_tags(self):
        return [item.text() for item in self.listw_tags.selectedItems()]

    def _refresh(self):
        self.tags_all = opcda.tags(self.opc)
        self.listw_tags.clear()
        self.listw_tags.addItems(self.tags_all)

    def _select_all(self):
        self.listw_tags.selectAll()

    def _select_none(self):
        self.listw_tags.clearSelection()

    def _toggle_pattern(self):
        toggle = self._next_toggle
        if toggle is 'select':
            self._next_toggle = 'deselect'
        elif toggle is 'deselect':
            self._next_toggle = 'select'
        pattern = self.le_pattern.text().lower()
        if len(pattern) is 0:
            matched_tags = []
        else:
            matched_tags = [
                tag for tag in self.tags_all if pattern in tag.lower()
            ]
        for tag in matched_tags:
            item = self.listw_tags.findItems(tag, Qt.MatchExactly)[0]
            if toggle is 'select':
                item.setSelected(True)
            elif toggle is 'deselect':
                item.setSelected(False)
示例#40
0
文件: waste.py 项目: tinavas/FSERP
 def __init__(self):
     ###
     logger.info('Inside WasteDish')
     self.wastedetail_tab_1 = QWidget()
     self.wastedetail_tab_1.setObjectName("wastedetail_tab_1")
     self.verticalLayout_9 = QVBoxLayout(self.wastedetail_tab_1)
     self.verticalLayout_9.setObjectName("verticalLayout_9")
     self.verticalLayout_8 = QVBoxLayout()
     self.verticalLayout_8.setObjectName("verticalLayout_8")
     self.horizontalLayout_12 = QHBoxLayout()
     self.horizontalLayout_12.setObjectName("horizontalLayout_12")
     self.waste_fromdate_label = QLabel(self.wastedetail_tab_1)
     self.waste_fromdate_label.setObjectName('waste_fromdate_label')
     self.horizontalLayout_12.addWidget(self.waste_fromdate_label)
     self.waste_fromdate_dateedit = QDateEdit(self.wastedetail_tab_1)
     self.waste_fromdate_dateedit.setCalendarPopup(True)
     self.waste_fromdate_dateedit.setObjectName("waste_fromdate_dateedit")
     self.horizontalLayout_12.addWidget(self.waste_fromdate_dateedit)
     self.waste_todate_label = QLabel(self.wastedetail_tab_1)
     self.waste_todate_label.setObjectName('waste_todate_label')
     self.horizontalLayout_12.addWidget(self.waste_todate_label)
     self.waste_todate_dateedit = QDateEdit(self.wastedetail_tab_1)
     self.waste_todate_dateedit.setCalendarPopup(True)
     self.waste_todate_dateedit.setObjectName("waste_todate_dateedit")
     self.waste_todate_dateedit.setMaximumDate(QDate.currentDate())
     self.horizontalLayout_12.addWidget(self.waste_todate_dateedit)
     spacerItem28 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                QSizePolicy.Minimum)
     self.horizontalLayout_12.addItem(spacerItem28)
     self.waste_table_search_button = QPushButton(self.wastedetail_tab_1)
     self.waste_table_search_button.setObjectName(
         "waste_table_search_button")
     self.horizontalLayout_12.addWidget(self.waste_table_search_button)
     self.verticalLayout_8.addLayout(self.horizontalLayout_12)
     self.waste_table = QTableWidget(self.wastedetail_tab_1)
     self.waste_table.setObjectName("waste_table")
     self.waste_table.setColumnCount(5)
     self.waste_table.setRowCount(0)
     item = QTableWidgetItem()
     self.waste_table.setHorizontalHeaderItem(0, item)
     item = QTableWidgetItem()
     self.waste_table.setHorizontalHeaderItem(1, item)
     item = QTableWidgetItem()
     self.waste_table.setHorizontalHeaderItem(2, item)
     item = QTableWidgetItem()
     self.waste_table.setHorizontalHeaderItem(3, item)
     item = QTableWidgetItem()
     self.waste_table.setHorizontalHeaderItem(4, item)
     self.waste_table.horizontalHeader().setCascadingSectionResizes(False)
     self.waste_table.horizontalHeader().setStretchLastSection(True)
     self.waste_table.verticalHeader().setVisible(False)
     self.waste_table.verticalHeader().setCascadingSectionResizes(False)
     self.waste_table.setSortingEnabled(True)
     self.verticalLayout_8.addWidget(self.waste_table)
     self.horizontalLayout_13 = QHBoxLayout()
     self.horizontalLayout_13.setObjectName("horizontalLayout_13")
     self.waste_table_newrow_button = QPushButton(self.wastedetail_tab_1)
     self.waste_table_newrow_button.setObjectName(
         "waste_table_newrow_button")
     self.horizontalLayout_13.addWidget(self.waste_table_newrow_button)
     spacerItem29 = QSpacerItem(612, 20, QSizePolicy.Expanding,
                                QSizePolicy.Minimum)
     self.horizontalLayout_13.addItem(spacerItem29)
     self.waste_table_discard_button = QPushButton(self.wastedetail_tab_1)
     self.waste_table_discard_button.setObjectName(
         "waste_table_discard_button")
     self.horizontalLayout_13.addWidget(self.waste_table_discard_button)
     self.verticalLayout_8.addLayout(self.horizontalLayout_13)
     self.verticalLayout_9.addLayout(self.verticalLayout_8)
     ##retranslate
     self.waste_fromdate_label.setText(
         QApplication.translate("MainWindow", "From Date", None,
                                QApplication.UnicodeUTF8))
     self.waste_fromdate_dateedit.setDisplayFormat(
         QApplication.translate("MainWindow", "dd/MM/yyyy", None,
                                QApplication.UnicodeUTF8))
     self.waste_todate_label.setText(
         QApplication.translate("MainWindow", "To Date", None,
                                QApplication.UnicodeUTF8))
     self.waste_todate_dateedit.setDisplayFormat(
         QApplication.translate("MainWindow", "dd/MM/yyyy", None,
                                QApplication.UnicodeUTF8))
     self.waste_table_search_button.setText(
         QApplication.translate("MainWindow", "Search", None,
                                QApplication.UnicodeUTF8))
     self.waste_table.horizontalHeaderItem(0).setText(
         QApplication.translate("MainWindow", "Code", None,
                                QApplication.UnicodeUTF8))
     self.waste_table.horizontalHeaderItem(1).setText(
         QApplication.translate("MainWindow", "Item", None,
                                QApplication.UnicodeUTF8))
     self.waste_table.horizontalHeaderItem(2).setText(
         QApplication.translate("MainWindow", "Category", None,
                                QApplication.UnicodeUTF8))
     self.waste_table.horizontalHeaderItem(3).setText(
         QApplication.translate("MainWindow", "Quantity", None,
                                QApplication.UnicodeUTF8))
     self.waste_table.horizontalHeaderItem(4).setText(
         QApplication.translate("MainWindow", "Reason", None,
                                QApplication.UnicodeUTF8))
     self.waste_table_newrow_button.setText(
         QApplication.translate("MainWindow", "New Row", None,
                                QApplication.UnicodeUTF8))
     self.waste_table_discard_button.setText(
         QApplication.translate("MainWindow", "Discard Item", None,
                                QApplication.UnicodeUTF8))
     self.wastedetail_tab_1.setTabOrder(self.waste_fromdate_dateedit,
                                        self.waste_todate_dateedit)
     self.wastedetail_tab_1.setTabOrder(self.waste_todate_dateedit,
                                        self.waste_table_search_button)
     ###signals and slots && other stuffs
     # self.mainwindow = Ui_MainWindow  # just for the ease of finding the attributes in pycharm
     self.schedule = SchedulePurchase()
     self.suplier = BusinessParty(category='Supplier')
     self.add = AddStockInventory()
     self.item = WasteMenu()
     self.waste_fromdate_dateedit.setDate(QDate.currentDate())
     self.waste_todate_dateedit.setDate(QDate.currentDate())
     self.waste_table.setEditTriggers(QAbstractItemView.NoEditTriggers)
     self.waste_table_newrow_button.clicked.connect(self.add_new_blank_rows)
     self.waste_table_discard_button.clicked.connect(self.discard)
     self.waste_table_search_button.clicked.connect(self.search_discard)
     self.wastedetail_tab_1.setFocusPolicy(Qt.StrongFocus)
     self.wastedetail_tab_1.focusInEvent = self.load_rows
示例#41
0
文件: waste.py 项目: tinavas/FSERP
class WasteItems():
    """Item waste management tab"""
    global logger

    def __init__(self):
        ###
        logger.info('Inside WasteItems')
        self.wastedetail_tab_1 = QWidget()
        self.wastedetail_tab_1.setObjectName("wastedetail_tab_1")
        self.verticalLayout_9 = QVBoxLayout(self.wastedetail_tab_1)
        self.verticalLayout_9.setObjectName("verticalLayout_9")
        self.verticalLayout_8 = QVBoxLayout()
        self.verticalLayout_8.setObjectName("verticalLayout_8")
        self.horizontalLayout_12 = QHBoxLayout()
        self.horizontalLayout_12.setObjectName("horizontalLayout_12")
        self.waste_fromdate_label = QLabel(self.wastedetail_tab_1)
        self.waste_fromdate_label.setObjectName('waste_fromdate_label')
        self.horizontalLayout_12.addWidget(self.waste_fromdate_label)
        self.waste_fromdate_dateedit = QDateEdit(self.wastedetail_tab_1)
        self.waste_fromdate_dateedit.setCalendarPopup(True)
        self.waste_fromdate_dateedit.setObjectName("waste_fromdate_dateedit")
        self.horizontalLayout_12.addWidget(self.waste_fromdate_dateedit)
        self.waste_todate_label = QLabel(self.wastedetail_tab_1)
        self.waste_todate_label.setObjectName('waste_todate_label')
        self.horizontalLayout_12.addWidget(self.waste_todate_label)
        self.waste_todate_dateedit = QDateEdit(self.wastedetail_tab_1)
        self.waste_todate_dateedit.setCalendarPopup(True)
        self.waste_todate_dateedit.setObjectName("waste_todate_dateedit")
        self.waste_todate_dateedit.setMaximumDate(QDate.currentDate())
        self.horizontalLayout_12.addWidget(self.waste_todate_dateedit)
        spacerItem28 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum)
        self.horizontalLayout_12.addItem(spacerItem28)
        self.waste_table_search_button = QPushButton(self.wastedetail_tab_1)
        self.waste_table_search_button.setObjectName(
            "waste_table_search_button")
        self.horizontalLayout_12.addWidget(self.waste_table_search_button)
        self.verticalLayout_8.addLayout(self.horizontalLayout_12)
        self.waste_table = QTableWidget(self.wastedetail_tab_1)
        self.waste_table.setObjectName("waste_table")
        self.waste_table.setColumnCount(6)
        self.waste_table.setRowCount(0)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(0, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(1, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(2, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(3, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(4, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(5, item)
        self.waste_table.horizontalHeader().setCascadingSectionResizes(False)
        self.waste_table.horizontalHeader().setStretchLastSection(True)
        self.waste_table.verticalHeader().setVisible(False)
        self.waste_table.verticalHeader().setCascadingSectionResizes(False)
        self.waste_table.setSortingEnabled(True)
        self.verticalLayout_8.addWidget(self.waste_table)
        self.verticalLayout_9.addLayout(self.verticalLayout_8)
        ##retranslate
        self.waste_fromdate_label.setText(
            QApplication.translate("MainWindow", "From Date", None,
                                   QApplication.UnicodeUTF8))
        self.waste_fromdate_dateedit.setDisplayFormat(
            QApplication.translate("MainWindow", "dd/MM/yyyy", None,
                                   QApplication.UnicodeUTF8))
        self.waste_todate_label.setText(
            QApplication.translate("MainWindow", "To Date", None,
                                   QApplication.UnicodeUTF8))
        self.waste_todate_dateedit.setDisplayFormat(
            QApplication.translate("MainWindow", "dd/MM/yyyy", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table_search_button.setText(
            QApplication.translate("MainWindow", "Search", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(0).setText(
            QApplication.translate("MainWindow", "Code", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(1).setText(
            QApplication.translate("MainWindow", "Item", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(2).setText(
            QApplication.translate("MainWindow", "Category", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(3).setText(
            QApplication.translate("MainWindow", "Units", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(4).setText(
            QApplication.translate("MainWindow", "Quantity", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(5).setText(
            QApplication.translate("MainWindow", "Reason", None,
                                   QApplication.UnicodeUTF8))

        ###signals and slots && other stuffs
        # self.mainwindow = Ui_MainWindow  # just for the ease of finding the attributes in pycharm
        self.item = WasteIngredients()
        self.waste_fromdate_dateedit.setDate(QDate.currentDate())
        self.waste_todate_dateedit.setDate(QDate.currentDate())
        self.waste_table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.waste_table_search_button.clicked.connect(self.search_discard)
        self.wastedetail_tab_1.setFocusPolicy(Qt.StrongFocus)
        self.wastedetail_tab_1.focusInEvent = self.load_rows

    def load_rows(self, event=None):
        """calling add row to restructure the table every time container resizes"""
        self.add_row_to_table()

    def search_discard(self):
        """
        searches the discard from_date and to_date
        :return:none
        """
        f_date = self.waste_fromdate_dateedit.text()
        from_date = datetime.strptime(f_date, '%d/%m/%Y')
        t_date = self.waste_todate_dateedit.text()
        to_date = datetime.strptime(t_date, '%d/%m/%Y')
        to_date = to_date + timedelta(hours=23, minutes=59, seconds=59)
        dataobj = self.item.find_itemdiscard(from_date=from_date,
                                             to_date=to_date)
        self.add_row_to_table(*dataobj)

    def add_row_to_table(self, *args):
        """
        complex stuff of auto complete to be added to each combo box
        :return:
        """
        table = self.waste_table
        if args:
            table.clearContents()
            table.setRowCount(0)
            table.setRowCount(len(args))
            for i, j in enumerate(args):
                code = QTableWidgetItem(j['code'])
                table.setItem(i, 0, code)
                item = QTableWidgetItem(j['item'])
                table.setItem(i, 1, item)
                category = QTableWidgetItem(j['category'])
                table.setItem(i, 2, category)
                unit = QTableWidgetItem(str(j['units']))
                table.setItem(i, 3, unit)
                quantity = QTableWidgetItem(str(j['quantity']))
                table.setItem(i, 4, quantity)
                reason = QTableWidgetItem(j['reason_for_discard'])
                table.setItem(i, 5, reason)
        table.setColumnWidth(0, (table.width() / 6))
        table.setColumnWidth(1, (table.width() / 6))
        table.setColumnWidth(2, (table.width() / 6))
        table.setColumnWidth(3, (table.width() / 6))
        table.setColumnWidth(4, (table.width() / 6))
        table.horizontalHeader().setStretchLastSection(True)
示例#42
0
class RadioApp(QWidget):
    def __init__(self):
        super().__init__()
        self.edit = False

        self.left_dock_create()
        self.middle_dock_create()
        self.right_dock_create()
        self.slotans_create()

        self.box = QHBoxLayout()
        self.box.addLayout(self.volbalayout)
        self.box.addLayout(self.middlelayout)
        self.box.addLayout(self.rightlayout)

        self.mainlayout = QVBoxLayout()
        self.mainlayout.addLayout(self.box)
        self.setLayout(self.mainlayout)

    def left_dock_create(self):
        self.statlabel = QLabel("RSSI: --")
        self.logolabel = QLabel()
        self.logolabel.setPixmap(
            QPixmap(os.path.join(script_path, "../assets/logo.png")))
        self.statlabel.setFont(QFont("DejaVu Sans", 12))

        self.btnvolba = []
        for i in range(1, 5):
            self.btnvolba.append(QPushButton("Voľba {}".format(i)))

        self.presetaddbtn = QPushButton()
        self.presetaddbtn.setIcon(QIcon(QPixmap("../assets/add.png")))

        self.volbalayout = QVBoxLayout()
        self.volbalayout.addWidget(self.logolabel)
        self.volbalayout.addWidget(self.statlabel)
        for btn in self.btnvolba:
            self.volbalayout.addWidget(btn)
        self.volbalayout.addWidget(self.presetaddbtn)

    def middle_dock_create(self):
        self.frekv = QLabel()
        self.frekv.setFont(QFont("DejaVu Sans", 26))
        self.write_frekv()

        self.btnstepleft = QPushButton("<")
        self.btnseekdown = QPushButton("<<")
        self.btnseekup = QPushButton(">>")
        self.btnstepright = QPushButton(">")

        self.laybtnmv = QHBoxLayout()
        self.laybtnmv.addWidget(self.btnseekdown)
        self.laybtnmv.addWidget(self.btnstepleft)
        self.laybtnmv.addWidget(self.btnstepright)
        self.laybtnmv.addWidget(self.btnseekup)

        self.labelrdsdt = QLabel("RDS")
        self.labelrdsdt.setFont(QFont("DejaVu Sans", 12))

        self.frekvlayout = QHBoxLayout()
        self.frekvlayout.addWidget(self.frekv)
        self.frekvlayout.setAlignment(Qt.AlignCenter)

        self.middlelayout = QVBoxLayout()
        self.middlelayout.addLayout(self.frekvlayout)
        self.middlelayout.addLayout(self.laybtnmv)
        self.middlelayout.addWidget(self.labelrdsdt)

    def right_dock_create(self):
        self.btnonoff = QPushButton("Reset")
        self.slidvol = QSlider(Qt.Vertical)
        self.slidvol.setMinimum(0)
        self.slidvol.setMaximum(100)
        self.slidvol.setValue(50)
        self.labspeaker = QLabel()
        self.labspeaker.setPixmap(
            QPixmap(os.path.join(script_path, "../assets/speaker.png")))
        self.sndvolumelabel = QLabel()

        self.rightlayout = QVBoxLayout()
        self.rightlayout.addWidget(self.btnonoff)
        self.rightlayout.addWidget(self.slidvol)
        self.rightlayout.addWidget(self.sndvolumelabel)
        self.rightlayout.addWidget(self.labspeaker)

    def slotans_create(self):
        self.slidvol.valueChanged.connect(self.set_radiovolume)
        self.btnstepleft.clicked.connect(lambda: self.step_frekv("d"))
        self.btnstepright.clicked.connect(lambda: self.step_frekv("u"))
        self.btnseekdown.clicked.connect(lambda: self.set_seek("d"))
        self.btnseekup.clicked.connect(lambda: self.set_seek("u"))

        self.presetaddbtn.clicked.connect(self.preset_editmode)
        self.btnonoff.clicked.connect(self.reset_radio)
        for btn in self.btnvolba:
            btn.clicked.connect(self.preset_choose)
        self.timerrssi = QTimer()
        self.timerrssi.timeout.connect(self.write_stats)
        self.timerrssi.start(3000)  # ms

    def reset_radio(self):
        dev_radio.shutdown()
        dev_radio.poweron()

    def preset_editmode(self):
        if self.edit == True:
            # Chceme sa vrátiť do normálneho režimu -> zvrátime editačný
            for btn in self.btnvolba:
                btn.setStyleSheet("")
                btn.clicked.disconnect()
                btn.clicked.connect(self.preset_choose)
        else:
            # Vstupujeme do editačného režimu
            for btn in self.btnvolba:
                btn.setStyleSheet("background-color: #30f030;")
                btn.clicked.disconnect()
                btn.clicked.connect(self.preset_set)
        self.edit = not self.edit

    def preset_set(self):
        button = self.sender()
        if isinstance(button, QPushButton):
            button.setText("{:.2f}".format(dev_radio.getfrequency() / 100))
            self.preset_editmode()

    def preset_choose(self):
        button = self.sender()
        if isinstance(button, QPushButton):
            try:
                frekv = int(float(button.text()) * 100)
            except ValueError:
                return
            dev_radio.setfrequency(frekv)
            self.write_frekv()

    def preset_save(self):
        with open("preset.txt", mode="w") as fw:
            for btn in self.btnvolba:
                try:
                    fw.write("{},".format(int(float(btn.text()) * 100)))
                except ValueError:
                    fw.write(" ,")

    def preset_restore(self):
        try:
            fr = open("preset.txt", mode="r")
            pres_list = fr.read().split(",")
        except FileNotFoundError:
            return

        fr.close()
        if len(pres_list) - 1 < len(self.btnvolba):
            print("Chyba: Zoznam predvolieb je krátky")
            return

        for i, btn in enumerate(self.btnvolba):
            try:
                btn.setText("{:.2f}".format(int(pres_list[i]) / 100))
            except ValueError:
                continue

    def set_seek(self, direction):
        if direction == "u":
            dev_radio.seekup()
        elif direction == "d":
            dev_radio.seekdown()
        self.write_frekv()

    def step_frekv(self, direction):
        curr_frekv = dev_radio.getfrequency()
        if direction == "u":
            curr_frekv += 10
            if curr_frekv > dev_radio.freqhigh:
                curr_frekv = dev_radio.freqlow
        elif direction == "d":
            curr_frekv -= 10
            if curr_frekv < dev_radio.freqlow:
                curr_frekv = dev_radio.freqhigh
        dev_radio.setfrequency(curr_frekv)
        self.write_frekv()

    def write_frekv(self):
        self.frekv.setText("<b>{:.2f} MHz</b>".format(
            dev_radio.getfrequency() / 100))

    def write_stats(self):
        self.statlabel.setText("<b>RSSI: {}</b>".format(dev_radio.getrssi()))

    def set_radiovolume(self):
        vol_percent = self.slidvol.value()
        self.sndvolumelabel.setText("{}%".format(vol_percent))
        new_volume = int(map_range(vol_percent, 0, 100, 0, 15))
        dev_radio.setvolume(new_volume)

    def rds_psshow(self, station):
        print("Stanica: {}".format(station))

    def rds_txtshow(self, text):
        print("Text: {}".format(text))

    def rds_tmshow(self, hodiny, minuty):
        print("{}:{}".format(hodiny, minuty))
示例#43
0
    def _make_total_days_off_panel(self):

        widget = QFrame()
        widget.setObjectName('HorseRegularFrame')

        widget.setFrameShape(QFrame.Panel)
        widget.setFrameShadow(QFrame.Sunken)
        layout = QVBoxLayout()

        #layout.addWidget(QLabel(_("Days off to date")))
        self.day_off_total_duration_labels = dict()
        self.day_off_month_duration_labels = dict()
        self.day_off_labels = dict()

        self._day_off_table_model = QStandardItemModel(10, 3)
        self._day_off_table_model.setHorizontalHeaderLabels(
            [None, None, _("This\nmonth"),
             _("Before")])
        self.day_off_table_view = QTableView(None)
        self.day_off_table_view.setModel(self._day_off_table_model)

        # self.day_off_table_view.setHorizontalHeader(self.headers_view)
        self.day_off_table_view.verticalHeader().hide()
        self.day_off_table_view.setAlternatingRowColors(True)
        self.day_off_table_view.setEditTriggers(
            QAbstractItemView.NoEditTriggers)

        self.day_off_table_view.hide()

        row = 0
        for det in DayEventType.symbols():
            ndx = self._day_off_table_model.index(row, 0)
            self._day_off_table_model.setData(ndx, det.description,
                                              Qt.DisplayRole)

            ndx = self._day_off_table_model.index(row, 1)
            fg, bg = self.DAY_EVENT_PALETTE[det]
            self._day_off_table_model.setData(ndx, QBrush(bg),
                                              Qt.BackgroundRole)
            self._day_off_table_model.setData(ndx, QBrush(fg),
                                              Qt.TextColorRole)
            self._day_off_table_model.setData(ndx,
                                              DayEventType.short_code(det),
                                              Qt.DisplayRole)

            row += 1

        layout.addWidget(self.day_off_table_view)

        grid = QGridLayout()
        self.days_off_layout = grid
        grid.setColumnStretch(3, 1)
        row = 0

        grid.addWidget(QLabel(_('Year')), row, self.YEAR_EVENT_COLUMN)
        grid.addWidget(QLabel(_('Month')), row, self.MONTH_EVENT_COLUMN)
        row += 1

        for det in DayEventType.symbols():
            self.day_off_total_duration_labels[det] = QLabel("-")
            self.day_off_month_duration_labels[det] = QLabel("-")
            self.day_off_labels[det] = QLabel(det.description)

            hlayout = QHBoxLayout()

            sl = QLabel()
            fg, bg = self.DAY_EVENT_PALETTE[det]

            def to_html_rgb(color):
                i = color.red() * 256 * 256 + color.green() * 256 + color.blue(
                )
                return "#{:06X}".format(i)

            p = QPalette()
            p.setColor(QPalette.Window, QColor(bg))
            p.setColor(QPalette.WindowText, QColor(fg))
            sl.setPalette(p)
            sl.setAlignment(Qt.AlignCenter)
            sl.setStyleSheet("border: 2px solid black; background: {}".format(
                to_html_rgb(QColor(bg))))

            t = DayEventType.short_code(det)
            mainlog.debug(t)
            sl.setAutoFillBackground(True)
            sl.setText(t)

            grid.addWidget(sl, row, 0)
            grid.addWidget(self.day_off_labels[det], row, 1)
            grid.addWidget(self.day_off_total_duration_labels[det], row,
                           self.YEAR_EVENT_COLUMN)
            grid.addWidget(self.day_off_month_duration_labels[det], row,
                           self.MONTH_EVENT_COLUMN)

            hlayout.addStretch()

            row += 1

        layout.addLayout(grid)
        layout.addStretch()

        self.day_off_table_view.resizeColumnsToContents()
        # self.day_off_table_view.setMinimumWidth( self.day_off_table_view.width())
        # self.day_off_table_view.resize( self.day_off_table_view.minimumWidth(),
        #                                 self.day_off_table_view.minimumHeight(),)

        widget.setLayout(layout)
        return widget
示例#44
0
    def create_directory_choose(self):
        group_box = QtGui.QGroupBox('An awesome web project called:')

        title_hbox = QHBoxLayout()
        title_hbox.setContentsMargins(10, 10, 10, 10)

        win_icon = self.create_icon_box('window_icon', 'Window Icon')
        exe_icon = self.create_icon_box('exe_icon', 'Exe Icon')
        mac_icon = self.create_icon_box('mac_icon', 'Mac Icon')

        self.title_label = QtGui.QLabel('TBD')
        self.title_label.setStyleSheet('font-size:20px; font-weight:bold;')
        title_hbox.addWidget(self.title_label)
        title_hbox.addWidget(QtGui.QLabel())
        title_hbox.addWidget(win_icon)
        title_hbox.addWidget(exe_icon)
        title_hbox.addWidget(mac_icon)

        vlayout = QtGui.QVBoxLayout()

        vlayout.setSpacing(5)
        vlayout.setContentsMargins(10, 5, 10, 5)

        vlayout.addLayout(title_hbox)
        #vlayout.addLayout(input_layout)
        #vlayout.addLayout(output_layout)

        group_box.setLayout(vlayout)

        return group_box
示例#45
0
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(560, 560)
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(1)
        sizePolicy.setVerticalStretch(1)
        sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth())
        Form.setSizePolicy(sizePolicy)
        Form.setMinimumSize(QtCore.QSize(0, 0))
        self.gridLayout_2 = QGridLayout(Form)
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.editorGroupBox = QGroupBox(Form)
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(1)
        sizePolicy.setVerticalStretch(1)
        sizePolicy.setHeightForWidth(
            self.editorGroupBox.sizePolicy().hasHeightForWidth())
        self.editorGroupBox.setSizePolicy(sizePolicy)
        self.editorGroupBox.setMinimumSize(QtCore.QSize(0, 0))
        self.editorGroupBox.setObjectName("editorGroupBox")
        self.gridLayout_3 = QGridLayout(self.editorGroupBox)
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.gridLayout = QGridLayout()
        self.gridLayout.setObjectName("gridLayout")
        self.variable_verticalLayout_1 = QVBoxLayout()
        self.variable_verticalLayout_1.setObjectName(
            "variable_verticalLayout_1")
        self.listBox = QListWidget(self.editorGroupBox)
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(1)
        sizePolicy.setVerticalStretch(1)
        sizePolicy.setHeightForWidth(
            self.listBox.sizePolicy().hasHeightForWidth())
        self.listBox.setSizePolicy(sizePolicy)
        self.listBox.setDragEnabled(True)
        self.listBox.setDragDropOverwriteMode(False)
        self.listBox.setDragDropMode(QAbstractItemView.InternalMove)
        self.listBox.setDefaultDropAction(QtCore.Qt.MoveAction)
        self.listBox.setAlternatingRowColors(True)
        self.listBox.setSelectionMode(QAbstractItemView.SingleSelection)
        self.listBox.setMovement(QListView.Snap)
        self.listBox.setResizeMode(QListView.Fixed)
        self.listBox.setSelectionRectVisible(False)
        self.listBox.setObjectName("listBox")
        self.variable_verticalLayout_1.addWidget(self.listBox)
        self.gridLayout.addLayout(self.variable_verticalLayout_1, 0, 0, 1, 1)
        self.variable_verticalLayout_2 = QVBoxLayout()
        self.variable_verticalLayout_2.setObjectName(
            "variable_verticalLayout_2")
        self.addButton = QPushButton(self.editorGroupBox)
        self.addButton.setObjectName("addButton")
        self.variable_verticalLayout_2.addWidget(self.addButton)
        self.editButton = QPushButton(self.editorGroupBox)
        self.editButton.setObjectName("editButton")
        self.variable_verticalLayout_2.addWidget(self.editButton)
        self.removeButton = QPushButton(self.editorGroupBox)
        self.removeButton.setObjectName("removeButton")
        self.variable_verticalLayout_2.addWidget(self.removeButton)
        spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum,
                                 QSizePolicy.Expanding)
        self.variable_verticalLayout_2.addItem(spacerItem)
        self.upButton = QPushButton(self.editorGroupBox)
        self.upButton.setObjectName("upButton")
        self.variable_verticalLayout_2.addWidget(self.upButton)
        self.downButton = QPushButton(self.editorGroupBox)
        self.downButton.setObjectName("downButton")
        self.variable_verticalLayout_2.addWidget(self.downButton)
        spacerItem1 = QSpacerItem(20, 40, QSizePolicy.Minimum,
                                  QSizePolicy.Expanding)
        self.variable_verticalLayout_2.addItem(spacerItem1)
        self.variable_verticalLayout_2.setStretch(3, 1)
        self.variable_verticalLayout_2.setStretch(6, 1)
        self.gridLayout.addLayout(self.variable_verticalLayout_2, 0, 1, 1, 1)
        self.gridLayout.setColumnStretch(0, 1)
        self.gridLayout_3.addLayout(self.gridLayout, 0, 0, 1, 1)
        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setContentsMargins(15, 15, 15, 15)
        self.horizontalLayout.setObjectName("horizontalLayout")
        spacerItem2 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                  QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem2)
        self.ok_pushButton = QPushButton(self.editorGroupBox)
        self.ok_pushButton.setObjectName("ok_pushButton")
        self.horizontalLayout.addWidget(self.ok_pushButton)
        self.cancel_pushButton = QPushButton(self.editorGroupBox)
        self.cancel_pushButton.setObjectName("cancel_pushButton")
        self.horizontalLayout.addWidget(self.cancel_pushButton)
        self.horizontalLayout.setStretch(0, 1)
        self.gridLayout_3.addLayout(self.horizontalLayout, 1, 0, 1, 1)
        self.gridLayout_2.addWidget(self.editorGroupBox, 0, 0, 1, 1)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)
示例#46
0
class MainWindow(QWidget):

    def __init__(self):
        super(MainWindow, self).__init__()
        self.setWindowTitle("Cobaya input generator for Cosmology")
        self.setGeometry(0, 0, 1500, 1000)
        self.move(
            QApplication.desktop().screenGeometry().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)
        titles = odict([
            ["Presets", odict([["preset", "Presets"]])],
            ["Cosmological Model", odict([
                ["theory", "Theory code"],
                ["primordial", "Primordial perturbations"],
                ["geometry", "Geometry"],
                ["hubble", "Hubble parameter constraint"],
                ["matter", "Matter sector"],
                ["neutrinos", "Neutrinos and other extra matter"],
                ["dark_energy", "Lambda / Dark energy"],
                ["bbn", "BBN"],
                ["reionization", "Reionization history"]])],
            ["Data sets", odict([
                ["like_cmb", "CMB experiments"],
                ["like_bao", "BAO experiments"],
                ["like_sn", "SN experiments"],
                ["like_H0", "Local H0 measurements"]])],
            ["Sampler", odict([["sampler", "Samplers"]])]])
        self.combos = odict()
        for group, fields in titles.items():
            group_box = QGroupBox(group)
            self.layout_options.addWidget(group_box)
            group_layout = QVBoxLayout(group_box)
            for a, desc in fields.items():
                self.combos[a] = QComboBox()
                if len(fields) > 1:
                    label = QLabel(desc)
                    group_layout.addWidget(label)
                group_layout.addWidget(self.combos[a])
                self.combos[a].addItems(
                    [text(k, v) for k, v in getattr(input_database, a).items()])
        # PLANCK NAMES CHECKBOX TEMPORARILY DISABLED
        #                if a == "theory":
        #                    # Add Planck-naming checkbox
        #                    self.planck_names = QCheckBox(
        #                        "Keep common parameter names "
        #                        "(useful for fast CLASS/CAMB switching)")
        #                    group_layout.addWidget(self.planck_names)
        # Connect to refreshers -- needs to be after adding all elements
        for field, combo in self.combos.items():
            if field == "preset":
                combo.currentIndexChanged.connect(self.refresh_preset)
            else:
                combo.currentIndexChanged.connect(self.refresh)
        #        self.planck_names.stateChanged.connect(self.refresh_keep_preset)
        # RIGHT: Output + buttons
        self.display_tabs = QTabWidget()
        self.display = {}
        for k in ["yaml", "python", "citations"]:
            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 create_input(self):
        return create_input(
            get_comments=True,
            #           planck_names=self.planck_names.isChecked(),
            **{field: list(getattr(input_database, field).keys())[combo.currentIndex()]
               for field, combo in self.combos.items() if field is not "preset"})

    @Slot()
    def refresh_keep_preset(self):
        self.refresh_display(self.create_input())

    @Slot()
    def refresh(self):
        self.combos["preset"].blockSignals(True)
        self.combos["preset"].setCurrentIndex(0)
        self.combos["preset"].blockSignals(False)
        self.refresh_display(self.create_input())

    @Slot()
    def refresh_preset(self):
        preset = list(getattr(input_database, "preset").keys())[
            self.combos["preset"].currentIndex()]
        info = create_input(
            get_comments=True,
            #            planck_names=self.planck_names.isChecked(),
            preset=preset)
        self.refresh_display(info)
        # Update combo boxes to reflect the preset values, without triggering update
        for k, v in input_database.preset[preset].items():
            if k in [input_database._desc]:
                continue
            self.combos[k].blockSignals(True)
            self.combos[k].setCurrentIndex(
                self.combos[k].findText(
                    text(v, getattr(input_database, k).get(v))))
            self.combos[k].blockSignals(False)

    def refresh_display(self, info):
        try:
            comments = info.pop(input_database._comment, None)
            comments_text = "\n# " + "\n# ".join(comments)
        except (TypeError,  # No comments
                AttributeError):  # Failed to generate info (returned str instead)
            comments_text = ""
        self.display["python"].setText(
            "from collections import OrderedDict\n\ninfo = " +
            pformat(info) + comments_text)
        self.display["yaml"].setText(yaml_dump(info) + comments_text)
        self.display["citations"].setText(prettyprint_citation(citation(info)))

    @Slot()
    def save_file(self):
        ftype = next(k for k, w in self.display.items()
                     if w is self.display_tabs.currentWidget())
        ffilter = {"yaml": "Yaml files (*.yaml *.yml)", "python": "(*.py)",
                   "citations": "(*.txt)"}[ftype]
        fsuffix = {"yaml": ".yaml", "python": ".py", "citations": ".txt"}[ftype]
        fname, path = self.save_dialog.getSaveFileName(
            self.save_dialog, "Save input file", fsuffix, ffilter, os.getcwd())
        if not fname.endswith(fsuffix):
            fname += fsuffix
        with open(fname, "w+") as f:
            f.write(self.display_tabs.currentWidget().toPlainText())

    @Slot()
    def copy_clipb(self):
        self.clipboard.setText(self.display_tabs.currentWidget().toPlainText())
示例#47
0
    def __init__(self, *args, **kwargs):
        QWidget.__init__(self, *args, **kwargs)

        mainLayout = QHBoxLayout(self)
        mainLayout.setContentsMargins(0, 0, 0, 0)
        label = QLabel("Aim Direction  : ")
        lineEdit1 = QLineEdit()
        lineEdit2 = QLineEdit()
        lineEdit3 = QLineEdit()
        verticalSeparator = Widget_verticalSeparator()
        checkBox = QCheckBox("Set Auto")
        mainLayout.addWidget(label)
        mainLayout.addWidget(lineEdit1)
        mainLayout.addWidget(lineEdit2)
        mainLayout.addWidget(lineEdit3)
        mainLayout.addWidget(verticalSeparator)
        mainLayout.addWidget(checkBox)

        validator = QDoubleValidator(-10000.0, 10000.0, 2)
        lineEdit1.setValidator(validator)
        lineEdit2.setValidator(validator)
        lineEdit3.setValidator(validator)
        lineEdit1.setText("0.0")
        lineEdit2.setText("1.0")
        lineEdit3.setText("0.0")
        checkBox.setChecked(True)
        self.label = label
        self.lineEdit1 = lineEdit1
        self.lineEdit2 = lineEdit2
        self.lineEdit3 = lineEdit3
        self.checkBox = checkBox
        self.setVectorEnabled()

        QtCore.QObject.connect(checkBox, QtCore.SIGNAL('clicked()'),
                               self.setVectorEnabled)
    def __init__(self, parent):
        super(TipOfTheDayDialog, self).__init__(parent)
        """Default class constructor."""

        ## qDebug("TipOfTheDayDialog constructor")

        self.mainWin = parent

        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWizardStyle(QWizard.ModernStyle)
        self.setMinimumSize(550, 400)

        ## self.setOption(QWizard.HaveHelpButton, True)

        page = QWizardPage(self)

        self.imgBanner = ImageWidget(self.mainWin.gImgDir,
                                     self.mainWin.gIconDir, self)

        # Read in the tips.txt file.
        # fileOpen = open(self.mainWin.gAppDir + os.sep + 'tips.txt')
        # tips = fileOpen.read()
        # fileOpen.close()
        # self.tipsList = [tip for tip in tips.split('\n') if tip] # remove the blank lines also.

        self.tipsList = [tip for tip in TIPS_TXT.split('\n')
                         if tip]  # remove the blank lines also.

        # Make sure we don't cause an IndexError.
        # DEV-We might be adding tips to the txt at runtime. The easy way to add and check tips.
        if int(self.mainWin.settings_general_current_tip) >= len(
                self.tipsList):
            self.mainWin.settings_general_current_tip = 0

        self.labelTipOfTheDay = QLabel(self)
        self.labelTipOfTheDay.setText(self.tipsList[int(
            self.mainWin.settings_general_current_tip)])
        self.labelTipOfTheDay.setWordWrap(True)

        # Forget about a standardish QCheckBox, real powerusers keep the lights on!
        self.lightswitch = LightSwitchWidget(self.mainWin.gImgDir,
                                             self.mainWin, self)

        self.showOnStartupLabel = QLabel(self)
        self.showOnStartupLabel.setText(self.tr('Show tips on startup'))

        layout = QVBoxLayout(self)
        hblayout = QHBoxLayout()
        hblayout2 = QHBoxLayout()
        hblayout.addStretch(1)
        hblayout.addWidget(self.imgBanner)
        hblayout.addStretch(1)
        layout.addLayout(hblayout)
        layout.addStrut(1)
        layout.addSpacerItem(QSpacerItem(0, 5))
        layout.addWidget(self.labelTipOfTheDay)
        layout.addStretch(1)
        hblayout2.addWidget(self.lightswitch)
        hblayout2.addWidget(self.showOnStartupLabel)
        hblayout2.addStretch(1)
        self.showOnStartupLabel.setAlignment(Qt.AlignBottom)

        layout.addLayout(hblayout2)
        page.setLayout(layout)
        self.addPage(page)

        self.setWindowTitle(self.tr('Tip of the Day'))

        buttonPrevious = QPushButton(self)
        buttonPrevious.setText(self.tr('&Previous'))
        buttonPrevious.setIcon(
            QIcon(self.mainWin.gIconDir + os.sep + 'undo.png'))
        buttonPrevious.setIconSize(QSize(24, 24))
        buttonNext = QPushButton(self)
        buttonNext.setText(self.tr('&Next'))
        buttonNext.setIcon(QIcon(self.mainWin.gIconDir + os.sep + 'redo.png'))
        buttonNext.setIconSize(QSize(24, 24))
        buttonClose = QPushButton(self)
        buttonClose.setText(self.tr('&Close'))
        buttonClose.setIcon(
            QIcon(self.mainWin.gIconDir + os.sep + 'windowclose.png'))
        buttonClose.setIconSize(QSize(24, 24))

        self.setButton(QWizard.CustomButton1, buttonPrevious)
        self.setButton(QWizard.CustomButton2, buttonNext)
        self.setButton(QWizard.CustomButton3, buttonClose)
        self.setOption(QWizard.HaveCustomButton1, True)
        self.setOption(QWizard.HaveCustomButton2, True)
        self.setOption(QWizard.HaveCustomButton3, True)
        self.customButtonClicked.connect(self.buttonTipOfTheDayClicked)

        listTipOfTheDayButtons = [
            QWizard.Stretch, QWizard.CustomButton1, QWizard.CustomButton2,
            QWizard.CustomButton3
        ]
        self.setButtonLayout(listTipOfTheDayButtons)

        self.DoSetWhatsThis()
    def __init__(self, parent=None):
        super(QtReducePreferencePane, self).__init__(parent)

        self.__createContents()

        self.toolBar = QtReducePreferencesToolBar(self)
        self.worksheet = QtReducePreferencesWorksheet(self)
        self.computation = QtReducePreferencesComputation(self)

        self.pagesWidget = QStackedWidget()
        self.pagesWidget.addWidget(self.toolBar)
        self.pagesWidget.addWidget(self.worksheet)
        self.pagesWidget.addWidget(self.computation)

        self.pagesWidget.setCurrentIndex(
            self.contentsWidget.row(self.contentsWidget.currentItem()))

        closeButton = QPushButton(self.tr("Close"))
        closeButton.clicked.connect(self.close)

        horizontalLayout = QHBoxLayout()
        horizontalLayout.addWidget(self.contentsWidget)
        horizontalLayout.addWidget(self.pagesWidget)

        buttonsLayout = QHBoxLayout()
        buttonsLayout.addStretch(1)
        buttonsLayout.addWidget(closeButton)

        mainLayout = QVBoxLayout()
        mainLayout.addLayout(horizontalLayout)
        mainLayout.addLayout(buttonsLayout)

        self.setLayout(mainLayout)

        self.setWindowTitle(self.tr("QReduce Preferences"))
示例#50
0
    def bake(self):
        
        self.bakeWidget = QDialog( self )
        
        def doCommand():
            ctlsGroup = []
            for widget in self.mainWindow.w_ctlListGroup.getChildrenWidgets():
                ctls = widget.items
                allExists=True
                for ctl in ctls:
                    if not pymel.core.objExists( ctl ): 
                        allExists=False
                        break
                if not allExists: continue
                ctlsGroup.append( ctls )
            mainCtl = self.mainWindow.w_mainCtl.lineEdit.text()
            minFrame = int( self.bakeWidget.le_minFrame.text() )
            maxFrame = int( self.bakeWidget.le_maxFrame.text() )
            BaseCommands.bake( mainCtl, ctlsGroup, minFrame, maxFrame )

        
        def closeCommand():
            self.bakeWidget.deleteLater()


        validator = QIntValidator( self )
        
        minFrame = pymel.core.playbackOptions( q=1, min=0 )
        maxFrame = pymel.core.playbackOptions( q=1, max=1 )
        
        mainLayout = QVBoxLayout( self.bakeWidget )
        
        timeRangeLayout = QHBoxLayout()
        l_minFrame = QLabel( "Min Frame : " )
        le_minFrame = QLineEdit(); le_minFrame.setValidator( validator )
        l_maxFrame = QLabel( "Max Frame : " )
        le_maxFrame = QLineEdit(); le_maxFrame.setValidator( validator )
        timeRangeLayout.addWidget( l_minFrame )
        timeRangeLayout.addWidget( le_minFrame )
        timeRangeLayout.addWidget( l_maxFrame )
        timeRangeLayout.addWidget( le_maxFrame )
        
        le_minFrame.setText( str( int(minFrame) ) )
        le_maxFrame.setText( str( int(maxFrame) ) )
        
        buttonsLayout = QHBoxLayout()
        b_bake = QPushButton( "Bake" )
        b_close = QPushButton( "Close" )
        buttonsLayout.addWidget( b_bake )
        buttonsLayout.addWidget( b_close )
        
        mainLayout.addLayout( timeRangeLayout )
        mainLayout.addLayout( buttonsLayout )
        
        QtCore.QObject.connect( b_bake,  QtCore.SIGNAL( "clicked()" ), doCommand )
        QtCore.QObject.connect( b_close, QtCore.SIGNAL( "clicked()" ), closeCommand )
        self.bakeWidget.show()

        self.bakeWidget.le_minFrame = le_minFrame
        self.bakeWidget.le_maxFrame = le_maxFrame
示例#51
0
    def __init__(self, parent=None):
        super(RobocompDslGui, self).__init__(parent)
        self.setWindowTitle("Create new component")
        # self._idsl_paths = []
        self._communications = {
            "implements": [],
            "requires": [],
            "subscribesTo": [],
            "publishes": []
        }
        self._interfaces = {}
        self._cdsl_doc = CDSLDocument()
        self._command_process = QProcess()

        self._main_widget = QWidget()
        self._main_layout = QVBoxLayout()
        self.setCentralWidget(self._main_widget)

        self._name_layout = QHBoxLayout()
        self._name_line_edit = QLineEdit()
        self._name_line_edit.textEdited.connect(self.update_component_name)
        self._name_line_edit.setPlaceholderText("New component name")
        self._name_layout.addWidget(self._name_line_edit)
        self._name_layout.addStretch()

        # DIRECTORY SELECTION
        self._dir_line_edit = QLineEdit()
        # self._dir_line_edit.textEdited.connect(self.update_completer)
        self._dir_completer = QCompleter()
        self._dir_completer_model = QFileSystemModel()
        if os.path.isdir(ROBOCOMP_COMP_DIR):
            self._dir_line_edit.setText(ROBOCOMP_COMP_DIR)
            self._dir_completer_model.setRootPath(ROBOCOMP_COMP_DIR)
        self._dir_completer.setModel(self._dir_completer_model)
        self._dir_line_edit.setCompleter(self._dir_completer)

        self._dir_button = QPushButton("Select directory")
        self._dir_button.clicked.connect(self.set_output_directory)
        self._dir_layout = QHBoxLayout()
        self._dir_layout.addWidget(self._dir_line_edit)
        self._dir_layout.addWidget(self._dir_button)

        # LIST OF ROBOCOMP INTERFACES
        self._interface_list = QListWidget()
        self._interface_list.setSelectionMode(
            QAbstractItemView.ExtendedSelection)
        self._interface_list.itemSelectionChanged.connect(
            self.set_comunication)

        # LIST OF CONNECTION TyPES
        self._type_combo_box = QComboBox()
        self._type_combo_box.addItems(
            ["publishes", "implements", "subscribesTo", "requires"])
        self._type_combo_box.currentIndexChanged.connect(
            self.reselect_existing)

        # BUTTON TO ADD A NEW CONNECTION
        # self._add_connection_button = QPushButton("Add")
        # self._add_connection_button.clicked.connect(self.add_new_comunication)
        self._add_connection_layout = QHBoxLayout()
        # self._add_connection_layout.addWidget(self._add_connection_button)
        self._language_combo_box = QComboBox()
        self._language_combo_box.addItems(["Python", "Cpp", "Cpp11"])
        self._language_combo_box.currentIndexChanged.connect(
            self.update_language)
        self._add_connection_layout.addWidget(self._language_combo_box)
        self._add_connection_layout.addStretch()
        self._gui_check_box = QCheckBox()
        self._gui_check_box.stateChanged.connect(self.update_gui_selection)
        self._gui_label = QLabel("Use Qt GUI")
        self._add_connection_layout.addWidget(self._gui_label)
        self._add_connection_layout.addWidget(self._gui_check_box)

        # WIDGET CONTAINING INTERFACES AND TYPES
        self._selection_layout = QVBoxLayout()
        self._selection_layout.addWidget(self._type_combo_box)
        self._selection_layout.addWidget(self._interface_list)
        self._selection_layout.addLayout(self._add_connection_layout)
        self._selection_widget = QWidget()
        self._selection_widget.setLayout(self._selection_layout)

        # TEXT EDITOR WITH THE RESULTING CDSL CODE
        self._editor = QTextEdit(self)
        self._editor.setHtml("")

        self._document = self._editor.document()
        self._component_directory = None

        # SPLITTER WITH THE SELECTION AND THE CODE
        self._body_splitter = QSplitter(Qt.Horizontal)
        self._body_splitter.addWidget(self._selection_widget)
        self._body_splitter.addWidget(self._editor)
        self._body_splitter.setStretchFactor(0, 2)
        self._body_splitter.setStretchFactor(1, 9)

        # CREATION BUTTONS
        self._create_button = QPushButton("Create .cdsl")
        self._create_button.clicked.connect(self.write_cdsl_file)
        self._creation_layout = QHBoxLayout()
        self._creation_layout.addStretch()
        self._creation_layout.addWidget(self._create_button)

        self._console = QConsole()
        self._command_process.readyReadStandardOutput.connect(
            self._console.standard_output)
        self._command_process.readyReadStandardError.connect(
            self._console.error_output)

        # ADDING WIDGETS TO MAIN LAYOUT
        self._main_widget.setLayout(self._main_layout)
        self._main_layout.addLayout(self._name_layout)
        self._main_layout.addLayout(self._dir_layout)
        self._main_layout.addWidget(self._body_splitter)
        self._main_layout.addLayout(self._creation_layout)
        self._main_layout.addWidget(self._console)
        self.setMinimumSize(800, 500)
        self._editor.setText(self._cdsl_doc.generate_doc())
示例#52
0
        def __init__(self, U, plot, length=1, title=None):
            super().__init__()

            layout = QVBoxLayout()

            if title:
                title = QLabel('<b>' + title + '</b>')
                title.setAlignment(Qt.AlignHCenter)
                layout.addWidget(title)
            layout.addWidget(plot)

            plot.set(U, 0)

            if length > 1:
                hlayout = QHBoxLayout()

                self.slider = QSlider(Qt.Horizontal)
                self.slider.setMinimum(0)
                self.slider.setMaximum(length - 1)
                self.slider.setTickPosition(QSlider.TicksBelow)
                hlayout.addWidget(self.slider)

                lcd = QLCDNumber(m.ceil(m.log10(length)))
                lcd.setDecMode()
                lcd.setSegmentStyle(QLCDNumber.Flat)
                hlayout.addWidget(lcd)

                layout.addLayout(hlayout)

                hlayout = QHBoxLayout()

                toolbar = QToolBar()
                self.a_play = QAction(
                    self.style().standardIcon(QStyle.SP_MediaPlay), 'Play',
                    self)
                self.a_play.setCheckable(True)
                self.a_rewind = QAction(
                    self.style().standardIcon(QStyle.SP_MediaSeekBackward),
                    'Rewind', self)
                self.a_toend = QAction(
                    self.style().standardIcon(QStyle.SP_MediaSeekForward),
                    'End', self)
                self.a_step_backward = QAction(
                    self.style().standardIcon(QStyle.SP_MediaSkipBackward),
                    'Step Back', self)
                self.a_step_forward = QAction(
                    self.style().standardIcon(QStyle.SP_MediaSkipForward),
                    'Step', self)
                self.a_loop = QAction(
                    self.style().standardIcon(QStyle.SP_BrowserReload), 'Loop',
                    self)
                self.a_loop.setCheckable(True)
                toolbar.addAction(self.a_play)
                toolbar.addAction(self.a_rewind)
                toolbar.addAction(self.a_toend)
                toolbar.addAction(self.a_step_backward)
                toolbar.addAction(self.a_step_forward)
                toolbar.addAction(self.a_loop)
                if hasattr(self, 'save'):
                    self.a_save = QAction(
                        self.style().standardIcon(QStyle.SP_DialogSaveButton),
                        'Save', self)
                    toolbar.addAction(self.a_save)
                    self.a_save.triggered.connect(self.save)
                hlayout.addWidget(toolbar)

                self.speed = QSlider(Qt.Horizontal)
                self.speed.setMinimum(0)
                self.speed.setMaximum(100)
                hlayout.addWidget(QLabel('Speed:'))
                hlayout.addWidget(self.speed)

                layout.addLayout(hlayout)

                self.timer = QTimer()
                self.timer.timeout.connect(self.update_solution)

                self.slider.valueChanged.connect(self.slider_changed)
                self.slider.valueChanged.connect(lcd.display)
                self.speed.valueChanged.connect(self.speed_changed)
                self.a_play.toggled.connect(self.toggle_play)
                self.a_rewind.triggered.connect(self.rewind)
                self.a_toend.triggered.connect(self.to_end)
                self.a_step_forward.triggered.connect(self.step_forward)
                self.a_step_backward.triggered.connect(self.step_backward)

                self.speed.setValue(50)

            elif hasattr(self, 'save'):
                hlayout = QHBoxLayout()
                toolbar = QToolBar()
                self.a_save = QAction(
                    self.style().standardIcon(QStyle.SP_DialogSaveButton),
                    'Save', self)
                toolbar.addAction(self.a_save)
                hlayout.addWidget(toolbar)
                layout.addLayout(hlayout)
                self.a_save.triggered.connect(self.save)

            self.setLayout(layout)
            self.plot = plot
            self.U = U
            self.length = length
示例#53
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().screenGeometry().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)
     titles = odict([
         ["Presets", odict([["preset", "Presets"]])],
         ["Cosmological Model", odict([
             ["theory", "Theory code"],
             ["primordial", "Primordial perturbations"],
             ["geometry", "Geometry"],
             ["hubble", "Hubble parameter constraint"],
             ["matter", "Matter sector"],
             ["neutrinos", "Neutrinos and other extra matter"],
             ["dark_energy", "Lambda / Dark energy"],
             ["bbn", "BBN"],
             ["reionization", "Reionization history"]])],
         ["Data sets", odict([
             ["like_cmb", "CMB experiments"],
             ["like_bao", "BAO experiments"],
             ["like_sn", "SN experiments"],
             ["like_H0", "Local H0 measurements"]])],
         ["Sampler", odict([["sampler", "Samplers"]])]])
     self.combos = odict()
     for group, fields in titles.items():
         group_box = QGroupBox(group)
         self.layout_options.addWidget(group_box)
         group_layout = QVBoxLayout(group_box)
         for a, desc in fields.items():
             self.combos[a] = QComboBox()
             if len(fields) > 1:
                 label = QLabel(desc)
                 group_layout.addWidget(label)
             group_layout.addWidget(self.combos[a])
             self.combos[a].addItems(
                 [text(k, v) for k, v in getattr(input_database, a).items()])
     # PLANCK NAMES CHECKBOX TEMPORARILY DISABLED
     #                if a == "theory":
     #                    # Add Planck-naming checkbox
     #                    self.planck_names = QCheckBox(
     #                        "Keep common parameter names "
     #                        "(useful for fast CLASS/CAMB switching)")
     #                    group_layout.addWidget(self.planck_names)
     # Connect to refreshers -- needs to be after adding all elements
     for field, combo in self.combos.items():
         if field == "preset":
             combo.currentIndexChanged.connect(self.refresh_preset)
         else:
             combo.currentIndexChanged.connect(self.refresh)
     #        self.planck_names.stateChanged.connect(self.refresh_keep_preset)
     # RIGHT: Output + buttons
     self.display_tabs = QTabWidget()
     self.display = {}
     for k in ["yaml", "python", "citations"]:
         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)
示例#54
0
    def setupUi(self, gui_slate):

        self.gui = gui_slate
        self.gui.get_option_selected = False
        self.gui.push_option_selected = False
        self.gui.extract_opt_selected = False
        self.gui.compare_opt_selected = False

        #Outer most Main Layout

        self.widget = QWidget()
        self.widget.setMinimumSize(850, 600)

        self.main_layout_h = QHBoxLayout()
        self.main_layout_h.setAlignment(QtCore.Qt.AlignTop)

        self.widget.setLayout(self.main_layout_h)

        self.gui.setCentralWidget(self.widget)

        self.left_base_widget = QWidget()
        #         self.left_base_widget.setMaximumWidth(600)
        #         self.left_base_widget.setMinimumWidth(450)
        #         self.left_base_widget.setMaximumHeight(700)

        self.right_base_widget = QWidget()

        #3 Sub main Layouts

        self.left_base_layout_v = QVBoxLayout()
        #         self.right_base_layout_v = QVBoxLayout()
        self.corner_logo_layout_v = QVBoxLayout()
        self.left_base_layout_v.setAlignment(QtCore.Qt.AlignTop)

        self.right_base_layout_v.setAlignment(QtCore.Qt.AlignTop)

        #Added Widgets and layouts to the outermost layout

        self.main_layout_h.addWidget(self.left_base_widget)
        self.main_layout_h.addWidget(self.right_base_widget)
        self.main_layout_h.addLayout(self.corner_logo_layout_v)

        #         , QtGui.QFont.Normal
        self.grp_heading_font = QtGui.QFont("Verdana", 10)
        self.grp_heading_font.setItalic(True)

        #Radio buttons layout

        self.radio_groupBox = QtGui.QGroupBox()
        self.radio_option_layout_lb_h = QHBoxLayout()

        self.radio_groupBox.setLayout(self.radio_option_layout_lb_h)

        self.radio_groupBox.setMinimumWidth(450)
        self.left_base_layout_v.addWidget(self.radio_groupBox)

        #Credentials layouts

        self.credentials_groupbox = QtGui.QGroupBox("GTAC Credentials")
        self.credentials_groupbox.setFont(self.grp_heading_font)
        self.credentials_layout_lb_v = QVBoxLayout()

        self.username_layout_lb_h = QHBoxLayout()
        self.password_layout_lb_h = QHBoxLayout()
        self.cr_layout_lb_h = QHBoxLayout()
        self.password_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft)
        self.credentials_layout_lb_v.addLayout(self.username_layout_lb_h)
        self.credentials_layout_lb_v.addLayout(self.password_layout_lb_h)
        self.credentials_layout_lb_v.addLayout(self.cr_layout_lb_h)

        self.credentials_groupbox.setLayout(self.credentials_layout_lb_v)
        self.left_base_layout_v.addWidget(self.credentials_groupbox)
        self.credentials_groupbox.setAlignment(QtCore.Qt.AlignLeft)
        self.credentials_groupbox.hide()

        #IP group box layouts

        self.IP_groupBox = QtGui.QGroupBox("IP Inputs")
        self.IP_groupBox.setFont(self.grp_heading_font)
        self.ip_file_layout_lb_v = QVBoxLayout()

        self.ip_file_select_layout_lb_h = QHBoxLayout()
        self.ip_file_select_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft)
        self.ip_file_layout_lb_v.addLayout(self.ip_file_select_layout_lb_h)

        self.IP_groupBox.setMaximumHeight(135)
        self.IP_groupBox.setLayout(self.ip_file_layout_lb_v)
        self.left_base_layout_v.addWidget(self.IP_groupBox)

        self.IP_groupBox.hide()

        # Commands  group box selection

        self.Commands_groupBox = QtGui.QGroupBox("Commands Inputs")
        self.Commands_groupBox.setFont(self.grp_heading_font)
        self.commands_label_layout_lb_v = QVBoxLayout()

        self.default_chkbx_layout_lb_h = QHBoxLayout()
        self.commands_file_layout_lb_h = QHBoxLayout()
        self.commands_file_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft)
        self.commands_custom_box_layout_lb_h = QHBoxLayout()
        self.none_radio_btn_layout_lb_h = QHBoxLayout()

        self.commands_label_layout_lb_v.addLayout(
            self.default_chkbx_layout_lb_h)
        self.commands_label_layout_lb_v.addLayout(
            self.commands_file_layout_lb_h)
        self.commands_label_layout_lb_v.addLayout(
            self.commands_custom_box_layout_lb_h)
        self.commands_label_layout_lb_v.addLayout(
            self.none_radio_btn_layout_lb_h)

        self.Commands_groupBox.setMaximumHeight(225)
        self.Commands_groupBox.setAlignment(QtCore.Qt.AlignLeft)
        self.Commands_groupBox.setLayout(self.commands_label_layout_lb_v)
        self.left_base_layout_v.addWidget(self.Commands_groupBox)

        self.Commands_groupBox.hide()

        # results group box

        self.results_groupBox = QtGui.QGroupBox("Results")
        self.results_groupBox.setFont(self.grp_heading_font)
        self.results_layout_lb_v = QVBoxLayout()

        self.output_layout_lb_h = QHBoxLayout()
        self.output_layout_lb_h.setAlignment(QtCore.Qt.AlignLeft)

        self.results_layout_lb_v.addLayout(self.output_layout_lb_h)

        self.results_groupBox.setLayout(self.results_layout_lb_v)
        self.left_base_layout_v.addWidget(self.results_groupBox)

        self.results_groupBox.hide()

        # Go Button

        self.go_btn_layout_lb_h = QHBoxLayout()
        self.left_base_layout_v.addLayout(self.go_btn_layout_lb_h)

        # Right and Left Widget on individual layouts

        self.left_base_widget.setLayout(self.left_base_layout_v)
        self.right_base_widget.setLayout(self.right_base_layout_v)

        #### just to see right base layout

        self.right_base = QtGui.QTextEdit(self.gui)
        self.right_base.setStyleSheet(
            """QToolTip { background-color: #00bfff; color: black; border: black solid 2px  }"""
        )
        self.right_base.setObjectName("IP_Address")
        self.right_base_layout_v.addWidget(self.right_base)
        #         self.right_base.setMaximumHeight(500)
        self.right_base.hide()

        self.snap_gif = QtGui.QLabel(self.gui)
        self.snap_gif.setText("")
        self.snap_gif.setStyleSheet("background-color: None")
        self.snap_gif.setPixmap(QtGui.QPixmap("Capture.png"))
        self.snap_gif.setObjectName("logo_corner")
        self.right_base_layout_v.addWidget(self.snap_gif)

        ######

        self.gui.setWindowTitle('SPEED +  3.0')
        self.gui.setWindowIcon(QtGui.QIcon(":/logo/Wind_icon.png"))
        self.gui.setAutoFillBackground(True)

        self.corner_logolabel = QtGui.QLabel(self.gui)
        self.corner_logolabel.setText("")
        self.corner_logolabel.setStyleSheet("background-color: None")
        self.corner_logolabel.setPixmap(QtGui.QPixmap(":/logo/ATT-LOGO-2.png"))
        self.corner_logolabel.setObjectName("logo_corner")
        #         self.corner_logo_layout_v.setAlignment(QtCore.Qt.AlignTop)
        self.corner_logo_layout_v.setAlignment(
            int(QtCore.Qt.AlignTop | QtCore.Qt.AlignRight))
        self.corner_logo_layout_v.addWidget(self.corner_logolabel)

        self.msgBox.setWindowIcon(QtGui.QIcon(":/logo/Wind_icon.png"))
        self.msgBox.setFont(QtGui.QFont("Verdana", 8, QtGui.QFont.Normal))
        self.make_menu()
        ## gif at&t logo
        #         self.movie_screen = QLabel()
        #         self.movie_screen.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
        #         self.movie_screen.setAlignment(QtCore.Qt.AlignCenter)
        #         self.right_base_layout_v.addWidget(self.movie_screen)
        #
        #         ag_file = "C:/Users/rg012f/eclipse-workspace/poojan_try/giphy.gif"
        #         self.movie = QtGui.QMovie(ag_file, QtCore.QByteArray(), None)
        #         self.movie.setCacheMode(QtGui.QMovie.CacheAll)
        #         self.movie.setSpeed(75)
        #         self.movie_screen.setMovie(self.movie)
        #
        #
        #         self.movie.setPaused(True)
        #         self.movie.start()
        #         self.right_base_widget.show()
        #         time.sleep(2)

        ######################### order of the below funtion calls is importnant change them wisely#####################
        self.check_save_username()
        self.create_views()
        self.left_radio_controls()
        self.connect_child_views()
示例#55
0
    def __init__(self, *args, **kwargs ):
        
        self.uiInfoPath = Window.infoBaseDir + '/Widget_mainController.json'
        
        QWidget.__init__( self, *args, **kwargs )
        mainLayout = QHBoxLayout( self ); mainLayout.setContentsMargins(0,0,0,0)
        mainLayout.setSpacing( 5 )
        
        label = QLabel( "Main Ctl : " )
        lineEdit = QLineEdit()
        button = QPushButton( "Load" )
        
        mainLayout.addWidget( label )
        mainLayout.addWidget( lineEdit )
        mainLayout.addWidget( button )
        
        QtCore.QObject.connect( button, QtCore.SIGNAL("clicked()"), self.loadCtl )

        self.lineEdit = lineEdit
        
        data = BaseCommands.readData( self.uiInfoPath )
        if data.has_key( 'lineEdit' ):
            self.lineEdit.setText( data['lineEdit'] )
示例#56
0
文件: admin_gui.py 项目: wiz21b/koi
    def __init__(self):
        super(MainWindow, self).__init__()

        self.edit_config = EditConfigurationDialog(self)
        self.edit_config.load_configuration()

        w = QWidget(self)

        big_hlayout = QHBoxLayout()

        layout = QVBoxLayout()
        big_hlayout.addLayout(layout)
        big_hlayout.addWidget(self.edit_config)

        layout.addWidget(
            QLabel("<h1>{} administration</h1>".format(
                configuration.get("Globals", "name"))))

        glayout = QGridLayout()

        row = 0

        HOST = "{} or {}".format(guess_server_public_ip(),
                                 socket.gethostname())
        glayout.addWidget(QLabel("<b>Server's IP address"), row, 0)
        ip_address = configuration.get("DEFAULT", "public_ip")
        if not ip_address:
            ip_address = "<font color='red'><b>NOT DEFINED</b></font>"
        glayout.addWidget(QLabel("{} (guessed: {})".format(ip_address, HOST)),
                          row, 1)

        row += 1
        glayout.addWidget(QLabel("<b>Client database URL"), row, 0)
        db_url = configuration.get("Database", "url")
        self.public_url_edit = QLabel(db_url)
        glayout.addWidget(self.public_url_edit, row, 1)

        row += 1
        glayout.addWidget(QLabel("<b>Client server URL"), row, 0)
        url = configuration.get("DownloadSite", "public_url")
        self.public_web_url_edit = QLabel(url)
        glayout.addWidget(self.public_web_url_edit, row, 1)

        row += 1
        glayout.addWidget(QLabel("Server local DB URL"), row, 0)
        db_url = configuration.get("Database", "admin_url")
        self.url_edit = QLabel(db_url)
        glayout.addWidget(self.url_edit, row, 1)

        row += 1
        glayout.addWidget(QLabel("Backup directory"), row, 0)
        db_url = configuration.get("Backup", "backup_directory")
        self.backup_directory_edit = QLabel(db_url)
        glayout.addWidget(self.backup_directory_edit, row, 1)

        row += 1
        glayout.addWidget(QLabel("Data/logs directory"), row, 0)
        self.data_directory_edit = QLabel(get_data_dir())
        glayout.addWidget(self.data_directory_edit, row, 1)

        qgb = QGroupBox("Life data")
        qgb.setLayout(glayout)
        layout.addWidget(qgb)

        hlayout = QHBoxLayout()
        b = QPushButton("Check database")
        b.clicked.connect(self.check_database)
        hlayout.addWidget(b)

        b = QPushButton("Check web server")
        b.clicked.connect(self.check_server)
        hlayout.addWidget(b)

        b = QPushButton("Show delivery_slips download page")
        b.clicked.connect(self.show_client_dowload_page)
        hlayout.addWidget(b)

        qgb = QGroupBox("Checks")
        qgb.setLayout(hlayout)
        layout.addWidget(qgb)

        hlayout = QHBoxLayout()
        # b = QPushButton("Set backup directory")
        # b.clicked.connect(self.set_backup_directory)
        # hlayout.addWidget( b)

        b = QPushButton("Restore backup")
        b.clicked.connect(self.restore_backup)
        hlayout.addWidget(b)

        b = QPushButton("Reset admin account")
        b.clicked.connect(self.create_root_account)
        hlayout.addWidget(b)

        # b = QPushButton("Set public IP")
        # b.clicked.connect(self.set_public_ip)
        # hlayout.addWidget( b)

        # Please use the command line, this is not for the faint hearted.

        # b = QPushButton("Clear database")
        # b.clicked.connect(self.create_database)
        # hlayout.addWidget( b)

        qgb = QGroupBox("Actions")
        qgb.setLayout(hlayout)
        layout.addWidget(qgb)

        vlayout = QVBoxLayout()

        # if platform.system() == 'Windows':
        #     # when running on Linux, it's expected that the
        #     # whole server configuration is set up by us
        #
        #     hlayout = QHBoxLayout()
        #     b = QPushButton("Start server manually")
        #     b.clicked.connect(self.start_server_manually)
        #     hlayout.addWidget( b)
        #
        #     b = QPushButton("Stop server manually")
        #     b.clicked.connect(self.stop_server_manually)
        #     hlayout.addWidget( b)
        #     vlayout.addLayout(hlayout)
        #
        #     hlayout = QHBoxLayout()
        #     b = QPushButton("Install services")
        #     b.clicked.connect(self.install_service)
        #     hlayout.addWidget( b)
        #
        #     b = QPushButton("Uninstall services")
        #     b.clicked.connect(self.uninstall_service)
        #     hlayout.addWidget( b)
        #     vlayout.addLayout(hlayout)
        #
        #     b = QPushButton("Install scheduled services")
        #     b.clicked.connect(self.install_on_start_tasks)
        #     vlayout.addWidget( b)
        #
        #     # b = QPushButton("Upgrade delivery_slips")
        #     # b.clicked.connect(self.upgrade_client)
        #     # layout.addWidget( b)
        #
        #     qgb = QGroupBox("Service & installation")
        #     qgb.setLayout(vlayout)
        #     layout.addWidget(qgb)

        self.log_view = QTextEdit()
        layout.addWidget(self.log_view)

        self.url_edit.setTextInteractionFlags(Qt.TextSelectableByMouse)
        self.public_url_edit.setTextInteractionFlags(Qt.TextSelectableByMouse)
        self.public_web_url_edit.setTextInteractionFlags(
            Qt.TextSelectableByMouse)
        self.backup_directory_edit.setTextInteractionFlags(
            Qt.TextSelectableByMouse)

        self.log_view.setReadOnly(True)

        w.setLayout(big_hlayout)

        self.setCentralWidget(w)
示例#57
0
文件: waste.py 项目: tinavas/FSERP
class WasteDish():
    """Dish waste management tab"""
    global logger

    def __init__(self):
        ###
        logger.info('Inside WasteDish')
        self.wastedetail_tab_1 = QWidget()
        self.wastedetail_tab_1.setObjectName("wastedetail_tab_1")
        self.verticalLayout_9 = QVBoxLayout(self.wastedetail_tab_1)
        self.verticalLayout_9.setObjectName("verticalLayout_9")
        self.verticalLayout_8 = QVBoxLayout()
        self.verticalLayout_8.setObjectName("verticalLayout_8")
        self.horizontalLayout_12 = QHBoxLayout()
        self.horizontalLayout_12.setObjectName("horizontalLayout_12")
        self.waste_fromdate_label = QLabel(self.wastedetail_tab_1)
        self.waste_fromdate_label.setObjectName('waste_fromdate_label')
        self.horizontalLayout_12.addWidget(self.waste_fromdate_label)
        self.waste_fromdate_dateedit = QDateEdit(self.wastedetail_tab_1)
        self.waste_fromdate_dateedit.setCalendarPopup(True)
        self.waste_fromdate_dateedit.setObjectName("waste_fromdate_dateedit")
        self.horizontalLayout_12.addWidget(self.waste_fromdate_dateedit)
        self.waste_todate_label = QLabel(self.wastedetail_tab_1)
        self.waste_todate_label.setObjectName('waste_todate_label')
        self.horizontalLayout_12.addWidget(self.waste_todate_label)
        self.waste_todate_dateedit = QDateEdit(self.wastedetail_tab_1)
        self.waste_todate_dateedit.setCalendarPopup(True)
        self.waste_todate_dateedit.setObjectName("waste_todate_dateedit")
        self.waste_todate_dateedit.setMaximumDate(QDate.currentDate())
        self.horizontalLayout_12.addWidget(self.waste_todate_dateedit)
        spacerItem28 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum)
        self.horizontalLayout_12.addItem(spacerItem28)
        self.waste_table_search_button = QPushButton(self.wastedetail_tab_1)
        self.waste_table_search_button.setObjectName(
            "waste_table_search_button")
        self.horizontalLayout_12.addWidget(self.waste_table_search_button)
        self.verticalLayout_8.addLayout(self.horizontalLayout_12)
        self.waste_table = QTableWidget(self.wastedetail_tab_1)
        self.waste_table.setObjectName("waste_table")
        self.waste_table.setColumnCount(5)
        self.waste_table.setRowCount(0)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(0, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(1, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(2, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(3, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(4, item)
        self.waste_table.horizontalHeader().setCascadingSectionResizes(False)
        self.waste_table.horizontalHeader().setStretchLastSection(True)
        self.waste_table.verticalHeader().setVisible(False)
        self.waste_table.verticalHeader().setCascadingSectionResizes(False)
        self.waste_table.setSortingEnabled(True)
        self.verticalLayout_8.addWidget(self.waste_table)
        self.horizontalLayout_13 = QHBoxLayout()
        self.horizontalLayout_13.setObjectName("horizontalLayout_13")
        self.waste_table_newrow_button = QPushButton(self.wastedetail_tab_1)
        self.waste_table_newrow_button.setObjectName(
            "waste_table_newrow_button")
        self.horizontalLayout_13.addWidget(self.waste_table_newrow_button)
        spacerItem29 = QSpacerItem(612, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum)
        self.horizontalLayout_13.addItem(spacerItem29)
        self.waste_table_discard_button = QPushButton(self.wastedetail_tab_1)
        self.waste_table_discard_button.setObjectName(
            "waste_table_discard_button")
        self.horizontalLayout_13.addWidget(self.waste_table_discard_button)
        self.verticalLayout_8.addLayout(self.horizontalLayout_13)
        self.verticalLayout_9.addLayout(self.verticalLayout_8)
        ##retranslate
        self.waste_fromdate_label.setText(
            QApplication.translate("MainWindow", "From Date", None,
                                   QApplication.UnicodeUTF8))
        self.waste_fromdate_dateedit.setDisplayFormat(
            QApplication.translate("MainWindow", "dd/MM/yyyy", None,
                                   QApplication.UnicodeUTF8))
        self.waste_todate_label.setText(
            QApplication.translate("MainWindow", "To Date", None,
                                   QApplication.UnicodeUTF8))
        self.waste_todate_dateedit.setDisplayFormat(
            QApplication.translate("MainWindow", "dd/MM/yyyy", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table_search_button.setText(
            QApplication.translate("MainWindow", "Search", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(0).setText(
            QApplication.translate("MainWindow", "Code", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(1).setText(
            QApplication.translate("MainWindow", "Item", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(2).setText(
            QApplication.translate("MainWindow", "Category", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(3).setText(
            QApplication.translate("MainWindow", "Quantity", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(4).setText(
            QApplication.translate("MainWindow", "Reason", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table_newrow_button.setText(
            QApplication.translate("MainWindow", "New Row", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table_discard_button.setText(
            QApplication.translate("MainWindow", "Discard Item", None,
                                   QApplication.UnicodeUTF8))
        self.wastedetail_tab_1.setTabOrder(self.waste_fromdate_dateedit,
                                           self.waste_todate_dateedit)
        self.wastedetail_tab_1.setTabOrder(self.waste_todate_dateedit,
                                           self.waste_table_search_button)
        ###signals and slots && other stuffs
        # self.mainwindow = Ui_MainWindow  # just for the ease of finding the attributes in pycharm
        self.schedule = SchedulePurchase()
        self.suplier = BusinessParty(category='Supplier')
        self.add = AddStockInventory()
        self.item = WasteMenu()
        self.waste_fromdate_dateedit.setDate(QDate.currentDate())
        self.waste_todate_dateedit.setDate(QDate.currentDate())
        self.waste_table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.waste_table_newrow_button.clicked.connect(self.add_new_blank_rows)
        self.waste_table_discard_button.clicked.connect(self.discard)
        self.waste_table_search_button.clicked.connect(self.search_discard)
        self.wastedetail_tab_1.setFocusPolicy(Qt.StrongFocus)
        self.wastedetail_tab_1.focusInEvent = self.load_rows

    def load_rows(self, event=None):
        pass

    def add_new_blank_rows(self):
        """
        deletes the schedules in the database
        """
        table = self.waste_table
        item = table.item(0, 0)
        if item:
            message = QMessageBox.critical(QMessageBox(), 'Warning!',
                                           'This will remove all the entries',
                                           QMessageBox.Ok | QMessageBox.Cancel)
            if message == QMessageBox.Ok:
                table.setRowCount(0)
                table.clearContents()
                self.add_row_to_table('new')
                self.waste_table_discard_button.setVisible(True)
        elif not item:
            self.waste_table_discard_button.setVisible(True)
            self.add_row_to_table('new')

    def add_row_to_table(self, *args):
        """
        complex stuff of auto complete to be added to each combo box
        :return:
        """
        table = self.waste_table
        if args:
            if args[0] != 'new':
                table.clearContents()
                table.setRowCount(0)
                table.setRowCount(len(args))
                for i, j in enumerate(args):
                    code = QTableWidgetItem(j['code'])
                    table.setItem(i, 0, code)
                    item = QTableWidgetItem(j['item'])
                    table.setItem(i, 1, item)
                    category = QTableWidgetItem(j['category'])
                    table.setItem(i, 2, category)
                    quantity = QTableWidgetItem(str(j['quantity']))
                    table.setItem(i, 3, quantity)
                    reason = QTableWidgetItem(j['reason_for_discard'])
                    table.setItem(i, 4, reason)
            if args[0] == 'new':
                row = table.rowCount() + 1
                table.setRowCount(row)
                codeline = QLineEdit()
                codeline.editingFinished.connect(
                    lambda: self.get_details_of_code(row))
                table.setCellWidget(row - 1, 0, codeline)
                itemcombo = QComboBox()
                self.fill_item_list(itemcombo)
                itemcombo.currentIndexChanged.connect(
                    lambda: self.get_details_of_item(row))
                table.setCellWidget(row - 1, 1, itemcombo)
                category = QTableWidgetItem()
                table.setItem(row - 1, 2, category)
                quantity = QLineEdit()
                table.setCellWidget(row - 1, 3, quantity)
                combo = QComboBox()
                combo.addItem("Cancelled")
                combo.addItem("Mishandling")
                combo.addItem("Excess")
                table.setCellWidget(row - 1, 4, combo)
        table.setColumnWidth(0, (table.width() / 5))
        table.setColumnWidth(1, (table.width() / 5))
        table.setColumnWidth(2, (table.width() / 5))
        table.setColumnWidth(3, (table.width() / 5))
        table.horizontalHeader().setStretchLastSection(
            True
        )  # important to resize last section else blank space after last column

    def fill_item_list(self, combo):
        """
        fill the item combo box
        :param combo: the combobox object
        :return: none
        """
        itemfield = combo
        itemfield.setStyleSheet("QAbstractItemView{"
                                "background: #4B77BE;"
                                "}")
        self.item.populate_item(itemfield)

    def get_details_of_code(self, rowcount):
        """
        fills the item, category and units based on the code
        :param rowcount: the row count
        :return: none
        """
        row = rowcount - 1
        table = self.waste_table
        codeline = table.cellWidget(row, 0)
        data = self.item.get_details_of_code(codeline.text())
        item = table.cellWidget(row, 1)
        index = item.findText(data['item'])
        item.setCurrentIndex(index)
        category = table.item(row, 2)
        category.setText(data['category'])

    def get_details_of_item(self, rowcount):
        """
        fills the code, category and units based on the item
        :param rowcount: the row count
        :return: none
        """
        row = rowcount - 1
        table = self.waste_table
        itemcombo = table.cellWidget(row, 1)
        data = self.item.get_details_of_item(itemcombo.currentText())
        code = table.cellWidget(row, 0)
        code.setText(data['code'])
        category = table.item(row, 2)
        category.setText(data['category'])

    def discard(self):
        """
        saves the details in db before printing
        """
        logger.info('WasteDish discard initiated')
        table = self.waste_table
        data = self.get_data()
        if data:
            for i in data:
                status = self.item.discard(i)
                if status:
                    model_index = table.indexFromItem(i['model_item'])
                    row = model_index.row()
                    table.removeRow(row)
                else:
                    msg = QMessageBox.critical(QMessageBox(), "Error!!",
                                               "The item cannot be discarded",
                                               QMessageBox.Ok)
                    if msg == QMessageBox.Ok:
                        return False

    def search_discard(self):
        """
        searches the discard from_date and to_date
        :return:none
        """
        table = self.waste_table
        item = table.cellWidget(0, 0)
        if item:
            msg = QMessageBox.critical(QMessageBox(), 'Warning!',
                                       'This will delete all the rows added',
                                       QMessageBox.Ok | QMessageBox.Cancel)
            if msg == QMessageBox.Cancel:
                return False
        f_date = self.waste_fromdate_dateedit.text()
        from_date = datetime.strptime(f_date, '%d/%m/%Y')
        t_date = self.waste_todate_dateedit.text()
        to_date = datetime.strptime(t_date, '%d/%m/%Y')
        to_date = to_date + timedelta(hours=23, minutes=59, seconds=59)
        dataobj = self.item.find_itemdiscard(from_date=from_date,
                                             to_date=to_date)
        self.add_row_to_table(*dataobj)
        self.waste_table_discard_button.setVisible(False)

    def get_data(self):
        """
        :return: fetches all the data for printing
        """
        table = self.waste_table
        rows = table.rowCount()
        dataobj = []
        for i in range(rows):
            dictionary = {}
            item = table.cellWidget(i, 0) if table.cellWidget(
                i, 0) is not None else table.item(i, 0)
            dictionary['code'] = item.text()
            if dictionary['code'] == '':
                break
            item = table.cellWidget(i, 1).currentText() if table.cellWidget(
                i, 1) is not None else table.item(i, 1).text()
            dictionary['item'] = item
            item = table.cellWidget(i, 2) if table.cellWidget(
                i, 2) is not None else table.item(i, 2)
            dictionary['category'] = item.text()
            item = table.cellWidget(i, 3) if table.cellWidget(
                i, 3) is not None else table.item(i, 3)
            dictionary['quantity'] = item.text()
            if dictionary['quantity'] == '':
                self.show_error('Quantity')
                return False
            item = table.cellWidget(i, 4).currentText() if table.cellWidget(
                i, 4) is not None else table.item(i, 4).text()
            dictionary['reason_for_discard'] = item
            dictionary['model_item'] = table.item(i, 2)
            dataobj.append(dictionary)
        return dataobj

    def show_error(self, text):
        """
        :return: pops up an error
        """
        QMessageBox.critical(QMessageBox(), "Fail!!",
                             "Please Enter %s properly" % text, QMessageBox.Ok)
示例#58
0
                def __init__(self):
                    super().__init__()
                    if separate_colorbars:
                        if rescale_colorbars:
                            self.vmins = tuple(np.min(u[0]) for u in U)
                            self.vmaxs = tuple(np.max(u[0]) for u in U)
                        else:
                            self.vmins = tuple(np.min(u) for u in U)
                            self.vmaxs = tuple(np.max(u) for u in U)
                    else:
                        if rescale_colorbars:
                            self.vmins = (min(np.min(u[0])
                                              for u in U), ) * len(U)
                            self.vmaxs = (max(np.max(u[0])
                                              for u in U), ) * len(U)
                        else:
                            self.vmins = (min(np.min(u) for u in U), ) * len(U)
                            self.vmaxs = (max(np.max(u) for u in U), ) * len(U)

                    layout = QHBoxLayout()
                    plot_layout = QGridLayout()
                    self.colorbarwidgets = [
                        cbar_widget(self, vmin=vmin, vmax=vmax)
                        if cbar_widget else None
                        for vmin, vmax in zip(self.vmins, self.vmaxs)
                    ]
                    plots = [
                        widget(self,
                               grid,
                               vmin=vmin,
                               vmax=vmax,
                               bounding_box=bounding_box,
                               codim=codim)
                        for vmin, vmax in zip(self.vmins, self.vmaxs)
                    ]
                    if legend:
                        for i, plot, colorbar, l in zip(
                                range(len(plots)), plots, self.colorbarwidgets,
                                legend):
                            subplot_layout = QVBoxLayout()
                            caption = QLabel(l)
                            caption.setAlignment(Qt.AlignHCenter)
                            subplot_layout.addWidget(caption)
                            if not separate_colorbars or backend == 'matplotlib':
                                subplot_layout.addWidget(plot)
                            else:
                                hlayout = QHBoxLayout()
                                hlayout.addWidget(plot)
                                if colorbar:
                                    hlayout.addWidget(colorbar)
                                subplot_layout.addLayout(hlayout)
                            plot_layout.addLayout(subplot_layout,
                                                  int(i / columns),
                                                  (i % columns), 1, 1)
                    else:
                        for i, plot, colorbar in zip(range(len(plots)), plots,
                                                     self.colorbarwidgets):
                            if not separate_colorbars or backend == 'matplotlib':
                                plot_layout.addWidget(plot, int(i / columns),
                                                      (i % columns), 1, 1)
                            else:
                                hlayout = QHBoxLayout()
                                hlayout.addWidget(plot)
                                if colorbar:
                                    hlayout.addWidget(colorbar)
                                plot_layout.addLayout(hlayout,
                                                      int(i / columns),
                                                      (i % columns), 1, 1)
                    layout.addLayout(plot_layout)
                    if not separate_colorbars:
                        layout.addWidget(self.colorbarwidgets[0])
                        for w in self.colorbarwidgets[1:]:
                            w.setVisible(False)
                    self.setLayout(layout)
                    self.plots = plots
示例#59
-1
    def __init__(self, *args, **kwargs ):
        
        QDialog.__init__( self, *args, **kwargs )
        self.installEventFilter( self )
        self.setWindowTitle( Window.title )
    
        mainLayout = QVBoxLayout( self )
        
        wLabelDescription = QLabel( "Select Object or Group" )
        
        validator = QIntValidator()
        
        hLayout = QHBoxLayout()
        wLabel = QLabel( "Num Controller : " )
        wLineEdit= QLineEdit();wLineEdit.setValidator(validator); wLineEdit.setText( '5' )
        hLayout.addWidget( wLabel )
        hLayout.addWidget( wLineEdit )
        
        button = QPushButton( "Create" )
        
        mainLayout.addWidget( wLabelDescription )
        mainLayout.addLayout( hLayout )
        mainLayout.addWidget( button )

        self.resize(Window.defaultWidth,Window.defaultHeight)
        
        self.wlineEdit = wLineEdit
        
        QtCore.QObject.connect( button, QtCore.SIGNAL( "clicked()" ), self.cmd_create )