本文整理汇总了Python中PySide.QtGui.QTabWidget.count方法的典型用法代码示例。如果您正苦于以下问题:Python QTabWidget.count方法的具体用法?Python QTabWidget.count怎么用?Python QTabWidget.count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QTabWidget
的用法示例。
在下文中一共展示了QTabWidget.count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Jaime
# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import count [as 别名]
#.........这里部分代码省略.........
self.config.read(config_file)
def loadParam(self,name,value):
name = name.strip()
# print 'get param [%s]' % name
if not self.config.has_section('PARAMS'):
# print 'cree la seccion'
self.config.add_section('PARAMS')
self.config.set('PARAMS',name.strip(),value)
# print 'seteo %s a %s ' % (name,value)
def getParam(self,name,default=None):
name = name.strip()
# print 'get param [%s]' % name
if self.config.has_section('PARAMS') and \
self.config.has_option('PARAMS',name):
# print 'get param 1 %s' % name
return self.config.get('PARAMS',name)
if default != None:
return default
return None
def toggleDelegationPolicy(self, delegate=None):
if self.page.linkDelegationPolicy() == QWebPage.DontDelegateLinks or \
( isinstance(delegate,bool) and delegate ):
self.logger.info('cambio a delegate links')
self.page.setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
elif self.page.linkDelegationPolicy() == QWebPage.DelegateAllLinks or \
( isinstance(delegate,bool) and not delegate ):
self.logger.info('cambio a dont delegate links')
self.page.setLinkDelegationPolicy(QWebPage.DontDelegateLinks)
else:
self.logger.warn("Can't set delegation policy")
def setGraph(self,filename):
self.graph_file = filename
def start(self):
self.logger.info('---------------------------- Jaime start work ---------------------------------')
self.logger.info('Graph file = %s' % self.graph_file)
if self.config.has_section('PARAMS') :
self.logger.info('[PARAMS]')
for name,value in self.config.items('PARAMS'):
self.logger.info(' %s = %s' % (name,value))
self.page.setNetworkAccessManager(self.network_manager)
self.page.loadFinished.connect(self.navigator.processPageLoadFinished)
self.page.loadStarted.connect(self.navigator.processLoadStarted)
self.page.linkClicked.connect(self.openLinkOnTab)
self.close_tab_timer.timeout.connect(self.closeOpenTab)
self.graph_parser.loadGraph(self.graph_file)
if not self.navigator.takeEntryPoint():
self.finishWork()
self.tabs_widget.show()
# self.tabs_widget.showMaximized()
def finishWork(self):
self.logger.info('Jaime termina su funcionamiento')
QApplication.closeAllWindows()
def openLinkOnTab(self,link):
l = len(self.tabs)
new_tab_key = 'newTab_%s' % time.time()
self.tabs[new_tab_key] = QWebView()
self.tabs[new_tab_key].load(link)
self.tabs_widget.insertTab(self.tabs_widget.count(),self.tabs[new_tab_key],new_tab_key)
if self.close_tab_timer.timerId() == -1 :
self.logger.info('starteo el close_tab_timer')
self.close_tab_timer.start()
def closeOpenTab(self):
if len(self.tabs) == 1 and self.close_tab_timer.timerId() != -1 :
self.logger.info('stopeo el close_tab_timer')
self.close_tab_timer.stop()
return
ks = self.tabs.keys()
ks.remove('mainTab')
ks.sort()
last_key = ks[0]
index = None
for i in range(len(self.tabs)):
if self.tabs_widget.tabText(i) == last_key:
index = i
break
if index:
del self.tabs[last_key]
self.tabs_widget.removeTab(index)
else:
# print 'stopeo el close_tab_timer'
self.logger.error('no se encontro tab para remover con nombre %s' % last_key)
示例2: window
# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import count [as 别名]
#.........这里部分代码省略.........
gsettings.setAttribute(QWebSettings.DnsPrefetchEnabled, True)
gsettings.setAttribute(QWebSettings.AcceleratedCompositingEnabled, True)
gsettings.setAttribute(QWebSettings.DnsPrefetchEnabled, True)
# Other settings
gsettings.setAttribute(QWebSettings.PrivateBrowsingEnabled, False)
# Create a vertical layout and add widgets
vlayout = QVBoxLayout()
vlayout.setSpacing(0)
vlayout.setContentsMargins(0, 0, 0, 0)
# toolbar.addWidget(self.input_widget)
vlayout.addWidget(self.input_widget)
vlayout.addWidget(self.bookmarks_widget)
vlayout.addWidget(self.tabs_widget)
# create a widget to hold the vertical layout
wrapper_widget = QWidget()
wrapper_widget.setLayout(vlayout)
self.setCentralWidget(wrapper_widget)
self.bbutton.clicked.connect(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).back)
self.fbutton.clicked.connect(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).forward)
self.hbutton.clicked.connect(self.goHome)
self.edit.returnPressed.connect(self.set_url)
# Add button signal to "go" slot
self.rbutton.clicked.connect(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).reload)
self.dbutton.clicked.connect(self.bookmark)
self.tbutton.clicked.connect(self.toggleTaskBar)
self.nbutton.clicked.connect(self.new_tab)
self.tabs.tabCloseRequested.connect(self.tabs.removeTab)
self.tabs.currentChanged.connect(self.change_tab)
widgets = (input_layout.itemAt(i).widget() for i in range(
input_layout.count()))
for widget in widgets:
if isinstance(widget, QPushButton):
widget.setFixedSize(33, 21)
widget.setFont(QFont("Helvetica Neue", 12, QFont.Normal))
widget.pressed.connect(self.press_button)
widget.released.connect(self.release_button)
# make a ctrl+q quit
sequence = QKeySequence(Qt.CTRL + Qt.Key_Q)
QShortcut(sequence, self, SLOT("close()"))
# make an accelerator to toggle fullscreen
sequence = QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_F)
QShortcut(sequence, self, self.toggle_fullscreen)
# make an accelerator to toggle input visibility
sequence = QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_L)
QShortcut(sequence, self, self.toggle_input)
# make an accelerator to focus adress-bar
sequence = QKeySequence(Qt.CTRL + Qt.Key_L)
QShortcut(sequence, self, self.focus_adress)
# make an accelerator to reload page
sequence = QKeySequence(Qt.CTRL + Qt.Key_R)
QShortcut(sequence, self, self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).reload)
# make an accelerator to create new tab
sequence = QKeySequence(Qt.CTRL + Qt.Key_T)
QShortcut(sequence, self, self.new_tab)
# make an accelerator to close tab
示例3: FormWidget
# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import count [as 别名]
class FormWidget(FormPage):
instanceAssigned = Signal(str)
instanceDeleted = Signal(str)
instanceSaved = Signal(str)
exception = Signal(str)
def __init__(self, parent = None, buttons = FormButtons.EditButtons):
super(FormWidget, self).__init__(parent)
self.buildButtonBox(buttons)
self.tabs = None
self._tabs = {}
def buildButtonBox(self, buttons):
buttonWidget = QGroupBox()
self.buttonbox = QHBoxLayout(buttonWidget)
if buttons & FormButtons.DeleteButton:
self.deletebutton = QPushButton("Delete", self)
self.deletebutton.clicked.connect(self.deleteInstance)
self.buttonbox.addWidget(self.deletebutton)
self.buttonbox.addStretch(1)
if buttons & FormButtons.ResetButton:
self.resetbutton = QPushButton("Reset", self)
self.resetbutton.clicked.connect(self.setInstance)
self.buttonbox.addWidget(self.resetbutton)
if buttons & FormButtons.SaveButton:
self.savebutton = QPushButton("Save", self)
self.savebutton.clicked.connect(self.save)
self.buttonbox.addWidget(self.savebutton)
self.layout().addWidget(buttonWidget)
def addWidgetToButtonBox(self, widget, *args):
self.buttonbox.insertWidget(0, widget, *args)
def addTab(self, widget, title):
if self.tabs is None:
self.tabs = QTabWidget(self)
self.tabs.currentChanged[int].connect(self.tabChanged)
# Remove stretch at the bottom:
self._removeStretch()
self.vbox.addWidget(self.tabs, 1)
if isinstance(widget, FormPage):
self.form.addSubLayout(widget.form)
self.tabs.addTab(widget, title)
self._tabs[title] = widget
return widget
def count(self):
return self.tabs and self.tabs.count()
def setTab(self, tab):
if self.tabs and tab <= self.tabs.count():
self.tabs.setCurrentIndex(tab)
def tabChanged(self, ix):
w = self.tabs.currentWidget()
if hasattr(w, "selected"):
w.selected()
def save(self):
try:
self.form.retrieve(self.instance())
if hasattr(self, "retrieve") and callable(self.retrieve):
self.retrieve(self.instance())
self.instanceSaved.emit(str(self.instance.key()))
self.statusMessage.emit("Saved")
except:
self.exception.emit("Save failed...")
self.setInstance()
def instance(self):
return self._instance
def setInstance(self, instance = None):
if instance:
self._instance = instance
self.form.apply(self.instance())
if hasattr(self, "assign") and callable(self.assign):
self.assign(self.instance())
self.instanceAssigned.emit(str(self.instance().key()))
def confirmDelete(self):
return QMessageBox.warning(self, "Are you sure?",
"Are you sure you want to delete this?",
QMessageBox.Cancel | QMessageBox.Ok,
QMessageBox.Cancel) == QMessageBox.Ok
def onDelete(self):
try:
with gripe.db.Tx.begin():
key = str(self.instance().key())
if grumble.model.delete(self.instance()):
self.instanceDeleted.emit(key)
except:
traceback.print_exc()
self.exception.emit("Delete failed...")
def deleteInstance(self):
if self.instance() and self.confirmDelete():
self.onDelete()