def __init__(self, user_display_name, user_profile, *args, **kwargs): super().__init__(*args, **kwargs) assert isinstance(user_profile, UserProfile) # Initialize the user management. self._user_display_name = user_display_name db_user = user_profile["database_user_name"] db_location = user_profile["database_location"] self._user_management = UserManagement(db_user, db_location) # Create the task box. self._task_list = TaskList() self._task_list.load_open_tasks(self._user_management) self._task_list.delete.connect(self._on_delete_task) self._task_list.start.connect(self._on_start_task) self._task_list.stop.connect(self._on_stop_task) self._task_list.done.connect(self._on_task_done) # Create the tracking controls. self._tracking_controls = TrackingControls() self._tracking_controls.create_task.connect(self._on_create_task) self._tracking_controls.general_work.connect(self._on_general_work) self._tracking_controls.pause.connect(self._on_pause) self._tracking_controls.end_of_work.connect(self._on_end_of_work) # Create the layout. layout = QVBoxLayout() layout.setAlignment(Qt.AlignCenter) self.setLayout(layout) layout.addWidget(self._tracking_controls) layout.addWidget(self._task_list)
class AboutDialog(QDialog): """Contains the necessary elements to show the about dialog.""" def __init__(self, parent=None): """Display a dialog that shows application information.""" super(AboutDialog, self).__init__(parent) self.setWindowTitle('About') help_icon = utilities.resource_filename('mosaic.images', 'md_help.png') self.setWindowIcon(QIcon(help_icon)) self.resize(300, 200) author = QLabel('Created by Mandeep') author.setAlignment(Qt.AlignCenter) icons = QLabel('Material design icons created by Google') icons.setAlignment(Qt.AlignCenter) github = QLabel('GitHub: mandeep') github.setAlignment(Qt.AlignCenter) self.layout = QVBoxLayout() self.layout.setAlignment(Qt.AlignVCenter) self.layout.addWidget(author) self.layout.addWidget(icons) self.layout.addWidget(github) self.setLayout(self.layout)
class PlotTab(QScrollArea): ''' InfoWindow tab for plots. ''' def __init__(self): super(PlotTab, self).__init__() self.layout = QVBoxLayout() container = QWidget() container.setLayout(self.layout) self.layout.setAlignment(Qt.AlignTop) self.setWidget(container) self.setWidgetResizable(True) self.plots = dict() def update_plots(self, data, sender): ''' Update plots in this tab using incoming data. ''' for fig, figdata in data.items(): # First extract plot data when present x, y = figdata.pop('x', None), figdata.pop('y', None) plot = self.plots.get((sender, fig)) if not plot: # If plot doesn't exist yet, create it plot = Plot(self, **figdata) self.plots[(sender, fig)] = plot self.layout.addWidget(plot) elif figdata: # When passed, apply updated figure settings plot.set(**figdata) if x is not None and y is not None: plot.update_data(x, y)
def __init__(self, parent=None): """Initiate the abstract widget that is displayed in the preferences dialog.""" super(Playback, self).__init__(parent) self.user_config_file = os.path.join(AppDirs('mosaic', 'Mandeep').user_config_dir, 'settings.toml') with open(self.user_config_file) as conffile: config = toml.load(conffile) playback_config = QGroupBox('Playback Configuration') playback_config_layout = QVBoxLayout() playback_config_layout.setAlignment(Qt.AlignTop) self.cover_art_playback = QCheckBox('Cover Art Playback') self.playlist_save_checkbox = QCheckBox('Save Playlist on Close') playback_config_layout.addWidget(self.cover_art_playback) playback_config_layout.addWidget(self.playlist_save_checkbox) playback_config.setLayout(playback_config_layout) main_layout = QVBoxLayout() main_layout.addWidget(playback_config) self.setLayout(main_layout) self.check_playback_setting(config) self.check_playlist_save(config) self.cover_art_playback.clicked.connect(lambda: self.cover_art_playback_setting(config)) self.playlist_save_checkbox.clicked.connect(lambda: self.playlist_save_setting(config))
def init_ui(self): """Initialize all GUI elements and show window.""" self.set_status('Welcome') self.create_menus() canvas_box = self.create_canvas() sequence_form = self.create_sequence_form() # let's have the sequence form over the canvas. vbox = QVBoxLayout() vbox.addLayout(sequence_form, stretch=0) vbox.setAlignment(Qt.AlignTop) vbox.addLayout(canvas_box, stretch=1) splitter = QSplitter(Qt.Horizontal) options = OptionPanel(self.args) for layout in [vbox, options]: widget = QWidget() widget.setLayout(layout) splitter.addWidget(widget) self.setCentralWidget(splitter) self.resize(600, 600) self.setWindowTitle('Dotplot') self.show()
def inut_ui(self, name, args): vl = QVBoxLayout() lbl = QLabel(self) lbl.setAlignment(QtCore.Qt.AlignCenter) lbl.setText(name) vl.addWidget(lbl) hl = QHBoxLayout() il = QVBoxLayout() il.setAlignment(QtCore.Qt.AlignTop) for arg in args: if arg['io'] == 'i': inp_lbl = QLabel(self) self._inputs[arg['name']] = inp_lbl inp_lbl.setText(arg['name']) il.addWidget(inp_lbl) ol = QVBoxLayout() ol.setAlignment(QtCore.Qt.AlignTop) for arg in args: if arg['io'] == 'o': out_lbl = QLabel(self) self._outputs[arg['name']] = out_lbl out_lbl.setAlignment(QtCore.Qt.AlignRight) out_lbl.setText(arg['name']) ol.addWidget(out_lbl) hl.addLayout(il) hl.addLayout(ol) vl.addLayout(hl) self.setLayout(vl)
class SImageView(QMainWindow): """docstring for SImageBrower""" def __init__(self, imageBrower, title = None): super(SImageView, self).__init__() self.setWindowTitle(title if title != None else "形象编辑器") self.setWindowIcon(QIcon("./resource/test.ico")) self.mainWidget = QWidget() self.mainContainer = QVBoxLayout() self.mainContainer.setAlignment(Qt.AlignLeft) self.setCentralWidget(self.mainWidget) self.mainWidget.setLayout(self.mainContainer) self.imageBrower = imageBrower self.mainContainer.addWidget(imageBrower) self.createToolBar() def createToolBar(self): self.toolBar = self.addToolBar("形象编辑") self.openAct = QAction(QIcon('./resource/open.png'), "&Open...", self, shortcut=QKeySequence.Open, statusTip="Open an image folder", triggered=self.open) self.toolBar.addAction(self.openAct) def open(self): imageDir = QFileDialog.getExistingDirectory(self) self.imageBrower.resetImageDir(imageDir)
def __init__(self): super().__init__() self.setTitle(_('Scores for correct and incorrect answers')) self.setSubTitle(_('Enter the scores of correct and incorrect ' 'answers. The program will compute scores based ' 'on them. Setting these scores is optional.')) form_widget = QWidget(parent=self) table_widget = QWidget(parent=self) main_layout = QVBoxLayout(self) form_layout = QFormLayout(form_widget) table_layout = QVBoxLayout(table_widget) self.setLayout(main_layout) form_widget.setLayout(form_layout) table_widget.setLayout(table_layout) main_layout.addWidget(form_widget) main_layout.addWidget(table_widget) main_layout.setAlignment(table_widget, Qt.AlignHCenter) self.combo = widgets.CustomComboBox(parent=self) self.combo.set_items([ _('No scores'), _('Same score for all the questions'), _('Base score plus per-question weight'), ]) self.combo.currentIndexChanged.connect(self._update_combo) self.correct_score = widgets.InputScore(is_positive=True) correct_score_label = QLabel(_('Score for correct answers')) incorrect_score_label = QLabel(_('Score for incorrect answers')) blank_score_label = QLabel(_('Score for blank answers')) self.incorrect_score = widgets.InputScore(is_positive=False) self.blank_score = widgets.InputScore(is_positive=False) self.button_reset = QPushButton(_('Reset question weights')) button_defaults = QPushButton(_('Compute default scores')) self.weights_table = widgets.CustomTableView() weights_table_label = QLabel(_('Per-question score weights:')) form_layout.addRow(self.combo) form_layout.addRow(correct_score_label, self.correct_score) form_layout.addRow(incorrect_score_label, self.incorrect_score) form_layout.addRow(blank_score_label, self.blank_score) table_layout.addWidget(weights_table_label) table_layout.addWidget(self.weights_table) table_layout.addWidget(self.button_reset) table_layout.addWidget(button_defaults) table_layout.setAlignment(weights_table_label, Qt.AlignHCenter) table_layout.setAlignment(self.weights_table, Qt.AlignHCenter) table_layout.setAlignment(self.button_reset, Qt.AlignHCenter) table_layout.setAlignment(button_defaults, Qt.AlignHCenter) self.button_reset.clicked.connect(self._reset_weights) button_defaults.clicked.connect(self._compute_default_values) self.base_score_widgets = [ self.correct_score, correct_score_label, self.incorrect_score, incorrect_score_label, self.blank_score, blank_score_label, button_defaults, ] self.weights_widgets = [ self.weights_table, weights_table_label, ] self.current_mode = None
class AnimationPanel(QWidget): """docstring for AnimationPanel""" rows = [] views = [] currRow = 0 currCol = 0 maxRow = 4 maxCol = 4 isSetBackground = False def __init__(self): super(AnimationPanel, self).__init__() self.setFixedSize(480,600) self.container = QVBoxLayout() self.setLayout(self.container) self.container.setSpacing(32) self.container.setAlignment(Qt.AlignTop) for i in range(0,self.maxRow): self.addRow() def addRow(self): row = QHBoxLayout() row.setSpacing(64) row.setAlignment(Qt.AlignLeft) self.rows.append(row) self.container.addLayout(row) def setBackGround(self,backColor): if self.isSetBackground : return palette = QPalette() palette.setColor(QPalette.Background,backColor) self.setAutoFillBackground(True) self.setPalette(palette); self.isSetBackground = True def closeAll(self): for i in range(0,self.maxRow): row = self.rows[i] for j in range(i*self.maxCol,min(i*self.maxCol+4,len(self.views))): row.removeWidget(self.views[j]) self.views[j].close() self.views = [] self.isSetBackground = False self.currRow = 0 self.currCol = 0 def addAnimationView(self,animationView): self.views.append(animationView) if self.currRow == self.maxRow: self.addRow() self.maxRow += 1 self.rows[self.currRow].addWidget(animationView) animationView.createAnimation() self.currRow = self.currRow+1 if self.currCol == self.maxCol-1 else self.currRow self.currCol = 0 if self.currCol == self.maxCol-1 else self.currCol+1
def __init__(self, parent=None): super(Example, self).__init__(parent) QApplication.setStyle(QStyleFactory.create('Fusion')) # -------------- QCOMBOBOX ---------------------- cbx = QComboBox() # agregar lista de nombres de estilos disponibles cbx.addItems(QStyleFactory.keys()) # responder al evento cambio de texto cbx.currentTextChanged.connect(self.textChanged) # seleccionar el ultimo elemento cbx.setItemText(4, 'Fusion') # -------------- QLISTWIDGET --------------------- items = ['Ubuntu', 'Linux', 'Mac OS', 'Windows', 'Fedora', 'Chrome OS', 'Android', 'Windows Phone'] self.lv = QListWidget() self.lv.addItems(items) self.lv.itemSelectionChanged.connect(self.itemChanged) # -------------- QTABLEWIDGET -------------------- self.table = QTableWidget(10, 3) # establecer nombre de cabecera de las columnas self.table.setHorizontalHeaderLabels(['Nombre', 'Edad', 'Nacionalidad']) # evento producido cuando cambia el elemento seleccionado self.table.itemSelectionChanged.connect(self.tableItemChanged) # alternar color de fila self.table.setAlternatingRowColors(True) # seleccionar solo filas self.table.setSelectionBehavior(QTableWidget.SelectRows) # usar seleccion simple, una fila a la vez self.table.setSelectionMode(QTableWidget.SingleSelection) table_data = [ ("Alice", 15, "Panama"), ("Dana", 25, "Chile"), ("Fernada", 18, "Ecuador") ] # agregar cada uno de los elementos al QTableWidget for i, (name, age, city) in enumerate(table_data): self.table.setItem(i, 0, QTableWidgetItem(name)) self.table.setItem(i, 1, QTableWidgetItem(str(age))) self.table.setItem(i, 2, QTableWidgetItem(city)) vbx = QVBoxLayout() vbx.addWidget(QPushButton('Tutoriales PyQT-5')) vbx.setAlignment(Qt.AlignTop) vbx.addWidget(cbx) vbx.addWidget(self.lv) vbx.addWidget(self.table) self.setWindowTitle("Items View") self.resize(362, 320) self.setLayout(vbx)
class PlotTab(QScrollArea): def __init__(self): super(PlotTab, self).__init__() self.layout = QVBoxLayout() container = QWidget() container.setLayout(self.layout) self.layout.setAlignment(Qt.AlignTop) self.setWidget(container) self.setWidgetResizable(True) def addPlot(self): self.layout.addWidget(Plot(self))
def display_content(self): # layout_main = QVBoxLayout() layout_main.setAlignment(Qt.AlignCenter) self.setLayout(layout_main) self.layouts.append(layout_main) # fonts = QFontDatabase() fonts.addApplicationFont('Fonts/Raleway/Raleway-ExtraLight.ttf') fonts.addApplicationFont('Fonts/OpenSans/OpenSans-Light.ttf') # title = QLabel("Eight Puzzle") title.setStyleSheet('font-size: 52px; color: #CECFD4;') title.setFont(QFont('Raleway')) layout_main.addWidget(title) layout_main.addSpacerItem(QSpacerItem(0, 12)) # layout_tiles = QGridLayout() layout_tiles.setAlignment(Qt.AlignCenter) layout_main.addLayout(layout_tiles) for index in range(9): tile = QPushButton(str(self.puzzle.state[index])) tile.setStyleSheet('background-color: #879AA4;' 'color: #CECFD4; font-size: 32px;') tile.setFont(QFont('Open Sans')) tile.setFixedSize(75, 75) tile.setEnabled(False) tile.setFocusPolicy(Qt.NoFocus) layout_tiles.addWidget(tile, index / 3, index % 3) if self.puzzle.state[index] is '0': tile.setVisible(False) self.tiles.append(tile) self.layouts.append(layout_tiles) layout_main.addSpacerItem(QSpacerItem(0, 25)) # layout_buttons = QGridLayout() layout_buttons.setAlignment(Qt.AlignCenter) layout_main.addLayout(layout_buttons) for index in range(3): button = QPushButton(['Shuffle', 'Solve', 'Quit'][index]) button.setStyleSheet('background-color: #CECFD4;' 'color: #363B57; font-size: 18px;') button.setFont(QFont('Raleway')) button.setFixedSize(90, 40) button.setFocusPolicy(Qt.NoFocus) layout_buttons.addWidget(button, 0, index) self.buttons.append(button) self.layouts.append(layout_buttons) layout_main.addSpacerItem(QSpacerItem(0, 10))
def init_ui(self, title): self.setWindowTitle(title) btn_close = create_button('Close', self.close) buttons = QHBoxLayout() buttons.addWidget(btn_close) buttons.setAlignment(Qt.AlignBottom) body = QVBoxLayout() body.setAlignment(Qt.AlignTop) header = QLabel( 'If you choose an automatic (scheduled) mode ' 'the "ctrl+n" shortcut and menu checkbox for ' 'quick toggle will switch between the manual ' 'and automatic mode (when used for the first ' 'time).' ) header.setWordWrap(True) mode_switches = QHBoxLayout() mode_switches.addWidget(QLabel('Mode:')) self.manual = create_button('Manual', self.on_set_manual) self.auto = create_button('Automatic', self.on_set_automatic) mode_switches.addWidget(self.manual) mode_switches.addWidget(self.auto) time_controls = QHBoxLayout() time_controls.setAlignment(Qt.AlignTop) start_at = TimeEdit(self, self.settings['start_at'], 'From', self.start_update) end_at = TimeEdit(self, self.settings['end_at'], 'To', self.end_update) time_controls.addWidget(start_at) time_controls.addWidget(end_at) self.time_controls = time_controls self.set_mode(self.settings['mode'], False) body.addWidget(header) body.addStretch(1) body.addLayout(mode_switches) body.addLayout(time_controls) body.addStretch(1) body.addLayout(buttons) self.setLayout(body) self.setGeometry(300, 300, 470, 255) self.show()
def __init__(self, listing, student_tabs): super().__init__(student_tabs.tabs) self.listing = listing layout = QVBoxLayout() self.setLayout(layout) self.table = QTableView() self.table.setMinimumWidth(500) self.table.setMinimumHeight(300) layout.addWidget(self.table) self.model = StudentsTableModel(listing, GroupWidget._COLUMN_MAP, self) self.table.setModel(self.model) self.table.setSelectionBehavior(QTableView.SelectRows) layout.setAlignment(self.table, Qt.AlignHCenter) self._resize_table()
class EdgeInfo(AbstractInfo): """ This class implements the information box for generic edges. """ def __init__(self, mainwindow, parent=None): """ Initialize the generic edge information box. :type mainwindow: MainWindow :type parent: QWidget """ super().__init__(mainwindow, parent) self.h1 = Header('General', self) self.typeKey = Key('Type', self) self.typeField = Str(self) self.typeField.setReadOnly(True) self.sourceKey = Key('Source', self) self.sourceField = Str(self) self.sourceField.setReadOnly(True) self.targetKey = Key('Target', self) self.targetField = Str(self) self.targetField.setReadOnly(True) self.generalLayout = QFormLayout() self.generalLayout.setSpacing(0) self.generalLayout.addRow(self.typeKey, self.typeField) self.generalLayout.addRow(self.sourceKey, self.sourceField) self.generalLayout.addRow(self.targetKey, self.targetField) self.mainLayout = QVBoxLayout(self) self.mainLayout.setAlignment(Qt.AlignTop) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.setSpacing(0) self.mainLayout.addWidget(self.h1) self.mainLayout.addLayout(self.generalLayout) def updateData(self, edge): """ Fetch new information and fill the widget with data. :type edge: AbstractEdge """ self.sourceField.setValue(edge.source.id) self.targetField.setValue(edge.target.id) self.typeField.setValue(edge.shortname.capitalize()) self.typeField.home(True) self.typeField.deselect()
def __init__(self, student_list, column_map, parent=None): super().__init__(parent) self.listing = students.GroupListing(None, student_list) self.column_map = column_map layout = QVBoxLayout() self.setLayout(layout) self.table = QTableView() self.table.setMinimumWidth(600) self.table.setMinimumHeight(300) layout.addWidget(self.table) self.model = StudentsTableModel(self.listing, column_map, self) self.table.setModel(self.model) self.table.setSelectionMode(QTableView.NoSelection) layout.setAlignment(self.table, Qt.AlignHCenter) self._resize_table()
def __init__(self, parent=None): """ Initialize the dialog. :type parent: QWidget """ super().__init__(parent) message = '{TITLE}<br/>' \ 'Version: {VERSION}<br/>' \ 'Author: {AUTHOR}<br/>' \ 'Copyright: © 2016 {AUTHOR}<br/>' \ 'License: {LICENSE}<br/>' \ '<br/>' \ '<a href="{GRAPHOL_HOME}" {STYLE}>Graphol</a> is developed by ' \ 'members of the DASI-lab group of the <a href="{DIAG_HOME}" {STYLE}>DIAG</a> ' \ 'at <a href="{SAPIENZA_HOME}" {STYLE}>Sapienza</a> University of Rome.'.format( TITLE=APPNAME, VERSION=VERSION, AUTHOR=AUTHOR, LICENSE=LICENSE, GRAPHOL_HOME=GRAPHOL_HOME, DIAG_HOME=DIAG_HOME, SAPIENZA_HOME=SAPIENZA_HOME, STYLE='style="text-decoration:none;"') self.icon = QLabel(self) self.icon.setPixmap(QPixmap(':/images/eddy-smile')) self.text = QLabel(message, self) self.text.setWordWrap(True) self.text.setOpenExternalLinks(True) self.text.setAlignment(Qt.AlignLeft) self.text.setFixedWidth(340) leftLayout = QVBoxLayout() leftLayout.addWidget(self.icon) leftLayout.setAlignment(Qt.AlignTop|Qt.AlignLeft) leftLayout.setContentsMargins(0, 0, 0, 0) rightLayout = QVBoxLayout() rightLayout.addWidget(self.text) rightLayout.setAlignment(Qt.AlignTop | Qt.AlignLeft) rightLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout = QHBoxLayout(self) self.mainLayout.addLayout(leftLayout) self.mainLayout.addLayout(rightLayout) self.setFixedWidth(520) self.setFixedHeight(self.sizeHint().height()) self.setModal(True) self.setWindowIcon(QIcon(':/images/eddy')) self.setWindowTitle('About {}'.format(APPNAME))
def __init__(self, label, widget, initially_visible=True, parent=None): super(PopupPanel, self).__init__(parent) layout = QVBoxLayout() layout.setAlignment(Qt.AlignTop) layout.setSpacing(0) layout.addWidget(ToggleWidgetLabel(label, widget, initially_visible)) # Tempting to call widget.setVisible(initially_visible) but this would # lead to the widget appearing instantly, most likely a top-level # window. if not initially_visible: widget.setVisible(False) container = PanelContainer(widget) container.setContentsMargins(0, 0, 0, 0) layout.addWidget(container) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout)
def init_ui(self, title): self.setWindowTitle(title) btn_close = create_button('Close', self.close) buttons = QHBoxLayout() buttons.addWidget(btn_close) buttons.setAlignment(Qt.AlignBottom) body = QVBoxLayout() body.setAlignment(Qt.AlignTop) header = QLabel(_( 'Select which parts of Anki should be displayed ' 'in eye-friendly, dark colors.\n\n' 'To disable all dialog windows, ' 'use the "Enable in dialogs" switch which is available in menu.' )) header.setAlignment(Qt.AlignCenter) stylers = QVBoxLayout() stylers.setAlignment(Qt.AlignTop) for styler in sorted(self.all_stylers, key=lambda s: s.name): styler_checkbox = StylerCheckButton(self, styler) self.stylers_checkboxes.append(styler_checkbox) stylers.addWidget(styler_checkbox) self.stylers_layout = stylers checked_boxes = sum(1 for checkbox in self.stylers_checkboxes if checkbox.isChecked()) check_all = QCheckBox(_('Check/uncheck all'), self) check_all.setChecked(checked_boxes > len(self.stylers_checkboxes) / 2) check_all.stateChanged.connect(self.check_uncheck_all) body.addWidget(header) body.addWidget(check_all) body.addLayout(stylers) body.addStretch(1) body.addLayout(buttons) self.setLayout(body) self.setGeometry(300, 300, 350, 300) self.show()
def __init__(self, cellular_automaton): super().__init__() self.speed = DEFAULT_SIMULATION_SPEED self.cell_size = CELL_SIZE self.cellular_automaton = cellular_automaton self.num_of_cells_x = self.cellular_automaton.size_x self.num_of_cells_y = self.cellular_automaton.size_y self.run = False self.setWindowTitle('Cellular automaton') self.setToolTip('Select cell') self.start_btn = QPushButton('Start', self) self.start_btn.setToolTip('Start simulation') self.clear_btn = QPushButton('Clear', self) self.clear_btn.setToolTip('Clear board') self.start_btn.clicked.connect(self.toggle) self.clear_btn.clicked.connect(self.clean) self.timer = QTimer(self) self.timer.timeout.connect(self.paint_update) self.slider = QSlider(Qt.Horizontal, self) self.slider.setMinimum(MIN_SIMULATION_SPEED) self.slider.setMaximum(MAX_SIMULATION_SPEED) self.slider.setValue(DEFAULT_SIMULATION_SPEED) self.slider.setToolTip('Speed of simulation') self.slider.valueChanged.connect(self.set_value) btn_layout = QHBoxLayout() btn_layout.addWidget(self.start_btn) btn_layout.addWidget(self.clear_btn) layout = QVBoxLayout() layout.setAlignment(Qt.AlignBottom) layout.addLayout(btn_layout, Qt.AlignCenter) layout.addWidget(self.slider, Qt.AlignCenter) self.setLayout(layout) self.menu_bar = QMenuBar(self) self.add_menu_bar() self.margin_left = MARGIN self.margin_top = MARGIN self.resize(WINDOW_X_SIZE, WINDOW_Y_SIZE) self.setMinimumSize(WINDOW_X_SIZE, WINDOW_Y_SIZE) self.resizeEvent = self.on_resize
class NodeInfo(AbstractInfo): """ This class implements the information box for generic nodes. """ def __init__(self, mainwindow, parent=None): """ Initialize the generic node information box. :type mainwindow: MainWindow :type parent: QWidget """ super().__init__(mainwindow, parent) self.node = None self.idKey = Key('ID', self) self.idField = Str(self) self.idField.setReadOnly(True) self.identityKey = Key('Identity', self) self.identityField = Str(self) self.identityField.setReadOnly(True) self.nodePropHeader = Header('Node properties', self) self.nodePropLayout = QFormLayout() self.nodePropLayout.setSpacing(0) self.nodePropLayout.addRow(self.idKey, self.idField) self.nodePropLayout.addRow(self.identityKey, self.identityField) self.mainLayout = QVBoxLayout(self) self.mainLayout.setAlignment(Qt.AlignTop) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.setSpacing(0) self.mainLayout.addWidget(self.nodePropHeader) self.mainLayout.addLayout(self.nodePropLayout) def updateData(self, node): """ Fetch new information and fill the widget with data. :type node: AbstractNode """ self.idField.setValue(node.id) self.identityField.setValue(node.identity.value) self.node = node
class PlotTab(QScrollArea): def __init__(self): super(PlotTab, self).__init__() self.layout = QVBoxLayout() container = QWidget() container.setLayout(self.layout) self.layout.setAlignment(Qt.AlignTop) self.setWidget(container) self.setWidgetResizable(True) self.plots = dict() def update_plots(self, data, sender): for fig, (x, y, color) in data.items(): plot = self.plots.get((sender, fig)) if not plot: plot = Plot(self) self.plots[(sender, fig)] = plot self.layout.addWidget(plot) plot.update_data(x, y)
def __init__(self, *args, **kwargs): """ Load the user profiles and create the login controls. """ super().__init__(*args, **kwargs) # Load the user profile collection. try: self.user_profile_collection = UserProfileCollection.from_dict(global_settings["users"]) except KeyError: self.user_profile_collection = UserProfileCollection() # Create and set the widget layout. layout = QVBoxLayout() layout.setAlignment(Qt.AlignCenter) self.setLayout(layout) # Fill the select-user combobox with the loaded profile names. self.select_user_combobox = QComboBox() layout.addWidget(self.select_user_combobox) self.select_user_combobox.addItem("") names = self.user_profile_collection.names() names = [(name.lower(), name) for name in names] # convert to lower case for sorting for _, name in sorted(names): self.select_user_combobox.addItem(name) # Add the login button. self.login_btn = QPushButton(text="Login", enabled=False) layout.addWidget(self.login_btn) # Add the create-user link. txt = QLabel(text="<a href='#'>Create new user</a>") layout.addWidget(txt) txt.setContextMenuPolicy(Qt.PreventContextMenu) # Connect signals and slots. This must be done after initializing all class members. self.select_user_combobox.currentIndexChanged.connect(self.on_selection_changed) self.login_btn.clicked.connect(self.on_login) txt.linkActivated.connect(self.on_show_create_user_dialog)
def __init__(self, day): assert type(day) == int or type(day) == str super().__init__() self.isNull = str(day) == "0" dayLabel = QLabel("" if self.isNull else str(day)) mainLayout = QVBoxLayout() mainLayout.setAlignment(Qt.AlignCenter) mainLayout.setContentsMargins(0, 0, 0, 0) mainLayout.addWidget(dayLabel) eventsWidget = QWidget() eventsLayout = QVBoxLayout() eventsLayout.addWidget(Event("The Great Quux")) eventsLayout.addWidget(Event("Fedora 15 ate my dingoes baby")) eventsWidget.setLayout(eventsLayout) self.scrollArea = QScrollArea() self.scrollArea.setWidget(eventsWidget) self.scrollArea.setWidgetResizable(True) mainLayout.addWidget(self.scrollArea) backgroundColor = "#319973" if self.isNull else "#6ED5AF" scrollBarStyle = ("QScrollBar { background: #333333 }" "QScrollBar::handle { background: #636363 }" "QScrollBar::handle:hover { background: #737373 }" "QScrollBar::up-arrow, QScrollBar::down-arrow, " "QScrollBar::left-arrow, QScrollBar::right-arrow, " "QScrollBar::sub-line, QScrollBar::add-line { background: transparent }") self.defaultStylesheet = ("QWidget {{ background: {0}; font-size: 18px }}".format(backgroundColor) + scrollBarStyle) self.enteredStylesheet = "QWidget { background: #84FFD2; font-size: 18px }" + scrollBarStyle self.selectedStylesheet = "QWidget { background: #FFAAAA; font-size: 18px }" + scrollBarStyle self.setStyleSheet(self.defaultStylesheet) self.setLayout(mainLayout)
def __init__(self, parent, repo): """QWidget Dictionary -> Void Consumes the parent and the repository dictionary and sets up the install page in the settings area""" QWidget.__init__(self, parent) self._userPlugins = helper.getPlugins() self._repo = repo # Add a scrollArea that if they are more plugins that fit into the # settings page scrollArea = QScrollArea(self) scrollArea.setWidgetResizable(True) scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) baseLayout = QVBoxLayout() baseLayout.setAlignment(Qt.AlignTop) self.setLayout(baseLayout) baseWidget = QWidget() scrollArea.setWidget(baseWidget) baseLayout.addWidget(scrollArea) self._vbox = QVBoxLayout() baseWidget.setLayout(self._vbox)
def init_ui(self, title): self.setWindowTitle(_(title)) btn_add_mapping = create_button('+ Add colors mapping', self.on_add) btn_close = create_button('Close', self.close) buttons = QHBoxLayout() buttons.addWidget(btn_close) buttons.addWidget(btn_add_mapping) buttons.setAlignment(Qt.AlignBottom) body = QVBoxLayout() body.setAlignment(Qt.AlignTop) header = QLabel(_( 'Specify how particular colors on your cards ' 'should be swapped when the night mode is on.' )) header.setAlignment(Qt.AlignCenter) mappings = QVBoxLayout() mappings.setAlignment(Qt.AlignTop) for normal_color, night_color in self.color_map.items(): mapping = ColorMapping(self, normal_color, night_color) mappings.addWidget(mapping) self.mappings = mappings body.addWidget(header) body.addLayout(mappings) body.addStretch(1) body.addLayout(buttons) self.setLayout(body) self.setGeometry(300, 300, 350, 300) self.show()
class MessageContainer(QWidget): """ A container to display the messages. Attributes ---------- sizeChanged: pyqtSignal(float) Emitted when it is resized. Sends its height value """ sizeChanged = pyqtSignal(float) def __init__(self, parent=None): """ Creates a layout for the message labels, which is vertical. Parameters --------- parent : QWidget Pass into QWidget init method """ super().__init__(parent=parent) self.layout = QVBoxLayout(self) self.layout.setAlignment(Qt.AlignTop) self.layout.setSpacing(0) def resizeEvent(self, event): """ Reimplemented from QWidget resizeEvent method """ self.sizeChanged.emit(event.size().height()) def insert_label(self, label): """ Insert a given QLabel into its layout """ self.layout.addWidget(label)
def __init__(self): super(CallType, self).__init__() self.setStyleSheet( "QFrame {border: 0px; border-right : 1px solid black}") self.types = { 'azul': 'Codigo Azul', 'normal': 'Llamado', 'bano': 'Baño' } self.logoH = QLabel() self.logoH.setAlignment(Qt.AlignCenter) self.logoH.setStyleSheet(' border: 0px; margin-bottom: 10px') pixmapLogoH = QPixmap(root + '/assets/logohospital.png') self.logoH.setPixmap(pixmapLogoH) self.icon = QLabel() self.icon.setAlignment(Qt.AlignCenter) self.icon.setStyleSheet(' border: 0px; margin: 0px') self.textType = QLabel() self.textType.setStyleSheet( 'color: white; font: 35px; font-weight: bold; border: 0px') self.textType.setAlignment(Qt.AlignCenter) frameTypes = QFrame() frameTypes.setStyleSheet('border: 0px') vboxTypes = QVBoxLayout(frameTypes) vboxTypes.setAlignment(Qt.AlignCenter) vboxTypes.addWidget(self.icon) vboxTypes.addWidget(self.textType) vbox = QVBoxLayout(self) vbox.setAlignment(Qt.AlignTop) vbox.addWidget(self.logoH) vbox.addWidget(frameTypes, 1)
def __init__(self, arguments_definition, values=None): QWidget.__init__(self) panel = QVBoxLayout() panel.setAlignment(Qt.AlignTop) self.setLayout(panel) self.map = {} added = 0 row = None args = arguments_definition['arguments'] for arg in args: if added % items_per_row == 0: row = QHBoxLayout() row.setAlignment(Qt.AlignLeft) panel.addLayout(row) else: row.addSpacerItem(QSpacerItem(gap_width, 1, QSizePolicy.Fixed)) entry = Entry(arg) self.map[entry.name] = entry lb_name = QLabel( f"{entry.name}{' *' if entry.is_mandatory else ''}:") lb_name.setFixedWidth(name_width) lb_name.setToolTip(entry.tooltip) row.addWidget(lb_name) entry.textbox.setFixedWidth(value_width) row.addWidget(entry.textbox) if values != None: entry.textbox.setText(values[entry.name]) added = added + 1
def __init__(self, parent): super(QWidget, self).__init__(parent) # go and init our text boxes self.grid = QGridLayout() self.setLayout(self.grid) self.onlyFloat = QDoubleValidator() # now the data in the graphic at the bottom self.length_input = InputLine("Length (in): ", 10, self.onlyFloat) self.od_input = InputLine("O.D. (in): ", 2.716, self.onlyFloat) self.start_offset_input = InputLine("Start Offset (in): ", 1.5, self.onlyFloat) self.head_offset_input = InputLine("Head Offset (in): ", 1, self.onlyFloat) self.tube = QLabel() self.tube.setPixmap(QPixmap("./graphics/BodyTubeDrawing.jpg")) vbox = QVBoxLayout() vbox.addWidget(self.length_input) vbox.addWidget(self.od_input) vbox.addWidget(self.start_offset_input) vbox.addWidget(self.head_offset_input) vbox.setAlignment(Qt.AlignTop) tempWidget = QWidget() tempWidget.setLayout(vbox) #self.grid.addWidget(self.head_offset_textbox, 5,1) self.grid.addWidget(tempWidget, 0, 0) self.grid.addWidget(self.tube, 6, 0, 1, 2) self.grid.setAlignment(self.tube, Qt.AlignHCenter) self.show()
def initUI(self): self.status_bar = self.statusBar() self.status_bar.showMessage("Ready") # toolbars exit_action, save_action, ex_action, load_action = self.create_toolbars( ) self.toolbar = self.addToolBar("Toolbar") self.toolbar.addAction(exit_action) self.toolbar.addAction(save_action) self.toolbar.addAction(ex_action) self.toolbar.addAction(load_action) # widgets total_hbox = QHBoxLayout() hbox_top_widgets = self.create_top_widgets() hbox_select = self.create_labeler() hbox_post = self.create_post_ui() vbox_ui = QVBoxLayout() vbox_ui.addLayout(hbox_top_widgets) vbox_ui.addLayout(hbox_select) vbox_ui.addLayout(hbox_post) vbox_ui.setAlignment(Qt.AlignTop) vbox_progress = self.create_progress() total_hbox.addLayout(vbox_ui) total_hbox.addLayout(vbox_progress) self.w.setLayout(total_hbox) self.setWindowTitle("Labeler") self.resize(1380, 720) # width hight # self.center_window() self.show()
class CardPaymentUI(QWidget): def __init__(self) -> None: super().__init__() self.layout = QVBoxLayout() self.layout.setAlignment(Qt.AlignTop) self.selectLayout = QHBoxLayout() self.accountSelect = QComboBox() self.cardSelect = QComboBox() self.selectLayout.addWidget(self.accountSelect) self.selectLayout.addWidget(self.cardSelect) self.buttonPayment = QPushButton() self.buttonPayment.setMinimumHeight(200) self.buttonPayment.setMaximumWidth(200) self.buttonPayment.setIcon( QIcon(resource_path('package/assets/utilities/card-payment.png'))) self.buttonPayment.setIconSize(QSize(200, 200)) self.buttonReset = QPushButton("Wróc do początku") self.layout.addLayout(self.selectLayout) self.layout.addWidget(self.buttonPayment) self.layout.addWidget(self.buttonReset) self.setLayout(self.layout) def setAccounts(self, accounts): for account in accounts: self.accountSelect.addItem(account.fullname, account) self.onAccountSelect(self.accountSelect.currentData()) def onAccountSelect(self, account): self.cardSelect.clear() for card in account.cards: self.cardSelect.addItem( f"{card.accountNumber} {card.balance}{card.currency}", card)
def recreate_gui(self): # delete old GUI for tab in self.tabs: for field in tab: field.delete() self.tabs.clear() for w in self.misc_widgets: w.hide() w.deleteLater() self.misc_widgets.clear() while self.tabs_widget.count() > 0: self.tabs_widget.removeTab(0) # create new GUI for tab in self.settings_defs["tabs"]: # don't bother creating tabs that would be empty - i.e. at least one qsid in a tab should be supported use_tab = False for field in tab["fields"]: if field["qsid"] in self.keyboard.supported_settings: use_tab = True break if not use_tab: continue w = QWidget() w.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) container = QGridLayout() w.setLayout(container) l = QVBoxLayout() l.addWidget(w) l.setAlignment(w, QtCore.Qt.AlignHCenter) w2 = QWidget() w2.setLayout(l) self.misc_widgets += [w, w2] self.tabs_widget.addTab(w2, tab["name"]) self.tabs.append(self.populate_tab(tab, container))
def __init__(self, modelsToRun, metricNames, data, parent=None): """Initializes ComputeWidget class. Args: modelsToRun: List of Model objects used for estimation calculation. metricNames: List of metric names as strings used for estimation calculation. data: Pandas dataframe containing imported data. parent: """ super(ComputeWidget, self).__init__(parent) layout = QVBoxLayout(self) # set fixed window size (width, height) self.setFixedSize(350, 200) self._progressBar = QProgressBar(self) self._numCombinations = len(modelsToRun) * len(metricNames) self._progressBar.setMaximum(self._numCombinations) self._label = QLabel() self._label.setText( "Computing results...\nModels completed: {0}".format(0)) self._modelCount = 0 layout.addWidget(self._label) layout.addWidget(self._progressBar) layout.setAlignment(Qt.AlignVCenter) self.setWindowTitle("Processing...") self.computeTask = TaskThread(modelsToRun, metricNames, data) self.computeTask.nextCalculation.connect(self._showCurrentCalculation) self.computeTask.modelFinished.connect(self._modelFinished) self.computeTask.taskFinished.connect(self._onFinished) self.computeTask.start() self.show()
def __init__(self): super().__init__() self.setMinimumWidth(600) self.setMinimumHeight(600) # set layout main_widget = QWidget(self) main_layout = QHBoxLayout(main_widget) self.setCentralWidget(main_widget) # plot self.sc = PlotCanvas(main_widget) main_layout.addWidget(self.sc) # field for parameter input_param = QVBoxLayout() input_param.setAlignment(Qt.AlignTop) label = QtWidgets.QLabel("a:") text_field = QtWidgets.QLineEdit(self) text_field.setFixedWidth(120) text_field.textChanged.connect(self.update) input_param.addWidget(label) input_param.addWidget(text_field) main_layout.addLayout(input_param)
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) # Layout LeftBoxLayout = QVBoxLayout() RightBoxLayout = QVBoxLayout() MainLayout = QHBoxLayout() LeftBoxLayout.setAlignment(Qt.AlignTop) RightBoxLayout.setAlignment(Qt.AlignTop) MainLayout.setAlignment(Qt.AlignTop) # for matplotlib graph self.MatplotlibWindow = MatplotlibWindow(width=200, height=200) LeftBoxLayout.addWidget(self.MatplotlibWindow) # ComboBox self.combo = QComboBox(self) self.combo.addItem("Ubuntu") self.combo.addItem("Mandriva") self.combo.addItem("Fedora") self.combo.addItem("Red Hat") self.combo.addItem("Gentoo") self.combo.activated.connect(self.onActivated) self.combo.activated[str].connect(self.onActivatedstr) RightBoxLayout.addWidget(self.combo) # button self.update = QPushButton("&Update") self.update.clicked.connect(self.update_graph) RightBoxLayout.addWidget(self.update) MainLayout.addLayout(LeftBoxLayout) MainLayout.addLayout(RightBoxLayout) self.setLayout(MainLayout) self.setWindowTitle("Matplotlib Window")
class alertWin(QWidget, parent.posClass, parent.win): def __init__(self): super().__init__() self.dim = [450, 150] self.alert = QLabel("") self.alert.setWordWrap(True) self.layout = QVBoxLayout() # self.setGeometry(100, 100, 200, 100) self.exButton = QPushButton("Close") self.alert.setAlignment(Qt.AlignCenter) font = QFont() font.setPointSize(12) self.alert.setFont(font) self.layout.setAlignment(Qt.AlignCenter) self.layout.addWidget(self.alert) self.setWindowTitle("Alert") self.layout.addWidget(self.exButton) self.setLayout(self.layout) self.exButton.clicked.connect(self.closeWin) def updateDim(self): self.dim[0] = self.geometry().width() self.dim[1] = self.geometry().height() def disAlert(self, text): self.updateDim() self.alert.setText(text) self.show() def closeWin(self): self.close()
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) # Layout LeftBoxLayout = QVBoxLayout() RightBoxLayout = QVBoxLayout() MainLayout = QHBoxLayout() LeftBoxLayout.setAlignment(Qt.AlignTop) RightBoxLayout.setAlignment(Qt.AlignTop) MainLayout.setAlignment(Qt.AlignTop) # for matplotlib graph self.MatplotlibWindow = MatplotlibWindow(width=200,height=200) LeftBoxLayout.addWidget(self.MatplotlibWindow) # ComboBox self.combo = QComboBox(self) self.combo.addItem("Ubuntu") self.combo.addItem("Mandriva") self.combo.addItem("Fedora") self.combo.addItem("Red Hat") self.combo.addItem("Gentoo") self.combo.activated.connect(self.onActivated) self.combo.activated[str].connect(self.onActivatedstr) RightBoxLayout.addWidget(self.combo) # button self.update = QPushButton("&Update") self.update.clicked.connect(self.update_graph) RightBoxLayout.addWidget(self.update) MainLayout.addLayout(LeftBoxLayout) MainLayout.addLayout(RightBoxLayout) self.setLayout(MainLayout) self.setWindowTitle("Matplotlib Window")
def loadAboutMenu(self): # ---- Initialize smallest components --------------------------------------------------------------------- button_list = [] button_list.append( self.make_button('Back to Main Menu', self.switch_main, 'Returns to the Main Menu')) label_list = [] label_list.append(self.make_label(self.aboutText)) # ---- Main Container ----------------------------------------------------------------------------------- # add components to main layout layout_main = QVBoxLayout() layout_main.setAlignment(Qt.AlignCenter) for label in label_list: layout_main.addWidget(label) for button in button_list: layout_main.addWidget(button) # widget to be returned container_main = QWidget() container_main.setLayout(layout_main) return container_main
def __init__(self, parent=None, nav_toolbar=None): # This view is not visible super(NavigatorView, self).__init__(None) self.navigator = Navigator() self.navigator.setFixedWidth(self.SIZE) self.navigator.setFixedHeight(self.SIZE) self.navigator.setContentsMargins(0, 0, 0, 0) # Widget containing nav toolbar and thumbnail layout = QVBoxLayout() if nav_toolbar: layout.addWidget(nav_toolbar) layout.addWidget(self.navigator) layout.setAlignment(self.navigator, Qt.AlignHCenter) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) container = QWidget() container.setContentsMargins(0, 0, 0, 0) container.setLayout(layout) # Widget containing toggle label and container self.widget = PopupPanel('Navigator', container, parent=parent) self.widget.setContentsMargins(0, 0, 0, 0)
class SliderHistorySizeWidget: def __init__(self, parent, controller): self.parent = parent self.controller = controller self.slider_widget = QWidget(self.parent) self.slider_widget.setGeometry(0, 100, 400, 50) self.slider_layout = QVBoxLayout(self.slider_widget) self.slider_layout.setContentsMargins(0, 0, 0, 20) self.slider_layout.setSpacing(20) self.slider_layout.setAlignment(Qt.AlignTop) self.slider_name = QLabel() self.slider_name.setText("Background history size") self.slider_name.setStyleSheet( "font-size:15px; color:#c5c5c5; text-transform:uppercase;") self.slider_name.setGeometry(0, 0, 375, 20) self.slider = QSlider(Qt.Horizontal, self.slider_widget) self.slider.setGeometry(0, 0, 375, 30) self.slider.setMinimum(1) self.slider.setMaximum(1000) self.slider.setValue(50) self.slider.setTickInterval(10) self.slider.setTickPosition(QSlider.TicksBelow) self.slider.valueChanged[int].connect( lambda: self.controller.slider_changed_value()) self.slider_layout.addWidget(self.slider_name) self.slider_layout.addWidget(self.slider) def get_slider_widget(self): return self.slider_widget def get_value(self): return self.slider.value()
def pswd_line(self): pswd1_label = QLabel("新密码:") pswd2_label = QLabel("新密码:") pswd1_label.setFont(QFont("", 12, QFont.Black)) pswd2_label.setFont(QFont("", 12, QFont.Black)) pswd1_label.setFixedSize(50, 35) pswd2_label.setFixedSize(50, 35) self.pswd1_input = QLineEdit() self.pswd2_input = QLineEdit() self.pswd1_input.setFixedSize(400, 35) self.pswd2_input.setFixedSize(400, 35) pswd1_line = QHBoxLayout() pswd2_line = QHBoxLayout() pswd1_line.addWidget(pswd1_label) pswd1_line.addWidget(self.pswd1_input) pswd2_line.addWidget(pswd2_label) pswd2_line.addWidget(self.pswd2_input) pswd1_line.setAlignment(Qt.AlignLeft) pswd2_line.setAlignment(Qt.AlignLeft) pswd_line = QVBoxLayout() pswd_line.setAlignment(Qt.AlignLeft) pswd_line.addLayout(pswd1_line) pswd_line.addLayout(pswd2_line) self.r_layout.addLayout(pswd_line)
def init_iu(self): # insist on white background color (for linux, mac) self.setAutoFillBackground(True) p = self.palette() p.setColor(self.backgroundRole(), Qt.white) self.setPalette(p) """ WIDGETS """ actual_version_label_title = QLabel(self.tr('Current software')) actual_version_label = QLabel(str(self.actual_version)) last_version_label_title = QLabel(self.tr('Last on web')) self.last_version_label = QLabel("-") self.close_button = QPushButton(self.tr("Close")) self.close_button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) self.close_button.clicked.connect(self.close_dialog) """ LAYOUT """ # versions layout layout_general_options = QFormLayout() general_options_group = QGroupBox(self.tr("HABBY version")) general_options_group.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) general_options_group.setLayout(layout_general_options) layout_general_options.addRow(actual_version_label_title, actual_version_label) layout_general_options.addRow(last_version_label_title, self.last_version_label) # general layout = QVBoxLayout(self) layout.addWidget(general_options_group) layout.addWidget(self.close_button) layout.setAlignment(self.close_button, Qt.AlignRight) self.setWindowTitle(self.tr("Check HABBY version")) self.setWindowIcon(QIcon(self.name_icon)) self.setMinimumWidth(300) self.setModal(True)
def initUI(self): row, col = 4, 5 labelAll = [[QLabel("0") for j in range(col)] for i in range(row)] hboxList = [QHBoxLayout() for i in range(row)] for i in range(row): hbox = hboxList[i] hbox.addStretch(1) for j in range(col): hbox.addWidget(labelAll[i][j]) print(hbox.setAlignment(labelAll[i][j], Qt.AlignHCenter)) vbox = QVBoxLayout() vbox.addStretch(1) for i in range(row): vbox.addLayout(hboxList[i]) print(vbox.setAlignment(hboxList[i], Qt.AlignVCenter)) self.setLayout(vbox)
class Results(QWidget): """ Shows the results for the session that just finished Tells whether the score entered is greater than the previous score """ def __init__(self, *args, **kwargs): super(Results, self).__init__(*args, **kwargs) self.setProperty("id", "results") self.vbox = QVBoxLayout(self) self.vbox.setAlignment(Qt.AlignCenter) self.vbox.setSpacing(4) self.message = QLabel() self.message.setProperty("id", "result") self.vbox.setAlignment(self.message, Qt.AlignCenter) self.vbox.addWidget(self.message) self.old_high_score = QLabel() self.old_high_score.setProperty("type", "results-label") self.vbox.addWidget(self.old_high_score) self.vbox.setAlignment(self.old_high_score, Qt.AlignCenter) self.score_entered = QLabel() self.score_entered.setProperty("type", "results-label") self.vbox.addWidget(self.score_entered) self.vbox.setAlignment(self.score_entered, Qt.AlignCenter) self.ok = QPushButton("OK") self.vbox.addWidget(self.ok) def generate_results(self, passed, old, new): if passed: self.message.setText("New high score!") self.old_high_score.setText(f"Old High Score:{old:>8}") self.score_entered.setText(f"New High Score:{new:>8}") self.message.setStyleSheet("color: green") self.old_high_score.setStyleSheet("color: red") self.score_entered.setStyleSheet("color: green") else: self.message.setText("You did not beat your score...") self.old_high_score.setText(f"Old High Score:{old:>8}") self.score_entered.setText(f"Your attempt:{new:>10}") self.message.setStyleSheet("color: red") self.old_high_score.setStyleSheet("color: white") self.score_entered.setStyleSheet("color: red")
def __init__(self, parent, student_list, column_map): super().__init__(parent) self.setWindowTitle(_('Preview the students to be loaded')) layout = QVBoxLayout(self) self.setLayout(layout) self.table = PreviewWidget(student_list, column_map, parent=self) self.button_swap = QPushButton(_('Swap first/last names'), parent=self) self.button_take_first = QPushButton( _('Take first name as full name'), parent=self) self.button_take_last = QPushButton( _('Take last name as full name'), parent=self) self.button_remove = QPushButton( _('Remove duplicate students'), parent=self) buttons = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel) self.button_accept = buttons.button(QDialogButtonBox.Ok) layout.addWidget(self.table) layout.addWidget(self.button_swap) layout.addWidget(self.button_take_first) layout.addWidget(self.button_take_last) layout.addWidget(self.button_remove) layout.addWidget(buttons) layout.setAlignment(self.button_swap, Qt.AlignHCenter) layout.setAlignment(self.button_take_first, Qt.AlignHCenter) layout.setAlignment(self.button_take_last, Qt.AlignHCenter) layout.setAlignment(self.button_remove, Qt.AlignHCenter) self.button_swap.clicked.connect(self.table.swap_names) self.button_take_first.clicked.connect(self._take_first_name) self.button_take_last.clicked.connect(self._take_last_name) self.button_remove.clicked.connect(self._remove_duplicates) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) if students.StudentColumn.FIRST_NAME not in column_map: self._disable_buttons() if any(s.is_duplicate for s in student_list): self.button_accept.setEnabled(False) self.button_remove.setEnabled(True) else: self.button_remove.setEnabled(False)
def _set_layout(self): hlayout = QHBoxLayout() vlayout = QVBoxLayout() vlayout.addItem(QSpacerItem(10, 15)) vlayout.addWidget(self.add_expression_button) vlayout.addItem(QSpacerItem(10, 10)) vlayout.addWidget(self.add_condition_button) vlayout.addItem(QSpacerItem(10, 15)) lb = QLabel('Conditions') vlayout.addWidget(lb) vlayout.addWidget(self.condition_list) vlayout.setAlignment(lb, Qt.AlignHCenter) vlayout.setAlignment(self.add_expression_button, Qt.AlignHCenter) vlayout.setAlignment(self.add_condition_button, Qt.AlignHCenter) hlayout.addLayout(vlayout) vlayout = QVBoxLayout() lb = QLabel('Expressions') vlayout.addWidget(lb) vlayout.addWidget(self.expression_list) vlayout.setAlignment(lb, Qt.AlignHCenter) hlayout.addLayout(vlayout) hlayout.addStretch() self.setLayout(hlayout)
class MainWindow(QMainWindow): def __init__(self, core, parent=None): super(MainWindow, self).__init__(parent) self.core = core self.setGeometry(50, 50, 1000, 1000) # timer self.plots_refresh_timer = None self.setMaximumSize(2000, 1100) self.setMinimumSize(2000, 1100) self.setWindowTitle("Risk Estimation GUI") self.widget = QWidget(self) self.setCentralWidget(self.widget) self.mainLayout = QHBoxLayout() self.initUI() self.show() def initUI(self): """ Input layout """ self.inputLayout = QVBoxLayout() self.inputLayout.setAlignment(QtCore.Qt.AlignTop) self.inputWidget = InputWidget(self.core) self.inputLayout.addWidget(self.inputWidget) """ Info panel """ self.infoLayout = QVBoxLayout() self.infoLayout.setAlignment(QtCore.Qt.AlignRight) self.infoPanel = InfoPanel(self.core) self.infoLayout.addWidget(self.infoPanel) """ GL layout """ self.glLayout = QVBoxLayout() self.glLayout.setAlignment(QtCore.Qt.AlignHCenter) self.birdEyeView = BirdEyeView(self.core) self.controlPanel = ControlPanel(self.core, self.birdEyeView, self.infoPanel) self.glLayout.addWidget(self.birdEyeView) self.glLayout.addWidget(self.controlPanel) # Main layout self.mainLayout.addLayout(self.inputLayout) self.mainLayout.addLayout(self.glLayout) self.mainLayout.addLayout(self.infoLayout) self.widget.setLayout(self.mainLayout) def keyPressEvent(self, event): self.birdEyeView.keyPressEvent(event)
def _setLayout(self): mainLayout = QVBoxLayout() mainLayout.addItem(QSpacerItem(1, 10)) mainLayout.addWidget(self.infoBox) mainLayout.addItem(QSpacerItem(1, 15)) hlayout = QHBoxLayout() hlayout.addItem(QSpacerItem(30, 1)) vlayout = QVBoxLayout() lb = QLabel('Available variables') vlayout.addWidget(lb) vlayout.setAlignment(lb, Qt.AlignHCenter) vlayout.addWidget(self.firstTable) hlayout.addLayout(vlayout) hlayout.addItem(QSpacerItem(15, 1)) vlayout = QVBoxLayout() lb = QLabel('Output variables') vlayout.addWidget(lb) vlayout.setAlignment(lb, Qt.AlignHCenter) vlayout.addWidget(self.secondTable) hlayout.addLayout(vlayout) hlayout.addItem(QSpacerItem(30, 1)) mainLayout.addLayout(hlayout) mainLayout.addItem(QSpacerItem(50, 20)) glayout = QGridLayout() glayout.addWidget(QLabel(' Select an operation'), 1, 1) glayout.addWidget(self.operationBox, 1, 2) glayout.setSpacing(10) mainLayout.addLayout(glayout) mainLayout.setAlignment(glayout, Qt.AlignTop | Qt.AlignLeft) mainLayout.addItem(QSpacerItem(50, 20)) hlayout = QHBoxLayout() hlayout.addItem(QSpacerItem(50, 10)) hlayout.addWidget(self.btnSubmit) hlayout.addItem(QSpacerItem(50, 10)) hlayout.addWidget(self.singlePrecisionBox) hlayout.addItem(QSpacerItem(50, 10)) mainLayout.addLayout(hlayout) mainLayout.addItem(QSpacerItem(30, 15)) mainLayout.addWidget(QLabel(' Message logs')) mainLayout.addWidget(self.logTextBox.widget) self.setLayout(mainLayout)
def _setLayout(self): mainLayout = QVBoxLayout() mainLayout.addItem(QSpacerItem(1, 10)) mainLayout.addWidget(self.timeSlider) mainLayout.addWidget(self.timeSelection) mainLayout.addItem(QSpacerItem(1, 10)) hlayout = QHBoxLayout() hlayout.addWidget(QLabel(' Select the reference variable ')) hlayout.addWidget(self.varBox, Qt.AlignLeft) hlayout.addStretch() mainLayout.addLayout(hlayout) mainLayout.addItem(QSpacerItem(1, 10)) hlayout = QHBoxLayout() hlayout.addItem(QSpacerItem(30, 1)) vlayout = QVBoxLayout() vlayout.setAlignment(Qt.AlignHCenter) lb = QLabel('Available variables') vlayout.addWidget(lb) vlayout.setAlignment(lb, Qt.AlignHCenter) vlayout.addWidget(self.firstTable) hlayout.addLayout(vlayout) hlayout.addItem(QSpacerItem(15, 1)) vlayout = QVBoxLayout() lb = QLabel('Output variables') vlayout.addWidget(lb) vlayout.setAlignment(lb, Qt.AlignHCenter) vlayout.addWidget(self.secondTable) hlayout.addLayout(vlayout) hlayout.addItem(QSpacerItem(30, 1)) mainLayout.addLayout(hlayout) mainLayout.addItem(QSpacerItem(50, 20)) hlayout = QHBoxLayout() hlayout.addItem(QSpacerItem(50, 10)) hlayout.addWidget(self.btnSubmit) hlayout.addItem(QSpacerItem(50, 10)) hlayout.addWidget(self.singlePrecisionBox) hlayout.addItem(QSpacerItem(50, 10)) mainLayout.addLayout(hlayout) mainLayout.addItem(QSpacerItem(30, 15)) mainLayout.addWidget(QLabel(' Message logs')) mainLayout.addWidget(self.logTextBox.widget) self.setLayout(mainLayout)
def __init__(self, parent, student_listings=None): super().__init__(parent) if student_listings is None: self.student_listings = students.StudentListings() inserted_group = students.StudentGroup(0, 'INSERTED') self.student_listings.create_listing(inserted_group) else: self.student_listings = student_listings layout = QVBoxLayout(self) self.setLayout(layout) self.tabs = QTabWidget(self) # Special tab for creating a new group: self.tabs.addTab(QWidget(), ' + ') # Group 0 is special: don't show it for listing in self.student_listings[1:]: self._add_group_tab(listing) # At least one normal group needs to be present: if len(self.student_listings) == 1: self._create_default_group() button_load = QPushButton(_('Add students from file'), parent=self) button_new_student = QPushButton( QIcon(utils.resource_path('new_id.svg')), _('New student'), parent=self) button_remove = QPushButton( QIcon(utils.resource_path('discard.svg')), _('Remove group'), parent=self) layout.addWidget(self.tabs) layout.addWidget(button_load) layout.addWidget(button_new_student) layout.addWidget(button_remove) layout.setAlignment(button_load, Qt.AlignHCenter) layout.setAlignment(button_new_student, Qt.AlignHCenter) layout.setAlignment(button_remove, Qt.AlignHCenter) self.tabs.setCurrentIndex(0) self._active_tab = 0 self.tabs.currentChanged.connect(self._tab_changed) self.tabs.tabBarDoubleClicked.connect(self._rename_group) button_load.clicked.connect(self._load_students) button_new_student.clicked.connect(self._new_student) button_remove.clicked.connect(self._remove_group)
def __init__(self): widgets_width = window_width - canvas_width super(MainWindow, self).__init__() self.resize(window_width, window_height) centralWidget = QWidget() self.setCentralWidget(centralWidget) self.glWidget = GLWidget(self) self.widgets = QGroupBox(parent=self) vbox = QVBoxLayout() vbox.setAlignment(Qt.AlignTop) vbox.addWidget(QLabel('light')) slider = QSlider(Qt.Horizontal) slider.setFocusPolicy(Qt.NoFocus) slider.valueChanged.connect(self.change_light_strength) vbox.addWidget(slider) button = QPushButton('Choose color') button.clicked.connect(self.change_light_color) button.setFocusPolicy(Qt.NoFocus) vbox.addWidget(button) check = QCheckBox('show axes') check.stateChanged.connect(self.change_axis_option) check.setFocusPolicy(Qt.NoFocus) vbox.addWidget(check) check = QCheckBox('draw invisible edges') check.stateChanged.connect(self.change_invisible_edges_option) check.setFocusPolicy(Qt.NoFocus) vbox.addWidget(check) check = QCheckBox('transparent') check.stateChanged.connect(self.change_transparent_option) check.setFocusPolicy(Qt.NoFocus) vbox.addWidget(check) check = QCheckBox('orthogonal projection') check.stateChanged.connect(self.change_projection_option) check.setFocusPolicy(Qt.NoFocus) vbox.addWidget(check) def add_scale_widgets(): grid = QGridLayout() grid.setSpacing(1) grid.addWidget(QLabel('X'), 1, 0) grid.addWidget(QLabel('Y'), 2, 0) grid.addWidget(QLabel('Z'), 3, 0) slider = QSlider(Qt.Horizontal) slider.setValue(99) slider.setFocusPolicy(Qt.NoFocus) slider.valueChanged.connect(self.change_x_scale) grid.addWidget(slider, 1, 1) slider = QSlider(Qt.Horizontal) slider.setValue(99) slider.setFocusPolicy(Qt.NoFocus) slider.valueChanged.connect(self.change_y_scale) grid.addWidget(slider, 2, 1) slider = QSlider(Qt.Horizontal) slider.setValue(99) slider.setFocusPolicy(Qt.NoFocus) slider.valueChanged.connect(self.change_z_scale) grid.addWidget(slider, 3, 1) gb = QGroupBox('scale', parent=self.widgets) gb.setLayout(grid) vbox.addWidget(gb) add_scale_widgets() def add_move_widgets(): grid = QGridLayout() grid.setSpacing(1) grid.addWidget(QLabel('X'), 1, 0) grid.addWidget(QLabel('Y'), 2, 0) grid.addWidget(QLabel('Z'), 3, 0) slider = QSlider(Qt.Horizontal) slider.setValue(50) slider.setFocusPolicy(Qt.NoFocus) slider.valueChanged.connect(self.change_x_pos) grid.addWidget(slider, 1, 1) slider = QSlider(Qt.Horizontal) slider.setValue(50) slider.setFocusPolicy(Qt.NoFocus) slider.valueChanged.connect(self.change_y_pos) grid.addWidget(slider, 2, 1) slider = QSlider(Qt.Horizontal) slider.setValue(50) slider.setFocusPolicy(Qt.NoFocus) slider.valueChanged.connect(self.change_z_pos) grid.addWidget(slider, 3, 1) gb = QGroupBox('move', parent=self.widgets) gb.setLayout(grid) vbox.addWidget(gb) add_move_widgets() vbox.addWidget(QLabel('figure parrameter')) slider = QSlider(Qt.Horizontal) slider.setValue(20) slider.setFocusPolicy(Qt.NoFocus) slider.valueChanged.connect(self.change_freq) vbox.addWidget(slider) vbox.addWidget(QLabel('number of polygons')) slider = QSlider(Qt.Horizontal) slider.setValue(20) slider.setFocusPolicy(Qt.NoFocus) slider.valueChanged.connect(self.change_num_of_polygons) vbox.addWidget(slider) self.widgets.resize(widgets_width, window_height) self.widgets.move(canvas_width, 0) self.widgets.setLayout(vbox) self.setWindowTitle("lab_6")
def create_widget(self): """ Create widget login """ # Main layout main_layout = QVBoxLayout(self) main_layout.setContentsMargins(0, 0, 0, 0) main_layout.addWidget(self.get_logo_widget(self)) title = QLabel('Welcome to <b>Alignak-app</b>') title.setObjectName('title_login') main_layout.addWidget(title) main_layout.setAlignment(title, Qt.AlignCenter) version = QLabel('Version %s' % __version__) version.setObjectName('version_login') main_layout.addWidget(version) main_layout.setAlignment(version, Qt.AlignCenter | Qt.AlignTop) # Login QWidget login_widget = QWidget(self) login_widget.setObjectName('login') login_layout = QGridLayout(login_widget) # Configuration button refresh_conf_btn = QPushButton() refresh_conf_btn.clicked.connect(init_config) refresh_conf_btn.setFixedSize(25, 25) refresh_conf_btn.setIcon(QIcon(get_image_path('refresh'))) refresh_conf_btn.setToolTip('Reload configuration') login_layout.addWidget(refresh_conf_btn, 2, 1, 1, 1) # Server button server_btn = QPushButton() server_btn.clicked.connect(self.handle_server) server_btn.setFixedSize(25, 25) server_btn.setIcon(QIcon(get_image_path('host'))) server_btn.setToolTip('Modify Alignak Server') login_layout.addWidget(server_btn, 2, 2, 1, 1) # Welcome text login_label = QLabel('<b>Log-in</b> to use the application') login_layout.addWidget(login_label, 2, 0, 1, 1) login_layout.setAlignment(login_label, Qt.AlignCenter) # Username field self.username_line = QLineEdit(self) self.username_line.setPlaceholderText('Username') login_layout.addWidget(self.username_line, 3, 0, 1, 3) # Password field self.password_line = QLineEdit(self) self.password_line.setPlaceholderText('Password') self.password_line.setEchoMode(QLineEdit.Password) login_layout.addWidget(self.password_line, 4, 0, 1, 3) # Login button login_button = QPushButton('LOGIN', self) login_button.clicked.connect(self.handle_login) login_button.setObjectName('valid') login_button.setMinimumHeight(30) login_button.setDefault(True) login_layout.addWidget(login_button, 5, 0, 1, 3) main_layout.addWidget(login_widget) self.setLayout(main_layout) self.center(self)
def __init__(self): super().__init__() eff = [ "Effect 1", "Effect 2", "Effect 3", "Effect 4", "Effect 5", "Effect 6", "Effect 7", "Effect 8", "Effect 9" ] layout = QVBoxLayout() self.effects = [] baseImg = "PUT YOUR IMAGE HERE" for i in range(len(eff)): self.effects.append(QPushButton(eff[i])) self.effects[i].setCheckable(True) self.effects[0].setChecked(True) self.effects[0].clicked.connect(lambda: self.changeEffect(0)) self.effects[1].clicked.connect(lambda: self.changeEffect(1)) self.effects[2].clicked.connect(lambda: self.changeEffect(2)) self.effects[3].clicked.connect(lambda: self.changeEffect(3)) self.effects[4].clicked.connect(lambda: self.changeEffect(4)) self.effects[5].clicked.connect(lambda: self.changeEffect(5)) self.effects[6].clicked.connect(lambda: self.changeEffect(6)) self.effects[7].clicked.connect(lambda: self.changeEffect(7)) self.effects[8].clicked.connect(lambda: self.changeEffect(8)) for i in range(len(eff)): layout.addWidget(self.effects[i]) self.buttons = QWidget() self.buttons.setLayout(layout) self.scroll = QScrollArea() self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) #self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.scroll.setWidgetResizable(False) self.scroll.setWidget(self.buttons) self.scroll.setFixedWidth(150) #self.scroll.setFixedSize(150, 300) self.imgLabel = QLabel() pixmap = QPixmap(baseImg) self.imgLabel.setPixmap(pixmap) #self.imgLabel.resize(pixmap.width(),pixmap.height()) VLayout = QVBoxLayout() self.slider = QSlider(Qt.Horizontal) self.slider.setFixedWidth(100) VLayout.addWidget(self.imgLabel) VLayout.addWidget(self.slider) VLayout.setAlignment(Qt.AlignCenter) self.left = QWidget() self.left.setLayout(VLayout) lay = QHBoxLayout() lay.addWidget(self.scroll) lay.addWidget(self.left) self.setLayout(lay) #self.setFixedSize(350, 320) self.setAutoFillBackground(True) p = self.palette() p.setColor(self.backgroundRole(), Qt.black) self.setPalette(p) self.setWindowTitle("GUI")
class Window(QWidget): def __init__(self): super().__init__() self.init_ui() def init_ui(self): mainLayout = QVBoxLayout() self.setGeometry(600, 200, 1000, 800) self.flag = False self.done_red = 'font-size: 18px; color: rgb(200,50,50)' self.done_blue = 'font-size: 18px; color: rgb(50,50,200)' self.done_green = 'font-size: 20px; color: rgb(50,200,100)' #H box for vertical panes paneLayout = QHBoxLayout() paneWidget = QWidget() paneWidget.setLayout(paneLayout) doneLayout = QHBoxLayout() doneWidget = QWidget() doneWidget.setLayout(doneLayout) #First vertical pane: Input layout self.inputLayout = QVBoxLayout() self.inputLayout.setAlignment(Qt.AlignTop) inputWidget = QWidget() inputWidget.setFixedWidth(250) inputWidget.setLayout(self.inputLayout) #Drop down menu for phantom plans lbl = QLabel("Select Phantom Plan") lbl.setFixedHeight(20) dropdown = QComboBox(self) dropdown.setFixedHeight(20) self.phantom_path = './MGH_Phantoms/' phantoms = gen1.get_phantom_list(self.phantom_path) dropdown.addItem('Select Phantom') for name in phantoms: dropdown.addItem(name) dropdown.activated[str].connect(self.onActivated) self.inputLayout.addWidget(lbl) self.inputLayout.addWidget(dropdown) #Text box for patient name name_lbl1 = QLabel("Enter Patient First Name (required)") name_lbl2 = QLabel("Enter Patient Last Name (required)") name_lbl1.setFixedHeight(20) name_lbl2.setFixedHeight(20) self.patientfirstname = QLineEdit() self.patientlastname = QLineEdit() self.inputLayout.addWidget(name_lbl1) self.inputLayout.addWidget(self.patientfirstname) self.inputLayout.addWidget(name_lbl2) self.inputLayout.addWidget(self.patientlastname) #Current Isocenter values self.currentiso_lbl = QLabel() self.currentiso_lbl.setFixedHeight(30) #Hbox for isocenter isoLayout = QHBoxLayout() isoWidget = QWidget() isoWidget.setFixedWidth(250) isoWidget.setLayout(isoLayout) #Isocenter parameters lbl_iso = QLabel("Enter new isocenter values below") lbl_iso.setFixedHeight(20) lbl_x = QLabel("X (mm)") lbl_y = QLabel("Y (mm)") lbl_z = QLabel("Z (mm)") self.le_x = QLineEdit() self.le_y = QLineEdit() self.le_z = QLineEdit() self.inputLayout.addWidget(self.currentiso_lbl) self.inputLayout.addWidget(lbl_iso) isoLayout.addWidget(lbl_x) isoLayout.addWidget(self.le_x) isoLayout.addWidget(lbl_y) isoLayout.addWidget(self.le_y) isoLayout.addWidget(lbl_z) isoLayout.addWidget(self.le_z) self.inputLayout.addWidget(isoWidget) #Gantry Angle gantry_lbl = QLabel("Gantry Angle") gantry_lbl.setFixedHeight(20) self.gantry = QLineEdit() self.inputLayout.addWidget(gantry_lbl) self.inputLayout.addWidget(self.gantry) #Generate new set and upload to WB new_lbl = QLabel("Click below to generate new phantom set") new_lbl.setFixedHeight(30) new_btn = QPushButton("Generate") new_btn.setFixedHeight(30) new_btn.setStyleSheet('font-size: 18px') new_btn.clicked.connect(self.generate_dicom) self.upload_btn = QPushButton("Upload to WB") self.upload_btn.setFixedHeight(30) self.upload_btn.setStyleSheet(self.done_red) self.upload_btn.clicked.connect(self.upload_to_WB) self.inputLayout.addWidget(new_lbl) self.inputLayout.addWidget(new_btn) self.inputLayout.addWidget(self.upload_btn) #Second vertical pane self.rtipLayout = QVBoxLayout() self.rtipLayout.setAlignment(Qt.AlignTop) rtipWidget = QWidget() rtipWidget.adjustSize() rtipWidget.setLayout(self.rtipLayout) #Current spot map self.spot_lbl = QLabel("Spot map specs") self.spot_lbl.setStyleSheet("font-size : 12px") self.spot_lbl.setFixedHeight(20) self.spot_stats = QLabel() self.spot_stats.setWordWrap(True) self.spot_stats.adjustSize() # Button to load new spot map spot_lbl2 = QLabel("Click below to browse for new spot map") spot_lbl2.setStyleSheet("font-size : 12px") spot_lbl2.setFixedHeight(30) dataLoadBtn = QPushButton("Browse") dataLoadBtn.setFixedHeight(30) dataLoadBtn.clicked.connect(self.load_spot_map) self.chkbox = QCheckBox("Check box to use loaded csv file") self.chkbox2 = QCheckBox( "Check box if the first beam is the setup beam") self.rtipLayout.addWidget(self.spot_lbl) self.rtipLayout.addWidget(self.spot_stats) self.rtipLayout.addWidget(spot_lbl2) self.rtipLayout.addWidget(dataLoadBtn) self.rtipLayout.addWidget(self.chkbox) self.rtipLayout.addWidget(self.chkbox2) # Add space for spot map statistics self.loadstatus = QLabel() self.loadstatus.setFixedHeight(40) self.csv_stats = QLabel() self.csv_stats.setAlignment(Qt.AlignTop) self.csv_stats.setWordWrap(True) self.rtipLayout.addWidget(self.loadstatus) self.rtipLayout.addWidget(self.csv_stats) #Third pane plotWidget = QWidget() plotLayout = QVBoxLayout() #Make figures and navi toolbar self.fig = Figure() self.canvas = FigureCanvas(self.fig) self.axes11 = self.fig.add_subplot(2, 1, 1) self.axes12 = self.fig.add_subplot(2, 1, 2) self.fig.tight_layout() navi_toolbar = NavigationToolbar(self.canvas, plotWidget) plotLayout.addWidget(navi_toolbar) plotLayout.addWidget(self.canvas, Qt.AlignHCenter) #Done status self.done_lbl = QLabel() self.done_lbl.setStyleSheet(self.done_green) self.done_lbl.setAlignment(Qt.AlignHCenter) doneLayout.addWidget(self.done_lbl) #Add widgets to main window paneLayout.addWidget(inputWidget) paneLayout.addWidget(rtipWidget) paneLayout.addLayout(plotLayout) mainLayout.addWidget(paneWidget) mainLayout.addWidget(doneWidget) self.setLayout(mainLayout) self.show() def onActivated(self, text): #Update labels string = "Spot Map Specs: %s" % text self.spot_lbl.setText(string) self.spot_lbl.adjustSize() #Pull in RTIP from phantom set self.phantom_dir = self.phantom_path + text + '/' #Get isocenter, gantry, and spot map self.isocenter, self.gantry_angle, self.msg = gen1.get_isocenter( self.phantom_dir) specs, mapy = gen1.plot_rtip_map(self.phantom_dir) self.currentiso_lbl.setText("Current isocenter position: %s" % self.isocenter) with open(specs, 'r') as f: text = f.read() self.spot_stats.setText(text) self.spot_stats.setAlignment(Qt.AlignTop) f.close() #Plot spot map self.axes11.clear() self.axes12.clear() self.axes11.scatter(mapy[:, 1], mapy[:, 2]) self.axes11.set_title("Spot Map") self.axes11.set_xlabel("X(mm)") self.axes11.set_ylabel("Y(mm") self.fig.tight_layout() self.canvas.draw() def load_spot_map(self): #Clear plots self.axes11.clear() self.axes12.clear() #Open file location dlg = QFileDialog() dlg.setFileMode(QFileDialog.ExistingFile) self.spotmap = dlg.getOpenFileName(self, 'Select Spot Map CSV', '~./') self.current_wdir = os.path.dirname(self.spotmap[0]) #Get data csv_msg = gen2.csv_check(self.spotmap[0]) self.done_lbl.setText(csv_msg) self.name, self.data, dose_array = gen2.dose_estimator(self.spotmap[0]) self.E_list = dose_array[:, 0] dose = dose_array[:, 1] #Update text box with statistics with open(self.name + '.txt', 'r') as f: file_text = f.read() self.csv_stats.setText(file_text) self.csv_stats.setAlignment(Qt.AlignTop) f.close() #Plot spot map self.axes11.scatter(self.data[:, 1], self.data[:, 2]) self.axes11.set_title("Spot Map") self.axes11.set_xlabel("X(mm)") self.axes11.set_ylabel("Y(mm") #Plot Bragg peaks. FIX TO MAKE MORE ROBUST WITH VARYING STEP SIZE BP_sum = np.zeros((200)) #dose at depth, column for each Bragg peak for n, e in enumerate(self.E_list): energy_vs_depth = gen2.E_depth(e) self.axes12.plot(energy_vs_depth[:, 0], energy_vs_depth[:, 2] * dose[n], linewidth=1) # Find max depth for setting x-axis max if n == 0: x_max = energy_vs_depth[-1, 0] #sum bragg peaks for m in range(energy_vs_depth.shape[0]): BP_sum[m] += energy_vs_depth[m, 2] * dose[n] # Plot data self.axes12.plot(np.arange(0, len(BP_sum) / 4, 0.25), BP_sum, color='black') self.axes12.set_xlim(0, x_max + 2) self.axes12.set_title("Approximate Bragg Peaks (normalized to dose)") self.axes12.set_xlabel("Depth/Z (cm)") self.axes12.set_ylabel("Dose (arb)") self.fig.tight_layout() self.canvas.draw() #Print values of interest self.loadstatus.setText("File loaded:\n%s" % self.name) self.loadstatus.setAlignment(Qt.AlignTop) def generate_dicom(self): #Generate new RTIP from csv if self.chkbox.isChecked(): csv_file = self.spotmap[0] if self.chkbox2.isChecked(): setup = True else: setup = False try: ct_directory, fgs, ibs = gen2.gen_rtip(csv_file, self.phantom_dir, setup) print(ct_directory) except: self.done_lbl.setText( "Could not process csv. Please check that format is correct" ) #If no new csv, use old treatment plan else: try: ct_directory = self.phantom_dir fgs = None ibs = None except: self.done_lbl.setText("No phantom directory selected!") return 0 #Name fname = self.patientfirstname.text() lname = self.patientlastname.text() #Create new dicom set and print done message try: self.new_dir, done_msg = gen3.gen_dicom(fname, lname, ct_directory) self.upload_btn.setStyleSheet(self.done_green) self.flag = True except: done_msg = "Could not generate new dicom set. Check Python log" self.done_lbl.setText(done_msg) #If text boxes filled, use those values, otherwise copy isocenter only from selected phantom if self.le_x.text() or self.gantry.text(): gen3.replace_iso_gantry_spots(self.new_dir, self.le_x.text(), self.le_y.text(), self.le_z.text(), self.gantry.text(), fgs, ibs) else: self.gantry_angle = None gen3.replace_iso_gantry_spots(self.new_dir, self.isocenter[0], self.isocenter[1], self.isocenter[2], self.gantry_angle, fgs, ibs) def upload_to_WB(self): if self.flag == False: self.done_lbl.setText("Cannot upload to Whiteboard") else: upload_msg = gen3.upload(self.new_dir) self.done_lbl.setText(upload_msg)
def init_UI(self): self.setWindowIcon(QIcon('./icons/ciao.png')) self.setWindowTitle('CIAO') self.setMinimumWidth(ccfg.ui_width_px) self.setMinimumHeight(ccfg.ui_height_px) layout = QGridLayout() imax = 2**ccfg.bit_depth-1 imin = 0 self.boxes_coords = [] for x1,x2,y1,y2 in zip(self.loop.sensor.search_boxes.x1, self.loop.sensor.search_boxes.x2, self.loop.sensor.search_boxes.y1, self.loop.sensor.search_boxes.y2): self.boxes_coords.append((x1,x2,y1,y2)) self.overlay_boxes = Overlay(coords=self.boxes_coords,mode='rects',color=ccfg.search_box_color,thickness=ccfg.search_box_thickness) self.overlay_slopes = Overlay(coords=[],mode='lines',color=ccfg.slope_line_color,thickness=ccfg.slope_line_thickness) self.id_spots = ZoomDisplay('Spots',clim=ccfg.spots_contrast_limits,colormap=ccfg.spots_colormap,zoom=0.25,overlays=[self.overlay_boxes,self.overlay_slopes],downsample=ccfg.spots_image_downsampling) layout.addWidget(self.id_spots,0,0,3,3) self.id_mirror = ZoomDisplay('Mirror',clim=ccfg.mirror_contrast_limits,colormap=ccfg.mirror_colormap,zoom=1.0) self.id_wavefront = ZoomDisplay('Wavefront',clim=ccfg.wavefront_contrast_limits,colormap=ccfg.wavefront_colormap,zoom=1.0) self.id_zoomed_spots = ZoomDisplay('Zoomed spots',clim=ccfg.spots_contrast_limits,colormap=ccfg.spots_colormap,zoom=5.0) layout.addWidget(self.id_mirror,0,3,1,1) layout.addWidget(self.id_wavefront,1,3,1,1) layout.addWidget(self.id_zoomed_spots,2,3,1,1) column_2 = QVBoxLayout() column_2.setAlignment(Qt.AlignTop) self.cb_closed = QCheckBox('Loop &closed') self.cb_closed.setChecked(self.loop.closed) self.cb_closed.stateChanged.connect(self.loop.set_closed) self.cb_paused = QCheckBox('Loop &paused') self.cb_paused.setChecked(self.loop.paused) self.cb_paused.stateChanged.connect(self.loop.set_paused) self.cb_safe = QCheckBox('Loop safe') self.cb_safe.setChecked(self.loop.safe) self.cb_safe.stateChanged.connect(self.loop.set_safe) loop_control_layout = QHBoxLayout() loop_control_layout.addWidget(self.cb_closed) loop_control_layout.addWidget(self.cb_paused) loop_control_layout.addWidget(self.cb_safe) self.cb_draw_boxes = QCheckBox('Draw boxes') self.cb_draw_boxes.setChecked(self.draw_boxes) self.cb_draw_boxes.stateChanged.connect(self.set_draw_boxes) self.cb_draw_lines = QCheckBox('Draw lines') self.cb_draw_lines.setChecked(self.draw_lines) self.cb_draw_lines.stateChanged.connect(self.set_draw_lines) self.cb_logging = QCheckBox('Logging') self.cb_logging.setChecked(False) self.cb_logging.stateChanged.connect(self.loop.sensor.set_logging) self.cb_logging.stateChanged.connect(self.loop.mirror.set_logging) self.pb_poke = QPushButton('Measure poke matrix') self.pb_poke.clicked.connect(self.loop.run_poke) self.pb_record_reference = QPushButton('Record reference') self.pb_record_reference.clicked.connect(self.loop.sensor.record_reference) self.pb_flatten = QPushButton('&Flatten') self.pb_flatten.clicked.connect(self.loop.mirror.flatten) self.pb_restore_flat = QPushButton('Restore flat') self.pb_restore_flat.clicked.connect(self.restore_flat) self.pb_restore_flat.setEnabled(False) self.pb_set_flat = QPushButton('Set flat') self.pb_set_flat.clicked.connect(self.set_flat) self.pb_set_flat.setCheckable(True) #print dir(self.pb_set_flat) #sys.exit() self.pb_quit = QPushButton('&Quit') self.pb_quit.clicked.connect(self.quit) poke_layout = QHBoxLayout() poke_layout.addWidget(QLabel('Modes:')) self.modes_spinbox = QSpinBox() n_actuators = int(np.sum(self.loop.mirror.mirror_mask)) self.modes_spinbox.setMaximum(n_actuators) self.modes_spinbox.setMinimum(0) self.modes_spinbox.valueChanged.connect(self.loop.set_n_modes) self.modes_spinbox.setValue(self.loop.get_n_modes()) poke_layout.addWidget(self.modes_spinbox) self.pb_invert = QPushButton('Invert') self.pb_invert.clicked.connect(self.loop.invert) poke_layout.addWidget(self.pb_invert) modal_layout = QHBoxLayout() modal_layout.addWidget(QLabel('Corrected Zernike orders:')) self.corrected_order_spinbox = QSpinBox() max_order = self.loop.sensor.reconstructor.N_orders self.corrected_order_spinbox.setMaximum(max_order) self.corrected_order_spinbox.setMinimum(0) self.corrected_order_spinbox.valueChanged.connect(self.loop.sensor.set_n_zernike_orders_corrected) self.corrected_order_spinbox.setValue(self.loop.sensor.get_n_zernike_orders_corrected()) modal_layout.addWidget(self.corrected_order_spinbox) modal_layout.addWidget(QLabel('(%d -> no filtering)'%max_order)) dark_layout = QHBoxLayout() self.cb_dark_subtraction = QCheckBox('Subtract dark') self.cb_dark_subtraction.setChecked(self.loop.sensor.dark_subtract) self.cb_dark_subtraction.stateChanged.connect(self.loop.sensor.set_dark_subtraction) dark_layout.addWidget(self.cb_dark_subtraction) dark_layout.addWidget(QLabel('Dark subtract N:')) self.n_dark_spinbox = QSpinBox() self.n_dark_spinbox.setMinimum(1) self.n_dark_spinbox.setMaximum(9999) self.n_dark_spinbox.valueChanged.connect(self.loop.sensor.set_n_dark) self.n_dark_spinbox.setValue(self.loop.sensor.n_dark) dark_layout.addWidget(self.n_dark_spinbox) self.pb_set_dark = QPushButton('Set dark') self.pb_set_dark.clicked.connect(self.loop.sensor.set_dark) dark_layout.addWidget(self.pb_set_dark) centroiding_layout = QHBoxLayout() centroiding_layout.addWidget(QLabel('Centroiding:')) self.cb_fast_centroiding = QCheckBox('Fast centroiding') self.cb_fast_centroiding.setChecked(self.loop.sensor.fast_centroiding) self.cb_fast_centroiding.stateChanged.connect(self.loop.sensor.set_fast_centroiding) centroiding_layout.addWidget(self.cb_fast_centroiding) self.centroiding_width_spinbox = QSpinBox() self.centroiding_width_spinbox.setMaximum(self.loop.sensor.search_boxes.half_width) self.centroiding_width_spinbox.setMinimum(0) self.centroiding_width_spinbox.valueChanged.connect(self.loop.sensor.set_centroiding_half_width) self.centroiding_width_spinbox.setValue(self.loop.sensor.centroiding_half_width) centroiding_layout.addWidget(self.centroiding_width_spinbox) bg_layout = QHBoxLayout() bg_layout.addWidget(QLabel('Background adjustment:')) self.bg_spinbox = QSpinBox() self.bg_spinbox.setValue(self.loop.sensor.background_correction) self.bg_spinbox.setMaximum(500) self.bg_spinbox.setMinimum(-500) self.bg_spinbox.valueChanged.connect(self.loop.sensor.set_background_correction) bg_layout.addWidget(self.bg_spinbox) aberration_layout = QHBoxLayout() aberration_layout.addWidget(QLabel('Defocus:')) self.f_spinbox = QDoubleSpinBox() self.f_spinbox.setValue(0.0) self.f_spinbox.setSingleStep(0.01) self.f_spinbox.setMaximum(10.0) self.f_spinbox.setMinimum(-10.0) self.f_spinbox.valueChanged.connect(self.loop.sensor.set_defocus) aberration_layout.addWidget(self.f_spinbox) aberration_layout.addWidget(QLabel('Astig 0:')) self.a0_spinbox = QDoubleSpinBox() self.a0_spinbox.setValue(0.0) self.a0_spinbox.setSingleStep(0.01) self.a0_spinbox.setMaximum(10.0) self.a0_spinbox.setMinimum(-10.0) self.a0_spinbox.valueChanged.connect(self.loop.sensor.set_astig0) aberration_layout.addWidget(self.a0_spinbox) aberration_layout.addWidget(QLabel('Astig 45:')) self.a1_spinbox = QDoubleSpinBox() self.a1_spinbox.setValue(0.0) self.a1_spinbox.setSingleStep(0.01) self.a1_spinbox.setMaximum(10.0) self.a1_spinbox.setMinimum(-10.0) self.a1_spinbox.valueChanged.connect(self.loop.sensor.set_astig1) aberration_layout.addWidget(self.a1_spinbox) self.pb_aberration_reset = QPushButton('Reset') def reset(): self.f_spinbox.setValue(0.0) self.a0_spinbox.setValue(0.0) self.a1_spinbox.setValue(0.0) self.loop.sensor.aberration_reset() self.pb_aberration_reset.clicked.connect(reset) aberration_layout.addWidget(self.pb_aberration_reset) exp_layout = QHBoxLayout() exp_layout.addWidget(QLabel('Exposure (us):')) self.exp_spinbox = QSpinBox() self.exp_spinbox.setValue(self.loop.sensor.cam.get_exposure()) self.exp_spinbox.setSingleStep(100) self.exp_spinbox.setMaximum(1000000) self.exp_spinbox.setMinimum(100) self.exp_spinbox.valueChanged.connect(self.loop.sensor.cam.set_exposure) exp_layout.addWidget(self.exp_spinbox) self.stripchart_error = StripChart(ylim=ccfg.error_plot_ylim,ytick_interval=ccfg.error_plot_ytick_interval,print_function=ccfg.error_plot_print_func,hlines=[0.0,ccfg.wavelength_m/14.0],buffer_length=ccfg.error_plot_buffer_length) self.stripchart_error.setAlignment(Qt.AlignRight) #self.stripchart_defocus = StripChart(ylim=ccfg.zernike_plot_ylim,ytick_interval=ccfg.zernike_plot_ytick_interval,print_function=ccfg.zernike_plot_print_func,buffer_length=ccfg.zernike_plot_buffer_length) #self.stripchart_defocus.setAlignment(Qt.AlignRight) self.lbl_tip = QLabel() self.lbl_tip.setAlignment(Qt.AlignRight) self.lbl_tilt = QLabel() self.lbl_tilt.setAlignment(Qt.AlignRight) self.lbl_cond = QLabel() self.lbl_cond.setAlignment(Qt.AlignRight) self.lbl_sensor_fps = QLabel() self.lbl_sensor_fps.setAlignment(Qt.AlignRight) self.ind_centroiding_time = Indicator(buffer_length=50,print_function=lambda x: '%0.0f us (centroiding)'%(x*1e6)) self.ind_centroiding_time.setAlignment(Qt.AlignRight) self.ind_image_max = Indicator(buffer_length=10,print_function=lambda x: '%d ADU (max)'%x) self.ind_image_mean = Indicator(buffer_length=10,print_function=lambda x: '%d ADU (mean)'%x) self.ind_image_min = Indicator(buffer_length=10,print_function=lambda x: '%d ADU (min)'%x) self.ind_mean_box_background = Indicator(buffer_length=10,print_function=lambda x: '%d ADU (background)'%x) self.ind_image_max.setAlignment(Qt.AlignRight) self.ind_image_mean.setAlignment(Qt.AlignRight) self.ind_image_min.setAlignment(Qt.AlignRight) self.ind_mean_box_background.setAlignment(Qt.AlignRight) self.lbl_mirror_fps = QLabel() self.lbl_mirror_fps.setAlignment(Qt.AlignRight) self.lbl_ui_fps = QLabel() self.lbl_ui_fps.setAlignment(Qt.AlignRight) flatten_layout = QHBoxLayout() flatten_layout.addWidget(self.pb_flatten) flatten_layout.addWidget(self.pb_restore_flat) flatten_layout.addWidget(self.pb_set_flat) column_2.addLayout(flatten_layout) column_2.addLayout(loop_control_layout) #column_2.addWidget(self.cb_fast_centroiding) column_2.addLayout(aberration_layout) #column_2.addLayout(exp_layout) #column_2.addLayout(centroiding_layout) if ccfg.estimate_background: column_2.addLayout(bg_layout) #column_2.addLayout(poke_layout) #column_2.addLayout(modal_layout) if ccfg.use_dark_subtraction: column_2.addLayout(dark_layout) column_2.addWidget(self.cb_draw_boxes) column_2.addWidget(self.cb_draw_lines) column_2.addWidget(self.pb_quit) column_2.addWidget(self.stripchart_error) #column_2.addWidget(self.stripchart_defocus) column_2.addWidget(self.lbl_tip) column_2.addWidget(self.lbl_tilt) column_2.addWidget(self.lbl_cond) column_2.addWidget(self.ind_image_max) column_2.addWidget(self.ind_image_mean) column_2.addWidget(self.ind_image_min) column_2.addWidget(self.ind_mean_box_background) column_2.addWidget(self.ind_centroiding_time) column_2.addWidget(self.lbl_sensor_fps) column_2.addWidget(self.lbl_mirror_fps) column_2.addWidget(self.lbl_ui_fps) column_2.addWidget(self.pb_poke) column_2.addWidget(self.pb_record_reference) column_2.addWidget(self.cb_logging) layout.addLayout(column_2,0,6,3,1) self.setLayout(layout)
def __init__(self): super().__init__() self.settings = QSettings("Vial", "Vial") themes.set_theme(self.get_theme()) self.current_device = None self.devices = [] # create empty VIA definitions. Easier than setting it to none and handling a bunch of exceptions self.via_stack_json = {"definitions": {}} self.sideload_json = None self.sideload_vid = self.sideload_pid = -1 self.combobox_devices = QComboBox() self.combobox_devices.currentIndexChanged.connect( self.on_device_selected) self.btn_refresh_devices = QToolButton() self.btn_refresh_devices.setToolButtonStyle(Qt.ToolButtonTextOnly) self.btn_refresh_devices.setText(tr("MainWindow", "Refresh")) self.btn_refresh_devices.clicked.connect(self.on_click_refresh) layout_combobox = QHBoxLayout() layout_combobox.addWidget(self.combobox_devices) layout_combobox.addWidget(self.btn_refresh_devices) self.layout_editor = LayoutEditor() self.keymap_editor = KeymapEditor(self.layout_editor) self.firmware_flasher = FirmwareFlasher(self) self.macro_recorder = MacroRecorder() self.matrix_tester = MatrixTest(self.layout_editor) self.editors = [(self.keymap_editor, "Keymap"), (self.layout_editor, "Layout"), (self.macro_recorder, "Macros"), (self.matrix_tester, "Matrix tester"), (self.firmware_flasher, "Firmware updater")] Unlocker.global_layout_editor = self.layout_editor self.tabs = QTabWidget() self.refresh_tabs() self.lbl_no_devices = QLabel( tr( "MainWindow", 'No devices detected. Connect a Vial-compatible device and press ' '"Refresh"\n' 'or select "File" → "Download VIA definitions" in order to enable' ' support for VIA keyboards.')) self.lbl_no_devices.setAlignment(Qt.AlignCenter) layout = QVBoxLayout() layout.addLayout(layout_combobox) layout.addWidget(self.tabs) layout.addWidget(self.lbl_no_devices) layout.setAlignment(self.lbl_no_devices, Qt.AlignHCenter) w = QWidget() w.setLayout(layout) self.setCentralWidget(w) self.init_menu() # cache for via definition files self.cache_path = QStandardPaths.writableLocation( QStandardPaths.CacheLocation) if not os.path.exists(self.cache_path): os.makedirs(self.cache_path) # check if the via defitions already exist if os.path.isfile(os.path.join(self.cache_path, "via_keyboards.json")): with open(os.path.join(self.cache_path, "via_keyboards.json")) as vf: self.via_stack_json = json.load(vf) vf.close() # make sure initial state is valid self.on_click_refresh()
def __init__(self, lbl='', onColor='green', offColor='red', initialState=False, maxSize=50, position=1, parent=None, callback=None, alignment=1, valignment=1): QFrame.__init__(self, parent) self.numberControl = ToggleSwitch(onColor, offColor, initialState, maxSize, parent, callback) if position < 3: layout = QVBoxLayout() else: layout = QHBoxLayout() self.lbl = lbl self.lblcontrol = QLabel(lbl, self) if position == 3: # left of switch self.lblcontrol.setAlignment(Qtc.AlignRight) elif position == 4: # right of switch self.lblcontrol.setAlignment(Qtc.AlignLeft) else: # Above or below self.lblcontrol.setAlignment(Qtc.AlignCenter) # add top or left if len: if position == 1 or position == 3: layout.addWidget(self.lblcontrol) layout.addWidget(self.numberControl) # Add bottom or right if len: if position == 2 or position == 4: layout.addWidget(self.lblcontrol) if alignment == 1: halign = Qtc.AlignCenter elif alignment == 2: halign = Qtc.AlignLeft else: halign = Qtc.AlignRight if valignment == 1: valign = Qtc.AlignVCenter elif valignment == 2: valign = Qtc.AlignTop else: valign = Qtc.AlignBottom layout.setAlignment(halign | valign) self.setLayout(layout) textfont = self.lblcontrol.font() metrics = QFontMetricsF(textfont) maxWidth = max((maxSize + 4), (maxSize * 2 + metrics.width(lbl))) maxHeight = max((maxSize / 2 + 4), (maxSize / 2 + metrics.height() + 2)) self.setMinimumSize(int(maxWidth), int(maxHeight)) self.show()
def set_controls(self, task_name: str): """Generates the labels and controls that appear in the controls area.""" # Clear the current toolbar: self.toolbar.clear() # Clear the current task panel: self.clear_layout(self.taskLayout) # Clear the current controls: self.clear_layout(self.controlsLayout) # Enable the refresh menu action in the View menu: self.refreshAct.setDisabled(False) # Load our task from global config: task = self.config["tasks"][task_name] # Make the toolbar items: if "label" in task: label_text = task["label"] else: label_text = task_name taskLabel = QLabel( chr(0xF10D5) + " " + "<strong>Task: </strong>" + label_text) taskLabel.setFont(qta.font("fa", 26)) self.toolbar.addWidget(taskLabel) toolbarSpacer = QWidget(self) # right-aligns the refresh button toolbarSpacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) refreshButton = QAction(qta.icon("mdi.refresh"), "Refresh", self) refreshButton.setStatusTip("Refresh the controls.") refreshButton.triggered.connect(self.load_config) self.toolbar.addWidget(toolbarSpacer) self.toolbar.addAction(refreshButton) # Make the task info panel: if "description" in task: taskLabel.setToolTip(task["description"]) taskDescription = QWidget() taskDescription.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Expanding) descriptionLayout = QVBoxLayout() descriptionLayout.setAlignment(Qt.AlignTop) descriptionLabel = QLabel(task["description"]) descriptionLabel.setWordWrap(True) descriptionHeading = QLabel( chr(0xF0EA7) + " " + "<strong>Description: </strong>") descriptionHeading.setFont(qta.font("fa", 26)) descriptionLayout.addWidget(descriptionHeading) descriptionLayout.addWidget(descriptionLabel) taskDescription.setLayout(descriptionLayout) self.taskLayout.addWidget(taskDescription, 6) if "sessions" in task: taskSessions = QWidget() sessionLayout = QVBoxLayout() sessionLayout.setAlignment(Qt.AlignTop) sessionsHeading = QLabel( chr(0xF0ED8) + " " + "<strong>Sessions: </strong>") sessionsHeading.setFont(qta.font("fa", 26)) sessionLayout.addWidget(sessionsHeading) for k, v in task["sessions"].items(): sessionLayout.addWidget(QLabel(v)) taskSessions.setLayout(sessionLayout) self.taskLayout.addWidget(taskSessions, 6) else: spacer = QWidget(self) spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) self.taskLayout.addWidget(spacer, 6) # Refresh the task info panel layout: self.task_panel.setLayout(self.taskLayout) # Make controls for this task: task["key"] = task_name # Insert task id key to the task dict # Construct on/off button controls for each board in our task: for key, board in task["boards"].items(): self.controlsLayout.addWidget(OnOffWidget(board, task)) self.controls.setLayout(self.controlsLayout)