def test_addWidget(self, sample_list_str): from PySideLib.QCdtWidgets import QTagWidget app = QApplication() mainwWindow = QMainWindow() tagWidget = QTagWidget(mainwWindow, sample_list_str) mainwWindow.setCentralWidget(tagWidget) mainwWindow.show()
def __init__(self, workspace, *args, **kwargs): super().__init__("interaction console", workspace, *args, **kwargs) self.base_caption = "Interaction Console" self.workspace = workspace self.target = None self.conversations = {} self.terminal = TerminalWidget(command=None) self.analyzer = None self.interaction_context = None main_layout = QVBoxLayout() controls_layout = QHBoxLayout() connect_button = QPushButton() connect_button.setText("Connect") connect_button.clicked.connect(self.connect) controls_layout.addWidget(connect_button) terminal_window = QMainWindow() terminal_window.setWindowFlags(Qt.Widget) terminal_window.setCentralWidget(self.terminal) main_layout.addLayout(controls_layout) main_layout.addWidget(terminal_window) self.setLayout(main_layout)
class QtPysideApp(QApplication): def __init__(self, renderer, title): QApplication.__init__(self, sys.argv) self.window = QMainWindow() self.window.setWindowTitle(title) self.window.resize(800,600) # Get OpenGL 4.1 context glformat = QGLFormat() glformat.setVersion(4, 1) glformat.setProfile(QGLFormat.CoreProfile) glformat.setDoubleBuffer(False) self.glwidget = MyGlWidget(renderer, glformat, self) self.window.setCentralWidget(self.glwidget) self.window.show() def __enter__(self): "setup for RAII using 'with' keyword" return self def __exit__(self, type_arg, value, traceback): "cleanup for RAII using 'with' keyword" self.glwidget.disposeGL() def run_loop(self): retval = self.exec_() sys.exit(retval)
def initWins(self): # viewer main form newWin = QMainWindow(self.mainWin) newWin.setAttribute(Qt.WA_DeleteOnClose) newWin.setContextMenuPolicy(Qt.CustomContextMenu) self.newWin = newWin # image list listWdg = dragQListWidget() listWdg.setWrapping(False) listWdg.setSelectionMode(QAbstractItemView.ExtendedSelection) listWdg.setContextMenuPolicy(Qt.CustomContextMenu) listWdg.label = None listWdg.setViewMode(QListWidget.IconMode) # set icon and listWdg sizes listWdg.setIconSize(QSize(self.iconSize, self.iconSize)) listWdg.setMaximumSize(160000, self.iconSize + 20) listWdg.setDragDropMode(QAbstractItemView.DragDrop) listWdg.customContextMenuRequested.connect(self.contextMenu) # dock the form dock = stateAwareQDockWidget(window) dock.setWidget(newWin) dock.setWindowFlags(newWin.windowFlags()) dock.setWindowTitle(newWin.windowTitle()) dock.setAttribute(Qt.WA_DeleteOnClose) self.dock = dock window.addDockWidget(Qt.BottomDockWidgetArea, dock) newWin.setCentralWidget(listWdg) self.listWdg = listWdg self.newWin.setWhatsThis("""<b>Library Viewer</b><br> To <b>open context menu</b> right click on an icon or a selection.<br> To <b>open an image</b> drag it onto the main window.<br> <b>Rating</b> is shown as 0 to 5 stars below each icon.<br> """) # end setWhatsThis
def _init_widgets(self): main = QMainWindow() main.setWindowFlags(Qt.Widget) # main.setCorner(Qt.TopLeftCorner, Qt.TopDockWidgetArea) # main.setCorner(Qt.TopRightCorner, Qt.RightDockWidgetArea) pathtree = QPathTree(self.current_simgr, self.current_state, self, self.workspace, parent=main) pathtree_dock = QDockWidget('PathTree', pathtree) main.setCentralWidget(pathtree_dock) # main.addDockWidget(Qt.BottomDockWidgetArea, pathtree_dock) pathtree_dock.setWidget(pathtree) simgrs = QSimulationManagers(self.workspace.instance, self.current_simgr, self.current_state, parent=main) simgrs_dock = QDockWidget('SimulationManagers', simgrs) main.addDockWidget(Qt.RightDockWidgetArea, simgrs_dock) simgrs_dock.setWidget(simgrs) state_viewer = StateInspector(self.workspace, self.current_state, parent=self) state_viewer_dock = QDockWidget('Selected State', state_viewer) main.addDockWidget(Qt.RightDockWidgetArea, state_viewer_dock) state_viewer_dock.setWidget(state_viewer) self._pathtree = pathtree self._simgrs = simgrs self._state_viewer = state_viewer main_layout = QHBoxLayout() main_layout.addWidget(main) main_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(main_layout)
def _init_widgets(self): window = QMainWindow() window.setWindowFlags(Qt.Widget) # pseudo code text box self._textedit = QCCodeEdit(self) self._textedit.setTextInteractionFlags(Qt.TextSelectableByKeyboard | Qt.TextSelectableByMouse) self._textedit.setLineWrapMode(QCCodeEdit.NoWrap) textedit_dock = QDockWidget('Code', self._textedit) window.setCentralWidget(textedit_dock) textedit_dock.setWidget(self._textedit) # decompilation self._options = QDecompilationOptions(self, self.workspace.instance, options=None) options_dock = QDockWidget('Decompilation Options', self._options) window.addDockWidget(Qt.RightDockWidgetArea, options_dock) options_dock.setWidget(self._options) layout = QHBoxLayout() layout.addWidget(window) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) self.workspace.plugins.instrument_code_view(self)
def main(): app = QApplication(sys.argv) mainWindow = QMainWindow() wrapper = AudioSplitter() mainWindow.setCentralWidget(wrapper) mainWindow.show() sys.exit(app.exec_())
def run_interface(): app = QApplication(sys.argv) window = QMainWindow() widget = DicomMoveWindow() window.setCentralWidget(widget) window.setWindowTitle("Dicom move") window.resize(600, widget.sizeHint().height()) window.show() sys.exit(app.exec_())
def main(): app = QApplication() window = QMainWindow() window.setMinimumSize(QSize(640, 480)) imageFlow = FlowWidget(window) proxy = QSortFilterProxyModel() proxy.setFilterRole(FlowModel.FileNameRole) proxy.setSortRole(FlowModel.FileNameRole) imageFlow.setProxyModel(proxy) searchFilter = QLineEdit() searchFilter.textChanged.connect( lambda text: proxy.setFilterWildcard(text)) layout = QVBoxLayout() layout.addWidget(searchFilter) layout.addWidget(imageFlow) widget = QWidget() widget.setLayout(layout) window.setCentralWidget(widget) window.show() # 画像を同期読み込み # for i, filePath in enumerate(glob.glob('C:/tmp/test_images2/*.png')): # image = QImage(filePath).scaled(100, 100) # item = FlowItem(filePath) # item.setImage(image) # imageFlow.appendItem(item) # 画像を非同期読み込み loader = BatchImageLoader() loader.addCallback(ImageLoadingCallback.LOADED, lambda img: img.scaled(100, 100)) tasks = {} def _on_load_image(taskId): filePath = tasks[taskId] image = loader.image(taskId) item = FlowItem(filePath, image) imageFlow.appendItem(item) def _on_load_complete(): proxy.sort(0) loader.loaded.connect(_on_load_image) loader.completed.connect(_on_load_complete) for filePath in glob.iglob('C:/tmp/test_images/*.png'): taskId = loader.addFile(filePath) tasks[taskId] = filePath loader.loadAsync() sys.exit(app.exec_())
def make_pdl_editor(parent): pdl_editor = PDLEditor() w = QMainWindow(parent=parent) w.setCentralWidget(pdl_editor) w.setWindowModality(Qt.WindowModal) w.resize(1000, 800) return w
def start(self): """Display the main window and pass control to the Gui object.""" main_window = QMainWindow() self.main_window = main_window self._build_menu_bar(main_window) tab_holder = TabHolder() self.tab_holder = tab_holder main_window.setCentralWidget(tab_holder) main_window.setGeometry(0, 0, 1000, 700) main_window.show() if len(sys.argv) > 1: self.create_or_open_database(sys.argv[1]) self.exec_()
def test_ThemeWidget(self): """ python -m unittest tests.test_qt.QtTest.test_ThemeWidget :return: """ app = QApplication(sys.argv) window = QMainWindow() widget = MyThemeWidget(None) window.setCentralWidget(widget) available_geometry = app.desktop().availableGeometry(window) size = available_geometry.height() * 0.75 window.setFixedSize(size, size * 0.8) window.show() app.exec_()
class App(QApplication): def __init__(self, sys_argv): super().__init__(sys_argv) # Show main window self.view = QMainWindow() self.centralWidget = QWidget(self.view) self.gridLayout = QGridLayout(self.centralWidget) self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setSpacing(0) self.video_item = QVideoWidget() self.gridLayout.addWidget(self.video_item) self.view.setCentralWidget(self.centralWidget) self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface) self.grabber = VideoFrameGrabber(self.video_item, self) self.mediaPlayer.setVideoOutput(self.grabber) self.grabber.frameAvailable.connect(self.process_frame) self.mediaPlayer.durationChanged.connect(self.update_duration) self.mediaPlayer.positionChanged.connect(self.update_slider_position) local = QUrl.fromLocalFile('D:\\SampleData\\albamonSample.mp4') media = QMediaContent(local) self.mediaPlayer.setMedia(media) self.mediaPlayer.play() self.view.show() def process_frame(self, image): # Save image here image.save('D:\\SampleData/temp/{}.jpg'.format(str(uuid.uuid4()))) def update_duration(self): pass def update_slider_position(self): pass
def _open_item_tracker(self): # Importing this at root level seems to crash linux tests :( from PySide2.QtWebEngineWidgets import QWebEngineView tracker_window = QMainWindow() tracker_window.setWindowTitle("Item Tracker") tracker_window.resize(370, 380) web_view = QWebEngineView(tracker_window) tracker_window.setCentralWidget(web_view) self.web_view = web_view def update_window_icon(): tracker_window.setWindowIcon(web_view.icon()) web_view.iconChanged.connect(update_window_icon) web_view.load(QUrl("https://spaghettitoastbook.github.io/echoes/tracker/")) tracker_window.show() self._item_tracker_window = tracker_window
def __init__(self, window: QMainWindow, vscreen: VScreen): self.window = window self.vscreen = vscreen window.setWindowFlags(Qt.Window | Qt.MSWindowsFixedSizeDialogHint | Qt.WindowMinimizeButtonHint | Qt.WindowCloseButtonHint | Qt.CustomizeWindowHint) self.centralWidget = QWidget() self.centralWidget.setLayout(QVBoxLayout()) self.centralWidget.layout().setContentsMargins(0, 0, 0, 0) window.setCentralWidget(self.centralWidget) self.monitor_overview_widget = VScreenOverview(vscreen, window) self.centralWidget.layout().addWidget(self.monitor_overview_widget) self.sub_widget = QWidget() self.sub_layout = QVBoxLayout() self.sub_widget.setLayout(self.sub_layout) self.centralWidget.layout().addWidget(self.sub_widget) self.monitor_info_group = QGroupBox() self.monitor_info_group.setLayout(QHBoxLayout()) for monitor in self.vscreen.monitor_order: info_box = QGroupBox("Monitor Information") info_box.ui = UiMonitorInfoBox(info_box, monitor) self.monitor_info_group.layout().addWidget(info_box) self.sub_layout.addWidget(self.monitor_info_group) self.button_group = QDialogButtonBox(Qt.Horizontal) self.button_group.setStyleSheet('* { button-layout: 2 }') self.close_button = self.button_group.addButton("Close", QDialogButtonBox.RejectRole) self.adjust_button = self.button_group.addButton("Adjust", QDialogButtonBox.ActionRole) self.about_button = self.button_group.addButton("About", QDialogButtonBox.HelpRole) self.sub_layout.addWidget(self.button_group) self.translate_ui()
def _init_widgets(self): self._linear_viewer = QLinearDisassembly(self.workspace, self, parent=self) self._flow_graph = QDisassemblyGraph(self.workspace, self, parent=self) self._feature_map = QFeatureMap(self, parent=self) self._statusbar = QDisasmStatusBar(self, parent=self) vlayout = QVBoxLayout() vlayout.addWidget(self._feature_map) vlayout.addWidget(self._flow_graph) vlayout.addWidget(self._linear_viewer) vlayout.addWidget(self._statusbar) vlayout.setContentsMargins(0, 0, 0, 0) self._feature_map.setMaximumHeight(25) vlayout.setStretchFactor(self._feature_map, 0) vlayout.setStretchFactor(self._flow_graph, 1) vlayout.setStretchFactor(self._linear_viewer, 1) vlayout.setStretchFactor(self._statusbar, 0) hlayout = QHBoxLayout() hlayout.addLayout(vlayout) base = QWidget() base.setLayout(hlayout) main_window = QMainWindow() main_window.setWindowFlags(Qt.Widget) main_window.setCentralWidget(base) self.main_window = main_window main_layout = QHBoxLayout() main_layout.addWidget(main_window) self.setLayout(main_layout) self.display_disasm_graph() # self.display_linear_viewer() self.workspace.plugins.instrument_disassembly_view(self)
def viewImage(self): """ display full size image in a new window Unused yet """ parent = window newWin = QMainWindow(parent) newWin.setAttribute(Qt.WA_DeleteOnClose) newWin.setContextMenuPolicy(Qt.CustomContextMenu) label = imageLabel(parent=newWin) label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) label.img = None newWin.setCentralWidget(label) sel = self.listWdg.selectedItems() item = sel[0] filename = item.data(Qt.UserRole)[0] newWin.setWindowTitle(filename) imImg = imImage.loadImageFromFile(filename, createsidecar=False, window=window) label.img = imImg newWin.showMaximized()
# for rect in rects: # dr = DraggableRectangle(rect) # dr.connect() # 本来なら終了時に disconnectするのでしょうね # drs.append(dr) # drの上書き防止 ### plt.show() # ラベル text = QLabel("drg_rect2.py") text.setAlignment(Qt.AlignCenter) # ボタン button = QPushButton("Click me!!!") # レイアウトを構成 layout = QVBoxLayout() layout.addWidget(text) layout.addWidget(button) layout.addWidget(canvas) widget = QWidget() widget.setLayout(layout) ### widget.show() window = QMainWindow() ### window.setCentralWidget(canvas) window.setCentralWidget(widget) window.show() app.exec_()
series2 = QtCharts.QPieSeries() series2.setName("Renewables") series2.append("Wood fuels", 319663) series2.append("Hydro power", 45875) series2.append("Wind power", 1060) series3 = QtCharts.QPieSeries() series3.setName("Others") series3.append("Nuclear energy", 238789) series3.append("Import energy", 37802) series3.append("Other", 32441) donut_breakdown = DonutBreakdownChart() donut_breakdown.setAnimationOptions(QtCharts.QChart.AllAnimations) donut_breakdown.setTitle("Total consumption of energy in Finland 2010") donut_breakdown.legend().setAlignment(Qt.AlignRight) donut_breakdown.add_breakdown_series(series1, Qt.red) donut_breakdown.add_breakdown_series(series2, Qt.darkGreen) donut_breakdown.add_breakdown_series(series3, Qt.darkBlue) window = QMainWindow() chart_view = QtCharts.QChartView(donut_breakdown) chart_view.setRenderHint(QPainter.Antialiasing) window.setCentralWidget(chart_view) available_geometry = app.desktop().availableGeometry(window) size = available_geometry.height() * 0.75 window.resize(size, size * 0.8) window.show() sys.exit(app.exec_())
class MainWindow(BaseQtView): def __init__(self, title: str = "", volume_widget: Optional[QWidget] = None, slice_widget: Optional[QWidget] = None): self.title = title self.volume_widget = volume_widget if volume_widget else QWidget() self.slice_widget = slice_widget if slice_widget else QWidget() self._init() def _init(self): print("Building...") self.win = QMainWindow() self._default_window_title = self.title widget = QWidget() self.win.setCentralWidget(widget) main_layout = QHBoxLayout() widget.setLayout(main_layout) main_layout.addWidget(self.slice_widget) main_layout.addWidget(self.volume_widget) side_layout = QVBoxLayout() main_layout.addLayout(side_layout) load_image_button = QPushButton("Load Section") side_layout.addWidget(load_image_button) load_image_button.clicked.connect(self.show_load_image_dialog) # Atlas BUttons button_hbox = QHBoxLayout() side_layout.addLayout(button_hbox) atlas_buttons = QButtonGroup(self.win) atlas_buttons.setExclusive(True) atlas_buttons.buttonToggled.connect(self.atlas_button_toggled) for resolution in [100, 25, 10]: atlas_button = QPushButton(f"{resolution}um") atlas_button.setCheckable(True) button_hbox.addWidget(atlas_button) atlas_buttons.addButton(atlas_button) # The 10um atlas takes way too long to download at the moment. # It needs some kind of progress bar or async download feature to be useful. # The disabled button here shows it as an option for the future, but keeps it from being used. if resolution == 10: atlas_button.setDisabled(True) self.title_reset_timer = Timer(interval=2, connect=lambda e: self._show_default_window_title(), iterations=1, start=False) self._show_default_window_title() self.statusbar = self.win.statusBar() self.image_coord_label = QLabel(text="Image Coords") self.statusbar.addPermanentWidget(self.image_coord_label) self.win.show() @property def qt_widget(self) -> QWidget: return self.win def on_image_coordinate_highlighted(self, image_coords, atlas_coords): i, j = image_coords x, y, z = atlas_coords self.image_coord_label.setText(f"(i={i}, j={j}) (x={x:.1f}, y={y:.1f}, z={z:.1f})") def on_error_raised(self, msg: str): self.show_temp_title(msg) def atlas_button_toggled(self, button: QPushButton, is_checked: bool): if not is_checked: # Don't do anything for the button being unselected. return resolution_label = button.text() resolution = int("".join(filter(str.isdigit, resolution_label))) self.load_atlas(resolution=resolution) # Command Routing def show_load_image_dialog(self): filename, filetype = QFileDialog.getOpenFileName( parent=self.win, caption="Load Image", dir="../data/RA_10X_scans/MEA", filter="OME-TIFF (*.ome.tiff)" ) if not filename: return self.load_section(filename=filename) def load_atlas(self, resolution: int): raise NotImplementedError("Connect to LoadAtlasCommand before using.") def load_section(self, filename: str): raise NotImplementedError("Connect to a LoadImageCommand before using.") # View Code def _show_default_window_title(self): self.win.setWindowTitle(self._default_window_title) def show_temp_title(self, title: str) -> None: self.win.setWindowTitle(title) self.title_reset_timer.stop() self.title_reset_timer.start(iterations=1)
class SeedTableView(BaseView): def __init__(self, workspace: Workspace, *args, **kwargs): super().__init__("SeedTableView", workspace, *args, **kwargs) self.base_caption = "Seed Table" self.workspace = workspace self.instance = workspace.instance workspace.instance.project.am_subscribe(self.on_project_load) self._init_widgets() def page_changed(self, i): self.table_data.set_page(self.page_dropdown.currentIndex() + 1) def _init_widgets(self): self.main = QMainWindow() self.main.setWindowFlags(Qt.Widget) self.container = QWidget() # create containing widget to keep things nice self.container.setLayout(QVBoxLayout()) # count label self.seed_count_label = QLabel("Count:") # create table self.page_dropdown = QComboBox() self.table = SeedTableWidget(self, self.workspace) self.table_data = SeedTableModel(self.workspace, self.table, self.page_dropdown, self.seed_count_label) self.table.setModel(self.table_data) self.table.init_parameters() # need to set table model before messing with column resizing self.container.layout().addWidget(self.table) # create bottom section self.bottom_widget = QWidget() self.bottom_widget.setLayout(QHBoxLayout()) # page buttons self.next_page_btn = QPushButton(">") self.next_page_btn.setMaximumWidth(40) self.next_page_btn.clicked.connect(self.table_data.go_next_page) self.prev_page_btn = QPushButton("<") self.prev_page_btn.setMaximumWidth(40) self.prev_page_btn.clicked.connect(self.table_data.go_prev_page) # page label self.page_label = QLabel("Page:") # page dropdown self.page_dropdown.addItems(list(map(str, range(1, 1)))) # test self.page_dropdown.setCurrentIndex(0) self.page_dropdown.activated.connect(self.page_changed) # filter box self.filter_box = SeedTableFilterBox(self) self.filter_box.returnPressed.connect(self._on_filter_change) # filter checkboxes # "NC", "C", "NT", "L", "E" self.nc_checkbox = QCheckBox("NC") self.nc_checkbox.stateChanged.connect(self._on_filter_change) self.c_checkbox = QCheckBox("C") self.c_checkbox.stateChanged.connect(self._on_filter_change) self.nt_checkbox = QCheckBox("NT") self.nt_checkbox.stateChanged.connect(self._on_filter_change) self.l_checkbox = QCheckBox("L") self.l_checkbox.stateChanged.connect(self._on_filter_change) self.e_checkbox = QCheckBox("E") self.e_checkbox.stateChanged.connect(self._on_filter_change) self.bottom_widget.layout().addWidget(self.seed_count_label) self.bottom_widget.layout().addWidget(self.filter_box) self.bottom_widget.layout().addWidget(self.nc_checkbox) self.bottom_widget.layout().addWidget(self.c_checkbox) self.bottom_widget.layout().addWidget(self.nt_checkbox) self.bottom_widget.layout().addWidget(self.l_checkbox) self.bottom_widget.layout().addWidget(self.e_checkbox) # self.bottom_widget.layout().addStretch() self.bottom_widget.layout().addWidget(self.prev_page_btn) self.bottom_widget.layout().addWidget(self.page_label) self.bottom_widget.layout().addWidget(self.page_dropdown) self.bottom_widget.layout().addWidget(self.next_page_btn) self.container.layout().addWidget(self.bottom_widget) self.main.setCentralWidget(self.container) main_layout = QVBoxLayout() main_layout.addWidget(self.main) self.setLayout(main_layout) def on_project_load(self, **kwargs): if self.instance.project.am_none: return pass def _on_filter_change(self): raw_filter = self.filter_box.text() inp = None if len(raw_filter) > 0: inp, _ = codecs.escape_decode(raw_filter, 'hex') flags = [] if self.nc_checkbox.isChecked(): flags.append("non-crashing") if self.c_checkbox.isChecked(): flags.append("crashing") if self.l_checkbox.isChecked(): flags.append("leaking") if self.nt_checkbox.isChecked(): flags.append("non-terminating") if self.e_checkbox.isChecked(): flags.append("exploit") self.table_data.clear_seeds() if len(flags) == 0 and inp is None: data = self.table_data.seed_db.get_all_seeds() else: if inp: data = self.table_data.seed_db.filter_seeds_by_value(inp) data = list(filter(lambda s: all([x in s.tags for x in flags]), data)) else: data = self.table_data.seed_db.filter_seeds_by_tag(tags=flags) self.table_data.add_seed(data)
from board_widget import BoardWidget from top_widget import TopWidget class Center(QWidget): def __init__(self, parent=None): super(Center, self).__init__(parent) layout = QVBoxLayout() p = self.palette() p.setColor(QPalette.Background, QColor(192, 192, 192)) self.setPalette(p) self.setAutoFillBackground(True) self.board = BoardWidget(16, 30, 99, parent=self) self.top = TopWidget(99, parent=self) layout.addWidget(self.top) layout.addWidget(self.board) self.setLayout(layout) if __name__ == '__main__': app = QApplication(sys.argv) window = QMainWindow() window.setCentralWidget(Center(parent=window)) window.setWindowTitle('Definitely not minesweeper') window.show() sys.exit(app.exec_())
from PySide2.QtWidgets import QMainWindow, QWidget, QGridLayout from pyqtgraph import ViewBox, PlotItem from pyqtgraph.Qt import QtGui, QtCore import pyqtgraph as pg app = QtGui.QApplication([]) window = QMainWindow() holder = QWidget() holder_layout = QGridLayout() holder.setLayout(holder_layout) window.setCentralWidget(holder) # # Grid section # grid_widget = pg.GraphicsLayoutWidget() grid_viewBox1 = ViewBox(enableMenu=True) grid_viewBox1.setXRange(0, 5, padding=0) grid_viewBox1.setYRange(0, 2.5, padding=0) grid_subplot1 = PlotItem(viewBox=grid_viewBox1) grid_subplot1.showGrid(True, True, 0.2) grid_viewBox1.setParent(grid_subplot1) grid_widget.addItem(grid_subplot1, col=0, row=0) grid_viewBox2 = ViewBox(enableMenu=True) grid_viewBox2.setXRange(0, 5, padding=0) grid_viewBox2.setYRange(0, 2.5, padding=0) grid_subplot2 = PlotItem(viewBox=grid_viewBox2) grid_subplot2.showGrid(True, True, 0.2) grid_viewBox2.setParent(grid_subplot2)
''.join(self.PrimerNombre.text()), ''.join(self.SegundoNombre.text()), ''.join(self.PrimerApellido.text()), ''.join(self.SegundoApellido.text()), ''.join(self.fechaDeNacimiento.text())) def limpiarCampos(self): self.DNI.clear() self.DNI.setReadOnly(False) self.PrimerNombre.clear() self.SegundoNombre.clear() self.PrimerApellido.clear() self.SegundoApellido.clear() self.fechaDeNacimiento.setDate(date.today()) #limpiar campos de texto y permitir la edicion de todos ellos def limpiarErrores(self): self.mostrarError.clear() def volverAlMenu(self): raiz.setCentralWidget(None) raiz.setCentralWidget(VentanaPrincipal()) if __name__ == '__main__': app = QApplication(sys.argv) raiz = QMainWindow() raiz.setCentralWidget(VentanaPrincipal()) raiz.show() sys.exit(app.exec_())
def __init__(self, Script:QMainWindow): # Set window parameters Script.setWindowTitle("ASL Tools - Script") Script.setWindowFlag(Qt.Window) # Main frame frame = QWidget(Script) self.h_layout = QHBoxLayout(frame) # Menubar menubar = Script.menuBar() menu_file:QMenu = menubar.addMenu("Fichier") self.action_file_new = QAction("Nouveau", menubar) self.action_file_new.setIcon(QIcon(":/images/new-file.svg")) self.action_file_new.setShortcut("Ctrl+N") menu_file.addAction(self.action_file_new) self.action_file_open = QAction("Ouvrir", menubar) self.action_file_open.setIcon(QIcon(":/images/open-file.svg")) self.action_file_open.setShortcut("Ctrl+O") menu_file.addAction(self.action_file_open) self.action_file_save = QAction("Enregistrer", menubar) self.action_file_save.setIcon(QIcon(":/images/save.svg")) self.action_file_save.setShortcut("Ctrl+S") menu_file.addAction(self.action_file_save) self.action_file_saveas = QAction("Enregistrer sous", menubar) self.action_file_saveas.setIcon(QIcon(":/images/save-as.svg")) self.action_file_saveas.setShortcut("Ctrl+Shift+S") menu_file.addAction(self.action_file_saveas) menu_file.addSeparator() self.action_file_export = QAction("Exporter", menubar) self.action_file_export.setIcon(QIcon(":/images/export.svg")) menu_file.addAction(self.action_file_export) menu_file.addSeparator() self.action_file_quit = QAction("Quitter", menubar) self.action_file_quit.setIcon(QIcon(":/images/quit.svg")) menu_file.addAction(self.action_file_quit) menu_edit:QMenu = menubar.addMenu("Edition") self.action_edit_copy = QAction("Copier", menubar) self.action_edit_copy.setIcon(QIcon(":/images/copy.svg")) self.action_edit_copy.setShortcut("Alt+C") menu_edit.addAction(self.action_edit_copy) self.action_edit_paste = QAction("Coller", menubar) self.action_edit_paste.setIcon(QIcon(":/images/paste.svg")) self.action_edit_paste.setShortcut("Alt+V") menu_edit.addAction(self.action_edit_paste) # Spacer spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.h_layout.addItem(spacer) # Main grid self.grid_layout = QtWidgets.QGridLayout() # Filename self.label_file = QtWidgets.QLabel(frame) self.label_file.setAlignment(QtCore.Qt.AlignCenter) self.label_file.setObjectName("label_file") self.grid_layout.addWidget(self.label_file, 0, 0, 1, 2) # Action widgets self.h_layout_actions = QtWidgets.QHBoxLayout() self.btn_add = QtWidgets.QToolButton(frame) self.btn_add.setEnabled(True) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/images/add.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.btn_add.setIcon(icon) self.btn_add.setIconSize(QtCore.QSize(24, 24)) self.btn_add.setAutoRaise(True) self.h_layout_actions.addWidget(self.btn_add) self.btn_remove = QtWidgets.QToolButton(frame) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/images/remove.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.btn_remove.setIcon(icon) self.btn_remove.setIconSize(QtCore.QSize(24, 24)) self.btn_remove.setAutoRaise(True) self.h_layout_actions.addWidget(self.btn_remove) self.btn_move_up = QtWidgets.QToolButton(frame) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/images/arrow-up.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.btn_move_up.setIcon(icon) self.btn_move_up.setIconSize(QtCore.QSize(24, 24)) self.btn_move_up.setAutoRaise(True) self.h_layout_actions.addWidget(self.btn_move_up) self.btn_move_down = QtWidgets.QToolButton(frame) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/images/arrow-down.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.btn_move_down.setIcon(icon) self.btn_move_down.setIconSize(QtCore.QSize(24, 24)) self.btn_move_down.setAutoRaise(True) self.h_layout_actions.addWidget(self.btn_move_down) spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.h_layout_actions.addItem(spacer) self.grid_layout.addLayout(self.h_layout_actions, 1, 0, 1, 1) # List widget self.list = QtWidgets.QListWidget(frame) self.grid_layout.addWidget(self.list, 2, 0, 1, 1) # Grid self.grid_layout_form = QtWidgets.QGridLayout() # Compliance self.label_compliance = QtWidgets.QLabel(frame) self.grid_layout_form.addWidget(self.label_compliance, 0, 0, 1, 1) self.compliance = QtWidgets.QSpinBox(frame) self.compliance.setMaximum(500) self.grid_layout_form.addWidget(self.compliance, 0, 1, 1, 1) # Resistance self.label_resistance = QtWidgets.QLabel(frame) self.grid_layout_form.addWidget(self.label_resistance, 1, 0, 1, 1) self.resistance = QtWidgets.QSpinBox(frame) self.resistance.setMaximum(500) self.grid_layout_form.addWidget(self.resistance, 1, 1, 1, 1) # Respiratory rate self.label_respi_rate = QtWidgets.QLabel(frame) self.grid_layout_form.addWidget(self.label_respi_rate, 2, 0, 1, 1) self.respi_rate = QtWidgets.QSpinBox(frame) self.respi_rate.setMaximum(500) self.grid_layout_form.addWidget(self.respi_rate, 2, 1, 1, 1) # Spacer spacerItem1 = QtWidgets.QSpacerItem(20, 30, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred) self.grid_layout_form.addItem(spacerItem1, 4, 0, 1, 1) # Pmus insp self.label_i_pmus = QtWidgets.QLabel(frame) self.grid_layout_form.addWidget(self.label_i_pmus, 5, 0, 1, 1) self.i_pmus = QtWidgets.QSpinBox(frame) self.i_pmus.setMaximum(100) self.grid_layout_form.addWidget(self.i_pmus, 5, 1, 1, 1) # Pmus insp inc self.label_i_pmus_inc = QtWidgets.QLabel(frame) self.grid_layout_form.addWidget(self.label_i_pmus_inc, 6, 0, 1, 1) self.i_pmus_inc = QtWidgets.QSpinBox(frame) self.i_pmus_inc.setMaximum(100) self.grid_layout_form.addWidget(self.i_pmus_inc, 6, 1, 1, 1) # Pmus insp hold self.label_i_pmus_hld = QtWidgets.QLabel(frame) self.grid_layout_form.addWidget(self.label_i_pmus_hld, 7, 0, 1, 1) self.i_pmus_hld = QtWidgets.QSpinBox(frame) self.i_pmus_hld.setMaximum(100) self.grid_layout_form.addWidget(self.i_pmus_hld, 7, 1, 1, 1) # Pmus insp rel self.label_i_pmus_rel = QtWidgets.QLabel(frame) self.grid_layout_form.addWidget(self.label_i_pmus_rel, 8, 0, 1, 1) self.i_pmus_rel = QtWidgets.QSpinBox(frame) self.i_pmus_rel.setMaximum(100) self.grid_layout_form.addWidget(self.i_pmus_rel, 8, 1, 1, 1) # Spacer spacerItem4 = QtWidgets.QSpacerItem(20, 30, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred) self.grid_layout_form.addItem(spacerItem4, 9, 0, 1, 1) # Pmus exp self.label_e_pmus = QtWidgets.QLabel(frame) self.grid_layout_form.addWidget(self.label_e_pmus, 10, 0, 1, 1) self.e_pmus = QtWidgets.QSpinBox(frame) self.e_pmus.setMaximum(100) self.grid_layout_form.addWidget(self.e_pmus, 10, 1, 1, 1) # Pmus exp inc self.label_e_pmus_inc = QtWidgets.QLabel(frame) self.grid_layout_form.addWidget(self.label_e_pmus_inc, 11, 0, 1, 1) self.e_pmus_inc = QtWidgets.QSpinBox(frame) self.e_pmus_inc.setMaximum(100) self.grid_layout_form.addWidget(self.e_pmus_inc, 11, 1, 1, 1) # Pmus exp hold self.label_e_pmus_hld = QtWidgets.QLabel(frame) self.grid_layout_form.addWidget(self.label_e_pmus_hld, 12, 0, 1, 1) self.e_pmus_hld = QtWidgets.QSpinBox(frame) self.e_pmus_hld.setMaximum(100) self.grid_layout_form.addWidget(self.e_pmus_hld, 12, 1, 1, 1) # Pmus exp rel self.label_e_pmus_rel = QtWidgets.QLabel(frame) self.grid_layout_form.addWidget(self.label_e_pmus_rel, 13, 0, 1, 1) self.e_pmus_rel = QtWidgets.QSpinBox(frame) self.e_pmus_rel.setMaximum(100) self.grid_layout_form.addWidget(self.e_pmus_rel, 13, 1, 1, 1) # Spacer spacerItem3 = QtWidgets.QSpacerItem(20, 30, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred) self.grid_layout_form.addItem(spacerItem3, 14, 0, 1, 1) # CRF self.label_crf = QtWidgets.QLabel(frame) self.grid_layout_form.addWidget(self.label_crf, 15, 0, 1, 1) self.crf = QtWidgets.QDoubleSpinBox(frame) self.crf.setDecimals(1) self.crf.setSingleStep(0.1) self.grid_layout_form.addWidget(self.crf, 15, 1, 1, 1) # Spacer spacerItem2 = QtWidgets.QSpacerItem(20, 30, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred) self.grid_layout_form.addItem(spacerItem2, 16, 0, 1, 1) # Repetions self.label_repetitions = QtWidgets.QLabel(frame) self.grid_layout_form.addWidget(self.label_repetitions, 17, 0, 1, 1) self.repetitions = QtWidgets.QSpinBox(frame) self.repetitions.setMaximum(9999) self.grid_layout_form.addWidget(self.repetitions, 17, 1, 1, 1) self.label_repetitions_total = QtWidgets.QLabel(frame) self.label_repetitions_total.setMinimumWidth(30) self.grid_layout_form.addWidget(self.label_repetitions_total, 17, 2, 1, 1) # Spacer spacerItem2 = QtWidgets.QSpacerItem(20, 30, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.grid_layout_form.addItem(spacerItem2, 18, 0, 1, 1) # Set form layout in the main grid self.grid_layout.addLayout(self.grid_layout_form, 2, 1, 1, 1) # Progress bar self.progress = QProgressBar(frame) self.progress.setMaximumHeight(10) self.progress.setTextVisible(False) self.grid_layout.addWidget(self.progress, 3, 0, 1, 2) # Spacer spacer = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.grid_layout.addItem(spacer, 4, 0, 1, 2) self.h_layout.addLayout(self.grid_layout) spacer = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.h_layout.addItem(spacer) # Set size and position w, h = self.h_layout.sizeHint().toTuple() w_s, h_s = QApplication.primaryScreen().size().toTuple() x = round(w_s/2 - w/2) y = round(h_s/2 - h/2) Script.setCentralWidget(frame) Script.resize(w, h) Script.move(x, y) self.retranslateUi(Script) QtCore.QMetaObject.connectSlotsByName(Script) Script.setTabOrder(self.btn_add, self.btn_remove) Script.setTabOrder(self.btn_remove, self.btn_move_up) Script.setTabOrder(self.btn_move_up, self.btn_move_down) Script.setTabOrder(self.btn_move_down, self.list) Script.setTabOrder(self.list, self.compliance) Script.setTabOrder(self.compliance, self.resistance) Script.setTabOrder(self.resistance, self.respi_rate) Script.setTabOrder(self.respi_rate, self.i_pmus) Script.setTabOrder(self.i_pmus, self.i_pmus_inc) Script.setTabOrder(self.i_pmus_inc, self.i_pmus_hld) Script.setTabOrder(self.i_pmus_hld, self.i_pmus_rel) Script.setTabOrder(self.i_pmus_rel, self.e_pmus) Script.setTabOrder(self.e_pmus, self.e_pmus_inc) Script.setTabOrder(self.e_pmus_inc, self.e_pmus_hld) Script.setTabOrder(self.e_pmus_hld, self.e_pmus_rel) Script.setTabOrder(self.e_pmus_rel, self.crf) Script.setTabOrder(self.crf, self.repetitions)
def __init__(self, BigScript: QMainWindow): # Set Window parameters BigScript.setWindowTitle("ASL Tools - Big Script") BigScript.setWindowFlag(Qt.Window) # Main frame frame = QWidget(BigScript) self.h_layout = QHBoxLayout(frame) # Menubar menubar = BigScript.menuBar() menu_file: QMenu = menubar.addMenu("Fichier") self.action_file_new = QAction("Nouveau", menubar) self.action_file_new.setIcon(QIcon(":/images/new-file.svg")) self.action_file_new.setShortcut("Ctrl+N") menu_file.addAction(self.action_file_new) self.action_file_save = QAction("Enregistrer", menubar) self.action_file_save.setIcon(QIcon(":/images/save.svg")) self.action_file_save.setShortcut("Ctrl+S") menu_file.addAction(self.action_file_save) self.action_file_saveas = QAction("Enregistrer sous", menubar) self.action_file_saveas.setIcon(QIcon(":/images/save-as.svg")) self.action_file_saveas.setShortcut("Ctrl+Shift+S") menu_file.addAction(self.action_file_saveas) menu_file.addSeparator() self.action_file_export = QAction("Exporter", menubar) self.action_file_export.setIcon(QIcon(":/images/export.svg")) menu_file.addAction(self.action_file_export) menu_file.addSeparator() self.action_file_quit = QAction("Quitter", menubar) self.action_file_quit.setIcon(QIcon(":/images/quit.svg")) menu_file.addAction(self.action_file_quit) # Spacer spacerItem = QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.h_layout.addItem(spacerItem) # Grid layout self.gridLayout = QtWidgets.QGridLayout() self.gridLayout.setSpacing(15) # File self.label_file = QtWidgets.QLabel(frame) self.label_file.setTextFormat(QtCore.Qt.PlainText) self.label_file.setAlignment(QtCore.Qt.AlignCenter) self.label_file.setObjectName("label_file") self.gridLayout.addWidget(self.label_file, 0, 0, 1, 4) # Header self.label_from = QLabel(frame) self.gridLayout.addWidget(self.label_from, 1, 1, 1, 1) self.label_to = QLabel(frame) self.gridLayout.addWidget(self.label_to, 1, 2, 1, 1) self.label_step = QLabel(frame) self.gridLayout.addWidget(self.label_step, 1, 3, 1, 1) # Resistance self.label_r = QLabel(frame) self.gridLayout.addWidget(self.label_r, 2, 0, 1, 1) self.r_from = QtWidgets.QSpinBox(frame) self.r_from.setObjectName("grid-spin") self.r_from.setMinimum(0) self.r_from.setMaximum(200) self.gridLayout.addWidget(self.r_from, 2, 1, 1, 1) self.r_to = QtWidgets.QSpinBox(frame) self.r_to.setObjectName("grid-spin") self.r_to.setMinimum(0) self.r_to.setMaximum(200) self.gridLayout.addWidget(self.r_to, 2, 2, 1, 1) self.r_step = QtWidgets.QSpinBox(frame) self.r_step.setObjectName("grid-spin") self.r_step.setMinimum(1) self.gridLayout.addWidget(self.r_step, 2, 3, 1, 1) # Compliance self.label_c = QLabel(frame) self.gridLayout.addWidget(self.label_c, 3, 0, 1, 1) self.c_from = QtWidgets.QSpinBox(frame) self.c_from.setObjectName("grid-spin") self.c_from.setMinimum(0) self.c_from.setMaximum(200) self.gridLayout.addWidget(self.c_from, 3, 1, 1, 1) self.c_to = QtWidgets.QSpinBox(frame) self.c_to.setObjectName("grid-spin") self.c_to.setMinimum(0) self.c_to.setMaximum(200) self.gridLayout.addWidget(self.c_to, 3, 2, 1, 1) self.c_step = QtWidgets.QSpinBox(frame) self.c_step.setObjectName("grid-spin") self.c_step.setMinimum(1) self.gridLayout.addWidget(self.c_step, 3, 3, 1, 1) # Breath rate self.label_br = QLabel(frame) self.gridLayout.addWidget(self.label_br, 4, 0, 1, 1) self.br_from = QtWidgets.QSpinBox(frame) self.br_from.setObjectName("grid-spin") self.br_from.setMinimum(1) self.br_from.setMaximum(100) self.gridLayout.addWidget(self.br_from, 4, 1, 1, 1) self.br_to = QtWidgets.QSpinBox(frame) self.br_to.setObjectName("grid-spin") self.br_to.setMinimum(1) self.br_to.setMaximum(100) self.gridLayout.addWidget(self.br_to, 4, 2, 1, 1) self.br_step = QtWidgets.QSpinBox(frame) self.br_step.setObjectName("grid-spin") self.br_step.setMinimum(1) self.gridLayout.addWidget(self.br_step, 4, 3, 1, 1) # Pmus self.label_i_pmus = QLabel(frame) self.gridLayout.addWidget(self.label_i_pmus, 5, 0, 1, 1) self.i_pmus_from = QtWidgets.QSpinBox(frame) self.i_pmus_from.setObjectName("grid-spin") self.i_pmus_from.setMinimum(0) self.i_pmus_from.setMaximum(100) self.gridLayout.addWidget(self.i_pmus_from, 5, 1, 1, 1) self.i_pmus_to = QtWidgets.QSpinBox(frame) self.i_pmus_to.setObjectName("grid-spin") self.i_pmus_to.setMinimum(0) self.i_pmus_to.setMaximum(100) self.gridLayout.addWidget(self.i_pmus_to, 5, 2, 1, 1) self.i_pmus_step = QtWidgets.QSpinBox(frame) self.i_pmus_step.setObjectName("grid-spin") self.i_pmus_step.setMinimum(1) self.gridLayout.addWidget(self.i_pmus_step, 5, 3, 1, 1) # Pmus increase self.label_i_pmus_inc = QLabel(frame) self.gridLayout.addWidget(self.label_i_pmus_inc, 6, 0, 1, 1) self.i_pmus_inc_from = QtWidgets.QSpinBox(frame) self.i_pmus_inc_from.setObjectName("grid-spin") self.i_pmus_inc_from.setMinimum(0) self.i_pmus_inc_from.setMaximum(100) self.gridLayout.addWidget(self.i_pmus_inc_from, 6, 1, 1, 1) self.i_pmus_inc_to = QtWidgets.QSpinBox(frame) self.i_pmus_inc_to.setObjectName("grid-spin") self.i_pmus_inc_to.setMinimum(0) self.i_pmus_inc_to.setMaximum(100) self.gridLayout.addWidget(self.i_pmus_inc_to, 6, 2, 1, 1) self.i_pmus_inc_step = QtWidgets.QSpinBox(frame) self.i_pmus_inc_step.setObjectName("grid-spin") self.i_pmus_inc_step.setMinimum(1) self.gridLayout.addWidget(self.i_pmus_inc_step, 6, 3, 1, 1) # Pmus hold self.label_i_pmus_hld = QLabel(frame) self.gridLayout.addWidget(self.label_i_pmus_hld, 7, 0, 1, 1) self.i_pmus_hld_from = QtWidgets.QSpinBox(frame) self.i_pmus_hld_from.setObjectName("grid-spin") self.i_pmus_hld_from.setMinimum(0) self.i_pmus_hld_from.setMaximum(100) self.gridLayout.addWidget(self.i_pmus_hld_from, 7, 1, 1, 1) self.i_pmus_hld_to = QtWidgets.QSpinBox(frame) self.i_pmus_hld_to.setObjectName("grid-spin") self.i_pmus_hld_to.setMinimum(0) self.i_pmus_hld_to.setMaximum(100) self.gridLayout.addWidget(self.i_pmus_hld_to, 7, 2, 1, 1) self.i_pmus_hld_step = QtWidgets.QSpinBox(frame) self.i_pmus_hld_step.setObjectName("grid-spin") self.i_pmus_hld_step.setMinimum(1) self.gridLayout.addWidget(self.i_pmus_hld_step, 7, 3, 1, 1) # Pmus hold self.label_i_pmus_rel = QLabel(frame) self.gridLayout.addWidget(self.label_i_pmus_rel, 8, 0, 1, 1) self.i_pmus_rel_from = QtWidgets.QSpinBox(frame) self.i_pmus_rel_from.setObjectName("grid-spin") self.i_pmus_rel_from.setMinimum(0) self.i_pmus_rel_from.setMaximum(100) self.gridLayout.addWidget(self.i_pmus_rel_from, 8, 1, 1, 1) self.i_pmus_rel_to = QtWidgets.QSpinBox(frame) self.i_pmus_rel_to.setObjectName("grid-spin") self.i_pmus_rel_to.setMinimum(0) self.i_pmus_rel_to.setMaximum(100) self.gridLayout.addWidget(self.i_pmus_rel_to, 8, 2, 1, 1) self.i_pmus_rel_step = QtWidgets.QSpinBox(frame) self.i_pmus_rel_step.setObjectName("grid-spin") self.i_pmus_rel_step.setMinimum(1) self.gridLayout.addWidget(self.i_pmus_rel_step, 8, 3, 1, 1) # Repetitions self.label_n_cycles = QLabel(frame) self.gridLayout.addWidget(self.label_n_cycles, 9, 0, 1, 1) self.n_cycles = QtWidgets.QSpinBox(frame) self.n_cycles.setObjectName("grid-spin") self.n_cycles.setMinimum(0) self.n_cycles.setMaximum(100) self.gridLayout.addWidget(self.n_cycles, 9, 1, 1, 1) # Informations separator = QtWidgets.QFrame(frame) separator.setFrameShape(QtWidgets.QFrame.HLine) separator.setFrameShadow(QtWidgets.QFrame.Sunken) self.gridLayout.addWidget(separator, 10, 0, 1, 4) self.label_tot_simus = QLabel(frame) self.gridLayout.addWidget(self.label_tot_simus, 11, 0, 1, 1) self.tot_simus = QLabel(frame) self.gridLayout.addWidget(self.tot_simus, 11, 1, 1, 1) self.label_tot_time = QLabel(frame) self.gridLayout.addWidget(self.label_tot_time, 12, 0, 1, 3) self.tot_time = QLabel(frame) self.gridLayout.addWidget(self.tot_time, 12, 1, 1, 3) # Progress self.progress = QProgressBar(frame) self.progress.setMaximumHeight(10) self.progress.setTextVisible(False) self.gridLayout.addWidget(self.progress, 13, 0, 1, 4) # Spacer spacerItem = QSpacerItem(40, 20, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.gridLayout.addItem(spacerItem, 14, 0, 1, 4) self.h_layout.addLayout(self.gridLayout) spacerItem5 = QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.h_layout.addItem(spacerItem5) # Set size and position w, h = self.h_layout.sizeHint().toTuple() w_s, h_s = QApplication.primaryScreen().size().toTuple() x = round(w_s / 2 - w / 2) y = round(h_s / 2 - h / 2) BigScript.setCentralWidget(frame) BigScript.resize(w, h) BigScript.move(x, y) self.retranslateUi(BigScript) QtCore.QMetaObject.connectSlotsByName(BigScript)
if point in centers: self._board[point].color = Qt.red self._application.processEvents() def _toogleCenter(self, cell): cell.isCenter = not cell.isCenter cell.color = self.CELL_CENTER_COLOR if cell.isCenter else self.CELL_SIMPLE_COLOR def _clearBoard(self): for cell in self._board.values(): if not cell.isCenter: cell.color = self.CELL_SIMPLE_COLOR if __name__ == '__main__': application = QApplication(sys.argv) mainWindow = QMainWindow() mainWindow.setWindowTitle('Partition') boardWidget = BoardWidget(WINDOW_SIZE, 5, application, mainWindow.statusBar()) settingsWidget = SettingsWidget(boardWidget) mainWindow.setCentralWidget( PartitionCentralWidget(boardWidget, settingsWidget)) mainWindow.show() sys.exit(application.exec_())
def playDiaporama(diaporamaGenerator, parent=None): """ Open a new window and play a slide show. @param diaporamaGenerator: generator for file names @type diaporamaGenerator: iterator object @param parent: @type parent: """ global isSuspended isSuspended = False # init diaporama window newWin = QMainWindow(parent) newWin.setAttribute(Qt.WA_DeleteOnClose) newWin.setContextMenuPolicy(Qt.CustomContextMenu) newWin.setWindowTitle(parent.tr('Slide show')) label = imageLabel(mainForm=parent) label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) label.img = None newWin.setCentralWidget(label) newWin.showFullScreen() # Pause key shortcut actionEsc = QAction('Pause', None) actionEsc.setShortcut(QKeySequence(Qt.Key_Escape)) newWin.addAction(actionEsc) # context menu event handler def contextMenuHandler(action): global isSuspended if action.text() == 'Pause': isSuspended = True # quit full screen mode newWin.showMaximized() elif action.text() == 'Full Screen': if action.isChecked(): newWin.showFullScreen() else: newWin.showMaximized() elif action.text() == 'Resume': newWin.close() isSuspended = False playDiaporama(diaporamaGenerator, parent=window) # rating : the tag is written into the .mie file; the file is # created if needed. elif action.text() in ['0', '1', '2', '3', '4', '5']: with exiftool.ExifTool() as e: e.writeXMPTag(name, 'XMP:rating', int(action.text())) # connect shortkey action actionEsc.triggered.connect( lambda checked=False, name=actionEsc: contextMenuHandler( name)) # named arg checked is sent # context menu def contextMenu(position): menu = QMenu() actionEsc.setEnabled(not isSuspended) action2 = QAction('Full Screen', None) action2.setCheckable(True) action2.setChecked(newWin.windowState() & Qt.WindowFullScreen) action3 = QAction('Resume', None) action3.setEnabled(isSuspended) for action in [actionEsc, action2, action3]: menu.addAction(action) action.triggered.connect( lambda checked=False, name=action: contextMenuHandler( name)) # named arg checked is sent subMenuRating = menu.addMenu('Rating') for i in range(6): action = QAction(str(i), None) subMenuRating.addAction(action) action.triggered.connect( lambda checked=False, name=action: contextMenuHandler( name)) # named arg checked is sent menu.exec_(position) # connect contextMenuRequested newWin.customContextMenuRequested.connect(contextMenu) newWin.setToolTip("Esc to exit full screen mode") newWin.setWhatsThis(""" <b>Slide Show</b><br> The slide show cycles through the starting directory and its subfolders to display images. Photos rated 0 or 1 star are not shown (by default, all photos are rated 5 stars).<br> Hit the Esc key to <b>exit full screen mode and pause.</b><br> Use the Context Menu for <b>rating and resuming.</b> The rating is saved in the .mie sidecar and the image file is not modified. """) # end of setWhatsThis # play diaporama window.modeDiaporama = True while True: if isSuspended: newWin.setWindowTitle(newWin.windowTitle() + ' Paused') break try: if not newWin.isVisible(): break name = next(diaporamaGenerator) # search rating in metadata rating = 5 # default with exiftool.ExifTool() as e: try: rt = e.readXMPTag( name, 'XMP:rating') # raise ValueError if sidecar not found r = search("\d", rt) if r is not None: rating = int(r.group(0)) except ValueError: rating = 5 # don't display image with low rating if rating < 2: app.processEvents() imImg = imImage.loadImageFromFile(name, createsidecar=False, cmsConfigure=True, window=window) # zoom might be modified by the mouse wheel : remember if label.img is not None: imImg.Zoom_coeff = label.img.Zoom_coeff coeff = imImg.resize_coeff(label) imImg.yOffset -= (imImg.height() * coeff - label.height()) / 2.0 imImg.xOffset -= (imImg.width() * coeff - label.width()) / 2.0 app.processEvents() if isSuspended: newWin.setWindowTitle(newWin.windowTitle() + ' Paused') break newWin.setWindowTitle( parent.tr('Slide show') + ' ' + name + ' ' + ' '.join(['*'] * imImg.meta.rating)) gc.collect() label.img = imImg label.repaint() app.processEvents() gc.collect() sleep(2) app.processEvents() except StopIteration: newWin.close() window.diaporamaGenerator = None break except ValueError: continue except RuntimeError: window.diaporamaGenerator = None break except: window.diaporamaGenerator = None window.modeDiaporama = False raise app.processEvents() window.modeDiaporama = False
#!/usr/bin/env python import sys import matplotlib matplotlib.use('Qt5Agg') from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure from PySide2.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QGridLayout from PySide2.QtCore import Qt, QSize, QMargins if __name__ == '__main__': app = QApplication(sys.argv) # generate the plot fig = Figure(figsize=(600, 600), dpi=72, facecolor=(1, 1, 1), edgecolor=(0, 0, 0)) ax = fig.add_subplot(111) ax.plot([0, 1]) # generate the canvas to display the plot canvas = FigureCanvas(fig) win = QMainWindow() # add the plot canvas to a window win.setCentralWidget(canvas) win.show() sys.exit(app.exec_())
else: lbl.setText('') sim.cleanup() t.stop() benc_timer.stop() action.changed.connect(_handle_sim_action) toolbar = QToolBar() lbl = QLabel() benc_timer = QTimer(w) def _on_bench(): global ticks lbl.setText(f'Frequency: {ticks} Hz') ticks = 0 benc_timer.timeout.connect(_on_bench) toolbar.addAction(action) toolbar.addSeparator() toolbar.addWidget(lbl) w.addToolBar(toolbar) w.setCentralWidget(ed) w.setWindowTitle(make_title()) w.show() app.exec_()