def __init__(self, parent=None): super(QtGUI, self).__init__(parent) # Create subcomponents of the GUI self.tab_container = QTabWidget() self.qt_printer = QtPrinter() self.qt_table_printer = QtTablePrinter() self.user_input = QCustomLineEdit() self.completion_model = QStringListModel() self.labels = [QLineEdit("None"), QLineEdit("None"), QLineEdit("None")] self.ground_truth = QLabel() self.row_label = QLabel() self.filter_label = QLabel() completer = QCompleter() completer.setModel(self.completion_model) self.user_input.setCompleter(completer) self.variable_history = QtTablePrinter() # Select global configs QTabManager.setParentWidget(self.tab_container) Window.selectWindowType(QtWindow) PropertyEditor.property_editor_class = QtPropertyEditor Printer.selectPrinter(self.qt_printer) TablePrinter.selectPrinter(self.qt_table_printer) # Get screen resolution: app = QApplication.instance() screen_resolution = app.desktop().screenGeometry() # Add ref labels self.ref_labels = [] for ref_label in ['Reference', 'Row Label', 'Filter']: self.ref_labels.append( QLabel('<span style=" font-size: ' + str(self.label_font) + 'pt; font-weight:600;">' + ref_label + ': </span>')) self.ref_labels[-1].setMinimumHeight(0.02 * screen_resolution.height()) # Font for user input: f = self.user_input.font() f.setPointSize(self.user_input_font) # sets the size to 27 self.user_input.setFont(f) f.setPointSize(self.label_font) for label in self.labels: label.setFont(f) label.setMinimumHeight(0.02 * screen_resolution.height()) label.setReadOnly(True) # Size self.user_input.setMinimumHeight(0.02 * screen_resolution.height()) self.qt_printer.text_box.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding) self.tab_container.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.qt_table_printer.table_widget.setSizePolicy( QSizePolicy.MinimumExpanding, QSizePolicy.Expanding) self.variable_history.table_widget.setSizePolicy( QSizePolicy.Minimum, QSizePolicy.Minimum) self.ground_truth.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum) # Layout layout = QVBoxLayout() # Add gt, rowlabels, filter hlayout = QHBoxLayout() for i in range(3): hlayout.addWidget(self.ref_labels[i]) hlayout.addWidget(self.labels[i]) # Add tabs for table and past history self.right_tab_widget = QTabWidget() self.right_tab_widget.addTab(self.qt_table_printer.table_widget, "Data Summary") self.right_tab_widget.addTab(self.variable_history.table_widget, "Past variables") # Add separate splitter for table and property editor h_splitter = QSplitter(Qt.Vertical) h_splitter.addWidget(self.right_tab_widget) h_splitter.setStretchFactor(0, 2) PropertyEditor.parent_widget = h_splitter # Add chat,window, tab splitter = QSplitter(Qt.Horizontal) splitter.addWidget(self.qt_printer.text_box) splitter.addWidget(self.tab_container) splitter.addWidget(h_splitter) splitter.setStretchFactor(0, 0) splitter.setStretchFactor(1, 2) splitter.setStretchFactor(2, 0) splitter.setSizes([1, 1000, 500]) # Final layout.addLayout(hlayout) layout.addWidget(splitter) layout.addWidget(self.user_input) self.setLayout(layout) # Connections self.qt_table_printer.table_widget.itemDoubleClicked.connect( self.double_click_table_cell)
Main executable that calls alpha with specified version and facilitates communication between user and alpha through command line """ import re from Alfarvis import create_alpha_module_dictionary from Alfarvis.printers import Printer from Alfarvis.printers.kernel_printer import KernelPrinter from Alfarvis.windows import Window from Alfarvis.windows.regular_window import RegularWindow if __name__ == "__main__": # pragma: no cover # Create alpha module dictionary alpha_module_dictionary = create_alpha_module_dictionary() Printer.selectPrinter(KernelPrinter()) Window.selectWindowType(RegularWindow) ThreadPoolManager.initialize() print("Input a text to receive response from Alfarvis") print("Enter Bye to close the program") #print(">", end=" ") input_text = '' pattern = re.compile('(L|l)oad (A|a)l(f|ph)a\s*\w*\s*(\d+.?\d*)\w*') latest_version = max(alpha_module_dictionary.keys()) alpha = alpha_module_dictionary[latest_version]() while (input_text != 'Bye' and input_text != 'bye'): try: input_text = input('> ') match_out = pattern.search(input_text) if match_out: print(match_out.groupdict) version = float(match_out.group(4))