本文整理汇总了Python中PyQt4.Qt.QScrollArea类的典型用法代码示例。如果您正苦于以下问题:Python QScrollArea类的具体用法?Python QScrollArea怎么用?Python QScrollArea使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QScrollArea类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PluginObject
class PluginObject(object):
tabName = 'Armory Search'
maxVersion = '0.93.99'
#############################################################################
def __init__(self, main):
def searchItem():
searchString = str(self.searchEntry.text())
if len(searchString) > 0:
likelyDataType = isLikelyDataType(searchString)
for wltID, wlt in self.main.walletMap.iteritems():
if wlt.hasAddr(searchString):
searchHash = searchString if likelyDataType == DATATYPE.Hex \
else addrStr_to_hash160(searchString)[1]
dialog = DlgAddressInfo(wlt, searchHash, main=self.main)
dialog.exec_()
break
if likelyDataType == DATATYPE.Hex:
walletLedger = wlt.cppWallet.getTxLedger()
txHashToFind = hex_to_binary(searchString, endOut=BIGENDIAN)
txFound = False
for entry in walletLedger:
if entry.getTxHash() == txHashToFind:
cppTx = TheBDM.getTxByHash(txHashToFind)
serializedCppTx = cppTx.serialize()
pytx = PyTx().unserialize(serializedCppTx)
DlgDispTxInfo(pytx, wlt, self.main, self.main).exec_()
txFound = True
break
if txFound:
break
self.main = main
lblHeader = QRichLabel(tr("""<b>Search Armory: </b>"""), doWrap=False)
self.searchButton = QPushButton("Search")
self.searchEntry = QLineEdit()
self.main.connect(self.searchButton, SIGNAL('clicked()'), searchItem)
topRow = makeHorizFrame([lblHeader, self.searchEntry, self.searchButton, 'stretch'])
self.searchPanel = makeVertFrame([topRow, 'stretch' ])
# Now set the scrollarea widget to the layout
self.tabToDisplay = QScrollArea()
self.tabToDisplay.setWidgetResizable(True)
self.tabToDisplay.setWidget(self.searchPanel)
#############################################################################
def getTabToDisplay(self):
return self.tabToDisplay
示例2: PluginObject
class PluginObject(object):
tabName = 'Armory Log'
maxVersion = '0.93.99'
#############################################################################
def __init__(self, main):
self.main = main
def updateLogDisplay():
self.pyLogTextDisplay.setText(getLastBytesOfFile(ARMORY_LOG_FILE))
self.pyLogTextDisplay.moveCursor(QtGui.QTextCursor.End)
self.cppLogTextDisplay.setText(getLastBytesOfFile(ARMCPP_LOG_FILE))
self.cppLogTextDisplay.moveCursor(QtGui.QTextCursor.End)
lblHeader = QRichLabel(tr("""<b>Log File Display</b>"""), doWrap=False)
self.updateButton = QPushButton("Update")
self.main.connect(self.updateButton, SIGNAL('clicked()'), updateLogDisplay)
topRow = makeHorizFrame([lblHeader, self.updateButton, 'stretch'])
self.pyLogTextDisplay = self.createLogDisplay()
self.cppLogTextDisplay = self.createLogDisplay()
logTabPanel = QTabWidget()
logTabPanel.addTab(self.pyLogTextDisplay, "Python Log")
logTabPanel.addTab(self.cppLogTextDisplay, "C++ Log")
self.logFrame = makeVertFrame([topRow, logTabPanel ])
# Now set the scrollarea widget to the layout
self.tabToDisplay = QScrollArea()
self.tabToDisplay.setWidgetResizable(True)
self.tabToDisplay.setWidget(self.logFrame)
updateLogDisplay()
def createLogDisplay(self):
logTextDisplay = QTextEdit()
logTextDisplay.setFont(GETFONT('Fixed', 8))
w,h = relaxedSizeNChar(logTextDisplay, 68)[0], int(12 * 8.2)
logTextDisplay.setMinimumWidth(w)
logTextDisplay.setMinimumHeight(h)
logTextDisplay.setReadOnly(True)
return logTextDisplay
#############################################################################
def getTabToDisplay(self):
return self.tabToDisplay
示例3: __init__
def __init__(self, main):
self.main = main
def updateLogDisplay():
self.pyLogTextDisplay.setText(getLastBytesOfFile(ARMORY_LOG_FILE))
self.pyLogTextDisplay.moveCursor(QtGui.QTextCursor.End)
self.cppLogTextDisplay.setText(getLastBytesOfFile(ARMCPP_LOG_FILE))
self.cppLogTextDisplay.moveCursor(QtGui.QTextCursor.End)
lblHeader = QRichLabel(tr("""<b>Log File Display</b>"""), doWrap=False)
self.updateButton = QPushButton("Update")
self.main.connect(self.updateButton, SIGNAL('clicked()'), updateLogDisplay)
topRow = makeHorizFrame([lblHeader, self.updateButton, 'stretch'])
self.pyLogTextDisplay = self.createLogDisplay()
self.cppLogTextDisplay = self.createLogDisplay()
logTabPanel = QTabWidget()
logTabPanel.addTab(self.pyLogTextDisplay, "Python Log")
logTabPanel.addTab(self.cppLogTextDisplay, "C++ Log")
self.logFrame = makeVertFrame([topRow, logTabPanel ])
# Now set the scrollarea widget to the layout
self.tabToDisplay = QScrollArea()
self.tabToDisplay.setWidgetResizable(True)
self.tabToDisplay.setWidget(self.logFrame)
updateLogDisplay()
示例4: config_widget
def config_widget(cls):
from PyQt4.Qt import QCoreApplication
from PyQt4.Qt import QScrollArea
cw = super(KOBOTOUCHEXTENDED, cls).config_widget()
qsa = QScrollArea()
qsa.setWidgetResizable(True)
qsa.setWidget(cw)
qsa.validate = cw.validate
desktop_geom = QCoreApplication.instance().desktop().availableGeometry()
if desktop_geom.height() < 800:
qsa.setBaseSize(qsa.size().width(), desktop_geom.height() - 100)
return qsa
示例5: setupUi
def setupUi(self, *args): # {{{
self.resize(990, 670)
self.download_shortcut = QShortcut(self)
self.download_shortcut.setKey(QKeySequence('Ctrl+D',
QKeySequence.PortableText))
p = self.parent()
if hasattr(p, 'keyboard'):
kname = u'Interface Action: Edit Metadata (Edit Metadata) : menu action : download'
sc = p.keyboard.keys_map.get(kname, None)
if sc:
self.download_shortcut.setKey(sc[0])
self.button_box = bb = QDialogButtonBox(self)
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.reject)
self.next_button = QPushButton(QIcon(I('forward.png')), _('Next'),
self)
self.next_button.setShortcut(QKeySequence('Alt+Right'))
self.next_button.clicked.connect(self.next_clicked)
self.prev_button = QPushButton(QIcon(I('back.png')), _('Previous'),
self)
self.prev_button.setShortcut(QKeySequence('Alt+Left'))
self.button_box.addButton(self.prev_button, bb.ActionRole)
self.button_box.addButton(self.next_button, bb.ActionRole)
self.prev_button.clicked.connect(self.prev_clicked)
bb.setStandardButtons(bb.Ok|bb.Cancel)
bb.button(bb.Ok).setDefault(True)
self.scroll_area = QScrollArea(self)
self.scroll_area.setFrameShape(QScrollArea.NoFrame)
self.scroll_area.setWidgetResizable(True)
self.central_widget = QTabWidget(self)
self.scroll_area.setWidget(self.central_widget)
self.l = QVBoxLayout(self)
self.setLayout(self.l)
self.l.addWidget(self.scroll_area)
ll = self.button_box_layout = QHBoxLayout()
self.l.addLayout(ll)
ll.addSpacing(10)
ll.addWidget(self.button_box)
self.setWindowIcon(QIcon(I('edit_input.png')))
self.setWindowTitle(BASE_TITLE)
self.create_basic_metadata_widgets()
if len(self.db.custom_column_label_map):
self.create_custom_metadata_widgets()
self.do_layout()
geom = gprefs.get('metasingle_window_geometry3', None)
if geom is not None:
self.restoreGeometry(bytes(geom))
示例6: __init__
def __init__(self, parent=None):
QScrollArea.__init__(self, parent)
self.setWidgetResizable(True)
category_map, category_names = {}, {}
for plugin in preferences_plugins():
if plugin.category not in category_map:
category_map[plugin.category] = plugin.category_order
if category_map[plugin.category] < plugin.category_order:
category_map[plugin.category] = plugin.category_order
if plugin.category not in category_names:
category_names[plugin.category] = (plugin.gui_category if
plugin.gui_category else plugin.category)
self.category_names = category_names
categories = list(category_map.keys())
categories.sort(cmp=lambda x, y: cmp(category_map[x], category_map[y]))
self.category_map = OrderedDict()
for c in categories:
self.category_map[c] = []
for plugin in preferences_plugins():
self.category_map[plugin.category].append(plugin)
for plugins in self.category_map.values():
plugins.sort(cmp=lambda x, y: cmp(x.name_order, y.name_order))
self.widgets = []
self._layout = QVBoxLayout()
self.container = QWidget(self)
self.container.setLayout(self._layout)
self.setWidget(self.container)
for name, plugins in self.category_map.items():
w = Category(name, plugins, self.category_names[name], parent=self)
self.widgets.append(w)
self._layout.addWidget(w)
w.plugin_activated.connect(self.show_plugin.emit)
示例7: do_layout
def do_layout(self):
self.central_widget.clear()
self.labels = []
sto = QWidget.setTabOrder
self.central_widget.tabBar().setVisible(False)
tab0 = QWidget(self)
self.central_widget.addTab(tab0, _("&Metadata"))
l = QGridLayout()
tab0.setLayout(l)
# Basic metadata in col 0
tl = QGridLayout()
gb = QGroupBox(_('Basic metadata'), tab0)
l.addWidget(gb, 0, 0, 1, 1)
gb.setLayout(tl)
self.button_box_layout.insertWidget(1, self.fetch_metadata_button)
self.button_box_layout.insertWidget(2, self.config_metadata_button)
sto(self.button_box, self.fetch_metadata_button)
sto(self.fetch_metadata_button, self.config_metadata_button)
sto(self.config_metadata_button, self.title)
def create_row(row, widget, tab_to, button=None, icon=None, span=1):
ql = BuddyLabel(widget)
tl.addWidget(ql, row, 1, 1, 1)
tl.addWidget(widget, row, 2, 1, 1)
if button is not None:
tl.addWidget(button, row, 3, span, 1)
if icon is not None:
button.setIcon(QIcon(I(icon)))
if tab_to is not None:
if button is not None:
sto(widget, button)
sto(button, tab_to)
else:
sto(widget, tab_to)
tl.addWidget(self.swap_title_author_button, 0, 0, 2, 1)
tl.addWidget(self.manage_authors_button, 2, 0, 2, 1)
tl.addWidget(self.paste_isbn_button, 12, 0, 1, 1)
tl.addWidget(self.tags_editor_button, 6, 0, 1, 1)
create_row(0, self.title, self.title_sort,
button=self.deduce_title_sort_button, span=2,
icon='auto_author_sort.png')
create_row(1, self.title_sort, self.authors)
create_row(2, self.authors, self.author_sort,
button=self.deduce_author_sort_button,
span=2, icon='auto_author_sort.png')
create_row(3, self.author_sort, self.series)
create_row(4, self.series, self.series_index,
button=self.clear_series_button, icon='trash.png')
create_row(5, self.series_index, self.tags)
create_row(6, self.tags, self.rating, button=self.clear_tags_button)
create_row(7, self.rating, self.pubdate, button=self.clear_ratings_button)
create_row(8, self.pubdate, self.publisher,
button=self.pubdate.clear_button, icon='trash.png')
create_row(9, self.publisher, self.languages)
create_row(10, self.languages, self.timestamp)
create_row(11, self.timestamp, self.identifiers,
button=self.timestamp.clear_button, icon='trash.png')
create_row(12, self.identifiers, self.comments,
button=self.clear_identifiers_button, icon='trash.png')
sto(self.clear_identifiers_button, self.swap_title_author_button)
sto(self.swap_title_author_button, self.manage_authors_button)
sto(self.manage_authors_button, self.tags_editor_button)
sto(self.tags_editor_button, self.paste_isbn_button)
tl.addItem(QSpacerItem(1, 1, QSizePolicy.Fixed, QSizePolicy.Expanding),
13, 1, 1 ,1)
# Custom metadata in col 1
w = getattr(self, 'custom_metadata_widgets_parent', None)
if w is not None:
gb = QGroupBox(_('Custom metadata'), tab0)
gbl = QVBoxLayout()
gb.setLayout(gbl)
sr = QScrollArea(gb)
sr.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
sr.setWidgetResizable(True)
sr.setFrameStyle(QFrame.NoFrame)
sr.setWidget(w)
gbl.addWidget(sr)
l.addWidget(gb, 0, 1, 1, 1)
sp = QSizePolicy()
sp.setVerticalStretch(10)
sp.setHorizontalPolicy(QSizePolicy.Minimum)
sp.setVerticalPolicy(QSizePolicy.Expanding)
gb.setSizePolicy(sp)
self.set_custom_metadata_tab_order()
# comments span col 0 & 1
w = QGroupBox(_('Comments'), tab0)
sp = QSizePolicy()
sp.setVerticalStretch(10)
sp.setHorizontalPolicy(QSizePolicy.Expanding)
sp.setVerticalPolicy(QSizePolicy.Expanding)
w.setSizePolicy(sp)
lb = QHBoxLayout()
w.setLayout(lb)
#.........这里部分代码省略.........
示例8: MetadataSingleDialogBase
class MetadataSingleDialogBase(ResizableDialog):
view_format = pyqtSignal(object, object)
cc_two_column = tweaks['metadata_single_use_2_cols_for_custom_fields']
one_line_comments_toolbar = False
use_toolbutton_for_config_metadata = True
def __init__(self, db, parent=None):
self.db = db
self.changed = set()
self.books_to_refresh = set()
self.rows_to_refresh = set()
ResizableDialog.__init__(self, parent)
def setupUi(self, *args): # {{{
self.resize(990, 670)
self.download_shortcut = QShortcut(self)
self.download_shortcut.setKey(QKeySequence('Ctrl+D',
QKeySequence.PortableText))
p = self.parent()
if hasattr(p, 'keyboard'):
kname = u'Interface Action: Edit Metadata (Edit Metadata) : menu action : download'
sc = p.keyboard.keys_map.get(kname, None)
if sc:
self.download_shortcut.setKey(sc[0])
self.button_box = bb = QDialogButtonBox(self)
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.reject)
self.next_button = QPushButton(QIcon(I('forward.png')), _('Next'),
self)
self.next_button.setShortcut(QKeySequence('Alt+Right'))
self.next_button.clicked.connect(self.next_clicked)
self.prev_button = QPushButton(QIcon(I('back.png')), _('Previous'),
self)
self.prev_button.setShortcut(QKeySequence('Alt+Left'))
self.button_box.addButton(self.prev_button, bb.ActionRole)
self.button_box.addButton(self.next_button, bb.ActionRole)
self.prev_button.clicked.connect(self.prev_clicked)
bb.setStandardButtons(bb.Ok|bb.Cancel)
bb.button(bb.Ok).setDefault(True)
self.scroll_area = QScrollArea(self)
self.scroll_area.setFrameShape(QScrollArea.NoFrame)
self.scroll_area.setWidgetResizable(True)
self.central_widget = QTabWidget(self)
self.scroll_area.setWidget(self.central_widget)
self.l = QVBoxLayout(self)
self.setLayout(self.l)
self.l.addWidget(self.scroll_area)
ll = self.button_box_layout = QHBoxLayout()
self.l.addLayout(ll)
ll.addSpacing(10)
ll.addWidget(self.button_box)
self.setWindowIcon(QIcon(I('edit_input.png')))
self.setWindowTitle(BASE_TITLE)
self.create_basic_metadata_widgets()
if len(self.db.custom_column_label_map):
self.create_custom_metadata_widgets()
self.do_layout()
geom = gprefs.get('metasingle_window_geometry3', None)
if geom is not None:
self.restoreGeometry(bytes(geom))
# }}}
def create_basic_metadata_widgets(self): # {{{
self.basic_metadata_widgets = []
self.languages = LanguagesEdit(self)
self.basic_metadata_widgets.append(self.languages)
self.title = TitleEdit(self)
self.title.textChanged.connect(self.update_window_title)
self.deduce_title_sort_button = QToolButton(self)
self.deduce_title_sort_button.setToolTip(
_('Automatically create the title sort entry based on the current '
'title entry.\nUsing this button to create title sort will '
'change title sort from red to green.'))
self.deduce_title_sort_button.setWhatsThis(
self.deduce_title_sort_button.toolTip())
self.title_sort = TitleSortEdit(self, self.title,
self.deduce_title_sort_button, self.languages)
self.basic_metadata_widgets.extend([self.title, self.title_sort])
self.deduce_author_sort_button = b = QToolButton(self)
b.setToolTip('<p>' +
_('Automatically create the author sort entry based on the current '
'author entry. Using this button to create author sort will '
'change author sort from red to green. There is a menu of '
'functions available under this button. Click and hold '
'on the button to see it.') + '</p>')
b.m = m = QMenu()
ac = m.addAction(QIcon(I('forward.png')), _('Set author sort from author'))
#.........这里部分代码省略.........
示例9: Ui_PartWindow
#.........这里部分代码省略.........
# QTabWidget. It needs to know the GLPane, but that's not created
# yet, so we set it later using KLUGE_setGLPane (below).
# Note: No parent supplied. Could this be the source of the
# minor vsplitter resizing problem I was trying to resolve a few
# months ago? Try supplying a parent later. Mark 2008-01-01
self.pwProjectTabWidget.setObjectName("pwProjectTabWidget")
self.pwProjectTabWidget.setCurrentIndex(0)
self.pwProjectTabWidget.setAutoFillBackground(True)
# Create the model tree "tab" widget. It will contain the MT GUI widget.
# Set the tab icon, too.
self.modelTreeTab = QWidget()
self.modelTreeTab.setObjectName("modelTreeTab")
self.pwProjectTabWidget.addTab(
self.modelTreeTab,
geticon("ui/modeltree/Model_Tree.png"),
"")
modelTreeTabLayout = QVBoxLayout(self.modelTreeTab)
modelTreeTabLayout.setMargin(0)
modelTreeTabLayout.setSpacing(0)
# Create the model tree (GUI) and add it to the tab layout.
self.modelTree = modelTree(self.modelTreeTab, parent)
self.modelTree.modelTreeGui.setObjectName("modelTreeGui")
modelTreeTabLayout.addWidget(self.modelTree.modelTreeGui)
# Create the property manager "tab" widget. It will contain the PropMgr
# scroll area, which will contain the property manager and all its
# widgets.
self.propertyManagerTab = QWidget()
self.propertyManagerTab.setObjectName("propertyManagerTab")
self.propertyManagerScrollArea = QScrollArea(self.pwProjectTabWidget)
self.propertyManagerScrollArea.setObjectName("propertyManagerScrollArea")
self.propertyManagerScrollArea.setWidget(self.propertyManagerTab)
self.propertyManagerScrollArea.setWidgetResizable(True)
# Eureka!
# setWidgetResizable(True) will resize the Property Manager (and its
# contents) correctly when the scrollbar appears/disappears.
# It even accounts correctly for collapsed/expanded groupboxes!
# Mark 2007-05-29
# Add the property manager scroll area as a "tabbed" widget.
# Set the tab icon, too.
self.pwProjectTabWidget.addTab(
self.propertyManagerScrollArea,
geticon("ui/modeltree/Property_Manager.png"),
"")
# Finally, add the "pwProjectTabWidget" to the left channel layout.
leftChannelVBoxLayout.addWidget(self.pwProjectTabWidget)
# Create the glpane and make it a child of the part splitter.
self.glpane = GLPane(assy, self, 'glpane name', parent)
# note: our owner (MWsemantics) assumes
# there is just this one GLPane for assy, and stores it
# into assy as assy.o and assy.glpane. [bruce 080216 comment]
self.pwProjectTabWidget.KLUGE_setGLPane(self.glpane)
# help fix bug 2522 [bruce 070829]
qt4warnDestruction(self.glpane, 'GLPane of PartWindow')
pwSplitter.addWidget(self.glpane)
# ##################################################################
# <pwBottomArea> is a container at the bottom of the part window
# spanning its entire width. It is intended to be used as an extra
示例10: __init__
#.........这里部分代码省略.........
if dlgEnterSegment.exec_():
segmentText = str(dlgEnterSegment.editSegment.text())
if len(segmentText)>0:
self.segDefList.append(KnownSeg(segmentText))
self.segDefTableModel.updateSegList(self.segDefList)
def addUnknownCaseSegment():
dlgEnterSegment = DlgEnterSegment(main, main)
if dlgEnterSegment.exec_():
segmentText = str(dlgEnterSegment.editSegment.text())
if len(segmentText)>0:
self.segDefList.append(UnknownCaseSeg(segmentText))
self.segDefTableModel.updateSegList(self.segDefList)
def addUnknownOrderSegment():
dlgEnterSegment = DlgEnterSegment(main, main, isUnknownOrder=True)
if dlgEnterSegment.exec_():
segmentText = str(dlgEnterSegment.editSegment.text())
minLen = int(str(dlgEnterSegment.minSelector.currentText()))
maxLen = int(str(dlgEnterSegment.maxSelector.currentText()))
if len(segmentText)>0:
self.segDefList.append(UnknownSeg(segmentText, minLen, maxLen))
self.segDefTableModel.updateSegList(self.segDefList)
def addOrdering():
if len(self.segDefList) > 0:
dlgSpecifyOrdering = DlgSpecifyOrdering(main, main, len(self.segDefList))
if dlgSpecifyOrdering.exec_():
self.segOrdStrSet.add(str(dlgSpecifyOrdering.parseOrderingList()).strip('[]'))
self.updateOrderingListBox()
else:
QMessageBox.warning(self.main, tr('Not Ready'), tr("""
No segments have been entered. You must enter some segments before you can order them."""), QMessageBox.Ok)
self.main = main
self.segDefList = []
self.segOrdStrSet = set()
segmentHeader = QRichLabel(tr("""<b>Build segments for pass phrase search: </b>"""), doWrap=False)
self.knownButton = QPushButton("Add Known Segment")
self.unknownCaseButton = QPushButton("Add Unknown Case Segment")
self.unknownOrderButton = QPushButton("Add Unknown Order Segment")
self.main.connect(self.knownButton, SIGNAL('clicked()'), addKnownSegment)
self.main.connect(self.unknownCaseButton, SIGNAL('clicked()'), addUnknownCaseSegment)
self.main.connect(self.unknownOrderButton, SIGNAL('clicked()'), addUnknownOrderSegment)
topRow = makeHorizFrame([segmentHeader, self.knownButton, self.unknownCaseButton, self.unknownOrderButton, 'stretch'])
self.segDefTableModel = SegDefDisplayModel()
self.segDefTableView = QTableView()
self.segDefTableView.setModel(self.segDefTableModel)
self.segDefTableView.setSelectionBehavior(QTableView.SelectRows)
self.segDefTableView.setSelectionMode(QTableView.SingleSelection)
self.segDefTableView.verticalHeader().setDefaultSectionSize(20)
self.segDefTableView.verticalHeader().hide()
h = tightSizeNChar(self.segDefTableView, 1)[1]
self.segDefTableView.setMinimumHeight(2 * (1.3 * h))
self.segDefTableView.setMaximumHeight(10 * (1.3 * h))
initialColResize(self.segDefTableView, [.1, .2, .4, .1, .1, .1])
self.segDefTableView.customContextMenuRequested.connect(self.showSegContextMenu)
self.segDefTableView.setContextMenuPolicy(Qt.CustomContextMenu)
segmentOrderingsHeader = QRichLabel(tr("""<b>Specify orderings for pass phrase search: </b>"""), doWrap=False)
self.addOrderingButton = QPushButton("Add Ordering")
self.main.connect(self.addOrderingButton, SIGNAL('clicked()'), addOrdering)
orderingButtonPanel = makeHorizFrame([segmentOrderingsHeader, self.addOrderingButton, 'stretch'])
self.segOrdListBox = QListWidget()
self.segOrdListBox.customContextMenuRequested.connect(self.showOrdContextMenu)
self.segOrdListBox.setContextMenuPolicy(Qt.CustomContextMenu)
self.searchButton = QPushButton("Search")
self.main.connect(self.searchButton, SIGNAL('clicked()'), searchForPassphrase)
self.stopButton = QPushButton("Stop Searching")
self.stopButton.setEnabled(False)
self.main.connect(self.stopButton, SIGNAL('clicked()'), endSearch)
totalSearchLabel = QRichLabel(tr("""<b>Total Passphrase Tries To Search: </b>"""), doWrap=False)
self.totalSearchTriesDisplay = QLineEdit()
self.totalSearchTriesDisplay.setReadOnly(True)
self.totalSearchTriesDisplay.setText(QString('0'))
self.totalSearchTriesDisplay.setFont(GETFONT('Fixed'))
self.totalSearchTriesDisplay.setMinimumWidth(tightSizeNChar(self.totalSearchTriesDisplay, 6)[0])
self.totalSearchTriesDisplay.setMaximumWidth(tightSizeNChar(self.totalSearchTriesDisplay, 12)[0])
searchButtonPanel = makeHorizFrame([self.searchButton, self.stopButton, 'stretch', totalSearchLabel, self.totalSearchTriesDisplay])
self.resultsDisplay = QTextEdit()
self.resultsDisplay.setReadOnly(True)
self.resultsDisplay.setFont(GETFONT('Fixed'))
self.resultsDisplay.setMinimumHeight(100)
self.searchPanel = makeVertFrame([topRow, self.segDefTableView, orderingButtonPanel,
self.segOrdListBox, searchButtonPanel, self.resultsDisplay, 'stretch'])
# Now set the scrollarea widget to the layout
self.tabToDisplay = QScrollArea()
self.tabToDisplay.setWidgetResizable(True)
self.tabToDisplay.setWidget(self.searchPanel)
示例11: __init__
#.........这里部分代码省略.........
a160 = CheckHash160(utxo.getRecipientScrAddr())
for pyAddr in self.dustTableModel.wlt.addrMap.values():
if a160 == pyAddr.getAddr160():
pubKey = pyAddr.binPublicKey65.toBinStr()
txoIdx = utxo.getTxOutIndex()
utxiList.append(UnsignedTxInput(rawTx, txoIdx, None, pubKey))
break
# Make copies, destroy them in the finally clause
privKeyMap = {}
for addrObj in self.dustTableModel.wlt.addrMap.values():
scrAddr = SCRADDR_P2PKH_BYTE + addrObj.getAddr160()
if self.dustTableModel.wlt.useEncryption and self.dustTableModel.wlt.isLocked:
# Target wallet is encrypted...
unlockdlg = DlgUnlockWallet(self.dustTableModel.wlt,
self.main, self.main, 'Unlock Wallet to Import')
if not unlockdlg.exec_():
QMessageBox.critical(self, 'Wallet is Locked', \
'Cannot send dust without unlocking the wallet!', \
QMessageBox.Ok)
return
privKeyMap[scrAddr] = addrObj.binPrivKey32_Plain.copy()
signedTx = PyCreateAndSignTx(utxiList,
[],
privKeyMap, SIGHASH_NONE|SIGHASH_ANYONECANPAY )
print "-------------"
print binary_to_hex(signedTx.serialize())
# sock = socket.create_connection(('dust-b-gone.bitcoin.petertodd.org',80))
# sock.send(signedTx.serialize())
# sock.send(b'\n')
# sock.close()
except socket.error as err:
QMessageBox.critical(self.main, tr('Negative Value'), tr("""
Failed to connect to dust-b-gone server: %s""" % err.strerror), QMessageBox.Ok)
except NegativeValueError:
QMessageBox.critical(self.main, tr('Negative Value'), tr("""
You must enter a positive value of at least 0.0000 0001
and less than %s for the dust limit.""" % MAX_DUST_LIMIT_STR), QMessageBox.Ok)
except TooMuchPrecisionError:
QMessageBox.critical(self.main.main, tr('Too much precision'), tr("""
Bitcoins can only be specified down to 8 decimal places.
The smallest unit of a Groestlcoin is 0.0000 0001 GRS.
Please enter a dust limit of at least 0.0000 0001 and less than %s.""" % MAX_DUST_LIMIT_STR), QMessageBox.Ok)
finally:
for scraddr in privKeyMap:
privKeyMap[scraddr].destroy()
self.main = main
self.lblHeader = QRichLabel(tr("""<b>Dust Outputs for Wallet: None Selected</b>"""), doWrap=False)
self.beGoneDustButton = QPushButton("Remove Dust")
self.beGoneDustButton.setEnabled(False)
self.main.connect(self.beGoneDustButton, SIGNAL('clicked()'), sendDust)
topRow = makeHorizFrame([self.lblHeader,'stretch'])
secondRow = makeHorizFrame([self.beGoneDustButton, 'stretch'])
self.dustLimitLabel = QLabel("Max Dust Value (GRS): ")
self.dustLimitText = QLineEdit()
self.dustLimitText.setFont(GETFONT('Fixed'))
self.dustLimitText.setMinimumWidth(tightSizeNChar(self.dustLimitText, 6)[0])
self.dustLimitText.setMaximumWidth(tightSizeNChar(self.dustLimitText, 12)[0])
self.dustLimitText.setAlignment(Qt.AlignRight)
self.dustLimitText.setText(coin2str(DEFAULT_DUST_LIMIT))
self.main.connect(self.dustLimitText, SIGNAL('textChanged(QString)'), updateDustLimit)
limitPanel = makeHorizFrame([self.dustLimitLabel, self.dustLimitText, 'stretch'])
self.dustTableModel = DustDisplayModel()
self.dustTableView = QTableView()
self.dustTableView.setModel(self.dustTableModel)
self.dustTableView.setSelectionMode(QTableView.NoSelection)
self.dustTableView.verticalHeader().setDefaultSectionSize(20)
self.dustTableView.verticalHeader().hide()
h = tightSizeNChar(self.dustTableView, 1)[1]
self.dustTableView.setMinimumHeight(2 * (1.3 * h))
self.dustTableView.setMaximumHeight(10 * (1.3 * h))
initialColResize(self.dustTableView, [100, .7, .3])
self.dustTableView.setContextMenuPolicy(Qt.CustomContextMenu)
self.lblTxioInfo = QRichLabel('')
self.lblTxioInfo.setMinimumWidth(tightSizeNChar(self.lblTxioInfo, 30)[0])
self.main.connect(self.main.walletsView, SIGNAL('clicked(QModelIndex)'),
updateDustLimit)
self.dustBGoneFrame = makeVertFrame([topRow, secondRow, limitPanel, self.dustTableView, 'stretch'])
# Now set the scrollarea widget to the layout
self.tabToDisplay = QScrollArea()
self.tabToDisplay.setWidgetResizable(True)
self.tabToDisplay.setWidget(self.dustBGoneFrame)
示例12: Preferences
class Preferences(QMainWindow):
run_wizard_requested = pyqtSignal()
def __init__(self, gui, initial_plugin=None, close_after_initial=False):
QMainWindow.__init__(self, gui)
self.gui = gui
self.must_restart = False
self.committed = False
self.close_after_initial = close_after_initial
self.resize(930, 720)
nh, nw = min_available_height()-25, available_width()-10
if nh < 0:
nh = 800
if nw < 0:
nw = 600
nh = min(self.height(), nh)
nw = min(self.width(), nw)
self.resize(nw, nh)
self.esc_action = QAction(self)
self.addAction(self.esc_action)
self.esc_action.setShortcut(QKeySequence(Qt.Key_Escape))
self.esc_action.triggered.connect(self.esc)
geom = gprefs.get('preferences_window_geometry', None)
if geom is not None:
self.restoreGeometry(geom)
# Center
if islinux:
self.move(gui.rect().center() - self.rect().center())
self.setWindowModality(Qt.WindowModal)
self.setWindowTitle(__appname__ + ' - ' + _('Preferences'))
self.setWindowIcon(QIcon(I('config.png')))
self.status_bar = StatusBar(self)
self.setStatusBar(self.status_bar)
self.stack = QStackedWidget(self)
self.cw = QWidget(self)
self.cw.setLayout(QVBoxLayout())
self.cw.layout().addWidget(self.stack)
self.bb = QDialogButtonBox(QDialogButtonBox.Close)
self.wizard_button = self.bb.addButton(_('Run welcome wizard'),
self.bb.ActionRole)
self.wizard_button.setIcon(QIcon(I('wizard.png')))
self.wizard_button.clicked.connect(self.run_wizard,
type=Qt.QueuedConnection)
self.cw.layout().addWidget(self.bb)
self.bb.button(self.bb.Close).setDefault(True)
self.bb.rejected.connect(self.close, type=Qt.QueuedConnection)
self.setCentralWidget(self.cw)
self.browser = Browser(self)
self.browser.show_plugin.connect(self.show_plugin)
self.stack.addWidget(self.browser)
self.scroll_area = QScrollArea(self)
self.stack.addWidget(self.scroll_area)
self.scroll_area.setWidgetResizable(True)
self.bar = QToolBar(self)
self.addToolBar(self.bar)
self.bar.setVisible(False)
self.bar.setIconSize(QSize(ICON_SIZE, ICON_SIZE))
self.bar.setMovable(False)
self.bar.setFloatable(False)
self.bar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
self.apply_action = self.bar.addAction(QIcon(I('ok.png')), _('&Apply'),
self.commit)
self.cancel_action = self.bar.addAction(QIcon(I('window-close.png')),
_('&Cancel'), self.cancel)
self.bar_title = BarTitle(self.bar)
self.bar.addWidget(self.bar_title)
self.restore_action = self.bar.addAction(QIcon(I('clear_left.png')),
_('Restore &defaults'), self.restore_defaults)
for ac, tt in [('apply', _('Save changes')),
('cancel', _('Cancel and return to overview'))]:
ac = getattr(self, ac+'_action')
ac.setToolTip(tt)
ac.setWhatsThis(tt)
ac.setStatusTip(tt)
for ch in self.bar.children():
if isinstance(ch, QToolButton):
ch.setCursor(Qt.PointingHandCursor)
ch.setAutoRaise(True)
self.stack.setCurrentIndex(0)
if initial_plugin is not None:
category, name = initial_plugin
plugin = get_plugin(category, name)
if plugin is not None:
self.show_plugin(plugin)
def run_wizard(self):
self.close()
self.run_wizard_requested.emit()
#.........这里部分代码省略.........
示例13: PluginObject
#.........这里部分代码省略.........
i+=1
mainLayout.addItem(QSpacerItem(15,15), i,0)
mainLayout.addWidget(self.lblSellLabel, i,1)
mainLayout.addWidget(self.lblSellPrice, i,2)
i+=1
mainLayout.addItem(QSpacerItem(15,15), i,0)
mainLayout.addWidget(self.lblBuyLabel, i,1)
mainLayout.addWidget(self.lblBuyPrice, i,2)
i+=1
mainLayout.addWidget(self.lblLastTime, i,0, 1,2)
mainLayout.addWidget(self.btnUpdate, i,2)
i+=1
mainLayout.addItem(QSpacerItem(20,20), i,0)
i+=1
mainLayout.addWidget(frmCalc, i,0, 1,3)
i+=1
mainLayout.addItem(QSpacerItem(30,30), i,0)
i+=1
mainLayout.addWidget(lblWltTableTitle, i,0, 1,3)
i+=1
mainLayout.addWidget(self.wltTable, i,0, 1,3)
mainLayout.setColumnStretch(0,0)
mainLayout.setColumnStretch(1,1)
mainLayout.setColumnStretch(2,1)
tabWidget = QWidget()
tabWidget.setLayout(mainLayout)
frmH = makeHorizFrame(['Stretch', tabWidget, 'Stretch'])
frm = makeVertFrame(['Space(20)', frmH, 'Stretch'])
# Now set the scrollarea widget to the layout
self.tabToDisplay = QScrollArea()
self.tabToDisplay.setWidgetResizable(True)
self.tabToDisplay.setWidget(frm)
#############################################################################
def getTabToDisplay(self):
return self.tabToDisplay
#############################################################################
def addCommasToPrice(self, pstr):
dispStr = pstr.strip().split('.')[0]
dispStr = ','.join([dispStr[::-1][3*i:3*(i+1)][::-1] \
for i in range((len(dispStr)-1)/3+1)][::-1])
if '.' in pstr:
dispStr = dispStr + '.' + pstr.split('.')[1]
return dispStr
#############################################################################
def fetchFormattedPrice(self, url):
sock = urllib2.urlopen(url)
value = ast.literal_eval(sock.read())['subtotal']['amount']
return self.addCommasToPrice(value)
#############################################################################
def checkUpdatePrice(self):
urlBase = 'http://coinbase.com/api/v1/prices/'
urlSell = urlBase + 'sell'
示例14: __init__
#.........这里部分代码省略.........
pwSplitter.addWidget(pwLeftArea)
# Makes it so pwLeftArea is not collapsible.
pwSplitter.setCollapsible (0, False)
# ##################################################################
# <pwProjectTabWidget> is a QTabWidget that contains the MT and PM
# widgets. It lives in the "left area" of the part window.
self.pwProjectTabWidget = _pwProjectTabWidget()
# _pwProjectTabWidget subclasses QTabWidget
# Note [bruce 070829]: to fix bug 2522 I need to intercept
# self.pwProjectTabWidget.removeTab, so I made it a subclass of
# QTabWidget. It needs to know the GLPane, but that's not created
# yet, so we set it later using KLUGE_setGLPane (below).
# Note: No parent supplied. Could this be the source of the
# minor vsplitter resizing problem I was trying to resolve a few
# months ago? Try supplying a parent later. Mark 2008-01-01
self.pwProjectTabWidget.setObjectName("pwProjectTabWidget")
self.pwProjectTabWidget.setCurrentIndex(0)
self.pwProjectTabWidget.setAutoFillBackground(True)
# Create the model tree "tab" widget. It will contain the MT GUI widget.
# Set the tab icon, too.
self.modelTreeTab = QWidget()
self.modelTreeTab.setObjectName("modelTreeTab")
self.pwProjectTabWidget.addTab(
self.modelTreeTab,
geticon("ui/modeltree/Model_Tree.png"),
"")
modelTreeTabLayout = QVBoxLayout(self.modelTreeTab)
modelTreeTabLayout.setMargin(0)
modelTreeTabLayout.setSpacing(0)
# Create the model tree (GUI) and add it to the tab layout.
self.modelTree = modelTree(self.modelTreeTab, parent)
self.modelTree.modelTreeGui.setObjectName("modelTreeGui")
modelTreeTabLayout.addWidget(self.modelTree.modelTreeGui)
# Create the property manager "tab" widget. It will contain the PropMgr
# scroll area, which will contain the property manager and all its
# widgets.
self.propertyManagerTab = QWidget()
self.propertyManagerTab.setObjectName("propertyManagerTab")
self.propertyManagerScrollArea = QScrollArea(self.pwProjectTabWidget)
self.propertyManagerScrollArea.setObjectName("propertyManagerScrollArea")
self.propertyManagerScrollArea.setWidget(self.propertyManagerTab)
self.propertyManagerScrollArea.setWidgetResizable(True)
# Eureka!
# setWidgetResizable(True) will resize the Property Manager (and its
# contents) correctly when the scrollbar appears/disappears.
# It even accounts correctly for collapsed/expanded groupboxes!
# Mark 2007-05-29
# Add the property manager scroll area as a "tabbed" widget.
# Set the tab icon, too.
self.pwProjectTabWidget.addTab(
self.propertyManagerScrollArea,
geticon("ui/modeltree/Property_Manager.png"),
"")
# Finally, add the "pwProjectTabWidget" to the left channel layout.
leftChannelVBoxLayout.addWidget(self.pwProjectTabWidget)
# Create the glpane and make it a child of the part splitter.
self.glpane = GLPane(assy, self, 'glpane name', parent)
# note: our owner (MWsemantics) assumes
# there is just this one GLPane for assy, and stores it
# into assy as assy.o and assy.glpane. [bruce 080216 comment]
self.pwProjectTabWidget.KLUGE_setGLPane(self.glpane)
# help fix bug 2522 [bruce 070829]
qt4warnDestruction(self.glpane, 'GLPane of PartWindow')
pwSplitter.addWidget(self.glpane)
# ##################################################################
# <pwBottomArea> is a container at the bottom of the part window
# spanning its entire width. It is intended to be used as an extra
# area for use by Property Managers (or anything else) that needs
# a landscape oriented layout.
# An example is the Sequence Editor, which is part of the
# Strand Properties PM.
self.pwBottomArea = QFrame()
# IMHO, self is not a good parent. Mark 2008-01-04.
pwBottomArea = self.pwBottomArea
pwBottomArea.setObjectName("pwBottomArea")
pwBottomArea.setMaximumHeight(50)
pwBottomArea.setSizePolicy(
QSizePolicy(QSizePolicy.Policy(QSizePolicy.Expanding),
QSizePolicy.Policy(QSizePolicy.Fixed)))
# Add a frame border to see what it looks like.
pwBottomArea.setFrameStyle( QFrame.Panel | QFrame.Sunken )
self.pwVBoxLayout.addWidget(pwBottomArea)
# Hide the bottom frame for now. Later this might be used for the
# sequence editor.
pwBottomArea.hide()
示例15: __init__
#.........这里部分代码省略.........
##########################################################################
##### Display the conversion values based on the Coinbase API
self.lastPriceFetch = 0
self.lblHeader = QRichLabel(tr("""<b>Tracking buy and sell prices on
Coinbase every 60 seconds</b>"""), doWrap=False)
self.lblLastTime = QRichLabel('', doWrap=False)
self.lblSellLabel = QRichLabel(tr('Coinbase <b>Sell</b> Price (USD):'), doWrap=False)
self.lblBuyLabel = QRichLabel(tr('Coinbase <b>Buy</b> Price (USD):'), doWrap=False)
self.lblSellPrice = QRichLabel('<Not Available>')
self.lblBuyPrice = QRichLabel('<Not Available>')
self.lastSellStr = ''
self.lastBuyStr = ''
self.btnUpdate = QPushButton(tr('Check Now'))
self.main.connect(self.btnUpdate, SIGNAL('clicked()'), self.checkUpdatePrice)
##########################################################################
##### A calculator for converting prices between USD and BTC
lblCalcTitle = QRichLabel(tr("""Convert between USD and BTC using
Coinbase sell price"""), hAlign=Qt.AlignHCenter, doWrap=False)
self.edtEnterUSD = QLineEdit()
self.edtEnterBTC = QLineEdit()
self.lblEnterUSD1 = QRichLabel('$')
self.lblEnterUSD2 = QRichLabel('USD')
self.lblEnterBTC = QRichLabel('BTC')
btnClear = QPushButton('Clear')
self.main.connect(self.edtEnterUSD, SIGNAL('textEdited(QString)'), self.updateCalcBTC)
self.main.connect(self.edtEnterBTC, SIGNAL('textEdited(QString)'), self.updateCalcUSD)
def clearCalc():
self.edtEnterUSD.setText('')
self.edtEnterBTC.setText('')
self.main.connect(btnClear, SIGNAL('clicked()'), clearCalc)
frmCalcMid = makeHorizFrame( [self.lblEnterUSD1,
self.edtEnterUSD,
self.lblEnterUSD2,
'Stretch',
self.edtEnterBTC,
self.lblEnterBTC])
frmCalcClear = makeHorizFrame(['Stretch', btnClear, 'Stretch'])
frmCalc = makeVertFrame([lblCalcTitle, frmCalcMid, frmCalcClear], STYLE_PLAIN)
##########################################################################
##### A table showing you the total balance of each wallet in USD and BTC
lblWltTableTitle = QRichLabel(tr("Wallet balances converted to USD"),
doWrap=False, hAlign=Qt.AlignHCenter)
numWallets = len(self.main.walletMap)
self.wltTable = QTableWidget(self.main)
self.wltTable.setRowCount(numWallets)
self.wltTable.setColumnCount(4)
self.wltTable.horizontalHeader().setStretchLastSection(True)
self.wltTable.setMinimumWidth(600)
##########################################################################
##### Setup the main layout for the tab
mainLayout = QGridLayout()
i=0
mainLayout.addWidget(self.lblHeader, i,0, 1,3)
i+=1
mainLayout.addItem(QSpacerItem(15,15), i,0)
mainLayout.addWidget(self.lblSellLabel, i,1)
mainLayout.addWidget(self.lblSellPrice, i,2)
i+=1
mainLayout.addItem(QSpacerItem(15,15), i,0)
mainLayout.addWidget(self.lblBuyLabel, i,1)
mainLayout.addWidget(self.lblBuyPrice, i,2)
i+=1
mainLayout.addWidget(self.lblLastTime, i,0, 1,2)
mainLayout.addWidget(self.btnUpdate, i,2)
i+=1
mainLayout.addItem(QSpacerItem(20,20), i,0)
i+=1
mainLayout.addWidget(frmCalc, i,0, 1,3)
i+=1
mainLayout.addItem(QSpacerItem(30,30), i,0)
i+=1
mainLayout.addWidget(lblWltTableTitle, i,0, 1,3)
i+=1
mainLayout.addWidget(self.wltTable, i,0, 1,3)
mainLayout.setColumnStretch(0,0)
mainLayout.setColumnStretch(1,1)
mainLayout.setColumnStretch(2,1)
tabWidget = QWidget()
tabWidget.setLayout(mainLayout)
frmH = makeHorizFrame(['Stretch', tabWidget, 'Stretch'])
frm = makeVertFrame(['Space(20)', frmH, 'Stretch'])
# Now set the scrollarea widget to the layout
self.tabToDisplay = QScrollArea()
self.tabToDisplay.setWidgetResizable(True)
self.tabToDisplay.setWidget(frm)