def __init__(self): super(MDIImageViewerWindow, self).__init__() self._recentFileActions = [] self._handlingScrollChangedSignal = False self._mdiArea = QtGui.QMdiArea() self._mdiArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self._mdiArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self._mdiArea.subWindowActivated.connect(self.subWindowActivated) self.setCentralWidget(self._mdiArea) #self._mdiArea.setViewMode(QtGui.QMdiArea.TabbedView) self._mdiArea.subWindowActivated.connect(self.updateMenus) self._windowMapper = QtCore.QSignalMapper(self) self._windowMapper.mapped[QtGui.QWidget].connect( self.setActiveSubWindow) self._actionMapper = QtCore.QSignalMapper(self) self._actionMapper.mapped[str].connect(self.mappedImageViewerAction) self._recentFileMapper = QtCore.QSignalMapper(self) self._recentFileMapper.mapped[str].connect(self.openRecentFile) self.createActions() self.addAction(self._activateSubWindowSystemMenuAct) self.createMenus() self.updateMenus() self.createStatusBar() self.readSettings() self.updateStatusBar() self.setUnifiedTitleAndToolBarOnMac(True)
def tocollect(self,collectChannel): if len(collectChannel): for num,channel in collectChannel.items(): text = channel.text() # collectChannel self.sMapper = QtCore.QSignalMapper(self) self.tMapper = QtCore.QSignalMapper(self) self.sMapper.setMapping(channel,num) self.tMapper.setMapping(channel,text) channel.triggered.connect(self.sMapper.map) channel.triggered.connect(self.tMapper.map) self.sMapper.mapped[str].connect(self.changeChannel) self.tMapper.mapped[str].connect(self.currentChannel)
def __init__(self, reactor, font = None, parent = None): super(scheduled_list, self).__init__(parent) self.reactor = reactor self.parent = parent self.font = font if self.font is None: self.font = QtGui.QFont('MS Shell Dlg 2',pointSize=10) self.setSelectionMode(QtGui.QAbstractItemView.NoSelection) self.setupLayout() self.d = {}#stores identification: corresponding widget self.mapper_cancel = QtCore.QSignalMapper() self.mapper_cancel.mapped.connect(self.on_user_cancel) self.mapper_duration = QtCore.QSignalMapper() self.mapper_duration.mapped.connect(self.on_user_new_duration)
def __init__(self, title, choices, rememberText='Remember my choice', parent=None): QtGui.QDialog.__init__(self, parent) layout = QtGui.QVBoxLayout() self.setLayout(layout) self.setWindowTitle(title) self.buttons = [] self.mapper = QtCore.QSignalMapper(self) i = 1 # create buttons and connect to signal mapper, which # will determine where signals came from and pass the # appropriate argument into the signal it emits for choice in choices: self.buttons.append(QtGui.QPushButton(choice)) layout.addWidget(self.buttons[-1]) self.mapper.setMapping(self.buttons[-1], i) self.connect(self.buttons[-1], QtCore.SIGNAL('clicked(bool)'), self.mapper, QtCore.SLOT('map()')) i=i+1 self.connect(self.mapper, QtCore.SIGNAL('mapped(int)'), self.done) if rememberText: self.remember = QtGui.QCheckBox(rememberText) layout.addWidget(self.remember) else: self.remember = QtGui.QCheckBox('') # not displayed self.remember.setVisible(False)
def configureSubPanelMenu(self): '''Dynamically add subpanels to View menu based on XML file configuration This also adds the subpanel to a stacked widget and stores object instances so that they can run when selected''' subPanels = xml.findall("./Subpanels/Subpanel") subPanelCount = 1 self.subPanelList = [] # Stores subpanel names self.subPanelClasses = [] # Stores subpanel object instances for subPanel in subPanels: self.subPanelList.append(subPanel.get("Name")) pathName = xml.find("./Subpanels/Subpanel/[@Name='" + subPanel.get("Name") +"']/Path").text className = xml.find("./Subpanels/Subpanel/[@Name='" + subPanel.get("Name") +"']/Class").text packageList = pathName.split('.') packageList.insert(0, 'subpanel') packageString = packageList[0] + '.' + packageList[1] + '.' + packageList[2] module = __import__(packageString) for package in packageList[1:]: # In case the module is buried into a deep package folder, loop until module is reached module = getattr(module, package) module = getattr(module, className) tempSubPanel = module() tempSubPanel.initialize(self.comm, xml, self.ui) self.ui.subPanel.addWidget(tempSubPanel) self.subPanelClasses.append(tempSubPanel) subPanelCount += 1 self.subPanelMapper = QtCore.QSignalMapper(self) self.subPanelMenu = [] for subPanelName in self.subPanelList: subPanel = self.ui.menuView.addAction(subPanelName) self.subPanelMenu.append(subPanel) # Need to store this separately because Python only binds stuff at runtime self.subPanelMapper.setMapping(subPanel, subPanelName) subPanel.triggered.connect(self.subPanelMapper.map) subPanel.setCheckable(True) self.subPanelMapper.mapped[str].connect(self.selectSubPanel)
def __init__(self, qApp): QMainWindow.__init__(self) self._firstwidget = None self._workspace = QWorkspace() self.setCentralWidget(self._workspace) self.setAcceptDrops(True) self.setWindowTitle("Pivy Quarter MDI example") filemenu = self.menuBar().addMenu("&File") windowmenu = self.menuBar().addMenu("&Windows") fileopenaction = QAction("&Create Box", self) fileexitaction = QAction("E&xit", self) tileaction = QAction("Tile", self) cascadeaction = QAction("Cascade", self) filemenu.addAction(fileopenaction) filemenu.addAction(fileexitaction) windowmenu.addAction(tileaction) windowmenu.addAction(cascadeaction) self.connect(fileopenaction, QtCore.SIGNAL("triggered()"), self.createBoxInFreeCAD) self.connect(fileexitaction, QtCore.SIGNAL("triggered()"), QtGui.qApp.closeAllWindows) self.connect(tileaction, QtCore.SIGNAL("triggered()"), self._workspace.tile) self.connect(cascadeaction, QtCore.SIGNAL("triggered()"), self._workspace.cascade) windowmapper = QtCore.QSignalMapper(self) self.connect(windowmapper, QtCore.SIGNAL("mapped(QWidget *)"), self._workspace.setActiveWindow) self.dirname = os.curdir
def getInsertActions(self, classlist): """Create actions to be used in menus/toolbars for inserting class instances. This function needs to be called only once. This also creates the signal mapping from the insert actions. Returns: (mapper, actions) mapper is a QSignalMapper and actions is a list of QAction objects. The triggering of any action in `actions` list causes the `mapper` to emit a mapped(action-name) signal. This can be connected to a slot in the editor's slot for inserting elements. For MooseTreeWidget, this is the insertElement slot (see default.py and mtree.py). """ if len(self._insertActions) == 0: self._insertMapper = QtCore.QSignalMapper(self) for classname in classlist: action = QtGui.QAction(classname, self) self._insertMapper.setMapping(action, QtCore.QString(classname)) self.connect(action, QtCore.SIGNAL('triggered()'), self._insertMapper, QtCore.SLOT('map()')) doc = moose.element('/classes/%s' % (classname)).docs doc = doc.split('Description:')[-1].split('Name:')[0].strip() action.setToolTip(doc) self._insertActions.append(action) return self._insertMapper, self._insertActions
def __init__(self, cfgpath): QtGui.QMainWindow.__init__(self) Ui_MainWindow.__init__(self) self.configpath = cfgpath self.paint = Viewer(self) self.setupUi(self) self.loadButton.clicked.connect(self.loadImage) self.maskClearButton.clicked.connect(self.paint.clearMask) self.brushSizeSB.valueChanged.connect(self.brushSizeChange) btnlist = [ self.horDownBtn, self.horDownLargeBtn, self.horUpBtn, self.horUpLargeBtn, self.vertDownBtn, self.vertDownLargeBtn, self.vertUpBtn, self.vertUpLargeBtn ] sigmap = QtCore.QSignalMapper(self) for i in range(len(btnlist)): self.connect(btnlist[i], QtCore.SIGNAL("clicked()"), sigmap, QtCore.SLOT("map()")) sigmap.setMapping(btnlist[i], i) self.connect(sigmap, QtCore.SIGNAL("mapped(int)"), self.paint.handleScaleBtn) self.alignToImage(self.paint.image.shape) self.brushsize = self.brushSizeSB.value() self.imagepath = ''
def __add_cbox_signal(self, cbox, row): smapper = QtCore.QSignalMapper(self) QtCore.QObject.connect(cbox, QtCore.SIGNAL("stateChanged(int)"), smapper, QtCore.SLOT("map()")) smapper.setMapping(cbox, row) QtCore.QObject.connect(smapper, QtCore.SIGNAL("mapped(int)"), self.__on_criterion_state_changed)
def __init__(self, qApp, freecadGraph): QMainWindow.__init__(self) self._firstwidget = None self._workspace = QWorkspace() self.setCentralWidget(self._workspace) self.setAcceptDrops(True) self.setWindowTitle("Pivy Quarter MDI example") child = self.createMdiChild() child.show() child.setSceneGraph(freecadGraph) windowmapper = QtCore.QSignalMapper(self) self.connect(QtCore.QSignalMapper(self), QtCore.SIGNAL("mapped(QWidget *)"), self._workspace.setActiveWindow)
def __init__(self): super(MainWindow, self).__init__() self.setupUi(self) self.mdiArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.mdiArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.setCentralWidget(self.mdiArea) self.mdiArea.subWindowActivated.connect(self.updateMenus) self.windowMapper = QtCore.QSignalMapper(self) self.windowMapper.mapped[QtGui.QWidget].connect(self.setActiveSubWindow) self.newAct.triggered.connect(self.newFile) self.saveAct.triggered.connect(self.save) self.closeAct.triggered.connect(self.mdiArea.closeActiveSubWindow) self.closeAllAct.triggered.connect(self.mdiArea.closeAllSubWindows) self.tileAct.triggered.connect(self.mdiArea.tileSubWindows) self.cascadeAct.triggered.connect(self.mdiArea.cascadeSubWindows) self.nextAct.triggered.connect(self.mdiArea.activateNextSubWindow) self.previousAct.triggered.connect(self.mdiArea.activatePreviousSubWindow) self.actionEditar_Productos.triggered.connect(self.editarArticulos) self.exitAct.triggered.connect(self.close) self.aboutAct.triggered.connect(self.about) self.printAct.triggered.connect(self.printDocument) self.previewAct.triggered.connect(self.previewDoc) # self.fontAct.triggered.connect(self.fontEdit) self.updateMenus() self.readSettings() self.setWindowTitle("MDI") self.setUnifiedTitleAndToolBarOnMac(True)
def on_view_horizontalHeader_sectionClicked(self, logicalIndex): self.logicalIndex = logicalIndex self.menuValues = QtGui.QMenu(self) self.signalMapper = QtCore.QSignalMapper(self) self.comboBox.blockSignals(True) self.comboBox.setCurrentIndex(self.logicalIndex) self.comboBox.blockSignals(True) valuesUnique = [ self.model.item(row, self.logicalIndex).text() for row in range(self.model.rowCount()) ] actionAll = QtGui.QAction("All", self) actionAll.triggered.connect(self.on_actionAll_triggered) self.menuValues.addAction(actionAll) self.menuValues.addSeparator() for actionNumber, actionName in enumerate( sorted(list(set(valuesUnique)))): action = QtGui.QAction(actionName, self) self.signalMapper.setMapping(action, actionNumber) action.triggered.connect(self.signalMapper.map) self.menuValues.addAction(action) self.signalMapper.mapped.connect(self.on_signalMapper_mapped) headerPos = self.view.mapToGlobal(self.horizontalHeader.pos()) posY = headerPos.y() + self.horizontalHeader.height() posX = headerPos.x() + self.horizontalHeader.sectionPosition( self.logicalIndex) self.menuValues.exec_(QtCore.QPoint(posX, posY))
def __init__(self, reactor, font=None, parent=None): super(running_scans_list, self).__init__(parent) self.reactor = reactor self.parent = parent self.font = font if self.font is None: self.font = QtGui.QFont('MS Shell Dlg 2', pointSize=12) self.setupLayout() self.d = {} self.setSelectionMode(QtGui.QAbstractItemView.NoSelection) self.mapper_pause = QtCore.QSignalMapper() self.mapper_pause.mapped.connect(self.emit_pause) self.mapper_continue = QtCore.QSignalMapper() self.mapper_continue.mapped.connect(self.emit_continue) self.mapper_stop = QtCore.QSignalMapper() self.mapper_stop.mapped.connect(self.on_stop.emit)
def __init__(self): """""" super(dbmanagerUI, self).__init__() self.setupUi(self) self.statusbar.showMessage("Ready") exitAction = QtGui.QAction(QtGui.QIcon('exit.png'), '&Exit', self) exitAction.setShortcut('Ctrl+Q') exitAction.setStatusTip('Exit Masar Configuration Manager.') exitAction.triggered.connect(QtGui.qApp.quit) self.groupdatabasemenubar() #default database source, could be 0: SQLite, 1: MongoDB, and 2: MySQL self.dbsource = None self.defaultdbinfo = self._loadmasarconfig() self.usedefaultdb = True self.comboxboxSignalMapper = QtCore.QSignalMapper(self) self.comboxboxSignalMapper.mapped[QtGui.QWidget].connect( self.comboboxSignalMapperMapped) self.pushbuttonSignalMapper = QtCore.QSignalMapper(self) self.pushbuttonSignalMapper.mapped[QtGui.QWidget].connect( self.pushbuttonSignalMapperMapped) self.showpvbuttonSignalMapper = QtCore.QSignalMapper(self) self.showpvbuttonSignalMapper.mapped[QtGui.QWidget].connect( self.showpvbuttonSignalMapperMapped) self.choosepvbuttonSignalMapper = QtCore.QSignalMapper(self) self.choosepvbuttonSignalMapper.mapped[QtGui.QWidget].connect( self.choosepvbuttonSignalMapperMapped) self.currentselectedrow4config = -1 self.selectedsystem = "Others" # self.pvgrouptreeview = QTreeView() self.pvGroupTreeView.setSelectionBehavior(QAbstractItemView.SelectRows) self.pvgroupmodel = QStandardItemModel() # self.pvgroupmodel.setHorizontalHeaderLabels(['id', 'date', 'version', "description"]) self.pvgroupmodel.setHorizontalHeaderLabels(["PV Groups"]) self.pvGroupTreeView.setModel(self.pvgroupmodel) self.pvGroupTreeView.setUniformRowHeights(True) self.test_in_progress_flag = 0
def __add_combo_signal(self, combo, row): smapper = QtCore.QSignalMapper(self) QtCore.QObject.connect(combo, QtCore.SIGNAL("currentIndexChanged(int)"), smapper, QtCore.SLOT("map()")) smapper.setMapping(combo, row) QtCore.QObject.connect(smapper, QtCore.SIGNAL("mapped(int)"), self.__on_criterion_direction_changed)
def tochannel(self): #QSignalMapper channellist = {'-3':self.redheartChannel,'0':self.privateChannel,'1':self.chineseChannel,'2':self.westernChannel, '3':self.seventyChannel,'4':self.eightyChannel,'5':self.nintyChannel, '6':self.cantoneseChannel,'7':self.rockChannel,'8':self.folkChannel, '9':self.lightmusicChannnel,'10':self.movieChannel,'13':self.jazzChannel, '14':self.elecChannel,'15':self.rapChannel,'16':self.rnbChannel,'17':self.japanChannel, '18':self.koreanChannel,'20':self.womenChannel,"22":self.franceChannel} for num,channel in channellist.items(): text = channel.text() self.sMapper = QtCore.QSignalMapper(self) self.tMapper = QtCore.QSignalMapper(self) self.sMapper.setMapping(channel,num) self.tMapper.setMapping(channel,text) channel.triggered.connect(self.sMapper.map) channel.triggered.connect(self.tMapper.map) self.sMapper.mapped[str].connect(self.changeChannel) self.tMapper.mapped[str].connect(self.currentChannel)
def __inti__(self, parent): super(QVariantDelegate, self).__init__(parent) self.m_finishedMapper = QtCore.QSignalMapper(self) self.connect(self.m_finishedMapper, QtCore.SIGNAL("mapped(QtGui.QWidget*)"), self, QtCore.SIGNAL("commitData(QtGui.QWidget*)")) self.connect(self.m_finishedMapper, QtCore.SIGNAL("mapped(QWidget*)"), self, QtCore.SIGNAL("closeEditor(QWidget*)"))
def __init__(self, Parent): super(TimelineTabs, self).__init__(Parent) self.buttons = [] self._positions = {} self._count = 0 self._mapper = QtCore.QSignalMapper(self) self.connect(self._mapper, QtCore.SIGNAL("mapped(const QString &)"), self._close_tab)
def __init__(self, *args): QtGui.QMainWindow.__init__(self, *args) self.demo = IzhikevichDemo() self.signalMapper = QtCore.QSignalMapper(self) self.demoFrame = QtGui.QFrame(self) self.controlPanel = QtGui.QFrame(self.demoFrame) self.figureNo = {} self.buttons = {} for key, value in list(IzhikevichDemo.parameters.items()): button = QtGui.QPushButton(key, self.controlPanel) self.figureNo[value[0]] = key self.buttons[key] = button keys = list(self.figureNo.keys()) keys.sort() length = len(keys) rows = int(numpy.rint(numpy.sqrt(length))) cols = int(numpy.ceil(length * 1.0 / rows)) layout = QtGui.QGridLayout() for ii in range(rows): for jj in range(cols): index = ii * cols + jj if index < length: key = self.figureNo[keys[index]] button = self.buttons[key] button.setToolTip(self.tr(IzhikevichDemo.documentation[key])) layout.addWidget(button, ii, jj) self.connect(button, QtCore.SIGNAL('clicked()'), self.signalMapper, QtCore.SLOT('map()')) self.signalMapper.setMapping(button, key) self.connect(self.signalMapper, QtCore.SIGNAL('mapped(const QString &)'), self._simulateAndPlot) self.controlPanel.setLayout(layout) self.plotPanel = QtGui.QFrame(self.demoFrame) self.VmPlot = Qwt.QwtPlot(self.plotPanel) self.VmPlot.setAxisTitle(Qwt.QwtPlot.xBottom, 'time (ms)') self.VmPlot.setAxisTitle(Qwt.QwtPlot.yLeft, 'Vm (mV)') self.VmPlot.replot() self.ImPlot = Qwt.QwtPlot(self.plotPanel) self.ImPlot.setAxisTitle(Qwt.QwtPlot.xBottom, 'time (ms)') self.ImPlot.setAxisTitle(Qwt.QwtPlot.yLeft, 'Im (nA)') self.vmPlotZoomer = self._make_zoomer(self.VmPlot) self.imPlotZoomer = self._make_zoomer(self.ImPlot) self.descriptionWidget = QtGui.QLabel('Click any of the buttons to simulate and plot the corresponding neuron.') self.descriptionWidget.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Sunken) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.descriptionWidget.setSizePolicy(sizePolicy) self.VmPlot.setSizePolicy(sizePolicy) self.ImPlot.setSizePolicy(sizePolicy) layout = QtGui.QVBoxLayout() layout.addWidget(self.VmPlot) layout.addWidget(self.ImPlot) layout.addWidget(self.descriptionWidget) self.plotPanel.setLayout(layout) layout = QtGui.QVBoxLayout() layout.addWidget(self.plotPanel) layout.addWidget(self.controlPanel) self.demoFrame.setLayout(layout) self.setCentralWidget(self.demoFrame)
def __init__(self): super(DatasetList, self).__init__() self.setupUi(self) self.check_mapper = QtCore.QSignalMapper() self.selection_widget.setColumnCount(2) self.selection_widget.setRowCount(0) self.selection_widget.setColumnWidth(0, 25) self.selection_widget.setColumnWidth(1, 300) self.connect_layout()
def _init_tab_shortcut(self): self.m = QtCore.QSignalMapper(self) self.shortcuts = [] for i in range(9): s = QtGui.QShortcut(QtGui.QKeySequence("Alt+"+str(i+1)), self.tab_widget) s.connect(s, QtCore.SIGNAL('activated()'), self.m, QtCore.SLOT('map()')) self.m.setMapping(s, i) self.shortcuts.append(s) self.connect(self.m, QtCore.SIGNAL('mapped(int)'), self, QtCore.SLOT('_show_tab(int)'))
def __init__(self, parent=None): #QtGui.QTableWidget.__init__(param) super(tableSet, self).__init__(parent) self.signalMapper = QtCore.QSignalMapper() self.signalMapper.mapped[QtGui.QWidget].connect( self.on_signalMapper_mapped) self.rowSize = 20 self.opSlotSize = 75 self.conditionalOptions = ('=', '>', '<', '>=', '<=', '<>', 'IS NULL', 'IS NOT NULL')
def __connect_slots(self): self.lineEdit.returnPressed.connect(self.__send_message) self.min_btn.clicked.connect(self.showMinimized) self.close_btn.clicked.connect(self.quit) self.send_btn.clicked.connect(self.__send_message) self.mapper = QtCore.QSignalMapper() self.__init_tables(16) self.mapper.mapped.connect(self.__enter_table) self.players_btn.clicked.connect(self.__show_players) self.rank_btn.clicked.connect(self.__show_rank)
def on_headerContext_requested(self, point): """Set up context menu for column filter. Slot for the horizontal header Arguments: point (QPoint): The relative position of the mouse when clicked """ logicalIndex = self.horizontalHeader().logicalIndexAt(point) if logicalIndex < 0: return self.logicalIndex = logicalIndex menu = QtGui.QMenu(self) actionSort = QtGui.QAction("Sort", self) actionSort.triggered.connect(self.on_sort_triggered) menu.addAction(actionSort) menu.addSeparator() # Add new field action actionNewField = QtGui.QAction('New Field', menu) actionNewField.triggered.connect(self.newFieldSig.emit) menu.addAction(actionNewField) # Add the hide field action actionHide = QtGui.QAction('Hide Field(s)', self) actionHide.triggered.connect(self.on_hideField) menu.addAction(actionHide) # Add the unhide menu hiddenFields = [ k.name for k in self.model().dataset.fields if k.hidden ] if hiddenFields: # Initialize signal mapper sm = QtCore.QSignalMapper(self) sm.mapped[QtCore.QString].connect(self.on_unhide) # Create the parent action unhideAction = QtGui.QAction("Unhide", menu) menu.addAction(unhideAction) hmenu = QtGui.QMenu('HiddenFields', self) unhideAction.setMenu(hmenu) # Add the submenu actions for h in hiddenFields: a = QtGui.QAction(h, hmenu) sm.setMapping(a, h) a.triggered.connect(sm.map) hmenu.addAction(a) menu.exec_(self.horizontalHeader().mapToGlobal(point))
def __init__(self, dbConnectionName, parent=None): super(CEQViewer, self).__init__(parent) self._db = QtSql.QSqlDatabase.database(dbConnectionName) try: from PyQt4 import QtNetwork self._notifyTCPServer = QtNetwork.QTcpServer(self) except: self._notifyTCPServer = None if self._notifyTCPServer: self._notifyTCPServer.newConnection.connect( self.onNewNotifyConnection) self._notifiers = {} # словарь QTCPSocket объектов self._notifierReadyReadMapper = QtCore.QSignalMapper() self._notifierReadyReadMapper.mapped.connect(self.onNotifyReadyRead) self._notifierDisconnectedMapper = QtCore.QSignalMapper() self._notifierDisconnectedMapper.mapped.connect( self.onNotifierDisconnected) self._notifyREPattern = re.compile(ur'queueTypeId=(\d+);') self._newNotifierIdx = 0 self._viewedEQTypeModel = CEQViewedTypeModel(self._db, self) self._updateModelsTimerId = None self._updateTimeout = 1.0 self._viewerWindow = None self._rowCount = 1 self._columnCount = 1 self._maxTicketCount = 6 self._notifyPort = 0
def __init__(self): QtGui.QMainWindow.__init__(self) self.mapper = QtCore.QSignalMapper(self) self.toolbar = self.addToolBar('Foo') self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextOnly) for text in 'One Two Three'.split(): action = QtGui.QAction(text, self) self.mapper.setMapping(action, text) action.triggered.connect(self.mapper.map) self.toolbar.addAction(action) self.mapper.mapped['QString'].connect(self.handleButton) self.edit = QtGui.QLineEdit(self) self.setCentralWidget(self.edit)
def on_view_horizontalHeader_sectionClicked(self, logicalIndex): self.logicalIndex = logicalIndex # local variable, and no parent menuValues = QtGui.QMenu() # delete the previous one try: self.signalMapper.deleteLater() except: pass self.signalMapper = QtCore.QSignalMapper(self) self.comboBox.blockSignals(True) self.comboBox.setCurrentIndex(self.logicalIndex) self.comboBox.blockSignals(True) valuesUnique = [ self.proxy.index(row, self.logicalIndex).data().toString() for row in xrange(self.proxy.rowCount()) ] print('printing col %d values' % self.logicalIndex) for row in range(self.proxy.rowCount()): print('row %d Item %s' % (row, self.model.item(row, self.logicalIndex).text())) actionAll = QtGui.QAction("All", self) actionAll.triggered.connect(self.on_actionAll_triggered) menuValues.addAction(actionAll) menuValues.addSeparator() for actionNumber, actionName in enumerate( sorted(list(set(valuesUnique)))): action = QtGui.QAction(actionName, self) self.signalMapper.setMapping(action, actionNumber) action.triggered.connect(self.signalMapper.map) menuValues.addAction(action) self.signalMapper.mapped.connect(self.on_signalMapper_mapped) headerPos = self.view.mapToGlobal(self.horizontalHeader.pos()) posY = headerPos.y() + self.horizontalHeader.height() posX = headerPos.x() + self.horizontalHeader.sectionPosition( self.logicalIndex) menuValues.exec_(QtCore.QPoint(posX, posY))
def addComponents(self): """Add widgets to the main window. The main window contains a databases tree view, a workspace and a console. """ self.setIconSize(QtCore.QSize(22, 22)) self.setWindowIcon(self.icons_dictionary['vitables_wm']) central_widget = QtGui.QWidget(self) central_layout = QtGui.QVBoxLayout(central_widget) self.vsplitter = QtGui.QSplitter(QtCore.Qt.Vertical, central_widget) central_layout.addWidget(self.vsplitter) self.setCentralWidget(central_widget) # Divide the top region of the window into 2 regions and put there # the workspace. The tree of databases will be added later on self.hsplitter = QtGui.QSplitter(self.vsplitter) self.hsplitter.addWidget(self.dbs_tree_view) self.workspace = QtGui.QMdiArea(self.hsplitter) sb_as_needed = QtCore.Qt.ScrollBarAsNeeded self.workspace.setHorizontalScrollBarPolicy(sb_as_needed) self.workspace.setVerticalScrollBarPolicy(sb_as_needed) self.workspace.setWhatsThis( translate( 'VTGUI', """<qt> <h3>The Workspace</h3> This is the area where open leaves of the object tree are displayed. Many tables and arrays can be displayed simultaneously. <p>The diferent views can be tiled as a mosaic or stacked as a cascade. </qt>""", 'WhatsThis help for the workspace')) # Put the logging console in the bottom region of the window self.logger = logger.Logger(self.vsplitter) # add self.logger as handler of main logger object vitables_logger = logging.getLogger('vitables') stream_handler = logging.StreamHandler(self.logger) stream_handler.setFormatter(logging.Formatter(_GUI_LOG_FORMAT)) vitables_logger.addHandler(stream_handler) # The signal mapper used to keep the the Window menu updated self.window_mapper = QtCore.QSignalMapper(self) self.window_mapper.mapped[QtGui.QWidget].connect(\ self.workspace.setActiveSubWindow) self.workspace.installEventFilter(self)
def __init__(self, *args): EditorWidgetBase.__init__(self, *args) self.setAcceptDrops(True) self.border = 10 self.sceneContainer = QtGui.QGraphicsScene(self) self.sceneContainer.setSceneRect(self.sceneContainer.itemsBoundingRect()) self.sceneContainer.setBackgroundBrush(QtGui.QColor(230,220,219,120)) self.insertMenu = QtGui.QMenu('&Insert') self._menus.append(self.insertMenu) self.insertMapper = QtCore.QSignalMapper(self) classlist = ['CubeMesh','CylMesh','Pool','FuncPool','SumFunc','Reac','Enz','MMenz','StimulusTable','Table'] insertMapper, actions = self.getInsertActions(classlist) for action in actions: self.insertMenu.addAction(action)
def _setup_color_stack(self): layout = QtGui.QGridLayout() color_mapper = QtCore.QSignalMapper(self.window()) self.connect(color_mapper, QtCore.SIGNAL("mapped(const QString &)"), self.choose_color) for counter, style in enumerate(styles): button = QtGui.QToolButton() button.setText("Abc") button.setStyleSheet(get_style(style)) button.setProperty('color_id', style) self.connect(button, QtCore.SIGNAL("clicked()"), color_mapper, QtCore.SLOT("map()")) color_mapper.setMapping(button, str(style)) layout.addWidget(button, counter / 6, counter % 6) widget = QtGui.QWidget() widget.setLayout(layout) return widget