本文整理汇总了Python中PyQt4.QtGui.QActionGroup.setExclusive方法的典型用法代码示例。如果您正苦于以下问题:Python QActionGroup.setExclusive方法的具体用法?Python QActionGroup.setExclusive怎么用?Python QActionGroup.setExclusive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QActionGroup
的用法示例。
在下文中一共展示了QActionGroup.setExclusive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt4.QtGui import QActionGroup [as 别名]
# 或者: from PyQt4.QtGui.QActionGroup import setExclusive [as 别名]
def __init__(self, mwHandle):
self.mw = mwHandle
for x in xrange(2, 20):
pin = eval("self.mw.pin%02d" % (x))
menu = QMenu(pin)
modeGroup = QActionGroup(self.mw)
modeGroup.setExclusive(True)
none = menu.addAction("&None")
modeGroup.addAction(none)
none.triggered.connect(self.clickNone)
none.setCheckable(True)
none.setChecked(True)
input = menu.addAction("&Input")
modeGroup.addAction(input)
input.triggered.connect(self.clickInput)
input.setCheckable(True)
output = menu.addAction("&Output")
modeGroup.addAction(output)
output.triggered.connect(self.clickOutput)
output.setCheckable(True)
if self.mw.board.pins[x].PWM_CAPABLE:
pwm = menu.addAction("&PWM")
modeGroup.addAction(pwm)
pwm.triggered.connect(self.clickPWM)
pwm.setCheckable(True)
if self.mw.board.pins[x].type == 2:
analogic = menu.addAction(u"&Analógico")
modeGroup.addAction(analogic)
analogic.triggered.connect(self.clickAnalog)
analogic.setCheckable(True)
pin.setMenu(menu)
pin.setStyleSheet("/* */") # force stylesheet update
示例2: signalConnections
# 需要导入模块: from PyQt4.QtGui import QActionGroup [as 别名]
# 或者: from PyQt4.QtGui.QActionGroup import setExclusive [as 别名]
def signalConnections(self):
#connect signals:
self.ui.actionUndo.triggered.connect(self.unDo)
self.ui.actionRedo.triggered.connect(self.reDo)
self.ui.actionSave_As.triggered.connect(self.saveFileAs)
self.ui.actionSave.triggered.connect(self.saveFile)
self.ui.actionOpen.triggered.connect(self.openFile)
self.ui.actionNew.triggered.connect(self.newFile)
self.ui.actionWhatsThis.triggered.connect(self.whatsThis)
self.ui.actionCheck_HW_2.triggered.connect(self.checkHW)
self.ui.actionUSBHelp.triggered.connect(self.USBHelp)
self.ui.actionArduino_IO.triggered.connect(self.ArduinoIOHelp)
self.ui.actionAbout.triggered.connect(self.AboutHelp)
self.ui.infoButton.clicked.connect(self.parseGrid)
#FOR DEBUG BUTTON
#self.ui.pushButton.clicked.connect(self.showInfo)
#self.ui.pushButton_3.clicked.connect(self.printLadder)
#action group for tool buttons:
self.connect(self.ui.actionContNO, QtCore.SIGNAL("triggered()"),lambda who="contNO": self.anyButton(who))
self.connect(self.ui.actionContNC, QtCore.SIGNAL("triggered()"),lambda who="contNC": self.anyButton(who))
self.connect(self.ui.actionCoil, QtCore.SIGNAL("triggered()"),lambda who="Coil": self.anyButton(who))
#self.connect(self.ui.actionCoilNot, QtCore.SIGNAL("triggered()"),lambda who="CoilNot": self.anyButton(who))
self.connect(self.ui.actionaddRung, QtCore.SIGNAL("triggered()"),lambda who="addRung": self.anyButton(who))
self.connect(self.ui.actionWiden, QtCore.SIGNAL("triggered()"),lambda who="Widen": self.anyButton(who))
#self.connect(self.ui.actionORbranch, QtCore.SIGNAL("triggered()"),lambda who="blankOR": self.anyButton(who))
self.connect(self.ui.actionDEL, QtCore.SIGNAL("triggered()"),lambda who="Del": self.anyButton(who))
self.connect(self.ui.actionORwire, QtCore.SIGNAL("triggered()"),lambda who="ORwire": self.anyButton(who))
self.connect(self.ui.actionNarrow, QtCore.SIGNAL("triggered()"),lambda who="Narrow": self.anyButton(who))
#self.connect(self.ui.actionRising, QtCore.SIGNAL("triggered()"),lambda who="Rising": self.anyButton(who))
self.connect(self.ui.actionFalling, QtCore.SIGNAL("triggered()"),lambda who="Fall": self.anyButton(who))
self.connect(self.ui.actionTimer, QtCore.SIGNAL("triggered()"),lambda who="Timer": self.anyButton(who))
self.connect(self.ui.actionCounter, QtCore.SIGNAL("triggered()"),lambda who="Counter": self.anyButton(who))
#make a actiongroup so tools are exclusive (only one clicked)
toolActionGroup = QActionGroup(self.ui.toolBar)#toolbar is named in _ui.py
toolActionGroup.addAction(self.ui.actionContNO)
toolActionGroup.addAction(self.ui.actionContNC)
toolActionGroup.addAction(self.ui.actionCoil)
#toolActionGroup.addAction(self.ui.actionCoilNot)
toolActionGroup.addAction(self.ui.actionaddRung)
toolActionGroup.addAction(self.ui.actionWiden)
#toolActionGroup.addAction(self.ui.actionORbranch)
toolActionGroup.addAction(self.ui.actionDEL)
toolActionGroup.addAction(self.ui.actionORwire)
toolActionGroup.addAction(self.ui.actionNarrow)
#toolActionGroup.addAction(self.ui.actionRising)
toolActionGroup.addAction(self.ui.actionFalling)
toolActionGroup.addAction(self.ui.actionTimer)
toolActionGroup.addAction(self.ui.actionCounter)
toolActionGroup.setExclusive(True)
self.connect(self.ui.actionWaltech, QtCore.SIGNAL("triggered()"),lambda HW="Waltech": self.chooseHW(HW))
self.connect(self.ui.actionArduino, QtCore.SIGNAL("triggered()"),lambda HW="Arduino": self.chooseHW(HW))
hwActionGroup = QActionGroup(self.ui.menuDiagnostics)
hwActionGroup.addAction(self.ui.actionWaltech)
hwActionGroup.addAction(self.ui.actionArduino)
示例3: create_menu
# 需要导入模块: from PyQt4.QtGui import QActionGroup [as 别名]
# 或者: from PyQt4.QtGui.QActionGroup import setExclusive [as 别名]
def create_menu(self, menu_name, menu_actions):
""" Creates a menu. Groups them so you can only select one at a time. """
menu_action_group = QActionGroup(self)
menu_action_group.setExclusive(True)
menubar = self.menuBar()
menu = menubar.addMenu(menu_name)
for action in menu_actions:
menu_action_group.addAction(action)
menu.addAction(action)
示例4: add_stations
# 需要导入模块: from PyQt4.QtGui import QActionGroup [as 别名]
# 或者: from PyQt4.QtGui.QActionGroup import setExclusive [as 别名]
def add_stations(self):
self.stations = {}
group = QActionGroup(self)
group.setExclusive(True)
for name in sorted(self.parent.stations.map.keys()):
url = self.parent.stations.map[name]
self.stations[name] = QAction(str(name), self)
self.stations[name].setCheckable(True)
self.stations[name].setActionGroup(group)
self.stations[name].triggered.connect(
lambda _=0, st=(name, url):
self.parent.station_changed.emit(st))
self.stations_menu.addAction(self.stations[name])
示例5: create_action_group
# 需要导入模块: from PyQt4.QtGui import QActionGroup [as 别名]
# 或者: from PyQt4.QtGui.QActionGroup import setExclusive [as 别名]
def create_action_group(parent, actions=[], enabled=True, exclusive=True, visible=True, hovered_slot=None, triggered_slot=None):
action_group = QActionGroup(parent)
for action in actions:
action_group.addAction(action)
action_group.setEnabled(enabled)
action_group.setExclusive(exclusive)
action_group.setVisible(visible)
if hovered_slot:
action_group.connect(action, SIGNAL('hovered(QAction)'), hovered_slot)
if triggered_slot:
action_group.connect(action, SIGNAL('triggered(QAction)'), triggered_slot)
return action_group
示例6: ToolBox
# 需要导入模块: from PyQt4.QtGui import QActionGroup [as 别名]
# 或者: from PyQt4.QtGui.QActionGroup import setExclusive [as 别名]
class ToolBox(QFrame):
"""
A tool box widget.
"""
# Emitted when a tab is toggled.
tabToogled = Signal(int, bool)
def setExclusive(self, exclusive):
"""
Set exclusive tabs (only one tab can be open at a time).
"""
if self.__exclusive != exclusive:
self.__exclusive = exclusive
self.__tabActionGroup.setExclusive(exclusive)
checked = self.__tabActionGroup.checkedAction()
if checked is None:
# The action group can be out of sync with the actions state
# when switching between exclusive states.
actions_checked = [page.action for page in self.__pages
if page.action.isChecked()]
if actions_checked:
checked = actions_checked[0]
# Trigger/toggle remaining open pages
if exclusive and checked is not None:
for page in self.__pages:
if checked != page.action and page.action.isChecked():
page.action.trigger()
def exclusive(self):
"""
Are the tabs in the toolbox exclusive.
"""
return self.__exclusive
exclusive_ = Property(bool,
fget=exclusive,
fset=setExclusive,
designable=True,
doc="Exclusive tabs")
def __init__(self, parent=None, **kwargs):
QFrame.__init__(self, parent, **kwargs)
self.__pages = []
self.__tabButtonHeight = -1
self.__tabIconSize = QSize()
self.__exclusive = False
self.__setupUi()
def __setupUi(self):
layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
# Scroll area for the contents.
self.__scrollArea = \
_ToolBoxScrollArea(self, objectName="toolbox-scroll-area")
self.__scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.__scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.__scrollArea.setSizePolicy(QSizePolicy.MinimumExpanding,
QSizePolicy.MinimumExpanding)
self.__scrollArea.setFrameStyle(QScrollArea.NoFrame)
self.__scrollArea.setWidgetResizable(True)
# A widget with all of the contents.
# The tabs/contents are placed in the layout inside this widget
self.__contents = QWidget(self.__scrollArea,
objectName="toolbox-contents")
# The layout where all the tab/pages are placed
self.__contentsLayout = QVBoxLayout()
self.__contentsLayout.setContentsMargins(0, 0, 0, 0)
self.__contentsLayout.setSizeConstraint(QVBoxLayout.SetMinAndMaxSize)
self.__contentsLayout.setSpacing(0)
self.__contents.setLayout(self.__contentsLayout)
self.__scrollArea.setWidget(self.__contents)
layout.addWidget(self.__scrollArea)
self.setLayout(layout)
self.setSizePolicy(QSizePolicy.Fixed,
QSizePolicy.MinimumExpanding)
self.__tabActionGroup = \
QActionGroup(self, objectName="toolbox-tab-action-group")
self.__tabActionGroup.setExclusive(self.__exclusive)
self.__actionMapper = QSignalMapper(self)
self.__actionMapper.mapped[QObject].connect(self.__onTabActionToogled)
def setTabButtonHeight(self, height):
"""
Set the tab button height.
"""
if self.__tabButtonHeight != height:
self.__tabButtonHeight = height
#.........这里部分代码省略.........
示例7: FreeseerApp
# 需要导入模块: from PyQt4.QtGui import QActionGroup [as 别名]
# 或者: from PyQt4.QtGui.QActionGroup import setExclusive [as 别名]
class FreeseerApp(QMainWindowWithDpi):
def __init__(self, config):
super(FreeseerApp, self).__init__()
self.config = config
self.icon = QIcon()
self.icon.addPixmap(QPixmap(_fromUtf8(":/freeseer/logo.png")), QIcon.Normal, QIcon.Off)
self.setWindowIcon(self.icon)
self.aboutDialog = AboutDialog()
self.aboutDialog.setModal(True)
self.logDialog = LogDialog()
#
# Translator
#
self.app = QApplication.instance()
self.current_language = None
self.uiTranslator = QTranslator()
self.uiTranslator.load(":/languages/tr_en_US.qm")
self.app.installTranslator(self.uiTranslator)
self.langActionGroup = QActionGroup(self)
self.langActionGroup.setExclusive(True)
QTextCodec.setCodecForTr(QTextCodec.codecForName('utf-8'))
self.connect(self.langActionGroup, SIGNAL('triggered(QAction *)'), self.translate)
# --- Translator
#
# Setup Menubar
#
self.menubar = self.menuBar()
self.menubar.setGeometry(self.qrect_with_dpi(0, 0, 500, 50))
self.menubar.setObjectName(_fromUtf8("menubar"))
self.menuFile = QMenu(self.menubar)
self.menuFile.setObjectName(_fromUtf8("menuFile"))
self.menuLanguage = QMenu(self.menubar)
self.menuLanguage.setObjectName(_fromUtf8("menuLanguage"))
self.menuHelp = QMenu(self.menubar)
self.menuHelp.setObjectName(_fromUtf8("menuHelp"))
exitIcon = QIcon.fromTheme("application-exit")
self.actionExit = QAction(self)
self.actionExit.setShortcut("Ctrl+Q")
self.actionExit.setObjectName(_fromUtf8("actionExit"))
self.actionExit.setIcon(exitIcon)
helpIcon = QIcon.fromTheme("help-contents")
self.actionOnlineHelp = QAction(self)
self.actionOnlineHelp.setObjectName(_fromUtf8("actionOnlineHelp"))
self.actionOnlineHelp.setIcon(helpIcon)
self.actionAbout = QAction(self)
self.actionAbout.setObjectName(_fromUtf8("actionAbout"))
self.actionAbout.setIcon(self.icon)
self.actionLog = QAction(self)
self.actionLog.setObjectName(_fromUtf8("actionLog"))
self.actionLog.setShortcut("Ctrl+L")
# Actions
self.menuFile.addAction(self.actionExit)
self.menuHelp.addAction(self.actionAbout)
self.menuHelp.addAction(self.actionLog)
self.menuHelp.addAction(self.actionOnlineHelp)
self.menubar.addAction(self.menuFile.menuAction())
self.menubar.addAction(self.menuLanguage.menuAction())
self.menubar.addAction(self.menuHelp.menuAction())
self.setupLanguageMenu()
# --- End Menubar
self.connect(self.actionExit, SIGNAL('triggered()'), self.close)
self.connect(self.actionAbout, SIGNAL('triggered()'), self.aboutDialog.show)
self.connect(self.actionLog, SIGNAL('triggered()'), self.logDialog.show)
self.connect(self.actionOnlineHelp, SIGNAL('triggered()'), self.openOnlineHelp)
self.retranslateFreeseerApp()
self.aboutDialog.aboutWidget.retranslate("en_US")
def openOnlineHelp(self):
"""Opens a link to the Freeseer Online Help"""
url = QUrl("http://freeseer.readthedocs.org")
QDesktopServices.openUrl(url)
def translate(self, action):
"""Translates the GUI via menu action.
When a language is selected from the language menu, this function is
called and the language to be changed to is retrieved.
"""
self.current_language = str(action.data().toString()).strip("tr_").rstrip(".qm")
log.info("Switching language to: %s" % action.text())
self.uiTranslator.load(":/languages/tr_%s.qm" % self.current_language)
self.app.installTranslator(self.uiTranslator)
self.retranslateFreeseerApp()
self.aboutDialog.aboutWidget.retranslate(self.current_language)
#.........这里部分代码省略.........
示例8: Tool
# 需要导入模块: from PyQt4.QtGui import QActionGroup [as 别名]
# 或者: from PyQt4.QtGui.QActionGroup import setExclusive [as 别名]
#.........这里部分代码省略.........
action_explorer = QAction("Explorer",self)
action_explorer.triggered.connect(self.parent.exp)
action_explorer.setCheckable(True)
action_explorer.setChecked(True)
action_console = QAction("Console",self)
action_console.triggered.connect(self.parent.cmd)
action_console.setCheckable(True)
action_console.setChecked(False)
#action_designer = QAction("Designer",self)
#action_designer.triggered.connect(self.parent.design)
action_Indentation = QAction("Indentation Guides",self)
action_Indentation.triggered.connect(self.parent.setIndent)
action_Indentation.setCheckable(True)
action_Indentation.setChecked(config.indent())
action_WhiteSpace = QAction("WhiteSpace",self)
action_WhiteSpace.triggered.connect(self.parent.setWhiteSpace)
action_WhiteSpace.setCheckable(True)
action_WhiteSpace.setChecked(config.whiteSpace())
action_EndLine = QAction("End of Lines",self)
action_EndLine.triggered.connect(self.parent.setEndLine)
action_EndLine.setCheckable(True)
action_Margin = QAction("Line Numbers",self)
action_Margin.triggered.connect(self.parent.setMargin)
action_Margin.setCheckable(True)
action_Margin.setChecked(config.margin())
action_ToolLabel = QAction("Tool Labels",self)
action_ToolLabel.triggered.connect(self.setToolLabel)
action_ToolLabel.setCheckable(True)
#action_ToolLabel.setChecked(config.toolLabel())
'''Encoding'''
encodingGroup = QActionGroup(self)
encodingGroup.setExclusive(True)
action_Ascii = QAction("Ascii",encodingGroup)
action_Ascii.setCheckable(True)
action_Unicode = QAction("Unicode",encodingGroup)
action_Unicode.setCheckable(False)
encodingGroup.addAction(action_Ascii)
encodingGroup.addAction(action_Unicode)
encodingGroup.selected.connect(self.parent.setEncoding)
if(config.encoding() == Encoding.ASCII):
action_Ascii.setChecked(True)
else:
action_Unicode.setChecked(True)
men.addAction(action_Update)
men.addAction(self.action_Help)
men.addAction(self.action_Full)
men.addSeparator()
men.addAction(action_Android)
men.addAction(action_Ant)
men.addAction(action_Squirrel)
men.addAction(action_Ios1)
men.addSeparator()
men.addAction(action_explorer)
men.addAction(action_console)
#men.addAction(action_designer)
men.addSeparator()
men.addAction(action_Indentation)
men.addAction(action_WhiteSpace)
men.addAction(action_EndLine)
men.addAction(action_Margin)
men.addAction(action_ToolLabel)
men.addSeparator()
men.addActions(encodingGroup.actions())
示例9: MainWindow
# 需要导入模块: from PyQt4.QtGui import QActionGroup [as 别名]
# 或者: from PyQt4.QtGui.QActionGroup import setExclusive [as 别名]
class MainWindow(ui_mainwindow.Ui_MainWindow, QMainWindow):
"""
Main application window
"""
def __init__(self):
super(MainWindow, self).__init__()
self.setupUi(self)
self.menutoolbar.setStyleSheet(roam.roam_style.menubarstyle)
self.project = None
self.tracking = GPSLogging(GPS)
self.canvas_page.set_gps(GPS, self.tracking)
self.canvas = self.canvas_page.canvas
roam.defaults.canvas = self.canvas
self.bar = roam.messagebaritems.MessageBar(self.centralwidget)
self.actionMap.setVisible(False)
self.actionLegend.setVisible(False)
self.menuGroup = QActionGroup(self)
self.menuGroup.setExclusive(True)
self.menuGroup.addAction(self.actionMap)
self.menuGroup.addAction(self.actionDataEntry)
self.menuGroup.addAction(self.actionLegend)
self.menuGroup.addAction(self.actionProject)
self.menuGroup.addAction(self.actionImport)
self.menuGroup.addAction(self.actionSync)
self.menuGroup.addAction(self.actionSettings)
self.menuGroup.addAction(self.actionGPS)
self.menuGroup.triggered.connect(self.updatePage)
self.projectbuttons = []
self.pluginactions = []
self.actionQuit.triggered.connect(self.exit)
self.actionHelp.triggered.connect(self.showhelp2)
self.actionLegend.triggered.connect(self.updatelegend)
self.projectwidget.requestOpenProject.connect(self.loadProject)
QgsProject.instance().readProject.connect(self._readProject)
self.gpswidget.setgps(GPS)
self.gpswidget.settracking(self.tracking)
self.actionSettings.toggled.connect(self.settingswidget.populateControls)
self.actionSettings.toggled.connect(self.settingswidget.readSettings)
self.settingswidget.settingsupdated.connect(self.settingsupdated)
self.dataentrywidget = DataEntryWidget(self.canvas, self.bar)
self.dataentrywidget.lastwidgetremoved.connect(self.dataentryfinished)
self.widgetpage.layout().addWidget(self.dataentrywidget)
self.dataentrywidget.rejected.connect(self.formrejected)
RoamEvents.featuresaved.connect(self.featureSaved)
RoamEvents.helprequest.connect(self.showhelp)
self.actionProject.triggered.connect(self.closeAnnotation)
self.pHelp=os.getcwd()
help_p = "help\IntraMaps Roam - Help.pdf"
self.pathHelp=os.path.join(self.pHelp,help_p)
def createSpacer(width=0, height=0):
widget = QWidget()
widget.setMinimumWidth(width)
widget.setMinimumHeight(height)
return widget
gpsspacewidget = createSpacer(30)
sidespacewidget = createSpacer(30)
sidespacewidget2 = createSpacer(height=20)
sidespacewidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sidespacewidget2.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
def createlabel(text):
style = """
QLabel {
color: #706565;
font: 14px "Calibri" ;
}"""
label = QLabel(text)
label.setStyleSheet(style)
return label
self.projectlabel = createlabel("Project: {project}")
self.userlabel = createlabel("User: {user}".format(user=getpass.getuser()))
self.positionlabel = createlabel('')
self.gpslabel = createlabel("GPS: Not active")
self.statusbar.addWidget(self.projectlabel)
self.statusbar.addWidget(self.userlabel)
spacer = createSpacer()
spacer2 = createSpacer()
#.........这里部分代码省略.........
示例10: MainWindow
# 需要导入模块: from PyQt4.QtGui import QActionGroup [as 别名]
# 或者: from PyQt4.QtGui.QActionGroup import setExclusive [as 别名]
class MainWindow(ui_mainwindow.Ui_MainWindow, QMainWindow):
"""
Main application window
"""
def __init__(self):
super(MainWindow, self).__init__()
self.setupUi(self)
self.canvaslayers = []
self.layerbuttons = []
self.project = None
self.selectionbands = defaultdict(partial(QgsRubberBand, self.canvas))
self.canvas.setCanvasColor(Qt.white)
self.canvas.enableAntiAliasing(True)
self.canvas.setWheelAction(QgsMapCanvas.WheelZoomToMouseCursor)
self.bar = roam.messagebaritems.MessageBar(self.centralwidget)
self.actionMap.setVisible(False)
self.actionLegend.setVisible(False)
pal = QgsPalLabeling()
self.canvas.mapRenderer().setLabelingEngine(pal)
self.canvas.setFrameStyle(QFrame.NoFrame)
self.menuGroup = QActionGroup(self)
self.menuGroup.setExclusive(True)
self.menuGroup.addAction(self.actionMap)
self.menuGroup.addAction(self.actionDataEntry)
self.menuGroup.addAction(self.actionLegend)
self.menuGroup.addAction(self.actionProject)
self.menuGroup.addAction(self.actionSync)
self.menuGroup.addAction(self.actionSettings)
self.menuGroup.addAction(self.actionGPS)
self.menuGroup.triggered.connect(self.updatePage)
self.editgroup = QActionGroup(self)
self.editgroup.setExclusive(True)
self.editgroup.addAction(self.actionPan)
self.editgroup.addAction(self.actionZoom_In)
self.editgroup.addAction(self.actionZoom_Out)
self.editgroup.addAction(self.actionInfo)
self.actionLegend.triggered.connect(self.updatelegend)
self.actionGPS = GPSAction(":/icons/gps", self.canvas, self)
self.projecttoolbar.addAction(self.actionGPS)
self.projectwidget.requestOpenProject.connect(self.loadProject)
QgsProject.instance().readProject.connect(self._readProject)
self.gpswidget.setgps(GPS)
self.actionSettings.toggled.connect(self.settingswidget.populateControls)
self.actionSettings.toggled.connect(self.settingswidget.readSettings)
self.settingswidget.settingsupdated.connect(self.settingsupdated)
self.dataentrywidget = DataEntryWidget(self.canvas, self.bar)
self.widgetpage.layout().addWidget(self.dataentrywidget)
self.dataentrywidget.rejected.connect(self.formrejected)
self.dataentrywidget.featuresaved.connect(self.featureSaved)
self.dataentrywidget.featuredeleted.connect(self.featuredeleted)
self.dataentrywidget.failedsave.connect(self.failSave)
self.dataentrywidget.helprequest.connect(self.showhelp)
def createSpacer(width=0, height=0):
widget = QWidget()
widget.setMinimumWidth(width)
widget.setMinimumHeight(height)
return widget
gpsspacewidget = createSpacer(30)
sidespacewidget = createSpacer(30)
sidespacewidget2 = createSpacer(height=20)
sidespacewidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sidespacewidget2.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
gpsspacewidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.topspaceraction = self.projecttoolbar.insertWidget(self.actionGPS, gpsspacewidget)
def createlabel(text):
style = """
QLabel {
color: #706565;
font: 14px "Calibri" ;
}"""
label = QLabel(text)
label.setStyleSheet(style)
return label
self.projectlabel = createlabel("Project: {project}")
self.userlabel = createlabel("User: {user}".format(user=getpass.getuser()))
self.positionlabel = createlabel('')
self.gpslabel = createlabel("GPS: Not active")
self.statusbar.addWidget(self.projectlabel)
self.statusbar.addWidget(self.userlabel)
spacer = createSpacer()
spacer2 = createSpacer()
#.........这里部分代码省略.........
示例11: __init__
# 需要导入模块: from PyQt4.QtGui import QActionGroup [as 别名]
# 或者: from PyQt4.QtGui.QActionGroup import setExclusive [as 别名]
def __init__(self, parent):
SMPluginWidget.__init__(self, parent)
self.internal_shell = None
# Initialize plugin
self.initialize_plugin()
self.no_doc_string = _("No documentation available")
self._last_console_cb = None
self._last_editor_cb = None
self.set_default_color_scheme()
self.plain_text = PlainText(self)
self.rich_text = RichText(self)
color_scheme = get_color_scheme(self.get_option("color_scheme_name"))
self.set_plain_text_font(self.get_plugin_font(), color_scheme)
self.plain_text.editor.toggle_wrap_mode(self.get_option("wrap"))
# Add entries to read-only editor context-menu
font_action = create_action(
self, _("&Font..."), None, "font.png", _("Set font style"), triggered=self.change_font
)
self.wrap_action = create_action(self, _("Wrap lines"), toggled=self.toggle_wrap_mode)
self.wrap_action.setChecked(self.get_option("wrap"))
self.plain_text.editor.readonly_menu.addSeparator()
add_actions(self.plain_text.editor.readonly_menu, (font_action, self.wrap_action))
self.set_rich_text_font(self.get_plugin_font("rich_text"))
self.shell = None
self.external_console = None
# locked = disable link with Console
self.locked = False
self._last_texts = [None, None]
self._last_rope_data = None
# Object name
layout_edit = QHBoxLayout()
layout_edit.setContentsMargins(0, 0, 0, 0)
txt = _("Source")
if sys.platform == "darwin":
source_label = QLabel(" " + txt)
else:
source_label = QLabel(txt)
layout_edit.addWidget(source_label)
self.source_combo = QComboBox(self)
self.source_combo.addItems([_("Console"), _("Editor")])
self.connect(self.source_combo, SIGNAL("currentIndexChanged(int)"), self.source_changed)
if not programs.is_module_installed("rope"):
self.source_combo.hide()
source_label.hide()
layout_edit.addWidget(self.source_combo)
layout_edit.addSpacing(10)
layout_edit.addWidget(QLabel(_("Object")))
self.combo = ObjectComboBox(self)
layout_edit.addWidget(self.combo)
self.object_edit = QLineEdit(self)
self.object_edit.setReadOnly(True)
layout_edit.addWidget(self.object_edit)
self.combo.setMaxCount(self.get_option("max_history_entries"))
self.combo.addItems(self.load_history())
self.connect(self.combo, SIGNAL("valid(bool)"), lambda valid: self.force_refresh())
# Plain text docstring option
self.docstring = True
self.rich_help = sphinxify is not None and self.get_option("rich_mode", True)
self.plain_text_action = create_action(self, _("Plain Text"), toggled=self.toggle_plain_text)
# Source code option
self.show_source_action = create_action(self, _("Show Source"), toggled=self.toggle_show_source)
# Rich text option
self.rich_text_action = create_action(self, _("Rich Text"), toggled=self.toggle_rich_text)
# Add the help actions to an exclusive QActionGroup
help_actions = QActionGroup(self)
help_actions.setExclusive(True)
help_actions.addAction(self.plain_text_action)
help_actions.addAction(self.rich_text_action)
# Automatic import option
self.auto_import_action = create_action(self, _("Automatic import"), toggled=self.toggle_auto_import)
auto_import_state = self.get_option("automatic_import")
self.auto_import_action.setChecked(auto_import_state)
# Lock checkbox
self.locked_button = create_toolbutton(self, triggered=self.toggle_locked)
layout_edit.addWidget(self.locked_button)
self._update_lock_icon()
# Option menu
options_button = create_toolbutton(self, text=_("Options"), icon=get_icon("tooloptions.png"))
options_button.setPopupMode(QToolButton.InstantPopup)
menu = QMenu(self)
#.........这里部分代码省略.........
示例12: __init__
# 需要导入模块: from PyQt4.QtGui import QActionGroup [as 别名]
# 或者: from PyQt4.QtGui.QActionGroup import setExclusive [as 别名]
#.........这里部分代码省略.........
self.fontSizeComboMenu = QWidgetAction(men)
self.fontSizeComboMenu.setDefaultWidget(self.fontSizeCombo)
action_explorer = QAction("Show Explorer",self)
action_explorer.triggered.connect(self.parent.exp)
action_console = QAction("Show Console",self)
action_console.triggered.connect(self.parent.cmd)
action_designer = QAction("Show Designer",self)
action_designer.triggered.connect(self.parent.design)
action_Indentation = QAction("Indentation Guides",self)
action_Indentation.triggered.connect(self.parent.setIndent)
action_WhiteSpace = QAction("Show WhiteSpace",self)
action_WhiteSpace.triggered.connect(self.parent.setWhiteSpace)
action_EndLine = QAction("Show End of Lines",self)
action_EndLine.triggered.connect(self.parent.setEndLine)
action_Margin = QAction("Line Numbers",self)
action_Margin.triggered.connect(self.parent.setMargin)
action_ToolLabel = QAction("Tool Labels",self)
action_ToolLabel.triggered.connect(self.setToolLabel)
action_Android = QAction(Icons.android,'Android', self)
action_Android.triggered.connect(self.parent.android)
action_Ant = QAction(Icons.ant_view,'Ant', self)
action_Ant.triggered.connect(self.parent.antt)
action_Squirrel = QAction(Icons.nut,'Squirrel', self)
action_Squirrel.triggered.connect(self.parent.squirrel)
action_Ios1 = QAction(Icons.ios,'iOS', self)
action_Update = QAction("Update",self)
action_Update.triggered.connect(self.parent.update)
'''Encoding'''
encodingGroup = QActionGroup(self)
encodingGroup.setExclusive(True)
action_Ascii = QAction("Ascii",encodingGroup)
action_Ascii.setCheckable(True)
action_Unicode = QAction("Unicode",encodingGroup)
action_Unicode.setCheckable(True)
encodingGroup.addAction(action_Ascii)
encodingGroup.addAction(action_Unicode)
encodingGroup.selected.connect(self.parent.setEncoding)
if(config.encoding() == Encoding.ASCII):
action_Ascii.setChecked(True)
else:
action_Unicode.setChecked(True)
men.addAction(action_Android)
men.addAction(action_Ant)
men.addAction(action_Squirrel)
men.addAction(action_Ios1)
men.addAction(action_Update)
men.addSeparator()
men.addAction(action_explorer)
men.addAction(action_console)
men.addAction(action_designer)
men.addAction(action_Indentation)
men.addAction(action_WhiteSpace)
men.addAction(action_EndLine)
men.addAction(action_Margin)
men.addAction(action_ToolLabel)
men.addSeparator()
men.addActions(encodingGroup.actions())
men.addSeparator()
head_font = QLabel("Font---------------------")
fnt = head_font.font()
fnt.setBold(True)
head_font.setFont(fnt)
示例13: MainWindow
# 需要导入模块: from PyQt4.QtGui import QActionGroup [as 别名]
# 或者: from PyQt4.QtGui.QActionGroup import setExclusive [as 别名]
#.........这里部分代码省略.........
else:
# If there's no tabs, offer to display the pluginlist
menu.addAction(self.actionShowPluginList)
menu.exec_(self.mainTabs.mapToGlobal(pos))
def __createPluginToolBar(self):
"""Creates the pluign toolbar.
"""
self.pluginToolBar = PluginToolBar(self)
self.pluginToolBar.setWindowTitle(QApplication.translate(
'MainWindow', 'Plugintoolbar', None, QApplication.UnicodeUTF8))
self.pluginToolBar.setObjectName('pluginToolBar')
self.addToolBar(self.pluginToolBar)
self.pluginToolBar.hide()
def __createLoggerWidget(self):
"""Creates the logger widget.
"""
self.loggerDockWindow = QDockWidget(self)
self.loggerDockWindow.setObjectName('loggerDockWindow')
self.loggerDockWindow.visibilityChanged[bool].connect(
self.actionShowLogger.setChecked)
self.loggerDockWindow.setWindowTitle(QApplication.translate(
'MainWindow', 'Logger', None, QApplication.UnicodeUTF8))
self.loggerWidget = LoggerWidget(self.loggerDockWindow)
self.loggerDockWindow.setWidget(self.loggerWidget)
self.addDockWidget(Qt.BottomDockWidgetArea, self.loggerDockWindow)
self.loggerDockWindow.hide()
def __createLanguageOptions(self):
"""Creates the language selection in the menubar.
"""
self.langGroup = QActionGroup(self)
self.langGroup.setExclusive(True)
self.langGroup.triggered['QAction*'].connect(self.languageChanged)
for key, name in self.languages.iteritems():
action = QAction(self)
action.setCheckable(True)
action.setData(key)
action.setText(name[0])
action.setStatusTip(name[1])
action.setActionGroup(self.langGroup)
self.menuLanguage.addAction(action)
if key == self.currentLanguage:
action.setChecked(True)
def __loadSettings(self, mainWin=True):
"""Loads settings from file.
:param mainWin: If set to ``False``, neither the values for the
window size or the window position will be loaded. This is
i.e done when the settings dialog returns 1.
:type mainWin: bool
"""
settings = Settings()
# We might want to use these methods to restore the
# application state and geometry.
if mainWin:
self.restoreGeometry(settings.geometry)
#self.restoreState(settings.state)
# If the geometry saved inticates fullscreen mode,
# we need to explicitly set the fullscreen menuaction checkbox
if self.isFullScreen():
self.actionFullscreen.setChecked(True)
示例14: __init__
# 需要导入模块: from PyQt4.QtGui import QActionGroup [as 别名]
# 或者: from PyQt4.QtGui.QActionGroup import setExclusive [as 别名]
def __init__(self, parent=None, paths=None):
QDialog.__init__(self, parent)
QShortcut(QKeySequence("Escape"), self, self.reject)
self.setWindowTitle("editR - Help Browser")
self.resize(500, 500)
self._paths = paths
self._port = robjects.r('tools:::httpdPort')[0]
if not self._port > 0:
robjects.r('tools::startDynamicHelp()')
self._port = robjects.r('tools:::httpdPort')[0]
self._host = "localhost"
self._help = True # by default we don't search, we call help
self.tabs = QTabWidget(self)
self.tabs.setDocumentMode(True)
self.tabs.setTabsClosable(True)
self.help_open("/doc/html/Search.html")
home_button = QToolButton(self)
home_action = QAction("&Home", self)
home_action.setToolTip("Return to start page")
home_action.setWhatsThis("Return to start page")
home_action.setIcon(QIcon(":go-home"))
home_button.setDefaultAction(home_action)
home_button.setAutoRaise(True)
backward_button = QToolButton(self)
backward_action = QAction("&Back", self)
backward_action.setToolTip("Move to previous page")
backward_action.setWhatsThis("Move to previous page")
backward_action.setIcon(QIcon(":go-previous"))
backward_button.setDefaultAction(backward_action)
backward_button.setAutoRaise(True)
forward_button = QToolButton(self)
forward_action = QAction("&Forward", self)
forward_action.setToolTip("Move to next page")
forward_action.setWhatsThis("Move to next page")
forward_action.setIcon(QIcon(":go-next"))
forward_button.setDefaultAction(forward_action)
forward_button.setAutoRaise(True)
self.search_edit = QLineEdit(self)
self.search_edit.setStyleSheet(_fromUtf8(
"QLineEdit{"
"padding-right: 16px;"
"padding-left: 5px;"
"background: url(:edit-find-small.png);"
"background-position: right;"
"background-repeat: no-repeat;"
"border: 1px solid grey;"
"border-radius: 6.5px;}"))
self.setFocusProxy(self.search_edit)
self.search_edit.setFocus(True)
self.options_tool = QToolButton(self)
self.options_tool.setAutoRaise(True)
self.options_tool.setIcon(QIcon(":preferences-system.svg"))
self.options_tool.setPopupMode(QToolButton.InstantPopup)
# create popup menu
menu = QMenu("Help options")
group = QActionGroup(menu)
help_action = QAction(QIcon(":help-contents.svg"), "Help", menu)
help_action.setCheckable(True)
help_action.setChecked(True)
search_action = QAction(QIcon(":edit-find.svg"), "Search", menu)
search_action.setCheckable(True)
group.addAction(help_action)
group.addAction(search_action)
group.setExclusive(True)
menu.addAction(help_action)
menu.addAction(search_action)
menu.addSeparator()
options = ["Titles","Keywords","Object names","Concepts","Exact match"]
for i in range(len(options)):
action = QAction(options[i], menu)
action.setCheckable(True)
action.setChecked(i<3)
menu.addAction(action)
self.options_tool.setMenu(menu)
# create connections
home_action.triggered.connect(self.home)
forward_action.triggered.connect(self.forward)
backward_action.triggered.connect(self.backward)
self.search_edit.returnPressed.connect(self.enter_pressed)
self.tabs.tabCloseRequested.connect(self.help_close)
hbox = QHBoxLayout()
# hbox.addStretch()
hbox.addWidget(backward_button)
hbox.addWidget(home_button)
hbox.addWidget(forward_button)
# hbox.addStretch()
hbox.addWidget(self.search_edit)
hbox.addWidget(self.options_tool)
vbox = QVBoxLayout(self)
vbox.addLayout(hbox)
#.........这里部分代码省略.........
示例15: MainWindow
# 需要导入模块: from PyQt4.QtGui import QActionGroup [as 别名]
# 或者: from PyQt4.QtGui.QActionGroup import setExclusive [as 别名]
class MainWindow(QMainWindow, Ui_MainWindow):
"""docstring for MainWindow."""
def __init__(self, parent=None):
super(MainWindow, self).__init__()
self._csvFilePath = ""
self.serialport = serial.Serial()
self.receiver_thread = readerThread(self)
self.receiver_thread.setPort(self.serialport)
self._localEcho = None
self.setupUi(self)
self.setCorner(Qt.TopLeftCorner, Qt.LeftDockWidgetArea)
self.setCorner(Qt.BottomLeftCorner, Qt.LeftDockWidgetArea)
font = QtGui.QFont()
font.setFamily(EDITOR_FONT)
font.setPointSize(10)
self.txtEdtOutput.setFont(font)
self.txtEdtInput.setFont(font)
self.quickSendTable.setFont(font)
if UI_FONT is not None:
font = QtGui.QFont()
font.setFamily(UI_FONT)
font.setPointSize(9)
self.dockWidget_PortConfig.setFont(font)
self.dockWidget_SendHex.setFont(font)
self.dockWidget_QuickSend.setFont(font)
self.setupFlatUi()
self.onEnumPorts()
icon = QtGui.QIcon(":/icon.ico")
self.setWindowIcon(icon)
self.actionAbout.setIcon(icon)
icon = QtGui.QIcon(":/qt_logo_16.ico")
self.actionAbout_Qt.setIcon(icon)
self._viewGroup = QActionGroup(self)
self._viewGroup.addAction(self.actionAscii)
self._viewGroup.addAction(self.actionHex_lowercase)
self._viewGroup.addAction(self.actionHEX_UPPERCASE)
self._viewGroup.setExclusive(True)
# bind events
self.actionOpen_Cmd_File.triggered.connect(self.openCSV)
self.actionSave_Log.triggered.connect(self.onSaveLog)
self.actionExit.triggered.connect(self.onExit)
self.actionOpen.triggered.connect(self.openPort)
self.actionClose.triggered.connect(self.closePort)
self.actionPort_Config_Panel.triggered.connect(self.onTogglePrtCfgPnl)
self.actionQuick_Send_Panel.triggered.connect(self.onToggleQckSndPnl)
self.actionSend_Hex_Panel.triggered.connect(self.onToggleHexPnl)
self.dockWidget_PortConfig.visibilityChanged.connect(self.onVisiblePrtCfgPnl)
self.dockWidget_QuickSend.visibilityChanged.connect(self.onVisibleQckSndPnl)
self.dockWidget_SendHex.visibilityChanged.connect(self.onVisibleHexPnl)
self.actionLocal_Echo.triggered.connect(self.onLocalEcho)
self.actionAlways_On_Top.triggered.connect(self.onAlwaysOnTop)
self.actionAscii.triggered.connect(self.onViewChanged)
self.actionHex_lowercase.triggered.connect(self.onViewChanged)
self.actionHEX_UPPERCASE.triggered.connect(self.onViewChanged)
self.actionAbout.triggered.connect(self.onAbout)
self.actionAbout_Qt.triggered.connect(self.onAboutQt)
self.btnOpen.clicked.connect(self.onOpen)
self.btnClear.clicked.connect(self.onClear)
self.btnSaveLog.clicked.connect(self.onSaveLog)
self.btnEnumPorts.clicked.connect(self.onEnumPorts)
self.btnSendHex.clicked.connect(self.sendHex)
self.receiver_thread.read.connect(self.receive)
self.receiver_thread.exception.connect(self.readerExcept)
self._signalMap = QSignalMapper(self)
self._signalMap.mapped[int].connect(self.tableClick)
# initial action
self.actionHEX_UPPERCASE.setChecked(True)
self.receiver_thread.setViewMode(VIEWMODE_HEX_UPPERCASE)
self.initQuickSend()
self.restoreLayout()
self.moveScreenCenter()
self.syncMenu()
if self.isMaximized():
self.setMaximizeButton("restore")
else:
self.setMaximizeButton("maximize")
self.LoadSettings()
def setupFlatUi(self):
self._dragPos = self.pos()
self._isDragging = False
self.setMouseTracking(True)
self.setWindowFlags(Qt.FramelessWindowHint)
self.setStyleSheet("""
QWidget {
background-color:#99d9ea;
#.........这里部分代码省略.........