def __init__(self, parent=None): super(AddDialogWidget, self).__init__(parent) nameLabel = QLabel("Name") addressLabel = QLabel("Address") buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.nameText = QLineEdit() self.addressText = QTextEdit() grid = QGridLayout() grid.setColumnStretch(1, 2) grid.addWidget(nameLabel, 0, 0) grid.addWidget(self.nameText, 0, 1) grid.addWidget(addressLabel, 1, 0, Qt.AlignLeft | Qt.AlignTop) grid.addWidget(self.addressText, 1, 1, Qt.AlignLeft) layout = QVBoxLayout() layout.addLayout(grid) layout.addWidget(buttonBox) self.setLayout(layout) self.setWindowTitle("Add a Contact") buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject)
def __init__(self, renderController, parent=None): super(RenderSlicerParamWidget, self).__init__(parent=parent) self.renderController = renderController self.renderController.slicesChanged.connect(self.setSlices) self.renderController.clippingBoxChanged.connect(self.showsClippingBox) self.slicesLabel = QLabel("Show slices for directions:") self.sliceLabelTexts = ["x:", "y:", "z:"] self.sliceLabels = [QLabel(text) for text in self.sliceLabelTexts] self.sliceCheckBoxes = [QCheckBox() for i in range(3)] for index in range(3): self.sliceCheckBoxes[index].clicked.connect(self.checkBoxChanged) self.sliceLabels[index].setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.sliceCheckBoxes[index].setEnabled(True) # Create a nice layout for the labels layout = QGridLayout() layout.setAlignment(Qt.AlignTop) layout.setColumnStretch(0, 1) layout.setColumnStretch(1, 3) layout.addWidget(self.slicesLabel, 0, 0, 1, -1) for index in range(3): layout.addWidget(self.sliceLabels[index], index+1, 0) layout.addWidget(self.sliceCheckBoxes[index], index+1, 1) # Create option to show clipping box self.clippingCheckBox = QCheckBox() self.clippingCheckBox.clicked.connect(self.clippingCheckBoxChanged) self.clippingLabel = QLabel("Clipping box:") self.clippingLabel.setAlignment(Qt.AlignRight | Qt.AlignVCenter) layout.addWidget(self.clippingLabel, 5, 0) layout.addWidget(self.clippingCheckBox, 5, 1) self.setLayout(layout)
def __init__(self, stepper): QWidget.__init__(self) button_layout = QGridLayout() self.setLayout(button_layout) button_layout.setColumnStretch(0, 0) button_layout.setColumnStretch(1, 0) button_layout.setColumnStretch(3, 0) button_layout.setRowStretch(0, 0) button_layout.setRowStretch(1, 0) button_layout.setRowStretch(3, 0) button_layout.setRowStretch(4, 0) qmy_button(button_layout, stepper.go_to_previous_turn, "pre", the_row=0, the_col=0) qmy_button(button_layout, stepper.go_to_next_turn, "next", the_row=0, the_col=1) qmy_button(button_layout, stepper.insert_before, "ins before", the_row=1, the_col=0) qmy_button(button_layout, stepper.insert_after, "ins after", the_row=1, the_col=1) qmy_button(button_layout, stepper.delete_current_turn, "delete turn", the_row=1, the_col=2) qmy_button(button_layout, stepper.commit, "commit", the_row=2, the_col=0) qmy_button(button_layout, stepper.commit_all, "commit all", the_row=2, the_col=1) qmy_button(button_layout, stepper.revert_current_and_redisplay, "revert", the_row=2, the_col=2) qmy_button(button_layout, stepper.save_file, "save", the_row=3, the_col=0) qmy_button(button_layout, stepper.save_file_as, "save as ...", the_row=3, the_col=1) qmy_button(button_layout, stepper.fill_time_code, "fill time", the_row=4, the_col=0) qmy_button(button_layout, stepper.sync_video, "sync video", the_row=4, the_col=1) button_layout.addWidget(QWidget(), 2, 3) button_layout.addWidget(QWidget(), 5, 0)
def __init__(self, user, parent=None): super(UserProfile, self).__init__(parent) name = user['user']['firstName'] if 'lastName' in user['user']: name += " " + user['user']['lastName'] description = "" if 'homeCity' in user['user']: description += "From " + user['user']['homeCity'] location = "" # FIXME: this may fail! location = user['user']['checkins']['items'][0]['venue']['name'] lastSeen = user['user']['checkins']['items'][0]['createdAt'] lastSeen = datetime.fromtimestamp(lastSeen).strftime("%d %b, %H:%M") location = "Last seen at <b>" + location + "</b>, at <i>" + lastSeen + "</i>" description = description + "<br>" + location self.descriptionLabel = QLabel(description) self.descriptionLabel.setWordWrap(True) self.photo_label = QLabel() self.photo = QImage(foursquare.image(user['user']['photo'])) self.photo_label.setPixmap(QPixmap(self.photo)) profileLayout = QGridLayout() self.setLayout(profileLayout) profileLayout.addWidget(self.photo_label, 0, 0, 2, 1) profileLayout.addWidget(Title(name), 0, 1) profileLayout.addWidget(self.descriptionLabel, 1, 1) profileLayout.setColumnStretch(1, 5)
def _createLayout(self): 'Create the Widget Layout' self._txtLogbook = QLineEdit() self._txtLogbook.setReadOnly(True) self._lblLogbook = QLabel(self.tr('&Logbook File:')) self._lblLogbook.setBuddy(self._txtLogbook) self._btnBrowse = QPushButton('...') self._btnBrowse.clicked.connect(self._btnBrowseClicked) self._btnBrowse.setStyleSheet('QPushButton { min-width: 24px; max-width: 24px; }') self._btnBrowse.setToolTip(self.tr('Browse for a Logbook')) self._cbxComputer = QComboBox() self._lblComputer = QLabel(self.tr('Dive &Computer:')) self._lblComputer.setBuddy(self._cbxComputer) self._btnAddComputer = QPushButton(QPixmap(':/icons/list-add.png'), self.tr('')) self._btnAddComputer.setStyleSheet('QPushButton { min-width: 24px; min-height: 24; max-width: 24px; max-height: 24; }') self._btnAddComputer.clicked.connect(self._btnAddComputerClicked) self._btnRemoveComputer = QPushButton(QPixmap(':/icons/list-remove.png'), self.tr('')) self._btnRemoveComputer.setStyleSheet('QPushButton { min-width: 24px; min-height: 24; max-width: 24px; max-height: 24; }') self._btnRemoveComputer.clicked.connect(self._btnRemoveComputerClicked) hbox = QHBoxLayout() hbox.addWidget(self._btnAddComputer) hbox.addWidget(self._btnRemoveComputer) gbox = QGridLayout() gbox.addWidget(self._lblLogbook, 0, 0) gbox.addWidget(self._txtLogbook, 0, 1) gbox.addWidget(self._btnBrowse, 0, 2) gbox.addWidget(self._lblComputer, 1, 0) gbox.addWidget(self._cbxComputer, 1, 1) gbox.addLayout(hbox, 1, 2) gbox.setColumnStretch(1, 1) self._pbTransfer = QProgressBar() self._pbTransfer.reset() self._txtStatus = QTextEdit() self._txtStatus.setReadOnly(True) self._btnTransfer = QPushButton(self.tr('&Transfer Dives')) self._btnTransfer.clicked.connect(self._btnTransferClicked) self._btnExit = QPushButton(self.tr('E&xit')) self._btnExit.clicked.connect(self.close) hbox = QHBoxLayout() hbox.addWidget(self._btnTransfer) hbox.addStretch() hbox.addWidget(self._btnExit) vbox = QVBoxLayout() vbox.addLayout(gbox) vbox.addWidget(self._pbTransfer) vbox.addWidget(self._txtStatus) vbox.addLayout(hbox) self.setLayout(vbox)
def __init__(self, fixtures_folder, parent=None): QWidget.__init__(self, parent) self.current_fixture = None self.fixtures_folder = fixtures_folder self.setWindowTitle("Frangitron DMX program editor") self.text = QPlainTextEdit() font = QFont("Monospace") font.setStyleHint(QFont.TypeWriter) font.setPixelSize(16) self.text.setFont(font) self.text.setStyleSheet( "color: white; background-color: rgb(30, 30, 30)") self.combo_fixture = QComboBox() self.frame_programs = QWidget() self.checkboxes_programs = list() self.layout_programs = QGridLayout(self.frame_programs) self.spinner_offset = QSpinBox() self.spinner_offset.setMinimum(1) self.spinner_offset.setMaximum(512) self.spinner_offset.setValue(1) self.spinner_offset.valueChanged.connect(self.address_changed) self.doc = QPlainTextEdit() self.doc.setReadOnly(True) self.doc.setFont(font) self.status = QLabel() layout = QGridLayout(self) layout.addWidget(self.combo_fixture, 0, 1) layout.addWidget(self.spinner_offset, 0, 2) layout.addWidget(self.frame_programs, 1, 1) layout.addWidget(self.text, 0, 0, 3, 1) layout.addWidget(self.doc, 2, 1, 1, 2) layout.addWidget(self.status, 3, 0, 1, 3) layout.setColumnStretch(0, 60) layout.setColumnStretch(1, 40) self.resize(1280, 800) self.streamer = Streamer(self.fixtures_folder) self.combo_fixture.addItems(sorted(self.streamer.fixtures)) self.combo_fixture.currentIndexChanged.connect(self.fixture_changed) self.timer = QTimer() self.timer.timeout.connect(self.tick) self.timer.start(500.0 / FRAMERATE) self.should_reload = True self.fixture_changed()
def __init__(self, parent=None): super(SettingsDialog, self).__init__(parent) self.setWindowTitle("Settings") main_layout = QVBoxLayout() buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) settings = QSettings() db_group = QGroupBox("Database") grid_layout = QGridLayout() grid_layout.addWidget(QLabel("File"), 0, 0) text = settings.value('DB/File') self.file = QLineEdit(text) self.file.setText(text) grid_layout.addWidget(self.file, 0, 1) browse = QPushButton("Browse") browse.clicked.connect(self.browse) grid_layout.addWidget(browse, 0, 2) db_group.setLayout(grid_layout) main_layout.addWidget(db_group) ip_width = QFontMetrics(QFont(self.font())).width("000.000.000.000 ") smtp_group = QGroupBox("SMTP") grid_layout = QGridLayout() grid_layout.addWidget(QLabel("Server"), 0, 0) text = settings.value('SMTP/Server') self.smtp_server = QLineEdit(text) self.smtp_server.setText(text) grid_layout.addWidget(self.smtp_server, 0, 1) smtp_group.setLayout(grid_layout) main_layout.addWidget(smtp_group) self.http_proxy = QGroupBox("HTTP Proxy") self.http_proxy.setCheckable(True) self.http_proxy.setChecked(bool(settings.value('HTTP Proxy/Enabled'))) grid_layout = QGridLayout() grid_layout.addWidget(QLabel("Server"), 0, 0) self.http_proxy_ip = QLineEdit() self.http_proxy_ip.setText(settings.value('HTTP Proxy/IP')) self.http_proxy_ip.setMinimumWidth(ip_width) grid_layout.addWidget(self.http_proxy_ip, 0, 1) grid_layout.setColumnStretch(0, 1) self.http_proxy.setLayout(grid_layout) main_layout.addWidget(self.http_proxy) main_layout.addWidget(buttonBox) self.setLayout(main_layout) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject)
def __init__(self, parent=None): super(SettingsDialog, self).__init__(parent) self.setWindowTitle("Settings") main_layout = QVBoxLayout() buttonBox = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel) settings = QSettings() db_group = QGroupBox("Database") grid_layout = QGridLayout() grid_layout.addWidget(QLabel("File"),0,0) text = settings.value('DB/File') self.file = QLineEdit(text) self.file.setText(text) grid_layout.addWidget(self.file,0,1) browse = QPushButton("Browse") browse.clicked.connect(self.browse) grid_layout.addWidget(browse,0,2) db_group.setLayout(grid_layout) main_layout.addWidget(db_group) ip_width = QFontMetrics(QFont(self.font())).width("000.000.000.000 ") smtp_group = QGroupBox("SMTP") grid_layout = QGridLayout() grid_layout.addWidget(QLabel("Server"),0,0) text = settings.value('SMTP/Server') self.smtp_server = QLineEdit(text) self.smtp_server.setText(text) grid_layout.addWidget(self.smtp_server,0,1) smtp_group.setLayout(grid_layout) main_layout.addWidget(smtp_group) self.http_proxy = QGroupBox("HTTP Proxy") self.http_proxy.setCheckable(True) self.http_proxy.setChecked(bool(settings.value('HTTP Proxy/Enabled'))) grid_layout = QGridLayout() grid_layout.addWidget(QLabel("Server"),0,0) self.http_proxy_ip = QLineEdit() self.http_proxy_ip.setText(settings.value('HTTP Proxy/IP')) self.http_proxy_ip.setMinimumWidth(ip_width) grid_layout.addWidget(self.http_proxy_ip,0,1) grid_layout.setColumnStretch(0,1) self.http_proxy.setLayout(grid_layout) main_layout.addWidget(self.http_proxy) main_layout.addWidget(buttonBox) self.setLayout(main_layout) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject)
def __init__(self): QFrame.__init__(self) layout = QGridLayout() self.btnMonitor1 = OutputButton(ID=2) self.btnMonitor1.setText("Monitor 1") layout.addWidget(self.btnMonitor1, 0, 1) self.btnChurch = OutputButton(ID=4) self.btnChurch.setText("Church") layout.addWidget(self.btnChurch, 1, 0) self.btnSpecial = OutputButton(ID=7) self.btnSpecial.setText("Stage") layout.addWidget(self.btnSpecial, 1, 1) self.btnGallery = OutputButton(ID=6) self.btnGallery.setText("Gallery") layout.addWidget(self.btnGallery, 2, 0) self.btnWelcome = OutputButton(ID=5) self.btnWelcome.setText("Welcome") layout.addWidget(self.btnWelcome, 2, 1) self.btnFont = OutputButton(ID=3) self.btnFont.setText("Font") layout.addWidget(self.btnFont, 3, 0) self.btnRecord = OutputButton(ID=8) self.btnRecord.setText("Record") layout.addWidget(self.btnRecord, 3, 1) self.btnPCMix = OutputButton(ID=2) self.btnPCMix.setText("PC Mix") layout.addWidget(self.btnPCMix, 4, 0) self.btnAll = IDedButton(ID=0) self.btnAll.setText("All") layout.addWidget(self.btnAll, 4, 1) self.outputButtons = { 2: self.btnMonitor1, 3: self.btnFont, 4: self.btnChurch, 5: self.btnWelcome, 6: self.btnGallery, 7: self.btnSpecial, 8: self.btnRecord, } layout.setColumnMinimumWidth(0, 100) layout.setColumnMinimumWidth(1, 100) layout.setColumnStretch(0, 1) layout.setColumnStretch(1, 1) self.setLayout(layout)
def createDragOverlay(self, tags, texts, images=None): """Creates a DragOverlay for this ModuleFrame with the given text and optional images. When DataIndexMimes (DataTree indices) are dropped on the text/images of this overlay, they are associated with the tag of the same index of the text/image. This is a user interface for when a ModuleFrame wants to accept drops for multiple purposes. """ self.dragOverlay = True self.overlay = OverlayFrame(self) layout = QGridLayout(self.overlay) layout.setAlignment(Qt.AlignCenter) layout.setColumnStretch(0, 5) if images is not None: for i, tag, text, image in zip(range(len(tags)), tags, texts, images): layout.addWidget( DropPanel(tag, text, self.overlay, self.overlayDroppedData, image), i, 0, 1, 1) layout.setRowStretch(i, 5) else: for i, tag, text in zip(range(len(tags)), tags, texts): layout.addWidget( DropPanel(tag, text, self.overlay, self.overlayDroppedData), i, 0, 1, 1) layout.setRowStretch(i, 5) # Add a Close button to deal with lack of cancel signal # for drag/drop class CloseLabel(QLabel): closeSignal = Signal() def __init__(self): super(CloseLabel, self).__init__("Close") self.setStyleSheet("QLabel { color : white; }") def mousePressEvent(self, e): self.closeSignal.emit() closeButton = CloseLabel() closeButton.closeSignal.connect(self.killRogueOverlays) layout.addWidget(closeButton, len(tags), 0, 1, 1) layout.setRowStretch(len(tags), 0) self.overlay.setLayout(layout)
def __init__(self, switcherState, parent=None): super(OutputsGrid, self).__init__(parent) self.signalMapper = QSignalMapper(self) self.longPressSignalMapper = QSignalMapper(self) layout = QGridLayout() mainMixFrame = MainMixControl() mainMixFrame.cut.connect(self.cut.emit) mainMixFrame.take.connect(self.take.emit) layout.addWidget(mainMixFrame, 0, 0, 1, 2) self.aux_buttons = [] for idx, output in switcherState.outputs.iteritems(): ob = OutputButton(output) layout.addWidget(ob, 1 + (idx / 2), idx % 2) ob.clicked.connect(self.signalMapper.map) self.signalMapper.setMapping(ob, idx) ob.longpress.connect(self.longPressSignalMapper.map) self.longPressSignalMapper.setMapping(ob, idx) self.aux_buttons.append(ob) self.signalMapper.mapped.connect(self.registerClick) self.longPressSignalMapper.mapped.connect(self.longPress) btnAll = ExpandingButton() btnAll.setProperty("class", "mainMix") btnAll.setText("Mix to all") btnAll.clicked.connect(self.mainToAll.emit) layout.addWidget(btnAll, 4, 0) self.btnAll = ExpandingButton() self.btnAll.setText("All") self.btnAll.clicked.connect(self.all.emit) layout.addWidget(self.btnAll, 4, 1) layout.setColumnMinimumWidth(0, 100) layout.setColumnMinimumWidth(1, 100) layout.setColumnStretch(0, 1) layout.setColumnStretch(1, 1) layout.setRowStretch(0, 2) for i in range(1, 5): layout.setRowStretch(i, 1) self.setLayout(layout)
def createOptionsGroupBox(self): self.optionsGroupBox = QGroupBox("Options") buttonsOrientationLabel = QLabel("Orientation of buttons:") buttonsOrientationComboBox = QComboBox() buttonsOrientationComboBox.addItem("Horizontal", Qt.Horizontal) buttonsOrientationComboBox.addItem("Vertical", Qt.Vertical) buttonsOrientationComboBox.currentIndexChanged[int].connect(self.buttonsOrientationChanged) self.buttonsOrientationComboBox = buttonsOrientationComboBox optionsLayout = QGridLayout() optionsLayout.addWidget(buttonsOrientationLabel, 0, 0) optionsLayout.addWidget(self.buttonsOrientationComboBox, 0, 1) optionsLayout.setColumnStretch(2, 1) self.optionsGroupBox.setLayout(optionsLayout)
def _init_detail_layout(self): detail_layout = QGridLayout() self.key_tree = QTreeWidget() self.key_tree.setColumnCount(2) self.key_tree.setColumnWidth(0, 200) self.key_tree.setHeaderLabels(['Key', 'Size']) self.value_tree = QTreeWidget() self.value_tree.setColumnCount(2) self.value_tree.setColumnWidth(0, 200) self.value_tree.setHeaderLabels(['Path', 'Size']) detail_layout.setColumnStretch(0, 1) detail_layout.setColumnStretch(1, 1) detail_layout.addWidget(self.value_tree) detail_layout.addWidget(self.key_tree) return detail_layout
def createDragOverlay(self, tags, texts, images=None): """Creates a DragOverlay for this ModuleFrame with the given text and optional images. When DataIndexMimes (DataTree indices) are dropped on the text/images of this overlay, they are associated with the tag of the same index of the text/image. This is a user interface for when a ModuleFrame wants to accept drops for multiple purposes. """ self.dragOverlay = True self.overlay = OverlayFrame(self) layout = QGridLayout(self.overlay) layout.setAlignment(Qt.AlignCenter) layout.setColumnStretch(0, 5) if images is not None: for i, tag, text, image in zip(range(len(tags)), tags, texts, images): layout.addWidget(DropPanel(tag, text, self.overlay, self.overlayDroppedData, image), i, 0, 1, 1) layout.setRowStretch(i, 5) else: for i, tag, text in zip(range(len(tags)), tags, texts): layout.addWidget(DropPanel(tag, text, self.overlay, self.overlayDroppedData), i, 0, 1, 1) layout.setRowStretch(i, 5) # Add a Close button to deal with lack of cancel signal # for drag/drop class CloseLabel(QLabel): closeSignal = Signal() def __init__(self): super(CloseLabel, self).__init__("Close") self.setStyleSheet("QLabel { color : white; }") def mousePressEvent(self, e): self.closeSignal.emit() closeButton = CloseLabel() closeButton.closeSignal.connect(self.killRogueOverlays) layout.addWidget(closeButton, len(tags), 0, 1, 1) layout.setRowStretch(len(tags), 0) self.overlay.setLayout(layout)
def __init__(self, parent=None): QWidget.__init__(self, parent) # Widgets, layouts and signals self._group = QButtonGroup() layout = QGridLayout() layout.setSpacing(0) for i in range(18): layout.setColumnMinimumWidth(i, 40) layout.setColumnStretch(i, 0) for i in list(range(7)) + [8, 9]: layout.setRowMinimumHeight(i, 40) layout.setRowStretch(i, 0) ## Element for z, position in _ELEMENT_POSITIONS.items(): widget = ElementPushButton(z) widget.setCheckable(True) layout.addWidget(widget, *position) self._group.addButton(widget, z) ## Labels layout.addWidget(QLabel(''), 7, 0) # Dummy layout.addWidget(QLabel('*'), 5, 2, Qt.AlignCenter) layout.addWidget(QLabel('*'), 8, 2, Qt.AlignCenter) layout.addWidget(QLabel('**'), 6, 2, Qt.AlignCenter) layout.addWidget(QLabel('**'), 9, 2, Qt.AlignCenter) for row in [0, 1, 2, 3, 4, 5, 6, 8, 9]: layout.setRowStretch(row, 1) self.setLayout(layout) # Signals self._group.buttonClicked.connect(self.selectionChanged) # Default self.setColorFunction(_category_color_function)
def __init__(self, renderController, parent=None): super(RenderSlicerParamWidget, self).__init__(parent=parent) self.renderController = renderController self.renderController.slicesChanged.connect(self.setSlices) self.renderController.clippingBoxChanged.connect(self.showsClippingBox) self.slicesLabel = QLabel("Show slices for directions:") self.sliceLabelTexts = ["x:", "y:", "z:"] self.sliceLabels = [QLabel(text) for text in self.sliceLabelTexts] self.sliceCheckBoxes = [QCheckBox() for i in range(3)] for index in range(3): self.sliceCheckBoxes[index].clicked.connect(self.checkBoxChanged) self.sliceLabels[index].setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.sliceCheckBoxes[index].setEnabled(True) # Create a nice layout for the labels layout = QGridLayout() layout.setAlignment(Qt.AlignTop) layout.setColumnStretch(0, 1) layout.setColumnStretch(1, 3) layout.addWidget(self.slicesLabel, 0, 0, 1, -1) for index in range(3): layout.addWidget(self.sliceLabels[index], index + 1, 0) layout.addWidget(self.sliceCheckBoxes[index], index + 1, 1) # Create option to show clipping box self.clippingCheckBox = QCheckBox() self.clippingCheckBox.clicked.connect(self.clippingCheckBoxChanged) self.clippingLabel = QLabel("Clipping box:") self.clippingLabel.setAlignment(Qt.AlignRight | Qt.AlignVCenter) layout.addWidget(self.clippingLabel, 5, 0) layout.addWidget(self.clippingCheckBox, 5, 1) self.setLayout(layout)
def __init__(self, controller): super(MainWindow, self).__init__() self.controller = controller self.setWindowTitle("av-control") self.resize(1024, 600) self.setWindowIcon(QIcon(":icons/video-display")) self.mainScreen = VideoSwitcher(controller, self) self.stack = QStackedWidget() self.stack.addWidget(self.mainScreen) outer = QWidget() mainLayout = QGridLayout() mainLayout.addWidget(self.stack, 0, 0, 1, 7) column = 0 self.spc = SystemPowerWidget(controller, self) syspower = ExpandingButton() syspower.setText("Power") syspower.clicked.connect(self.showSystemPower) syspower.setIcon(QIcon(":icons/system-shutdown")) syspower.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) mainLayout.addWidget(syspower, 1, column) column += 1 self.bc = BlindsControl(controller["Blinds"], self) blinds = ExpandingButton() blinds.setText("Blinds") blinds.clicked.connect(lambda: self.showScreen(self.bc)) blinds.setIcon(QIcon(":icons/blinds")) blinds.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) mainLayout.addWidget(blinds, 1, column) column += 1 self.sc = ProjectorScreensControl(controller["Screens"], self) screens = ExpandingButton() screens.setText("Screens") screens.clicked.connect(lambda: self.showScreen(self.sc)) screens.setIcon(QIcon(":icons/screens")) screens.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) mainLayout.addWidget(screens, 1, column) column += 1 if controller.hasDevice("Lights"): self.lightsMenu = LightingControl(controller["Lights"], self) lights = ExpandingButton() lights.setText("Lights") lights.clicked.connect(lambda: self.showScreen(self.lightsMenu)) lights.setIcon(QIcon(":icons/lightbulb_on")) lights.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) mainLayout.addWidget(lights, 1, column) column += 1 self.advMenu = AdvancedMenu(self.controller, self) adv = ExpandingButton() adv.setText("Advanced") adv.setIcon(QIcon(":icons/applications-system")) adv.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) adv.clicked.connect(lambda: self.showScreen(self.advMenu)) mainLayout.addWidget(adv, 1, column) column += 1 for i in range(column): mainLayout.setColumnStretch(i, 1) tray = QHBoxLayout() tray.addWidget(Clock()) tray.addWidget(SystemStatus(controller)) mainLayout.addLayout(tray, 1, column) mainLayout.setRowStretch(0, 8) mainLayout.setRowStretch(1, 0) outer.setLayout(mainLayout) self.setCentralWidget(outer) self.pnd = PowerNotificationDialog(self) self.pnd.accepted.connect(self.hidePowerDialog)
def __init__(self, parent=None): QDialog.__init__(self, parent) self.setWindowTitle('Runner') self.setMinimumWidth(750) # Runner self._runner = None self._running_timer = QTimer() self._running_timer.setInterval(500) # Widgets self._dlg_progress = QProgressDialog() self._dlg_progress.setRange(0, 100) self._dlg_progress.setModal(True) self._dlg_progress.hide() lbl_outputdir = QLabel("Output directory") self._txt_outputdir = DirBrowseWidget() max_workers = cpu_count() #@UndefinedVariable lbl_workers = QLabel('Number of workers') self._spn_workers = QSpinBox() self._spn_workers.setRange(1, max_workers) self._spn_workers.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) lbl_max_workers = QLabel('(max: %i)' % max_workers) self._chk_overwrite = QCheckBox("Overwrite existing results in output directory") self._chk_overwrite.setChecked(True) self._lbl_available = QLabel('Available') self._lst_available = QListView() self._lst_available.setModel(_AvailableOptionsListModel()) self._lst_available.setSelectionMode(QListView.SelectionMode.MultiSelection) tlb_available = QToolBar() spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) tlb_available.addWidget(spacer) act_open = tlb_available.addAction(getIcon("document-open"), "Open") act_open.setShortcut(QKeySequence.Open) tlb_available.addSeparator() act_remove = tlb_available.addAction(getIcon("list-remove"), "Remove") act_clear = tlb_available.addAction(getIcon("edit-clear"), "Clear") self._btn_addtoqueue = QPushButton(getIcon("go-next"), "") self._btn_addtoqueue.setToolTip("Add to queue") self._btn_addtoqueue.setEnabled(False) self._btn_addalltoqueue = QPushButton(getIcon("go-last"), "") self._btn_addalltoqueue.setToolTip("Add all to queue") self._btn_addalltoqueue.setEnabled(False) self._lbl_options = QLabel('Queued/Running/Completed') self._tbl_options = QTableView() self._tbl_options.setModel(_StateOptionsTableModel()) self._tbl_options.setItemDelegate(_StateOptionsItemDelegate()) self._tbl_options.setSelectionMode(QListView.SelectionMode.NoSelection) self._tbl_options.setColumnWidth(1, 60) self._tbl_options.setColumnWidth(2, 80) header = self._tbl_options.horizontalHeader() header.setResizeMode(0, QHeaderView.Interactive) header.setResizeMode(1, QHeaderView.Fixed) header.setResizeMode(2, QHeaderView.Fixed) header.setResizeMode(3, QHeaderView.Stretch) self._btn_start = QPushButton(getIcon("media-playback-start"), "Start") self._btn_cancel = QPushButton("Cancel") self._btn_cancel.setEnabled(False) self._btn_close = QPushButton("Close") self._btn_import = QPushButton("Import") self._btn_import.setEnabled(False) # Layouts layout = QVBoxLayout() sublayout = QGridLayout() sublayout.addWidget(lbl_outputdir, 0, 0) sublayout.addWidget(self._txt_outputdir, 0, 1) sublayout.addWidget(lbl_workers, 1, 0) subsublayout = QHBoxLayout() subsublayout.addWidget(self._spn_workers) subsublayout.addWidget(lbl_max_workers) sublayout.addLayout(subsublayout, 1, 1) layout.addLayout(sublayout) sublayout.addWidget(self._chk_overwrite, 2, 0, 1, 3) sublayout = QGridLayout() sublayout.setColumnStretch(0, 1) sublayout.setColumnStretch(2, 3) sublayout.addWidget(self._lbl_available, 0, 0) sublayout.addWidget(self._lst_available, 1, 0) sublayout.addWidget(tlb_available, 2, 0) subsublayout = QVBoxLayout() subsublayout.addStretch() subsublayout.addWidget(self._btn_addtoqueue) subsublayout.addWidget(self._btn_addalltoqueue) subsublayout.addStretch() sublayout.addLayout(subsublayout, 1, 1) sublayout.addWidget(self._lbl_options, 0, 2) sublayout.addWidget(self._tbl_options, 1, 2) layout.addLayout(sublayout) sublayout = QHBoxLayout() sublayout.addStretch() sublayout.addWidget(self._btn_import) sublayout.addWidget(self._btn_start) sublayout.addWidget(self._btn_cancel) sublayout.addWidget(self._btn_close) layout.addLayout(sublayout) self.setLayout(layout) # Signal self._running_timer.timeout.connect(self._onRunningTimer) act_open.triggered.connect(self._onOpen) act_remove.triggered.connect(self._onRemove) act_clear.triggered.connect(self._onClear) self._btn_addtoqueue.released.connect(self._onAddToQueue) self._btn_addalltoqueue.released.connect(self._onAddAllToQueue) self._btn_start.released.connect(self._onStart) self._btn_cancel.released.connect(self._onCancel) self._btn_close.released.connect(self._onClose) self._btn_import.released.connect(self._onImport) self.options_added.connect(self._onOptionsAdded) self.options_running.connect(self._onOptionsRunning) self.options_simulated.connect(self._onOptionsSimulated) self.options_error.connect(self._onOptionsError) self.results_error.connect(self._onResultsError) # Defaults settings = get_settings() section = settings.add_section('gui') if hasattr(section, 'outputdir'): self._txt_outputdir.setPath(section.outputdir) if hasattr(section, 'maxworkers'): self._spn_workers.setValue(int(section.maxworkers)) if hasattr(section, 'overwrite'): state = True if section.overwrite.lower() == 'true' else False self._chk_overwrite.setChecked(state)
def __init__(self, parent): super(MainControl, self).__init__(parent) self.parent = parent self.selectedMinerals = parent.selectedMinerals self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) lb0 = QLabel('Minecraft Prism chunk minerals finder') lb1 = QLabel('Chunk X') lb2 = QLabel('Chunk Z') lb3 = QLabel('Show deposits of:') lb4 = QLabel('Slice Elevation') #lb0.setFrameStyle(QFrame.Box) lb0.setAlignment(Qt.AlignVCenter | Qt.AlignCenter) lb2.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.txtChunkX = QLineEdit() self.txtChunkZ = QLineEdit() self.txtElevation = QLineEdit(str(self.parent.presenter.elevation)) self.txtChunkX.setAlignment(Qt.AlignVCenter | Qt.AlignCenter) self.txtChunkZ.setAlignment(Qt.AlignVCenter | Qt.AlignCenter) self.txtElevation.setAlignment(Qt.AlignVCenter | Qt.AlignCenter) self.btnViewChunk = QPushButton('View Chunk') self.btnViewChunk.clicked.connect(self.btnViewChunk_OnClick) self.btnSliceUp = QPushButton('Slice Up') self.btnSliceUp.clicked.connect(self.btnSliceUp_OnClick) self.btnSliceDown = QPushButton('Slice Down') self.btnSliceDown.clicked.connect(self.btnSliceDown_OnClick) self.lstMinerals = QListWidget() self.lstMinerals.setSelectionMode(QAbstractItemView.ExtendedSelection) self.lstMinerals.addItem(SelectedMineral('Gold', 14)) self.lstMinerals.addItem(SelectedMineral('Iron', 15)) self.lstMinerals.addItem(SelectedMineral('Diamond', 56)) self.lstMinerals.addItem(SelectedMineral('Redstone', 73)) self.lstMinerals.addItem(SelectedMineral('Obsidian', 49)) self.lstMinerals.addItem(SelectedMineral('Coal', 16)) self.lstMinerals.addItem(SelectedMineral('Lazurit', 21)) self.lstMinerals.setCurrentItem(self.lstMinerals.item(0)) self.lstMinerals.itemSelectionChanged.connect(self.onSelectedMinerals) elevBox = QHBoxLayout() elevBox.addWidget(lb4) elevBox.addWidget(self.txtElevation) elevBox.addWidget(self.btnSliceUp) elevBox.addWidget(self.btnSliceDown) ly = QGridLayout() ly.addWidget(lb0, 0, 0, 1, 4) ly.addWidget(lb1, 1, 0, 1, 1) ly.addWidget(self.txtChunkX, 1, 1, 1, 1) ly.addWidget(lb2, 1, 2, 1, 1) ly.addWidget(self.txtChunkZ, 1, 3, 1, 1) ly.addWidget(lb3, 2, 0, 1, 2) ly.addWidget(self.lstMinerals, 2, 2, 1, 2) ly.addWidget(self.btnViewChunk, 3, 1, 1, 2) ly.addLayout(elevBox, 4, 0, 1, 4) ly.setColumnStretch(0, 20) ly.setColumnStretch(1, 15) ly.setColumnStretch(2, 46) ly.setColumnStretch(3, 19) self.setLayout(ly)
def initUI(self): ''' Method to setup the buttons/entries of the Gui ''' self.dateFrame = dateFrame( ); # Initialize the dateFrame self.iopLabel = QLabel('IOP Number'); # Initialize Entry widget for the IOP name self.iopName = QLineEdit(); # Initialize Entry widget for the IOP name self.stationLabel = QLabel('Station Name'); # Initialize Entry widget for the IOP name self.stationName = QLineEdit(); # Initialize Entry widget for the IOP name self.sourceButton = QPushButton('Source Directory'); # Initialize button for selecting the source directory self.destButton = QPushButton('Destination Directory'); # Initialize button for selecting the destination directory self.sourcePath = QLineEdit(''); # Initialize entry widget that will display the source directory path self.destPath = QLineEdit(''); # Initialize entry widget that will display the destination directory path self.sourceSet = indicator(); # Initialize an indictor that will appear when the source path is set self.destSet = indicator(); # Initialize an indictor that will appear when the destination path is set self.sourcePath.setEnabled( False ); # Disable the sourcePath widget; that way no one can manually edit it self.destPath.setEnabled( False ); # Disable the destPath widget; that way no one can manually edit it self.sourcePath.hide(); # Hide the source directory path self.destPath.hide(); # Hide the destination directory path self.sourceSet.hide(); # Hide the source directory indicator self.destSet.hide(); # Hide the destination directory indicator self.sourceButton.clicked.connect( self.select_source ); # Set method to run when the source button is clicked self.destButton.clicked.connect( self.select_dest ); # Set method to run when the destination button is clicked self.copyButton = QPushButton( 'Copy Files' ); # Create 'Copy Files' button self.copyButton.clicked.connect( self.copy_files ); # Set method to run when 'Copy Files' button is clicked self.copyButton.setEnabled(False); # Set enabled state to False; cannot click until after the source and destination directories set self.copySucces = indicator(); # Initialize an indictor that will appear when the copy complete successfuly self.copySucces.hide(); self.procButton = QPushButton( 'Process Files' ); # Create 'Process Files' button self.procButton.clicked.connect( self.proc_files ); # Set method to run when 'Process Files' button is clicked self.procButton.setEnabled(False); # Set enabled state to False; cannot click until after 'Copy Files' completes self.procSucces = indicator(); # Initialize an indictor that will appear when the processing complete successfuly self.procSucces.hide(); self.genButton = QPushButton( 'Generate Sounding' ); # Create 'Generate Sounding' button self.genButton.clicked.connect( self.gen_sounding ); # Set method to run when 'Generate Sounding' button is clicked self.genButton.setEnabled(False); # Set enabled state to False; cannot click until after 'Process Files' completes self.genSucces = indicator(); # Initialize an indictor that will appear when the sounding generation complete successfuly self.genSucces.hide(); self.uploadButton = QPushButton( 'FTP Upload' ); # Create 'FTP Upload' button self.uploadButton.clicked.connect( self.ftp_upload ); # Set method to run when 'FTP Upload' button is clicked self.uploadButton.setEnabled(False); # Set enabled state to False; cannot click until after 'Generate Sounding' completes self.uploadSucces = indicator(); # Initialize an indictor that will appear when the ftp upload complete successfuly self.uploadSucces.hide(); self.checkButton = QPushButton( 'Check website' ); # Create 'Check website' button self.checkButton.clicked.connect( self.check_site ); # Set method to run when 'Check website' button is clicked self.checkButton.setEnabled(False); # Set enabled state to False; cannot click until after 'FTP Upload' completes self.resetButton = QPushButton( 'Reset' ); # Create 'Check website' button self.resetButton.clicked.connect( self.reset_values ); # Set method to run when 'Check website' button is clicked versionLabel = QLabel( 'version: {}'.format(__version__) ); # Version label versionLabel.setAlignment( Qt.AlignHCenter ); # Set alignment to center log_handler = QLogger( ); # Initialize a QLogger logging.Handler object logging.getLogger('Meso1819').addHandler( log_handler ); # Get the Meso1819 root logger and add the handler to it grid = QGridLayout(); # Initialize grid layout grid.setSpacing(10); # Set spacing to 10 for i in range(4): grid.setColumnStretch(i, 0); # Set column stretch for ith column grid.setColumnMinimumWidth(i, 60); # Set column min width for ith column grid.setColumnStretch(4, 0); # Set column stretch for 5th column grid.setColumnMinimumWidth(4, 20); # Set column min width for 5th column grid.setRowStretch(1, 0); # Set column stretch for 5th column grid.setRowStretch(3, 0); # Set column stretch for 5th column grid.setRowMinimumHeight(1, 25); # Set column min width for 5th column grid.setRowMinimumHeight(3, 25); # Set column min width for 5th column grid.addWidget( self.sourceButton, 0, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( self.sourceSet, 0, 4, 1, 1 ); # Place a widget in the grid grid.addWidget( self.sourcePath, 1, 0, 1, 5 ); # Place a widget in the grid grid.addWidget( self.destButton, 2, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( self.destSet, 2, 4, 1, 1 ); # Place a widget in the grid grid.addWidget( self.destPath, 3, 0, 1, 5 ); # Place a widget in the grid grid.addWidget( self.iopLabel, 4, 0, 1, 2 ); # Place a widget in the grid grid.addWidget( self.iopName, 5, 0, 1, 2 ); # Place a widget in the grid grid.addWidget( self.stationLabel, 4, 2, 1, 2 ); # Place a widget in the grid grid.addWidget( self.stationName, 5, 2, 1, 2 ); # Place a widget in the grid grid.addWidget( self.dateFrame, 6, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( self.copyButton, 7, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( self.copySucces, 7, 4, 1, 1 ); # Place a widget in the grid grid.addWidget( self.procButton, 8, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( self.procSucces, 8, 4, 1, 1 ); # Place a widget in the grid grid.addWidget( self.genButton, 9, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( self.genSucces, 9, 4, 1, 1 ); # Place a widget in the grid grid.addWidget( self.uploadButton, 10, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( self.uploadSucces, 10, 4, 1, 1 ); # Place a widget in the grid grid.addWidget( self.checkButton, 11, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( self.resetButton, 12, 0, 1, 4 ); # Place a widget in the grid grid.addWidget( log_handler.frame, 0, 6, 13, 1); grid.addWidget( versionLabel, 20, 0, 1, 7) centralWidget = QWidget(); # Create a main widget centralWidget.setLayout( grid ); # Set the main widget's layout to the grid self.setCentralWidget(centralWidget); # Set the central widget of the base class to the main widget self.show( ); # Show the main widget
def _make_total_days_off_panel(self): widget = QFrame() widget.setObjectName('HorseRegularFrame') widget.setFrameShape(QFrame.Panel) widget.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout() #layout.addWidget(QLabel(_("Days off to date"))) self.day_off_total_duration_labels = dict() self.day_off_month_duration_labels = dict() self.day_off_labels = dict() self._day_off_table_model = QStandardItemModel(10, 3) self._day_off_table_model.setHorizontalHeaderLabels( [None, None, _("This\nmonth"), _("Before")]) self.day_off_table_view = QTableView(None) self.day_off_table_view.setModel(self._day_off_table_model) # self.day_off_table_view.setHorizontalHeader(self.headers_view) self.day_off_table_view.verticalHeader().hide() self.day_off_table_view.setAlternatingRowColors(True) self.day_off_table_view.setEditTriggers( QAbstractItemView.NoEditTriggers) self.day_off_table_view.hide() row = 0 for det in DayEventType.symbols(): ndx = self._day_off_table_model.index(row, 0) self._day_off_table_model.setData(ndx, det.description, Qt.DisplayRole) ndx = self._day_off_table_model.index(row, 1) fg, bg = self.DAY_EVENT_PALETTE[det] self._day_off_table_model.setData(ndx, QBrush(bg), Qt.BackgroundRole) self._day_off_table_model.setData(ndx, QBrush(fg), Qt.TextColorRole) self._day_off_table_model.setData(ndx, DayEventType.short_code(det), Qt.DisplayRole) row += 1 layout.addWidget(self.day_off_table_view) grid = QGridLayout() self.days_off_layout = grid grid.setColumnStretch(3, 1) row = 0 grid.addWidget(QLabel(_('Year')), row, self.YEAR_EVENT_COLUMN) grid.addWidget(QLabel(_('Month')), row, self.MONTH_EVENT_COLUMN) row += 1 for det in DayEventType.symbols(): self.day_off_total_duration_labels[det] = QLabel("-") self.day_off_month_duration_labels[det] = QLabel("-") self.day_off_labels[det] = QLabel(det.description) hlayout = QHBoxLayout() sl = QLabel() fg, bg = self.DAY_EVENT_PALETTE[det] def to_html_rgb(color): i = color.red() * 256 * 256 + color.green() * 256 + color.blue( ) return "#{:06X}".format(i) p = QPalette() p.setColor(QPalette.Window, QColor(bg)) p.setColor(QPalette.WindowText, QColor(fg)) sl.setPalette(p) sl.setAlignment(Qt.AlignCenter) sl.setStyleSheet("border: 2px solid black; background: {}".format( to_html_rgb(QColor(bg)))) t = DayEventType.short_code(det) mainlog.debug(t) sl.setAutoFillBackground(True) sl.setText(t) grid.addWidget(sl, row, 0) grid.addWidget(self.day_off_labels[det], row, 1) grid.addWidget(self.day_off_total_duration_labels[det], row, self.YEAR_EVENT_COLUMN) grid.addWidget(self.day_off_month_duration_labels[det], row, self.MONTH_EVENT_COLUMN) hlayout.addStretch() row += 1 layout.addLayout(grid) layout.addStretch() self.day_off_table_view.resizeColumnsToContents() # self.day_off_table_view.setMinimumWidth( self.day_off_table_view.width()) # self.day_off_table_view.resize( self.day_off_table_view.minimumWidth(), # self.day_off_table_view.minimumHeight(),) widget.setLayout(layout) return widget
def createMainWidget(self): """ TOWRITE :return: TOWRITE :rtype: `QScrollArea`_ """ widget = QWidget(self) # Misc groupBoxMisc = QGroupBox(self.tr("General Information"), widget) labelStitchesTotal = QLabel(self.tr("Total Stitches:"), self) labelStitchesReal = QLabel(self.tr("Real Stitches:"), self) labelStitchesJump = QLabel(self.tr("Jump Stitches:"), self) labelStitchesTrim = QLabel(self.tr("Trim Stitches:"), self) labelColorTotal = QLabel(self.tr("Total Colors:"), self) labelColorChanges = QLabel(self.tr("Color Changes:"), self) labelRectLeft = QLabel(self.tr("Left:"), self) labelRectTop = QLabel(self.tr("Top:"), self) labelRectRight = QLabel(self.tr("Right:"), self) labelRectBottom = QLabel(self.tr("Bottom:"), self) labelRectWidth = QLabel(self.tr("Width:"), self) labelRectHeight = QLabel(self.tr("Height:"), self) fieldStitchesTotal = QLabel(u'%s' % (self.stitchesTotal), self) fieldStitchesReal = QLabel(u'%s' % (self.stitchesReal), self) fieldStitchesJump = QLabel(u'%s' % (self.stitchesJump), self) fieldStitchesTrim = QLabel(u'%s' % (self.stitchesTrim), self) fieldColorTotal = QLabel(u'%s' % (self.colorTotal), self) fieldColorChanges = QLabel(u'%s' % (self.colorChanges), self) fieldRectLeft = QLabel(u'%s' % (str(self.boundingRect.left()) + " mm"), self) fieldRectTop = QLabel(u'%s' % (str(self.boundingRect.top()) + " mm"), self) fieldRectRight = QLabel(u'%s' % (str(self.boundingRect.right()) + " mm"), self) fieldRectBottom = QLabel(u'%s' % (str(self.boundingRect.bottom()) + " mm"), self) fieldRectWidth = QLabel(u'%s' % (str(self.boundingRect.width()) + " mm"), self) fieldRectHeight = QLabel(u'%s' % (str(self.boundingRect.height()) + " mm"), self) gridLayoutMisc = QGridLayout(groupBoxMisc) gridLayoutMisc.addWidget(labelStitchesTotal, 0, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelStitchesReal, 1, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelStitchesJump, 2, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelStitchesTrim, 3, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelColorTotal, 4, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelColorChanges, 5, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectLeft, 6, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectTop, 7, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectRight, 8, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectBottom, 9, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectWidth, 10, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectHeight, 11, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldStitchesTotal, 0, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldStitchesReal, 1, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldStitchesJump, 2, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldStitchesTrim, 3, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldColorTotal, 4, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldColorChanges, 5, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectLeft, 6, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectTop, 7, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectRight, 8, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectBottom, 9, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectWidth, 10, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectHeight, 11, 1, Qt.AlignLeft) gridLayoutMisc.setColumnStretch(1,1) groupBoxMisc.setLayout(gridLayoutMisc) # TODO: Color Histogram # Stitch Distribution # groupBoxDist = QGroupBox(self.tr("Stitch Distribution"), widget) # TODO: Stitch Distribution Histogram # Widget Layout vboxLayoutMain = QVBoxLayout(widget) vboxLayoutMain.addWidget(groupBoxMisc) # vboxLayoutMain.addWidget(groupBoxDist) vboxLayoutMain.addStretch(1) widget.setLayout(vboxLayoutMain) scrollArea = QScrollArea(self) scrollArea.setWidgetResizable(True) scrollArea.setWidget(widget) return scrollArea
class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") Form.resize(560, 560) sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth()) Form.setSizePolicy(sizePolicy) Form.setMinimumSize(QtCore.QSize(0, 0)) self.gridLayout_2 = QGridLayout(Form) self.gridLayout_2.setObjectName("gridLayout_2") self.editorGroupBox = QGroupBox(Form) sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth( self.editorGroupBox.sizePolicy().hasHeightForWidth()) self.editorGroupBox.setSizePolicy(sizePolicy) self.editorGroupBox.setMinimumSize(QtCore.QSize(0, 0)) self.editorGroupBox.setObjectName("editorGroupBox") self.gridLayout_3 = QGridLayout(self.editorGroupBox) self.gridLayout_3.setObjectName("gridLayout_3") self.gridLayout = QGridLayout() self.gridLayout.setObjectName("gridLayout") self.variable_verticalLayout_1 = QVBoxLayout() self.variable_verticalLayout_1.setObjectName( "variable_verticalLayout_1") self.listBox = QListWidget(self.editorGroupBox) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth( self.listBox.sizePolicy().hasHeightForWidth()) self.listBox.setSizePolicy(sizePolicy) self.listBox.setDragEnabled(True) self.listBox.setDragDropOverwriteMode(False) self.listBox.setDragDropMode(QAbstractItemView.InternalMove) self.listBox.setDefaultDropAction(QtCore.Qt.MoveAction) self.listBox.setAlternatingRowColors(True) self.listBox.setSelectionMode(QAbstractItemView.SingleSelection) self.listBox.setMovement(QListView.Snap) self.listBox.setResizeMode(QListView.Fixed) self.listBox.setSelectionRectVisible(False) self.listBox.setObjectName("listBox") self.variable_verticalLayout_1.addWidget(self.listBox) self.gridLayout.addLayout(self.variable_verticalLayout_1, 0, 0, 1, 1) self.variable_verticalLayout_2 = QVBoxLayout() self.variable_verticalLayout_2.setObjectName( "variable_verticalLayout_2") self.addButton = QPushButton(self.editorGroupBox) self.addButton.setObjectName("addButton") self.variable_verticalLayout_2.addWidget(self.addButton) self.editButton = QPushButton(self.editorGroupBox) self.editButton.setObjectName("editButton") self.variable_verticalLayout_2.addWidget(self.editButton) self.removeButton = QPushButton(self.editorGroupBox) self.removeButton.setObjectName("removeButton") self.variable_verticalLayout_2.addWidget(self.removeButton) spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.variable_verticalLayout_2.addItem(spacerItem) self.upButton = QPushButton(self.editorGroupBox) self.upButton.setObjectName("upButton") self.variable_verticalLayout_2.addWidget(self.upButton) self.downButton = QPushButton(self.editorGroupBox) self.downButton.setObjectName("downButton") self.variable_verticalLayout_2.addWidget(self.downButton) spacerItem1 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.variable_verticalLayout_2.addItem(spacerItem1) self.variable_verticalLayout_2.setStretch(3, 1) self.variable_verticalLayout_2.setStretch(6, 1) self.gridLayout.addLayout(self.variable_verticalLayout_2, 0, 1, 1, 1) self.gridLayout.setColumnStretch(0, 1) self.gridLayout_3.addLayout(self.gridLayout, 0, 0, 1, 1) self.horizontalLayout = QHBoxLayout() self.horizontalLayout.setContentsMargins(15, 15, 15, 15) self.horizontalLayout.setObjectName("horizontalLayout") spacerItem2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem2) self.ok_pushButton = QPushButton(self.editorGroupBox) self.ok_pushButton.setObjectName("ok_pushButton") self.horizontalLayout.addWidget(self.ok_pushButton) self.cancel_pushButton = QPushButton(self.editorGroupBox) self.cancel_pushButton.setObjectName("cancel_pushButton") self.horizontalLayout.addWidget(self.cancel_pushButton) self.horizontalLayout.setStretch(0, 1) self.gridLayout_3.addLayout(self.horizontalLayout, 1, 0, 1, 1) self.gridLayout_2.addWidget(self.editorGroupBox, 0, 0, 1, 1) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): Form.setWindowTitle( QApplication.translate("Form", "Form", None, QApplication.UnicodeUTF8)) self.editorGroupBox.setTitle( QApplication.translate("Form", "Maya Module Path Editor", None, QApplication.UnicodeUTF8)) self.addButton.setText( QApplication.translate("Form", "<<", None, QApplication.UnicodeUTF8)) self.editButton.setText( QApplication.translate("Form", "Edit", None, QApplication.UnicodeUTF8)) self.removeButton.setText( QApplication.translate("Form", ">>", None, QApplication.UnicodeUTF8)) self.upButton.setText( QApplication.translate("Form", "Move Up", None, QApplication.UnicodeUTF8)) self.downButton.setText( QApplication.translate("Form", "Move Down", None, QApplication.UnicodeUTF8)) self.ok_pushButton.setText( QApplication.translate("Form", "Save", None, QApplication.UnicodeUTF8)) self.cancel_pushButton.setText( QApplication.translate("Form", "Close", None, QApplication.UnicodeUTF8))
def createMainWidget(self): """ TOWRITE :return: TOWRITE :rtype: QScrollArea """ widget = QWidget(self) # Misc groupBoxMisc = QGroupBox(self.tr("General Information"), widget) labelStitchesTotal = QLabel(self.tr("Total Stitches:"), self) labelStitchesReal = QLabel(self.tr("Real Stitches:"), self) labelStitchesJump = QLabel(self.tr("Jump Stitches:"), self) labelStitchesTrim = QLabel(self.tr("Trim Stitches:"), self) labelColorTotal = QLabel(self.tr("Total Colors:"), self) labelColorChanges = QLabel(self.tr("Color Changes:"), self) labelRectLeft = QLabel(self.tr("Left:"), self) labelRectTop = QLabel(self.tr("Top:"), self) labelRectRight = QLabel(self.tr("Right:"), self) labelRectBottom = QLabel(self.tr("Bottom:"), self) labelRectWidth = QLabel(self.tr("Width:"), self) labelRectHeight = QLabel(self.tr("Height:"), self) fieldStitchesTotal = QLabel(u'%s' % (self.stitchesTotal), self) fieldStitchesReal = QLabel(u'%s' % (self.stitchesReal), self) fieldStitchesJump = QLabel(u'%s' % (self.stitchesJump), self) fieldStitchesTrim = QLabel(u'%s' % (self.stitchesTrim), self) fieldColorTotal = QLabel(u'%s' % (self.colorTotal), self) fieldColorChanges = QLabel(u'%s' % (self.colorChanges), self) fieldRectLeft = QLabel(u'%s' % (str(self.boundingRect.left()) + " mm"), self) fieldRectTop = QLabel(u'%s' % (str(self.boundingRect.top()) + " mm"), self) fieldRectRight = QLabel( u'%s' % (str(self.boundingRect.right()) + " mm"), self) fieldRectBottom = QLabel( u'%s' % (str(self.boundingRect.bottom()) + " mm"), self) fieldRectWidth = QLabel( u'%s' % (str(self.boundingRect.width()) + " mm"), self) fieldRectHeight = QLabel( u'%s' % (str(self.boundingRect.height()) + " mm"), self) gridLayoutMisc = QGridLayout(groupBoxMisc) gridLayoutMisc.addWidget(labelStitchesTotal, 0, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelStitchesReal, 1, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelStitchesJump, 2, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelStitchesTrim, 3, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelColorTotal, 4, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelColorChanges, 5, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectLeft, 6, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectTop, 7, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectRight, 8, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectBottom, 9, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectWidth, 10, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectHeight, 11, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldStitchesTotal, 0, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldStitchesReal, 1, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldStitchesJump, 2, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldStitchesTrim, 3, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldColorTotal, 4, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldColorChanges, 5, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectLeft, 6, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectTop, 7, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectRight, 8, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectBottom, 9, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectWidth, 10, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectHeight, 11, 1, Qt.AlignLeft) gridLayoutMisc.setColumnStretch(1, 1) groupBoxMisc.setLayout(gridLayoutMisc) # TODO: Color Histogram # Stitch Distribution # groupBoxDist = QGroupBox(self.tr("Stitch Distribution"), widget) # TODO: Stitch Distribution Histogram # Widget Layout vboxLayoutMain = QVBoxLayout(widget) vboxLayoutMain.addWidget(groupBoxMisc) # vboxLayoutMain.addWidget(groupBoxDist) vboxLayoutMain.addStretch(1) widget.setLayout(vboxLayoutMain) scrollArea = QScrollArea(self) scrollArea.setWidgetResizable(True) scrollArea.setWidget(widget) return scrollArea
class AllInputsPanel(QWidget): inputSelected = Signal(Input) def __init__(self, switcherState, parent=None): super(AllInputsPanel, self).__init__(parent) self.switcherState = switcherState self.selectedInput = None self.page = 0 self.sources = [] self.layout = QGridLayout() self.input_buttons = QButtonGroup() self.btnPageUp = ExpandingButton() self.btnPageUp.setIcon(QIcon(":icons/go-up")) self.btnPageUp.clicked.connect(lambda: self.setPage(self.page - 1)) self.layout.addWidget(self.btnPageUp, 0, 5, 3, 1) self.btnPageDown = ExpandingButton() self.btnPageDown.setIcon(QIcon(":icons/go-down")) self.btnPageDown.clicked.connect(lambda: self.setPage(self.page + 1)) self.layout.addWidget(self.btnPageDown, 3, 5, 3, 1) for col in range(5): self.layout.setColumnStretch(col, 1) for row in range(3): btn = InputButton(None) self.layout.addWidget(btn, row * 2, col, 2, 1) self.input_buttons.addButton(btn) btn.clicked.connect(self.selectInput) btn.setFixedWidth(120) self.setLayout(self.layout) self.switcherState.inputsChanged.connect(self.setSources) self.setSources() self.displayInputs() def setSources(self): self.sources = [ vs for vs in VideoSource if vs in self.switcherState.inputs.keys() ] def displayInputs(self): idx = 0 start = self.page * 15 end = start + 15 self.input_buttons.setExclusive(False) for btn in self.input_buttons.buttons(): btn.hide() btn.setChecked(False) self.input_buttons.setExclusive(True) for vs in self.sources[start:end]: inp = self.switcherState.inputs[vs] row = (idx / 5) * 2 col = idx % 5 btn = self.layout.itemAtPosition(row, col).widget() btn.setInput(inp) btn.setChecked(inp == self.selectedInput) btn.show() idx += 1 self.btnPageUp.setEnabled(self.page > 0) self.btnPageDown.setEnabled(end < len(self.switcherState.inputs)) def setPage(self, page): self.page = page self.displayInputs() def selectInput(self): inputBtn = self.sender() self.selectedInput = inputBtn.input self.inputSelected.emit(inputBtn.input)
def setupUi(self): scene = QGraphicsScene(self) self.view = QGraphicsView(scene, self) self.view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.view.setVisible(True) self.view.setInteractive(True) self.createPixmapIcon() self.mapWidget = MapWidget(self.mapManager) scene.addItem(self.mapWidget) self.mapWidget.setCenter(QGeoCoordinate(-8.1, -34.95)) self.mapWidget.setZoomLevel(5) #... self.slider = QSlider(Qt.Vertical, self) self.slider.setTickInterval(1) self.slider.setTickPosition(QSlider.TicksBothSides) self.slider.setMaximum(self.mapManager.maximumZoomLevel()) self.slider.setMinimum(self.mapManager.minimumZoomLevel()) self.slider.valueChanged[int].connect(self.sliderValueChanged) self.mapWidget.zoomLevelChanged[float].connect(self.mapZoomLevelChanged) mapControlLayout = QVBoxLayout() self.mapWidget.mapTypeChanged.connect(self.mapTypeChanged) for mapType in self.mapWidget.supportedMapTypes(): radio = QRadioButton(self) if mapType == QGraphicsGeoMap.StreetMap: radio.setText('Street') elif mapType == QGraphicsGeoMap.SatelliteMapDay: radio.setText('Sattelite') elif mapType == QGraphicsGeoMap.SatelliteMapNight: radio.setText('Sattelite - Night') elif mapType == QGraphicsGeoMap.TerrainMap: radio.setText('Terrain') if mapType == self.mapWidget.mapType(): radio.setChecked(True) radio.toggled[bool].connect(self.mapTypeToggled) self.mapControlButtons.append(radio) self.mapControlTypes.append(mapType) mapControlLayout.addWidget(radio) self.latitudeEdit = QLineEdit() self.longitudeEdit = QLineEdit() formLayout = QFormLayout() formLayout.addRow('Latitude', self.latitudeEdit) formLayout.addRow('Longitude', self.longitudeEdit) self.captureCoordsButton = QToolButton() self.captureCoordsButton.setText('Capture coordinates') self.captureCoordsButton.setCheckable(True) self.captureCoordsButton.toggled[bool].connect( self.mapWidget.setMouseClickCoordQuery) self.mapWidget.coordQueryResult.connect(self.updateCoords) self.setCoordsButton = QPushButton() self.setCoordsButton.setText('Set coordinates') self.setCoordsButton.clicked.connect(self.setCoordsClicked) buttonLayout = QHBoxLayout() buttonLayout.addWidget(self.captureCoordsButton) buttonLayout.addWidget(self.setCoordsButton) coordControlLayout = QVBoxLayout() coordControlLayout.addLayout(formLayout) coordControlLayout.addLayout(buttonLayout) widget = QWidget(self) layout = QGridLayout() layout.setRowStretch(0, 1) layout.setRowStretch(1, 0) topLayout = QGridLayout() bottomLayout = QGridLayout() topLayout.setColumnStretch(0, 0) topLayout.setColumnStretch(1, 1) bottomLayout.setColumnStretch(0, 0) bottomLayout.setColumnStretch(1, 1) topLayout.addWidget(self.slider, 0, 0) topLayout.addWidget(self.view, 0, 1) bottomLayout.addLayout(mapControlLayout, 0, 0) bottomLayout.addLayout(coordControlLayout, 0, 1) layout.addLayout(topLayout, 0, 0) layout.addLayout(bottomLayout, 1, 0) self.layout = layout widget.setLayout(layout) self.setCentralWidget(widget) self.view.setContextMenuPolicy(Qt.CustomContextMenu) self.view.customContextMenuRequested.connect(self.customContextMenuRequest)
def __init__(self, controller, joystickAdapter=None): super(MainWindow, self).__init__() self.controller = controller self.setWindowTitle("av-control") self.resize(1024, 600) self.setWindowIcon(QIcon(":icons/video-display")) atem = controller['ATEM'] self.switcherState = SwitcherState(atem) self.mainScreen = VideoSwitcher(controller, self, self.switcherState, joystickAdapter) # This is possibly a bad / too complicated idea... # self.mainScreen.setEnabled(self.switcherState.connected) # self.switcherState.connectionChanged.connect(self.mainScreen.setEnabled) self.stack = QStackedWidget() self.stack.addWidget(self.mainScreen) outer = QWidget() mainLayout = QGridLayout() mainLayout.addWidget(self.stack, 0, 0, 1, 7) column = 0 self.spc = SystemPowerWidget(controller, self) syspower = ExpandingButton() syspower.setText("Power") syspower.clicked.connect(self.showSystemPower) syspower.setIcon(QIcon(":icons/system-shutdown")) syspower.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) mainLayout.addWidget(syspower, 1, column) column += 1 if controller.hasDevice("Blinds"): self.bc = BlindsControl(controller["Blinds"], self) blinds = ExpandingButton() blinds.setText("Blinds") blinds.clicked.connect(lambda: self.showScreen(self.bc)) blinds.setIcon(QIcon(":icons/blinds")) blinds.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) mainLayout.addWidget(blinds, 1, column) column += 1 if controller.hasDevice("Lights"): self.lightsMenu = LightingControl(controller["Lights"], self) lights = ExpandingButton() lights.setText("Lights") lights.clicked.connect(lambda: self.showScreen(self.lightsMenu)) lights.setIcon(QIcon(":icons/lightbulb_on")) lights.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) mainLayout.addWidget(lights, 1, column) column += 1 if controller.hasDevice("Recorder"): hyperdeck = controller['Recorder'] self.hyperdeckState = HyperdeckState(hyperdeck) self.recorderScreen = RecorderControl(hyperdeck, atem, self.hyperdeckState, self) recorder = ExpandingButton() recorder.setText("Recorder") recorder.setIcon(QIcon(":icons/drive-optical")) recorder.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) recorder.clicked.connect(lambda: self.showScreen(self.recorderScreen)) mainLayout.addWidget(recorder, 1, column) column += 1 def update_recorder_icon(transport): if 'status' in transport: if transport['status'] == TransportState.RECORD: recorder.setIcon(QIcon(":icons/media-record")) elif transport['status'] == TransportState.PLAYING: recorder.setIcon(QIcon(":icons/media-playback-start")) else: recorder.setIcon(QIcon(":icons/drive-optical")) self.hyperdeckState.transportChange.connect(update_recorder_icon) self.advMenu = AdvancedMenu(self.controller, self.switcherState.mixTransition, atem, self) adv = ExpandingButton() adv.setText("Advanced") adv.setIcon(QIcon(":icons/applications-system")) adv.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) adv.clicked.connect(lambda: self.showScreen(self.advMenu)) mainLayout.addWidget(adv, 1, column) column += 1 for i in range(column): mainLayout.setColumnStretch(i, 1) tray = QHBoxLayout() tray.addWidget(Clock()) tray.addWidget(SystemStatus(controller)) mainLayout.addLayout(tray, 1, column) mainLayout.setRowStretch(0, 8) mainLayout.setRowStretch(1, 0) outer.setLayout(mainLayout) self.setCentralWidget(outer) self.pnd = PowerNotificationDialog(self) self.pnd.accepted.connect(self.hidePowerDialog)