def __init__(self): QtCore.QObject.__init__(self) elements = utils.loadUi(self._SETTINGS_UI, parent=utils.window()) self.columnEdited = 0 self.dialog = elements["Dialog"] elements["buttonClose"].clicked.connect(self.dialog.close) self._optionsTree = elements["treeWidgetOptions"] self._optionsTree.setColumnWidth(2, 0) self._actionAdd = QtGui.QAction("&Add", self._optionsTree) self._actionRemove = QtGui.QAction("&Remove", self._optionsTree) self._actionRefresh = QtGui.QAction("Re&fresh", self._optionsTree) self._menu = QtGui.QMenu("Menu", None) self._menu.addAction(self._actionAdd) self._menu.addAction(self._actionRemove) self._menu.addAction(self._actionRefresh) self._optionsTree.itemExpanded.connect(self.expandOption) self._optionsTree.itemDoubleClicked.connect(self.startEditing) self._optionsTree.currentItemChanged.connect(self.finishEditing) self._optionsTree.itemChanged.connect(self.updateOption) self._actionAdd.triggered.connect(self.addSetting) self._actionRemove.triggered.connect(self.removeSetting) self._actionRefresh.triggered.connect(self.reloadTree) self._optionsTree.customContextMenuRequested.connect( self.contextMenuShow) self._escapeFilter = _EscapeFilter()
def __init__(self, header, errors): ''' Sets title of the dialog and fills the tree with information stored in given list of ErrorBox instances. ''' QtCore.QObject.__init__(self) elements = loadUi(self._DIALOG_UI, parent=window()) self._dialog = elements["dialog"] self._dialog.setWindowTitle(header) tree = elements["treeWidgetErrors"] items = [] for error in errors: item = QtGui.QTreeWidgetItem(tree) infos = [] fields = vars(error) for name in sorted(fields): if name != "traceback": infos.append(fields[name]) item.setText(0, ", ".join(infos)) QtGui.QTreeWidgetItem(item, [error.traceback]) item.setExpanded(True) items.append(item) tree.resizeColumnToContents(0) size = QtCore.QSize( min(window().size().width(), tree.columnWidth(0) + 40), min(window().size().height(), self._dialog.size().height())) self._dialog.resize(size) for item in items: item.setExpanded(False)
def __init__(self, header, errors): ''' Sets title of the dialog and fills the tree with information stored in given list of ErrorBox instances. ''' QtCore.QObject.__init__(self) elements = loadUi(self._DIALOG_UI, parent=window()) self._dialog = elements["dialog"] self._dialog.setWindowTitle(header) tree = elements["treeWidgetErrors"] items = [] for error in errors: item = QtGui.QTreeWidgetItem(tree) infos = [] fields = vars(error) for name in sorted(fields): if name != "traceback": infos.append(fields[name]) item.setText(0, ", ".join(infos)) QtGui.QTreeWidgetItem(item, [error.traceback]) item.setExpanded(True) items.append(item) tree.resizeColumnToContents(0) size = QtCore.QSize(min(window().size().width(), tree.columnWidth(0) + 40), min(window().size().height(), self._dialog.size().height())) self._dialog.resize(size) for item in items: item.setExpanded(False)
def __init__(self, default_queryset=None, *args, **kwargs): super(NewSaleView, self).__init__(*args, **kwargs) self.ui = loadUi("shop/new_sale.ui", self) self.connect(self.ui.add_product, QtCore.SIGNAL("clicked()"), self.on_product_search)
def __init__(self, parent=None): super(TimeSlider, self).__init__(parent) #self.setupUi(self) viewPath = os.path.abspath('views/timeSlider.ui') print "TimeSlider viewPath: {0}".format(viewPath) # TESTING self.ui = utils.loadUi(viewPath, self) self._dataMapper = QDataWidgetMapper() # used to keep track of playback time self.time = QElapsedTimer() self.timer = QTimer() self.timer.timerEvent = self.updateTime # add context menu to audio action = QAction('Open Audio Folder...', self.ui) action.triggered.connect(self.openAudioFolder) self.ui.AudioCheck.addAction(action) # hide hidden controls self.ui.IsRecordingCheck.setVisible(False) self.ui.IsPlayingCheck.setVisible(False) self.ui.RecordingIndex.valueChanged.connect(self.recordingIndexChanged) self.ui.TimeSlider.valueChanged.connect(self.timeSliderValueChanged) self.ui.IsPlayingCheck.toggled.connect(self.updateIsPlaying) self.ui.IsRecordingCheck.toggled.connect(self.updateIsRecording) self.ui.AudioCheck.toggled.connect(self.audioCheckToggled) self.ui.PlayBtn.clicked.connect(self.play) self.ui.RecordBtn.clicked.connect(self.recordBtnAction) self.ui.NewBtn.clicked.connect(StoryTimeWindow.instance().newRecording)
def __init__(self, summary, files, runAgain=True): ''' Takes a dictionary with summary of a test execution and a dictionary of files produced by channels and builds a tree. If runAgain is True, then the 'Run Again' button will be enabled. ''' QtCore.QObject.__init__(self) elements = loadUi(self._DIALOG_UI, parent=window()) self._dialog = elements["dialog"] self._tree = elements["treeWidgetReport"] raButton = elements["buttonRunAgain"] sdButton = elements["buttonShowDetails"] elements["buttonClose"].clicked.connect(self._dialog.accept) self._dialog.finished.connect(self.closed) if runAgain is False: raButton.setEnabled(False) else: raButton.clicked.connect(self._dialog.accept) raButton.clicked.connect(self.runAgainClicked) sdButton.clicked.connect(self._dialog.accept) sdButton.clicked.connect(self.showDetailsClicked) sdButton.setDefault(True) font = self._tree.font() font.setPointSize(font.pointSize() + 2) self._largeFont = font font = QtGui.QFont(font) font.setBold(True) self._largeBoldFont = font self._metrics = QtGui.QFontMetrics(self._largeBoldFont) self._tree.header().setResizeMode( QtGui.QHeaderView.ResizeMode.ResizeToContents) self._tree.header().sectionResized.connect(self._update, QtCore.Qt.QueuedConnection) useColor = { STATUS_PASSED: (summary[STATUS_PASSED] > 0 and (summary[STATUS_FAILED] + summary[STATUS_NOT_COMPLETED] + summary[STATUS_NOT_COMPLETED]) == 0), STATUS_FAILED: summary[STATUS_FAILED] > 0, STATUS_ERROR: summary[STATUS_ERROR] > 0, STATUS_NOT_COMPLETED: summary[STATUS_NOT_COMPLETED] > 0, COUNTER_CORE_DUMPS: summary[COUNTER_CORE_DUMPS] > 0 } for id in (COUNTER_N_TESTS, COUNTER_TESTS_RUN, STATUS_PASSED, STATUS_FAILED, STATUS_NOT_COMPLETED, STATUS_ERROR, COUNTER_CORE_DUMPS, COUNTER_RUN_TIME): if id == COUNTER_CORE_DUMPS and summary[COUNTER_CORE_DUMPS] == 0: continue self._addItem(id, str(summary[id]), useColor.get(id, False)) self._filesItems = [] for name, value in files: self._addItem(name, value, False, file=True) header = self._tree.header() for i in xrange(3): header.setResizeMode(i, header.ResizeToContents)
def __init__(self, pixmapMapping, index, parent=None): super(ImageView, self).__init__(parent) viewPath = os.path.abspath('views/imageView.ui') print "ImageView viewPath: {0}".format(viewPath) # TESTING self.ui = utils.loadUi(viewPath, self) self._dataMapper = QDataWidgetMapper() self.pixmapMapping = pixmapMapping # for use when adjusting layout stretch self.index = index self.ui.GraphicsView.setStyleSheet( 'QGraphicsView { border-style: none; }' )
def __init__(self, parent=None): super(ImageSlider, self).__init__(parent) #self.setupUi(self) viewPath = os.path.abspath('views/imageSlider.ui') print "ImageSlider viewPath: {0}".format(viewPath) # TESTING self.ui = utils.loadUi(viewPath, self) self._dataMapper = QDataWidgetMapper() self.ui.ImageSlider.valueChanged.connect(self._dataMapper.submit) self.ui.PrevImageCheck.toggled.connect(StoryTimeWindow.instance().setPrevImageViewVisible) self.ui.NextImageCheck.toggled.connect(StoryTimeWindow.instance().setNextImageViewVisible)
def __init__(self): QtCore.QObject.__init__(self) elements = utils.loadUi(self._ABOUT_UI, parent=utils.window()) self.dialog = elements["Dialog"] self.dialog.setWindowTitle("About %s" % getProgramName()) elements["buttonClose"].clicked.connect(self.dialog.close) elements["labelName"].setText(NAME.upper()) elements["labelVersion"].setText(VERSION) elements["labelDescription"].setText(DESCRIPTION) elements["labelCopyright"].setText(COPYRIGHT) elements["labelWebsite"].setText(self._LINK % (WEBSITE_URL, WEBSITE_URL)) elements["labelLicensing"].setText(self._LINK % (LICENSING_URL, LICENSING_URL))
def __init__(self, default_queryset=None, *args, **kwargs): super(ProductSearchView, self).__init__(*args, **kwargs) self.default_queryset = default_queryset if self.default_queryset is None: self.default_queryset = ClientProduct.objects.all() self.ui = loadUi("shop/product_search.ui", self) self.ui.result_table.setColumnWidth(0, 310) self.ui.result_table.setColumnWidth(1, 90) self.ui.result_table.horizontalHeader().setResizeMode( QtGui.QHeaderView.Fixed) self.set_items(self.default_queryset) self.ui.close_button.setShortcut('Esc') self.connect(self.ui.close_button, QtCore.SIGNAL('clicked()'), self.close)
def __init__(self): QtCore.QObject.__init__(self) elements = utils.loadUi(self._DIALOG_UI, parent=utils.window()) self.dialog = elements["Dialog"] self._deviceList = elements["treeWidgetDevices"] elements["buttonClose"].clicked.connect(self.dialog.close) self._deviceList.itemSelectionChanged.connect(self._updateDialogButtons) elements["buttonConnectAll"].clicked.connect(self._connectAll) elements["buttonDisconnectAll"].clicked.connect(self._disconnectAll) self._addButton = elements["buttonAdd"] self._addButton.clicked.connect(self._addDevice) self._editButton = elements["buttonEdit"] self._editButton.clicked.connect(self._editDevice) self._removeButton = elements["buttonRemove"] self._removeButton.clicked.connect(self._removeDevice) self._deviceItems = {} self._errors = {} self._refresh()
def __init__(self): QtCore.QObject.__init__(self) elements = utils.loadUi(self._DIALOG_UI, parent=utils.window()) self.dialog = elements["Dialog"] self._deviceList = elements["treeWidgetDevices"] elements["buttonClose"].clicked.connect(self.dialog.close) self._deviceList.itemSelectionChanged.connect( self._updateDialogButtons) elements["buttonConnectAll"].clicked.connect(self._connectAll) elements["buttonDisconnectAll"].clicked.connect(self._disconnectAll) self._addButton = elements["buttonAdd"] self._addButton.clicked.connect(self._addDevice) self._editButton = elements["buttonEdit"] self._editButton.clicked.connect(self._editDevice) self._removeButton = elements["buttonRemove"] self._removeButton.clicked.connect(self._removeDevice) self._deviceItems = {} self._errors = {} self._refresh()
def __init__(self): QtCore.QObject.__init__(self) elements = utils.loadUi(self._MAIN_WINDOW_UI) self.window = elements["MainWindow"] # Binding Window's custom event handlers self.window.closeEvent = self.closeEvent self.centralWidget = elements["centralWidget"] # Menus self.menuFile = elements["menuFile"] elements["actionQuit"].triggered.connect(self.window.close) self._actionQuit = elements["actionQuit"] self.menuEdit = elements["menuEdit"] self._actionDevices = elements["actionDevices"] self.menuView = elements["menuView"] # Tool bars self.toolBarMain = elements["toolBarMain"] self.toolBarSwitch = elements["toolBarSwitch"] self.toolBarView = elements["toolBarView"] # Dialogs self.about = about.About() elements["actionAbout"].triggered.connect(self.about.run) self.devices = devices.DevicesDialog() elements["actionDevices"].triggered.connect(self.devices.run) self.settings = settings.SettingsDialog() elements["actionSettings"].triggered.connect(self.settings.run) # Views self._viewGroup = QtGui.QActionGroup(self.window) self._views = view.all(self) for i, obj in enumerate(self._views): self._viewGroup.addAction(obj.action) self.menuView.addAction(obj.action) self.toolBarSwitch.addAction(obj.action) obj.action.setShortcut("ALT+%d" % (i+1)) # Uniform width of ToolBar buttons self._buttonWidth = QtGui.QFontMetrics(self.window.font()).width( 'a' * self._TOOLBAR_BUTTON_LETTERS) for toolBar in (self.toolBarMain, self.toolBarSwitch): for action in toolBar.actions(): if action.isSeparator(): continue toolBar.widgetForAction(action).setFixedWidth(self._buttonWidth) # Settings self._loadState()
def __init__(self): QtCore.QObject.__init__(self) elements = utils.loadUi(self._MAIN_WINDOW_UI) self.window = elements["MainWindow"] # Binding Window's custom event handlers self.window.closeEvent = self.closeEvent self.centralWidget = elements["centralWidget"] # Menus self.menuFile = elements["menuFile"] elements["actionQuit"].triggered.connect(self.window.close) self._actionQuit = elements["actionQuit"] self.menuEdit = elements["menuEdit"] self._actionDevices = elements["actionDevices"] self.menuView = elements["menuView"] # Tool bars self.toolBarMain = elements["toolBarMain"] self.toolBarSwitch = elements["toolBarSwitch"] self.toolBarView = elements["toolBarView"] # Dialogs self.about = about.About() elements["actionAbout"].triggered.connect(self.about.run) self.devices = devices.DevicesDialog() elements["actionDevices"].triggered.connect(self.devices.run) self.settings = settings.SettingsDialog() elements["actionSettings"].triggered.connect(self.settings.run) # Views self._viewGroup = QtGui.QActionGroup(self.window) self._views = view.all(self) for i, obj in enumerate(self._views): self._viewGroup.addAction(obj.action) self.menuView.addAction(obj.action) self.toolBarSwitch.addAction(obj.action) obj.action.setShortcut("ALT+%d" % (i + 1)) # Uniform width of ToolBar buttons self._buttonWidth = QtGui.QFontMetrics(self.window.font()).width("a" * self._TOOLBAR_BUTTON_LETTERS) for toolBar in (self.toolBarMain, self.toolBarSwitch): for action in toolBar.actions(): if action.isSeparator(): continue toolBar.widgetForAction(action).setFixedWidth(self._buttonWidth) # Settings self._loadState()
def __init__(self, parent): QtCore.QObject.__init__(self) self._parent = parent if not (self.NAME and self._UI_FILE and self._ICON_FILE): raise NotImplementedError elements = utils.loadUi(self._UI_FILE, self.NAME) self.view = elements["View"] self.action = QtGui.QAction(QtGui.QIcon(self._ICON_FILE), self.NAME.capitalize(), self.view) self.action.setCheckable(True) self.action.changed.connect(self._update) # prepare actions for menus and toolbar for attr in ("_menuFile", "_menuEdit", "_menuView", "_toolBar"): actions = [] for item in getattr(self, attr): if isinstance(item, (list, tuple)): if item and item[0] not in elements: menu = QtGui.QMenu(item[0]) item = item[1:] else: menu = QtGui.QMenu(elements[item[0]].text()) menu.addActions( tuple(self._separator() if n is None else elements[n] for n in item)) actions.append(menu) else: actions.append( self._separator() if item is None else elements[item]) setattr(self, attr, tuple(actions)) # set of device response IDs the view is responsible for reception of self.reqIds = set() # setup handling signals from devices parent.devices.connected.connect(self._deviceConnected) parent.devices.disconnected.connect(self._deviceDisconnected) parent.devices.requestSent.connect(self._deviceRequestSent) parent.devices.responseReceived.connect(self._deviceResponseReceived) self._elements = elements
def __init__(self, dev=None): ''' Initializer. :param dev: A device to configure. If not provided, a new device will be added :type dev: Device ''' QtCore.QObject.__init__(self) elements = utils.loadUi(self._DIALOG_UI, parent=utils.window()) self.dialog = elements["Dialog"] self.dialog.setWindowTitle("Edit device" if dev else "Add device") elements["buttonBox"].accepted.connect(self._accept) self._name = elements["lineEditName"] self._desc = elements["lineEditDescription"] self._address = elements["comboBoxAddress"] self._address.completer().setCaseSensitivity(QtCore.Qt.CaseSensitive) self._lastAddresses = utils.LastValues(self._CONFIG_NAME, self._CONFIG_SECTION_COMPLETERS, "address") self._lastAddresses.add(devices.DEFAULT_IP) self._port = elements["spinBoxPort"] self._port.setValue(devices.DEFAULT_PORT) self._connect = elements["checkBoxConnect"] self._connect.setChecked(True) self._autoconnect = elements["checkBoxAutoconnect"] self._device = dev if dev: self._name.setText(dev.name) self._desc.setText(dev.description) address, port = dev.address self._lastAddresses.add(address) self._port.setValue(port) autoconnect = dev.params.get("autoconnect", False) self._autoconnect.setChecked(bool(autoconnect)) for addr in self._lastAddresses.all(): self._address.addItem(addr) self._address.setCurrentIndex(0) # New created device self.params = None
def __init__(self, parent=None): viewPath = os.path.abspath('views/main.ui') print "viewPath: {0}".format(viewPath) # TESTING self.ui = utils.loadUi(viewPath, None) self.ui.setWindowTitle('Story Time') self.ui.setFocusPolicy(Qt.StrongFocus) self.ui.setAcceptDrops(True) if utils.getOS() == 'windows': self.ui.setWindowIcon(QIcon(os.path.abspath('StoryTime.ico'))) self.ui.show() # setup model self._model = StoryTimeModel(self.ui) # current image self.curImageView = ImageView(Mappings.curImage, 1, self.ui) self.curImageView.setModel(self._model) self.ui.layoutCurImage.addWidget(self.curImageView) # prev image self.prevImageView = ImageView(Mappings.prevImage, 0, self.ui) self.prevImageView.setModel(self._model) self.ui.layoutPrevImage.addWidget(self.prevImageView) # prev image self.nextImageView = ImageView(Mappings.nextImage, 2, self.ui) self.nextImageView.setModel(self._model) self.ui.layoutNextImage.addWidget(self.nextImageView) self.setImageViewVisible('prev', False) self.setImageViewVisible('next', False) self.imageSlider = ImageSlider(self.ui) self.imageSlider.setModel(self._model) self.ui.layoutControls.addWidget(self.imageSlider) self.timeSlider = TimeSlider(self.ui) self.timeSlider.setModel(self._model) self.ui.layoutControls.addWidget(self.timeSlider) # setup key press eater self.eventEater = EventEater() self.eventEater.keyPressEvent = self.keyPressEvent self.eventEater.handlePaths = self.loadPaths self.ui.installEventFilter(self.eventEater) self.imageSlider.installEventFilter(self.eventEater) self.timeSlider.installEventFilter(self.eventEater) # build some dynamic menus self.buildAudioInputsMenu() self.ui.menuFPS.setEnabled(False) # hookup menu actions self.ui.menuFile.aboutToShow.connect(self.fileMenuAboutToShow) self.ui.actionNewRecording.triggered.connect(self.newRecording) self.ui.actionOpenRecording.triggered.connect(self.openRecording) self.ui.actionSaveRecordingAs.triggered.connect(self.saveRecordingAs) self.ui.actionExportMovie.triggered.connect(self.exportMovie) self.ui.actionExportForEditing.triggered.connect(self.exportForEditing) self.ui.actionOpenStoryTimeDir.triggered.connect(self.openStoryTimePath) self.ui.actionImportImages.triggered.connect(self.importImages) self.ui.actionClearImages.triggered.connect(self._model.clearImages) self.ui.actionNewRecording.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_N)) self.ui.actionOpenRecording.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_O)) self.ui.actionSaveRecordingAs.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_S)) self.ui.actionExportMovie.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_M)) self.ui.actionExportForEditing.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_E)) self.ui.actionImportImages.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_I)) # Active and reveal the window self.ui.activateWindow() self.ui.raise_()
def __init__(self, parent=None): """Constructor""" super(ComputeWeightsTab, self).__init__(parent) utils.loadUi(uifile, self) self.initWidgets()
def __init__(self, default_queryset=None, *args, **kwargs): super(BaseView, self).__init__(*args, **kwargs) self.ui = loadUi("base.ui", self) self.connect(self.ui.new_sale, QtCore.SIGNAL("triggered()"), self.on_new_sale)
def loadUi(self, file): ''' Loads the given ui file. ''' return utils.loadUi(file, self.NAME, self.view)
def __init__(self, parent=None): """Constructor""" super(AboutDialog, self).__init__(parent) utils.loadUi(uifile, self) self.initWidgets()