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()
Example #3
0
  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