def __init__(self): QFrame.__init__(self) layout = QGridLayout() self.btnMonitor1 = OutputButton(ID=2) self.btnMonitor1.setText("Monitor 1") layout.addWidget(self.btnMonitor1, 0, 1) self.btnChurch = OutputButton(ID=4) self.btnChurch.setText("Church") layout.addWidget(self.btnChurch, 1, 0) self.btnSpecial = OutputButton(ID=7) self.btnSpecial.setText("Stage") layout.addWidget(self.btnSpecial, 1, 1) self.btnGallery = OutputButton(ID=6) self.btnGallery.setText("Gallery") layout.addWidget(self.btnGallery, 2, 0) self.btnWelcome = OutputButton(ID=5) self.btnWelcome.setText("Welcome") layout.addWidget(self.btnWelcome, 2, 1) self.btnFont = OutputButton(ID=3) self.btnFont.setText("Font") layout.addWidget(self.btnFont, 3, 0) self.btnRecord = OutputButton(ID=8) self.btnRecord.setText("Record") layout.addWidget(self.btnRecord, 3, 1) self.btnPCMix = OutputButton(ID=2) self.btnPCMix.setText("PC Mix") layout.addWidget(self.btnPCMix, 4, 0) self.btnAll = IDedButton(ID=0) self.btnAll.setText("All") layout.addWidget(self.btnAll, 4, 1) self.outputButtons = { 2: self.btnMonitor1, 3: self.btnFont, 4: self.btnChurch, 5: self.btnWelcome, 6: self.btnGallery, 7: self.btnSpecial, 8: self.btnRecord, } layout.setColumnMinimumWidth(0, 100) layout.setColumnMinimumWidth(1, 100) layout.setColumnStretch(0, 1) layout.setColumnStretch(1, 1) self.setLayout(layout)
def __init__(self, switcherState, parent=None): super(OutputsGrid, self).__init__(parent) self.signalMapper = QSignalMapper(self) self.longPressSignalMapper = QSignalMapper(self) layout = QGridLayout() mainMixFrame = MainMixControl() mainMixFrame.cut.connect(self.cut.emit) mainMixFrame.take.connect(self.take.emit) layout.addWidget(mainMixFrame, 0, 0, 1, 2) self.aux_buttons = [] for idx, output in switcherState.outputs.iteritems(): ob = OutputButton(output) layout.addWidget(ob, 1 + (idx / 2), idx % 2) ob.clicked.connect(self.signalMapper.map) self.signalMapper.setMapping(ob, idx) ob.longpress.connect(self.longPressSignalMapper.map) self.longPressSignalMapper.setMapping(ob, idx) self.aux_buttons.append(ob) self.signalMapper.mapped.connect(self.registerClick) self.longPressSignalMapper.mapped.connect(self.longPress) btnAll = ExpandingButton() btnAll.setProperty("class", "mainMix") btnAll.setText("Mix to all") btnAll.clicked.connect(self.mainToAll.emit) layout.addWidget(btnAll, 4, 0) self.btnAll = ExpandingButton() self.btnAll.setText("All") self.btnAll.clicked.connect(self.all.emit) layout.addWidget(self.btnAll, 4, 1) layout.setColumnMinimumWidth(0, 100) layout.setColumnMinimumWidth(1, 100) layout.setColumnStretch(0, 1) layout.setColumnStretch(1, 1) layout.setRowStretch(0, 2) for i in range(1, 5): layout.setRowStretch(i, 1) self.setLayout(layout)
def __init__(self, parent=None): QWidget.__init__(self, parent) # Widgets, layouts and signals self._group = QButtonGroup() layout = QGridLayout() layout.setSpacing(0) for i in range(18): layout.setColumnMinimumWidth(i, 40) layout.setColumnStretch(i, 0) for i in list(range(7)) + [8, 9]: layout.setRowMinimumHeight(i, 40) layout.setRowStretch(i, 0) ## Element for z, position in _ELEMENT_POSITIONS.items(): widget = ElementPushButton(z) widget.setCheckable(True) layout.addWidget(widget, *position) self._group.addButton(widget, z) ## Labels layout.addWidget(QLabel(''), 7, 0) # Dummy layout.addWidget(QLabel('*'), 5, 2, Qt.AlignCenter) layout.addWidget(QLabel('*'), 8, 2, Qt.AlignCenter) layout.addWidget(QLabel('**'), 6, 2, Qt.AlignCenter) layout.addWidget(QLabel('**'), 9, 2, Qt.AlignCenter) for row in [0, 1, 2, 3, 4, 5, 6, 8, 9]: layout.setRowStretch(row, 1) self.setLayout(layout) # Signals self._group.buttonClicked.connect(self.selectionChanged) # Default self.setColorFunction(_category_color_function)
def __init__(self, parent=None): super(SummaryTab, self).__init__(parent) #create the widgets self.label_info = QLabel("No summary data to display") label_sent_packets = QLabel("Sent Packet Count") self.label_sent_packets = StyledLabel() self.label_sent_packets.setMaximumHeight(30) label_received_packets = QLabel("Received Packet Count") self.label_received_packets = StyledLabel() self.label_received_packets.setMaximumHeight(30) label_packets_lost = QLabel("Packets Lost") self.label_packets_lost = StyledLabel() self.label_packets_lost.setMaximumHeight(30) label_loss_percentage = QLabel("Packet Loss Percentage") self.label_loss_percentage = StyledLabel() self.label_loss_percentage.setMaximumHeight(30) label_output_delay = QLabel("Average Output Delay") self.label_output_delay = StyledLabel() self.label_output_delay.setMaximumHeight(30) #setup summary_layout #first, setup a stacked summary_layout to indicate first there's no summary data self.layout_stack = QStackedLayout() summary_centerer_layout = QHBoxLayout() summary_layout = QGridLayout() #if I use formlayout, i'm afraid things will stretch out too much horizontally row = 1; col = 0; summary_layout.addWidget(label_sent_packets, row, col) col += 2 summary_layout.addWidget(self.label_sent_packets, row, col) #leave a middle column empty row += 1; col -= 2; summary_layout.addWidget(label_received_packets, row, col) col += 2 summary_layout.addWidget(self.label_received_packets, row, col) row += 1; col -= 2 summary_layout.addWidget(label_packets_lost, row, col) col += 2 summary_layout.addWidget(self.label_packets_lost, row, col) row += 1; col -= 2; summary_layout.addWidget(label_loss_percentage, row, col) col += 2 summary_layout.addWidget(self.label_loss_percentage, row, col) row += 1; col -= 2; summary_layout.addWidget(label_output_delay, row, col) col += 2 summary_layout.addWidget(self.label_output_delay, row, col) #center things out summary_layout.setColumnMinimumWidth(1, 100) # 100 pixels in the middle summary_layout.setRowMinimumHeight(0, 10) #100 pixels from top summary_centerer_layout.addStretch() summary_centerer_layout.addLayout(summary_layout) summary_centerer_layout.addStretch() #make a dump widget for the stacked summary_layout widget = QWidget() widget.setLayout(summary_centerer_layout) self.layout_stack.insertWidget(0, widget) #setup summary_layout for info label! layout_info_label = QVBoxLayout() layout_info_label.addStretch() layout_info_label.addWidget(self.label_info) layout_info_label.addStretch() #make dump widget for info label summary_layout!! widget_info_label = QWidget() widget_info_label.setLayout(layout_info_label) self.layout_stack.insertWidget(1, widget_info_label) self.setLayout(self.layout_stack) self.zeroOut()
def initUI(self): ''' Method to setup the buttons/entries of the Gui ''' self.dateFrame = dateFrame( ); # Initialize the dateFrame self.iopLabel = QLabel('IOP Number'); # Initialize Entry widget for the IOP name self.iopName = QLineEdit(); # Initialize Entry widget for the IOP name self.stationLabel = QLabel('Station Name'); # Initialize Entry widget for the IOP name self.stationName = QLineEdit(); # Initialize Entry widget for the IOP name self.sourceButton = QPushButton('Source Directory'); # Initialize button for selecting the source directory self.destButton = QPushButton('Destination Directory'); # Initialize button for selecting the destination directory self.sourcePath = QLineEdit(''); # Initialize entry widget that will display the source directory path self.destPath = QLineEdit(''); # Initialize entry widget that will display the destination directory path self.sourceSet = indicator(); # Initialize an indictor that will appear when the source path is set self.destSet = indicator(); # Initialize an indictor that will appear when the destination path is set self.sourcePath.setEnabled( False ); # Disable the sourcePath widget; that way no one can manually edit it self.destPath.setEnabled( False ); # Disable the destPath widget; that way no one can manually edit it self.sourcePath.hide(); # Hide the source directory path self.destPath.hide(); # Hide the destination directory path self.sourceSet.hide(); # Hide the source directory indicator self.destSet.hide(); # Hide the destination directory indicator self.sourceButton.clicked.connect( self.select_source ); # Set method to run when the source button is clicked self.destButton.clicked.connect( self.select_dest ); # Set method to run when the destination button is clicked self.copyButton = QPushButton( 'Copy Files' ); # Create 'Copy Files' button self.copyButton.clicked.connect( self.copy_files ); # Set method to run when 'Copy Files' button is clicked self.copyButton.setEnabled(False); # Set enabled state to False; cannot click until after the source and destination directories set self.copySucces = indicator(); # Initialize an indictor that will appear when the copy complete successfuly self.copySucces.hide(); self.procButton = QPushButton( 'Process Files' ); # Create 'Process Files' button self.procButton.clicked.connect( self.proc_files ); # Set method to run when 'Process Files' button is clicked self.procButton.setEnabled(False); # Set enabled state to False; cannot click until after 'Copy Files' completes self.procSucces = indicator(); # Initialize an indictor that will appear when the processing complete successfuly self.procSucces.hide(); self.genButton = QPushButton( 'Generate Sounding' ); # Create 'Generate Sounding' button self.genButton.clicked.connect( self.gen_sounding ); # Set method to run when 'Generate Sounding' button is clicked self.genButton.setEnabled(False); # Set enabled state to False; cannot click until after 'Process Files' completes self.genSucces = indicator(); # Initialize an indictor that will appear when the sounding generation complete successfuly self.genSucces.hide(); self.uploadButton = QPushButton( 'FTP Upload' ); # Create 'FTP Upload' button self.uploadButton.clicked.connect( self.ftp_upload ); # Set method to run when 'FTP Upload' button is clicked self.uploadButton.setEnabled(False); # Set enabled state to False; cannot click until after 'Generate Sounding' completes self.uploadSucces = indicator(); # Initialize an indictor that will appear when the ftp upload complete successfuly self.uploadSucces.hide(); self.checkButton = QPushButton( 'Check website' ); # Create 'Check website' button self.checkButton.clicked.connect( self.check_site ); # Set method to run when 'Check website' button is clicked self.checkButton.setEnabled(False); # Set enabled state to False; cannot click until after 'FTP Upload' completes self.resetButton = QPushButton( 'Reset' ); # Create 'Check website' button self.resetButton.clicked.connect( self.reset_values ); # Set method to run when 'Check website' button is clicked versionLabel = QLabel( 'version: {}'.format(__version__) ); # Version label versionLabel.setAlignment( Qt.AlignHCenter ); # Set alignment to center log_handler = QLogger( ); # Initialize a QLogger logging.Handler object logging.getLogger('Meso1819').addHandler( log_handler ); # Get the Meso1819 root logger and add the handler to it grid = QGridLayout(); # Initialize grid layout grid.setSpacing(10); # Set spacing to 10 for i in range(4): grid.setColumnStretch(i, 0); # Set column stretch for ith column grid.setColumnMinimumWidth(i, 60); # Set column min width for ith column grid.setColumnStretch(4, 0); # Set column stretch for 5th column grid.setColumnMinimumWidth(4, 20); # Set column min width for 5th column grid.setRowStretch(1, 0); # Set column stretch for 5th column grid.setRowStretch(3, 0); # Set column stretch for 5th column grid.setRowMinimumHeight(1, 25); # Set column min width for 5th column grid.setRowMinimumHeight(3, 25); # Set column min width for 5th column grid.addWidget( self.sourceButton, 0, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( self.sourceSet, 0, 4, 1, 1 ); # Place a widget in the grid grid.addWidget( self.sourcePath, 1, 0, 1, 5 ); # Place a widget in the grid grid.addWidget( self.destButton, 2, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( self.destSet, 2, 4, 1, 1 ); # Place a widget in the grid grid.addWidget( self.destPath, 3, 0, 1, 5 ); # Place a widget in the grid grid.addWidget( self.iopLabel, 4, 0, 1, 2 ); # Place a widget in the grid grid.addWidget( self.iopName, 5, 0, 1, 2 ); # Place a widget in the grid grid.addWidget( self.stationLabel, 4, 2, 1, 2 ); # Place a widget in the grid grid.addWidget( self.stationName, 5, 2, 1, 2 ); # Place a widget in the grid grid.addWidget( self.dateFrame, 6, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( self.copyButton, 7, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( self.copySucces, 7, 4, 1, 1 ); # Place a widget in the grid grid.addWidget( self.procButton, 8, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( self.procSucces, 8, 4, 1, 1 ); # Place a widget in the grid grid.addWidget( self.genButton, 9, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( self.genSucces, 9, 4, 1, 1 ); # Place a widget in the grid grid.addWidget( self.uploadButton, 10, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( self.uploadSucces, 10, 4, 1, 1 ); # Place a widget in the grid grid.addWidget( self.checkButton, 11, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( self.resetButton, 12, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( log_handler.frame, 0, 6, 13, 1); grid.addWidget( versionLabel, 20, 0, 1, 7) centralWidget = QWidget(); # Create a main widget centralWidget.setLayout( grid ); # Set the main widget's layout to the grid self.setCentralWidget(centralWidget); # Set the central widget of the base class to the main widget self.show( ); # Show the main widget
def initUI(self): """Met en place les éléments de l'interface.""" # -+++++++------------------- main window -------------------+++++++- # self.setWindowTitle(u"Encodage / Décodage de Huffman") self.centerAndResize() centralwidget = QWidget(self) mainGrid = QGridLayout(centralwidget) mainGrid.setColumnMinimumWidth(0, 450) # -+++++++------------------ groupe analyse -----------------+++++++- # analysGroup = QGroupBox(u"Analyse", centralwidget) self.analysGrid = QGridLayout(analysGroup) # ----------- groupe de la table des codes ---------- # codeTableGroup = QGroupBox(u"Table des codes", analysGroup) codeTableGrid = QGridLayout(codeTableGroup) # un tableau pour les codes self.codesTableModel = MyTableModel() self.codesTable = QTableView(codeTableGroup) self.codesTable.setModel(self.codesTableModel) self.codesTable.setFont(QFont("Mono", 8)) self.codesTable.resizeColumnsToContents() self.codesTable.setSortingEnabled(True) codeTableGrid.addWidget(self.codesTable, 0, 0, 1, 1) self.analysGrid.addWidget(codeTableGroup, 1, 0, 1, 1) # ----------- label du ratio de compression ---------- # self.ratioLab = QLabel(u"Ratio de compression: ", analysGroup) font = QFont() font.setBold(True) font.setWeight(75) font.setKerning(True) self.ratioLab.setFont(font) self.analysGrid.addWidget(self.ratioLab, 2, 0, 1, 1) # -+++++++-------- groupe de la table de comparaison --------+++++++- # self.compGroup = QGroupBox(analysGroup) self.compGroup.setTitle(u"Comparaisons") compGrid = QGridLayout(self.compGroup) # un tableau pour le ratio self.compTable = QTableWidget(self.compGroup) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.compTable.sizePolicy().hasHeightForWidth()) self.compTable.setSizePolicy(sizePolicy) self.compTable.setBaseSize(QSize(0, 0)) font = QFont() font.setWeight(50) self.compTable.setFont(font) self.compTable.setEditTriggers(QAbstractItemView.NoEditTriggers) self.compTable.setShowGrid(True) self.compTable.setGridStyle(Qt.SolidLine) # lignes / colonnes self.compTable.setColumnCount(2) self.compTable.setRowCount(3) self.compTable.setVerticalHeaderItem(0, QTableWidgetItem("Taille (bits)")) self.compTable.setVerticalHeaderItem(1, QTableWidgetItem("Entropie")) self.compTable.setVerticalHeaderItem(2, QTableWidgetItem("Taille moy. (bits)")) for i in range(2): self.compTable.verticalHeaderItem(i).setTextAlignment( Qt.AlignRight) self.compTable.setHorizontalHeaderItem(0, QTableWidgetItem("ASCII")) self.compTable.setHorizontalHeaderItem(1, QTableWidgetItem("Huffman")) # nom des items self.compTabASCIIMem = QTableWidgetItem() self.compTable.setItem(0, 0, self.compTabASCIIMem) self.compTabASCIIEnt = QTableWidgetItem() self.compTable.setItem(1, 0, self.compTabASCIIEnt) self.compTabASCIIAvg = QTableWidgetItem() self.compTable.setItem(2, 0, self.compTabASCIIAvg) self.compTabHuffMem = QTableWidgetItem() self.compTable.setItem(0, 1, self.compTabHuffMem) self.compTabHuffEnt = QTableWidgetItem() self.compTable.setItem(1, 1, self.compTabHuffEnt) self.compTabHuffAvg = QTableWidgetItem() self.compTable.setItem(2, 1, self.compTabHuffAvg) # parem du tableau self.compTable.horizontalHeader().setCascadingSectionResizes(False) self.compTable.verticalHeader().setVisible(True) font = QFont("Mono", 8) self.compTable.setFont(font) compGrid.addWidget(self.compTable, 1, 0, 1, 1) self.analysGrid.addWidget(self.compGroup, 0, 0, 1, 1) mainGrid.addWidget(analysGroup, 0, 1, 1, 1) # -+++++++----------------- groupe du texte -----------------+++++++- # groupBox = QGroupBox(u"Texte", centralwidget) textGrid = QGridLayout(groupBox) # -+++++++------------- groupe du texte original ------------+++++++- # orgTextGroup = QGroupBox(u"Texte original (Ctrl+T)", groupBox) orgTextGrid = QGridLayout(orgTextGroup) self.orgText = QTextEdit(orgTextGroup) self.orgText.setPalette(self.defaultPalette) orgTextGrid.addWidget(self.orgText, 0, 0, 1, 1) textGrid.addWidget(orgTextGroup, 0, 0, 1, 2) # -+++++++------------ groupe du texte compressé ------------+++++++- # compressedTextGroup = QGroupBox(u"Texte compressé (Ctrl+H)", groupBox) compressedTextGrid = QGridLayout(compressedTextGroup) self.compressedText = QTextEdit(compressedTextGroup) self.compressedText.setPalette(self.defaultPalette) compressedTextGrid.addWidget(self.compressedText, 0, 0, 1, 1) textGrid.addWidget(compressedTextGroup, 1, 0, 1, 2) # -+++++++------------ groupe pour le texte ascii -----------+++++++- # asciiTextGroup = QGroupBox(u"Texte ASCII", groupBox) asciiTextGrid = QGridLayout(asciiTextGroup) self.asciiText = QTextBrowser(asciiTextGroup) self.asciiText.setPalette(self.defaultPalette) asciiTextGrid.addWidget(self.asciiText, 0, 0, 1, 1) textGrid.addWidget(asciiTextGroup, 2, 0, 1, 2) # -+++++++-------------------- label de log -----------------+++++++- # self.logLab = QLabel(analysGroup) textGrid.addWidget(self.logLab, 3, 0, 1, 2) # -+++++++----------- bouton pour encoder le texte ----------+++++++- # self.encodeBut = QPushButton(groupBox) self.encodeBut.setStatusTip( u"Cliquez sur ce bouton pour encoder le texte original.") self.encodeBut.setText(u"ENCODER") self.encodeBut.clicked.connect(self.encode_text) textGrid.addWidget(self.encodeBut, 4, 0, 1, 1) # -+++++++----------- bouton pour décoder le texte ----------+++++++- # self.decodeBut = QPushButton(groupBox) self.decodeBut.setStatusTip( u"Cliquez sur ce bouton pour décoder le texte compressé.") self.decodeBut.setText(u"DÉCODER") self.decodeBut.clicked.connect(self.decode_text) textGrid.addWidget(self.decodeBut, 4, 1, 1, 1) mainGrid.addWidget(groupBox, 0, 0, 1, 1) self.setCentralWidget(centralwidget) # -+++++++--------------- une barre de statut ---------------+++++++- # self.setStatusBar(QStatusBar(self)) # -+++++++--------------------- le menu ---------------------+++++++- # self.fileMenu = QMenu(u"Fichier") self.fileMenu.addAction(u"Importer un texte...", self.open_text) self.fileMenu.addAction( u"Importer un texte encodé...", lambda: self.open_text(True)) self.fileMenu.addAction(u"Importer un dictionnaire...", self.open_dict) self.fileMenu.addAction(u"Enregistrer le dictionnaire...", self.save_dict) self.fileMenu.addAction(u"Quitter", self.close) self.menuBar().addMenu(self.fileMenu) QMetaObject.connectSlotsByName(self)