本文整理汇总了Python中PyQt4.Qt.QToolBar.addSeparator方法的典型用法代码示例。如果您正苦于以下问题:Python QToolBar.addSeparator方法的具体用法?Python QToolBar.addSeparator怎么用?Python QToolBar.addSeparator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QToolBar
的用法示例。
在下文中一共展示了QToolBar.addSeparator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Editor
# 需要导入模块: from PyQt4.Qt import QToolBar [as 别名]
# 或者: from PyQt4.Qt.QToolBar import addSeparator [as 别名]
class Editor(QWidget): # {{{
def __init__(self, parent=None, one_line_toolbar=False):
QWidget.__init__(self, parent)
self.toolbar1 = QToolBar(self)
self.toolbar2 = QToolBar(self)
self.toolbar3 = QToolBar(self)
for i in range(1, 4):
t = getattr(self, 'toolbar%d'%i)
t.setIconSize(QSize(18, 18))
self.editor = EditorWidget(self)
self.tabs = QTabWidget(self)
self.tabs.setTabPosition(self.tabs.South)
self.wyswyg = QWidget(self.tabs)
self.code_edit = QPlainTextEdit(self.tabs)
self.source_dirty = False
self.wyswyg_dirty = True
self._layout = QVBoxLayout(self)
self.wyswyg.layout = l = QVBoxLayout(self.wyswyg)
self.setLayout(self._layout)
l.setContentsMargins(0, 0, 0, 0)
if one_line_toolbar:
tb = QHBoxLayout()
l.addLayout(tb)
else:
tb = l
tb.addWidget(self.toolbar1)
tb.addWidget(self.toolbar2)
tb.addWidget(self.toolbar3)
l.addWidget(self.editor)
self._layout.addWidget(self.tabs)
self.tabs.addTab(self.wyswyg, _('Normal view'))
self.tabs.addTab(self.code_edit, _('HTML Source'))
self.tabs.currentChanged[int].connect(self.change_tab)
self.highlighter = Highlighter(self.code_edit.document())
self.layout().setContentsMargins(0, 0, 0, 0)
# toolbar1 {{{
self.toolbar1.addAction(self.editor.action_undo)
self.toolbar1.addAction(self.editor.action_redo)
self.toolbar1.addAction(self.editor.action_select_all)
self.toolbar1.addAction(self.editor.action_remove_format)
self.toolbar1.addAction(self.editor.action_clear)
self.toolbar1.addSeparator()
for x in ('copy', 'cut', 'paste'):
ac = getattr(self.editor, 'action_'+x)
self.toolbar1.addAction(ac)
self.toolbar1.addSeparator()
self.toolbar1.addAction(self.editor.action_background)
# }}}
# toolbar2 {{{
for x in ('', 'un'):
ac = getattr(self.editor, 'action_%sordered_list'%x)
self.toolbar2.addAction(ac)
self.toolbar2.addSeparator()
for x in ('superscript', 'subscript', 'indent', 'outdent'):
self.toolbar2.addAction(getattr(self.editor, 'action_' + x))
if x in ('subscript', 'outdent'):
self.toolbar2.addSeparator()
self.toolbar2.addAction(self.editor.action_block_style)
w = self.toolbar2.widgetForAction(self.editor.action_block_style)
w.setPopupMode(w.InstantPopup)
self.toolbar2.addAction(self.editor.action_insert_link)
# }}}
# toolbar3 {{{
for x in ('bold', 'italic', 'underline', 'strikethrough'):
ac = getattr(self.editor, 'action_'+x)
self.toolbar3.addAction(ac)
self.toolbar3.addSeparator()
for x in ('left', 'center', 'right', 'justified'):
ac = getattr(self.editor, 'action_align_'+x)
self.toolbar3.addAction(ac)
self.toolbar3.addSeparator()
self.toolbar3.addAction(self.editor.action_color)
# }}}
self.code_edit.textChanged.connect(self.code_dirtied)
self.editor.page().contentsChanged.connect(self.wyswyg_dirtied)
@dynamic_property
def html(self):
def fset(self, v):
self.editor.html = v
def fget(self):
self.tabs.setCurrentIndex(0)
return self.editor.html
return property(fget=fget, fset=fset)
def change_tab(self, index):
# print 'reloading:', (index and self.wyswyg_dirty) or (not index and
# self.source_dirty)
if index == 1: # changing to code view
if self.wyswyg_dirty:
#.........这里部分代码省略.........
示例2: Preview
# 需要导入模块: from PyQt4.Qt import QToolBar [as 别名]
# 或者: from PyQt4.Qt.QToolBar import addSeparator [as 别名]
class Preview(QWidget):
sync_requested = pyqtSignal(object, object)
split_requested = pyqtSignal(object, object, object)
split_start_requested = pyqtSignal()
link_clicked = pyqtSignal(object, object)
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.l = l = QVBoxLayout()
self.setLayout(l)
l.setContentsMargins(0, 0, 0, 0)
self.view = WebView(self)
self.view.page().sync_requested.connect(self.request_sync)
self.view.page().split_requested.connect(self.request_split)
self.view.page().loadFinished.connect(self.load_finished)
self.inspector = self.view.inspector
self.inspector.setPage(self.view.page())
l.addWidget(self.view)
self.bar = QToolBar(self)
l.addWidget(self.bar)
ac = actions['auto-reload-preview']
ac.setCheckable(True)
ac.setChecked(True)
ac.toggled.connect(self.auto_reload_toggled)
self.auto_reload_toggled(ac.isChecked())
self.bar.addAction(ac)
ac = actions['sync-preview-to-editor']
ac.setCheckable(True)
ac.setChecked(True)
ac.toggled.connect(self.sync_toggled)
self.sync_toggled(ac.isChecked())
self.bar.addAction(ac)
self.bar.addSeparator()
ac = actions['split-in-preview']
ac.setCheckable(True)
ac.setChecked(False)
ac.toggled.connect(self.split_toggled)
self.split_toggled(ac.isChecked())
self.bar.addAction(ac)
ac = actions['reload-preview']
ac.triggered.connect(self.refresh)
self.bar.addAction(ac)
actions['preview-dock'].toggled.connect(self.visibility_changed)
self.current_name = None
self.last_sync_request = None
self.refresh_timer = QTimer(self)
self.refresh_timer.timeout.connect(self.refresh)
parse_worker.start()
self.current_sync_request = None
self.search = HistoryLineEdit2(self)
self.search.initialize('tweak_book_preview_search')
self.search.setPlaceholderText(_('Search in preview'))
self.search.returnPressed.connect(partial(self.find, 'next'))
self.bar.addSeparator()
self.bar.addWidget(self.search)
for d in ('next', 'prev'):
ac = actions['find-%s-preview' % d]
ac.triggered.connect(partial(self.find, d))
self.bar.addAction(ac)
def find(self, direction):
text = unicode(self.search.text())
self.view.findText(text, QWebPage.FindWrapsAroundDocument | (
QWebPage.FindBackward if direction == 'prev' else QWebPage.FindFlags(0)))
def request_sync(self, tagname, href, lnum):
if self.current_name:
c = current_container()
if tagname == 'a' and href:
if href and href.startswith('#'):
name = self.current_name
else:
name = c.href_to_name(href, self.current_name) if href else None
if name == self.current_name:
return self.view.page().go_to_anchor(urlparse(href).fragment, lnum)
if name and c.exists(name) and c.mime_map[name] in OEB_DOCS:
return self.link_clicked.emit(name, urlparse(href).fragment or TOP)
self.sync_requested.emit(self.current_name, lnum)
def request_split(self, loc, totals):
if self.current_name:
self.split_requested.emit(self.current_name, loc, totals)
def sync_to_editor(self, name, lnum):
self.current_sync_request = (name, lnum)
QTimer.singleShot(100, self._sync_to_editor)
def _sync_to_editor(self):
if not actions['sync-preview-to-editor'].isChecked():
return
try:
#.........这里部分代码省略.........
示例3: Preview
# 需要导入模块: from PyQt4.Qt import QToolBar [as 别名]
# 或者: from PyQt4.Qt.QToolBar import addSeparator [as 别名]
class Preview(QWidget):
sync_requested = pyqtSignal(object, object)
split_requested = pyqtSignal(object, object)
split_start_requested = pyqtSignal()
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.l = l = QVBoxLayout()
self.setLayout(l)
l.setContentsMargins(0, 0, 0, 0)
self.view = WebView(self)
self.view.page().sync_requested.connect(self.request_sync)
self.view.page().split_requested.connect(self.request_split)
self.view.page().loadFinished.connect(self.load_finished)
self.inspector = self.view.inspector
self.inspector.setPage(self.view.page())
l.addWidget(self.view)
self.bar = QToolBar(self)
l.addWidget(self.bar)
ac = actions['auto-reload-preview']
ac.setCheckable(True)
ac.setChecked(True)
ac.toggled.connect(self.auto_reload_toggled)
self.auto_reload_toggled(ac.isChecked())
self.bar.addAction(ac)
ac = actions['sync-preview-to-editor']
ac.setCheckable(True)
ac.setChecked(True)
ac.toggled.connect(self.sync_toggled)
self.sync_toggled(ac.isChecked())
self.bar.addAction(ac)
self.bar.addSeparator()
ac = actions['split-in-preview']
ac.setCheckable(True)
ac.setChecked(False)
ac.toggled.connect(self.split_toggled)
self.split_toggled(ac.isChecked())
self.bar.addAction(ac)
ac = actions['reload-preview']
ac.triggered.connect(self.refresh)
self.bar.addAction(ac)
actions['preview-dock'].toggled.connect(self.visibility_changed)
self.current_name = None
self.last_sync_request = None
self.refresh_timer = QTimer(self)
self.refresh_timer.timeout.connect(self.refresh)
parse_worker.start()
self.current_sync_request = None
def request_sync(self, lnum):
if self.current_name:
self.sync_requested.emit(self.current_name, lnum)
def request_split(self, loc):
if self.current_name:
self.split_requested.emit(self.current_name, loc)
def sync_to_editor(self, name, lnum):
self.current_sync_request = (name, lnum)
QTimer.singleShot(100, self._sync_to_editor)
def _sync_to_editor(self):
if not actions['sync-preview-to-editor'].isChecked():
return
try:
if self.refresh_timer.isActive() or self.current_sync_request[0] != self.current_name:
return QTimer.singleShot(100, self._sync_to_editor)
except TypeError:
return # Happens if current_sync_request is None
lnum = self.current_sync_request[1]
self.current_sync_request = None
self.view.page().go_to_line(lnum)
def show(self, name):
if name != self.current_name:
self.refresh_timer.stop()
self.current_name = name
parse_worker.add_request(name)
self.view.setUrl(QUrl.fromLocalFile(current_container().name_to_abspath(name)))
def refresh(self):
if self.current_name:
self.refresh_timer.stop()
# This will check if the current html has changed in its editor,
# and re-parse it if so
parse_worker.add_request(self.current_name)
# Tell webkit to reload all html and associated resources
current_url = QUrl.fromLocalFile(current_container().name_to_abspath(self.current_name))
if current_url != self.view.url():
# The container was changed
self.view.setUrl(current_url)
else:
#.........这里部分代码省略.........