本文整理汇总了Python中PySide.QtGui.QFrame.setLayout方法的典型用法代码示例。如果您正苦于以下问题:Python QFrame.setLayout方法的具体用法?Python QFrame.setLayout怎么用?Python QFrame.setLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QFrame
的用法示例。
在下文中一共展示了QFrame.setLayout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createDisplayFields
# 需要导入模块: from PySide.QtGui import QFrame [as 别名]
# 或者: from PySide.QtGui.QFrame import setLayout [as 别名]
def createDisplayFields(self):
display_widget = QFrame()
display_widget.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Sunken)
self.left_layout.addWidget(display_widget)
self.display_layout = QHBoxLayout()
# self.turn = self.transcript.current_turn()
self.time_field = qHotField("time", str, "00:00:00", min_size=75, max_size=75, pos="top", handler=self.update_time)
self.display_layout.addWidget(self.time_field)
self.speaker_field = qHotField("speaker", str, " ", min_size=75, max_size=75, pos="top", handler=self.update_speaker)
self.display_layout.addWidget(self.speaker_field)
self.utt_field = qHotField("utterance", str, " ", min_size=350, max_size=500, pos="top", handler=self.update_utterance, multiline=True)
self.utt_field.setStyleSheet("font: 14pt \"Courier\";")
# self.utt_field.efield.setFont(QFont('SansSerif', 12))
self.display_layout.addWidget(self.utt_field)
display_widget.setLayout(self.display_layout)
self.display_layout.setStretchFactor(self.speaker_field, 0)
self.display_layout.setStretchFactor(self.utt_field, 1)
self.transcript_slider = QSlider(QtCore.Qt.Horizontal, self)
self.display_layout.addWidget(self.transcript_slider)
self.transcript_slider.setMaximum(100)
self.connect(self.transcript_slider,
QtCore.SIGNAL("sliderMoved(int)"), self.position_transcript)
self.left_layout.addWidget(self.transcript_slider)
示例2: __init__
# 需要导入模块: from PySide.QtGui import QFrame [as 别名]
# 或者: from PySide.QtGui.QFrame import setLayout [as 别名]
def __init__(self, sync_manager, network_access_manager, url=None, username=None, password=None, certificate=""):
self.sync_manager = sync_manager
self.nam = network_access_manager
self.certificate = certificate
self.replies = set()
super(SettingsWindow, self).__init__()
self.setWindowIcon(QIcon(os.path.join('icons', 'Logo_sync.png')))
self.setGeometry(70, 60, 300, 250)
self.setWindowTitle("c't SESAM Sync Settings")
layout = QBoxLayout(QBoxLayout.TopToBottom)
layout.setContentsMargins(0, 0, 0, 0)
# Header bar
header_bar = QFrame()
header_bar.setStyleSheet("QWidget { background: rgb(40, 40, 40); } " +
"QToolButton { background: rgb(40, 40, 40); }" +
"QToolTip { color: rgb(255, 255, 255); background-color: rgb(20, 20, 20); " +
"border: 1px solid white; }")
header_bar.setAutoFillBackground(True)
header_bar.setFixedHeight(45)
header_bar_layout = QBoxLayout(QBoxLayout.RightToLeft)
header_bar_layout.addStretch()
header_bar.setLayout(header_bar_layout)
layout.addWidget(header_bar)
self.create_header_bar(header_bar_layout)
self.certificate_loaded.connect(self.test_connection)
# Main area
main_area = QFrame()
main_layout = QBoxLayout(QBoxLayout.TopToBottom)
main_area.setLayout(main_layout)
layout.addWidget(main_area)
self.create_main_area(main_layout, url, username, password)
# Show the window
layout.addStretch()
self.setLayout(layout)
self.show()
示例3: BorderBox
# 需要导入模块: from PySide.QtGui import QFrame [as 别名]
# 或者: from PySide.QtGui.QFrame import setLayout [as 别名]
def BorderBox(self, layout):
from PySide.QtGui import QFrame
toto = QFrame()
toto.setLayout(layout)
toto.setFrameShape(QFrame.Box)
toto.setFrameShadow(QFrame.Sunken)
return toto
示例4: init_notebooks
# 需要导入模块: from PySide.QtGui import QFrame [as 别名]
# 或者: from PySide.QtGui.QFrame import setLayout [as 别名]
def init_notebooks(self):
frame = QFrame()
layout = QVBoxLayout()
frame.setLayout(layout)
self.ui.scrollArea.setWidget(frame)
for notebook_struct in self.app.provider.list_notebooks():
notebook = Notebook.from_tuple(notebook_struct)
count = self.app.provider.get_notebook_notes_count(notebook.id)
widget = QWidget()
menu = QMenu(self)
menu.addAction(self.tr('Change Name'), Slot()(partial(
self.change_notebook, notebook=notebook,
)))
action = menu.addAction(self.tr('Remove Notebook'), Slot()(partial(
self.remove_notebook, notebook=notebook,
)))
action.setEnabled(False)
widget.ui = Ui_Notebook()
widget.ui.setupUi(widget)
widget.ui.name.setText(notebook.name)
widget.ui.content.setText(self.tr('Containts %d notes') % count)
widget.ui.actionBtn.setIcon(QIcon.fromTheme('gtk-properties'))
widget.setFixedHeight(50)
layout.addWidget(widget)
widget.ui.actionBtn.clicked.connect(Slot()(partial(
self.show_notebook_menu,
menu=menu, widget=widget,
)))
示例5: new_tab
# 需要导入模块: from PySide.QtGui import QFrame [as 别名]
# 或者: from PySide.QtGui.QFrame import setLayout [as 别名]
def new_tab(self):
"""Open new tab."""
tasklist = QTreeView()
tasklist.hide()
tasklist.setObjectName('taskList')
tasklist.setMinimumWidth(100)
tasklist.setMaximumWidth(250)
new_tab = QWebView()
new_tab.setObjectName('webView')
inspector = QWebInspector(self)
inspector.setObjectName('webInspector')
inspector.hide()
page_layout = QVBoxLayout()
page_layout.setSpacing(0)
page_layout.setContentsMargins(0, 0, 0, 0)
page_layout.addWidget(new_tab)
page_layout.addWidget(inspector)
page_widget = QFrame()
page_widget.setObjectName('pageWidget')
page_widget.setLayout(page_layout)
complete_tab_layout = QHBoxLayout()
complete_tab_layout.setSpacing(0)
complete_tab_layout.setContentsMargins(0, 0, 0, 0)
complete_tab_layout.addWidget(tasklist)
complete_tab_layout.addWidget(page_widget)
complete_tab_widget = QFrame()
complete_tab_widget.setLayout(complete_tab_layout)
new_tab.load(QUrl(self.startpage))
self.tabs.setUpdatesEnabled(False)
if self.new_tab_behavior == "insert":
self.tabs.insertTab(self.tabs.currentIndex()+1, complete_tab_widget,
unicode(new_tab.title()))
elif self.new_tab_behavior == "append":
self.tabs.appendTab(complete_tab_widget, unicode(new_tab.title()))
self.tabs.setCurrentWidget(complete_tab_widget)
self.tabs.setTabText(self.tabs.currentIndex(),
unicode(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).title()))
self.tabs.setUpdatesEnabled(True)
# tab.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
# tab.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
new_tab.titleChanged.connect(self.change_tab)
new_tab.urlChanged.connect(self.change_tab)
new_tab.loadStarted.connect(self.load_start)
new_tab.loadFinished.connect(self.load_finish)
new_tab.loadProgress.connect(self.pbar.setValue)
new_tab.page().linkHovered.connect(self.linkHover)
inspector.setPage(new_tab.page())
示例6: __init__
# 需要导入模块: from PySide.QtGui import QFrame [as 别名]
# 或者: from PySide.QtGui.QFrame import setLayout [as 别名]
def __init__(self):
super(MainWindow, self).__init__()
self.nam = QNetworkAccessManager()
self.setWindowIcon(QIcon(os.path.join('icons', 'Logo_rendered_edited.png')))
layout = QBoxLayout(QBoxLayout.TopToBottom)
layout.setContentsMargins(0, 0, 0, 0)
self.preference_manager = PreferenceManager()
self.kgk_manager = KgkManager()
self.kgk_manager.set_preference_manager(self.preference_manager)
self.settings_manager = PasswordSettingsManager(self.preference_manager)
self.setting_dirty = True
# Header bar
header_bar = QFrame()
header_bar.setStyleSheet(
"QWidget { background: rgb(40, 40, 40); } " +
"QToolButton { background: rgb(40, 40, 40); }" +
"QToolTip { color: rgb(255, 255, 255); background-color: rgb(20, 20, 20); " +
"border: 1px solid white; }")
header_bar.setAutoFillBackground(True)
header_bar.setFixedHeight(45)
header_bar_layout = QBoxLayout(QBoxLayout.LeftToRight)
header_bar_layout.addStretch()
header_bar.setLayout(header_bar_layout)
layout.addWidget(header_bar)
self.create_header_bar(header_bar_layout)
# Widget area
main_area = QFrame()
main_layout = QBoxLayout(QBoxLayout.TopToBottom)
main_area.setLayout(main_layout)
layout.addWidget(main_area)
self.create_main_area(main_layout)
# Window layout
layout.addStretch()
main_layout.addStretch()
self.setLayout(layout)
settings = QSettings()
size = settings.value("MainWindow/size")
if not size:
size = QSize(350, 450)
self.resize(size)
position = settings.value("MainWindow/pos")
if not position:
position = QPoint(0, 24)
self.move(position)
self.setWindowTitle("c't SESAM")
self.master_password_edit.setFocus()
self.show()
示例7: __init__
# 需要导入模块: from PySide.QtGui import QFrame [as 别名]
# 或者: from PySide.QtGui.QFrame import setLayout [as 别名]
def __init__(self, parent, app, widget, on_change):
"""Init and connect signals"""
self.parent = parent
self.app = app
self.widget = widget
self.note = None
self.on_change = on_change
self._resource_labels = {}
self._resources = []
self._res_hash = {}
frame = QFrame()
frame.setLayout(QVBoxLayout())
frame.setFixedWidth(100)
self.widget.setFixedWidth(100)
self.widget.setWidget(frame)
self.widget.hide()
self.mime = magic.open(magic.MIME_TYPE)
self.mime.load()
示例8: init_msh_ui
# 需要导入模块: from PySide.QtGui import QFrame [as 别名]
# 或者: from PySide.QtGui.QFrame import setLayout [as 别名]
def init_msh_ui(self):
comps = QGroupBox('Components')
mdlgr = QGroupBox('Models - {0}'.format(self.mdlmanager.count()))
mdllay = QVBoxLayout()
mdllay.addWidget(self.mdlmanager.get_frame())
#mdllay.addStretch()
mdlgr.setLayout(mdllay)
matgr = QGroupBox('Materials - {0}'.format(self.matmanager.count()))
matlay = QVBoxLayout()
matlay.addWidget(self.matmanager.get_frame())
#matlay.addStretch()
matgr.setLayout(matlay)
frame2lay = QHBoxLayout()
frame2lay.addWidget(matgr)
frame2lay.addWidget(mdlgr)
comps.setLayout(frame2lay)
# Misc stuff.
self.setGeometry(200, 100, WIDTH_MSH, HEIGHT_MSH)
frame = QFrame()
framelay = QVBoxLayout()
framelay.addWidget(self.infomanager.get_frame())
framelay.addWidget(comps)
#framelay.addStretch()
load = QPushButton('Open')
load.clicked.connect(self.load_msh)
save = QPushButton('Save')
save.clicked.connect(self.save)
close = QPushButton('Close')
close.clicked.connect(self.close)
btnlay = QHBoxLayout()
btnlay.addWidget(QLabel('<b>MSH Suite</b> Version {0}'.format(SUITE_VER)))
btnlay.addStretch()
btnlay.addWidget(load)
btnlay.addWidget(save)
btnlay.addWidget(close)
framelay.addLayout(btnlay)
frame.setLayout(framelay)
self.setCentralWidget(frame)
self.setWindowTitle('MSH Suite - {0}'.format(self.msh.info.name))
示例9: _view_server
# 需要导入模块: from PySide.QtGui import QFrame [as 别名]
# 或者: from PySide.QtGui.QFrame import setLayout [as 别名]
def _view_server(kwargs, queue):
from PySide.QtGui import QApplication, QMainWindow, QFrame, QGridLayout
from RubikView import RubikView
# Grab the partition to view from the queue.
app = QApplication(sys.argv)
frame = QFrame()
layout = QGridLayout()
frame.setLayout(layout)
mainwindow = QMainWindow()
mainwindow.setCentralWidget(frame)
mainwindow.resize(1024, 768)
mainwindow.move(30, 30)
# Find next highest square number and fill within that shape
partitions = queue.get()
side = math.ceil(math.sqrt(len(partitions)))
aspect = (side, side)
views = []
for i, partition in enumerate(partitions):
rview = RubikView(mainwindow)
if "renderer" in kwargs:
rview.set_face_renderer(kwargs["renderer"])
else:
rview.set_face_renderer(colored_face_renderer(**kwargs))
rview.set_partition(partition)
r, c = np.unravel_index(i, aspect)
layout.addWidget(rview, r, c)
views.append(rview)
mainwindow.show()
mainwindow.raise_()
rotation = kwargs.get("rotation", (45, 3, 3, 1))
for rview in views:
rview.set_rotation_quaternion(*rotation)
app.exec_()
示例10: initUI
# 需要导入模块: from PySide.QtGui import QFrame [as 别名]
# 或者: from PySide.QtGui.QFrame import setLayout [as 别名]
def initUI(self):
open_msh_btn = QPushButton('Open .MSH...')
open_msh_btn.clicked.connect(self.load_msh)
open_msh_btn.setToolTip('<b>Loads a .MSH file</b> for editing.')
dump_msh_btn = QPushButton('Dump .MSH...')
dump_msh_btn.clicked.connect(self.dump_msh)
dump_msh_btn.setToolTip('<b>Dumps .MSH file information</b> into a text file.')
munge_anim_btn = QPushButton('Munge Animation')
munge_anim_btn.clicked.connect(self.munge_anim)
munge_anim_btn.setToolTip('<b>Launches the AnimMunger.</b>')
buttonslay = QGridLayout()
buttonslay.addWidget(open_msh_btn, 1, 1)
buttonslay.addWidget(dump_msh_btn, 1, 3)
buttonslay.addWidget(munge_anim_btn, 3, 1)
frame = QFrame()
frame.setLayout(buttonslay)
self.setCentralWidget(frame)
self.setGeometry(200, 100, WIDTH_LAUNCH, HEIGHT_LAUNCH)
self.setWindowTitle('MSH Suite')
self.show()
示例11: __init__
# 需要导入模块: from PySide.QtGui import QFrame [as 别名]
# 或者: from PySide.QtGui.QFrame import setLayout [as 别名]
def __init__(self):
super(MainWindow, self).__init__()
self.clip_filename = None
self.audio_filename = None
layout = QBoxLayout(QBoxLayout.TopToBottom)
clip_row = QBoxLayout(QBoxLayout.LeftToRight)
self.clip_button = QPushButton()
self.clip_button.clicked.connect(self.open_clip)
self.clip_button.setText(self.tr("Open clip"))
clip_row.addWidget(self.clip_button)
self.clip_view = QLabel()
clip_row.addWidget(self.clip_view)
clip_frame = QFrame()
clip_frame.setLayout(clip_row)
layout.addWidget(clip_frame)
audio_row = QBoxLayout(QBoxLayout.LeftToRight)
self.audio_button = QPushButton()
self.audio_button.clicked.connect(self.open_audio)
self.audio_button.setText(self.tr("Open audio"))
audio_row.addWidget(self.audio_button)
self.audio_view = QLabel()
audio_row.addWidget(self.audio_view)
audio_frame = QFrame()
audio_frame.setLayout(audio_row)
layout.addWidget(audio_frame)
save_row = QBoxLayout(QBoxLayout.LeftToRight)
self.save_button = QPushButton()
self.save_button.clicked.connect(self.save)
self.save_button.setText(self.tr("Save synced clip"))
save_row.addWidget(self.save_button)
save_frame = QFrame()
save_frame.setLayout(save_row)
layout.addWidget(save_frame)
self.update_save_button()
layout.addStretch()
self.setLayout(layout)
self.show()
示例12: __init__
# 需要导入模块: from PySide.QtGui import QFrame [as 别名]
# 或者: from PySide.QtGui.QFrame import setLayout [as 别名]
def __init__(self, parent=None):
"""Initialize the parent class of this instance."""
super(window, self).__init__(parent)
app.aboutToQuit.connect(self.myExitHandler)
self.style_sheet = self.styleSheet('style')
# app.setStyle(QStyleFactory.create('Macintosh'))
#app.setStyleSheet(self.style_sheet)
self.layout().setSpacing(0)
self.layout().setContentsMargins(0,0,0,0)
app.setOrganizationName("Eivind Arvesen")
app.setOrganizationDomain("https://github.com/eivind88/raskolnikov")
app.setApplicationName("Raskolnikov")
app.setApplicationVersion("0.0.1")
settings = QSettings()
self.data_location = QDesktopServices.DataLocation
self.temp_location = QDesktopServices.TempLocation
self.cache_location = QDesktopServices.CacheLocation
self.startpage = "https://duckduckgo.com/"
self.new_tab_behavior = "insert"
global bookmarks
global saved_tabs
print "Currently saved_tabs:\n", saved_tabs
global menubar
menubar = QMenuBar()
# Initialize a statusbar for the window
self.statusbar = self.statusBar()
self.statusbar.setFont(QFont("Helvetica Neue", 11, QFont.Normal))
self.statusbar.setStyleSheet(self.style_sheet)
self.statusbar.setMinimumHeight(15)
self.pbar = QProgressBar()
self.pbar.setMaximumWidth(100)
self.statusbar.addPermanentWidget(self.pbar)
self.statusbar.hide()
self.setMinimumSize(504, 235)
# self.setWindowModified(True)
# app.alert(self, 0)
self.setWindowTitle("Raskolnikov")
# toolbar = self.addToolBar('Toolbar')
# toolbar.addAction(exitAction)
# self.setUnifiedTitleAndToolBarOnMac(True)
self.setWindowIcon(QIcon(""))
# Create input widgets
self.bbutton = QPushButton(u"<")
self.fbutton = QPushButton(u">")
self.hbutton = QPushButton(u"⌂")
self.edit = QLineEdit("")
self.edit.setFont(QFont("Helvetica Neue", 12, QFont.Normal))
self.edit.setPlaceholderText("Enter URL")
# self.edit.setMinimumSize(400, 24)
self.rbutton = QPushButton(u"↻")
self.dbutton = QPushButton(u"☆")
self.tbutton = QPushButton(u"⁐")
# ↆ ⇧ √ ⌘ ⏎ ⏏ ⚠ ✓ ✕ ✖ ✗ ✘ ::: ❤ ☮ ☢ ☠ ✔ ☑ ♥ ✉ ☣ ☤ ✘ ☒ ♡ ツ ☼ ☁ ❅ ✎
self.nbutton = QPushButton(u"+")
self.nbutton.setObjectName("NewTab")
self.nbutton.setMinimumSize(35, 30)
self.nbutton.setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Minimum)
self.edit.setTextMargins(2, 1, 2, 0)
# create a horizontal layout for the input
input_layout = QHBoxLayout()
input_layout.setSpacing(4)
input_layout.setContentsMargins(0, 0, 0, 0)
# add the input widgets to the input layout
input_layout.addWidget(self.bbutton)
input_layout.addWidget(self.fbutton)
input_layout.addWidget(self.hbutton)
input_layout.addWidget(self.edit)
input_layout.addWidget(self.rbutton)
input_layout.addWidget(self.dbutton)
input_layout.addWidget(self.tbutton)
# create a widget to hold the input layout
self.input_widget = QFrame()
self.input_widget.setObjectName("InputWidget")
self.input_widget.setStyleSheet(self.style_sheet)
# set the layout of the widget
self.input_widget.setLayout(input_layout)
self.input_widget.setVisible(True)
# CREATE BOOKMARK-LINE HERE
self.bookmarks_layout = QHBoxLayout()
self.bookmarks_layout.setSpacing(0)
self.bookmarks_layout.setContentsMargins(0, 0, 0, 0)
#.........这里部分代码省略.........
示例13: window
# 需要导入模块: from PySide.QtGui import QFrame [as 别名]
# 或者: from PySide.QtGui.QFrame import setLayout [as 别名]
class window(QMainWindow):
"""Main window."""
def __init__(self, parent=None):
"""Initialize the parent class of this instance."""
super(window, self).__init__(parent)
app.aboutToQuit.connect(self.myExitHandler)
self.style_sheet = self.styleSheet('style')
# app.setStyle(QStyleFactory.create('Macintosh'))
#app.setStyleSheet(self.style_sheet)
self.layout().setSpacing(0)
self.layout().setContentsMargins(0,0,0,0)
app.setOrganizationName("Eivind Arvesen")
app.setOrganizationDomain("https://github.com/eivind88/raskolnikov")
app.setApplicationName("Raskolnikov")
app.setApplicationVersion("0.0.1")
settings = QSettings()
self.data_location = QDesktopServices.DataLocation
self.temp_location = QDesktopServices.TempLocation
self.cache_location = QDesktopServices.CacheLocation
self.startpage = "https://duckduckgo.com/"
self.new_tab_behavior = "insert"
global bookmarks
global saved_tabs
print "Currently saved_tabs:\n", saved_tabs
global menubar
menubar = QMenuBar()
# Initialize a statusbar for the window
self.statusbar = self.statusBar()
self.statusbar.setFont(QFont("Helvetica Neue", 11, QFont.Normal))
self.statusbar.setStyleSheet(self.style_sheet)
self.statusbar.setMinimumHeight(15)
self.pbar = QProgressBar()
self.pbar.setMaximumWidth(100)
self.statusbar.addPermanentWidget(self.pbar)
self.statusbar.hide()
self.setMinimumSize(504, 235)
# self.setWindowModified(True)
# app.alert(self, 0)
self.setWindowTitle("Raskolnikov")
# toolbar = self.addToolBar('Toolbar')
# toolbar.addAction(exitAction)
# self.setUnifiedTitleAndToolBarOnMac(True)
self.setWindowIcon(QIcon(""))
# Create input widgets
self.bbutton = QPushButton(u"<")
self.fbutton = QPushButton(u">")
self.hbutton = QPushButton(u"⌂")
self.edit = QLineEdit("")
self.edit.setFont(QFont("Helvetica Neue", 12, QFont.Normal))
self.edit.setPlaceholderText("Enter URL")
# self.edit.setMinimumSize(400, 24)
self.rbutton = QPushButton(u"↻")
self.dbutton = QPushButton(u"☆")
self.tbutton = QPushButton(u"⁐")
# ↆ ⇧ √ ⌘ ⏎ ⏏ ⚠ ✓ ✕ ✖ ✗ ✘ ::: ❤ ☮ ☢ ☠ ✔ ☑ ♥ ✉ ☣ ☤ ✘ ☒ ♡ ツ ☼ ☁ ❅ ✎
self.nbutton = QPushButton(u"+")
self.nbutton.setObjectName("NewTab")
self.nbutton.setMinimumSize(35, 30)
self.nbutton.setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Minimum)
self.edit.setTextMargins(2, 1, 2, 0)
# create a horizontal layout for the input
input_layout = QHBoxLayout()
input_layout.setSpacing(4)
input_layout.setContentsMargins(0, 0, 0, 0)
# add the input widgets to the input layout
input_layout.addWidget(self.bbutton)
input_layout.addWidget(self.fbutton)
input_layout.addWidget(self.hbutton)
input_layout.addWidget(self.edit)
input_layout.addWidget(self.rbutton)
input_layout.addWidget(self.dbutton)
input_layout.addWidget(self.tbutton)
# create a widget to hold the input layout
self.input_widget = QFrame()
self.input_widget.setObjectName("InputWidget")
self.input_widget.setStyleSheet(self.style_sheet)
# set the layout of the widget
self.input_widget.setLayout(input_layout)
self.input_widget.setVisible(True)
# CREATE BOOKMARK-LINE HERE
#.........这里部分代码省略.........
示例14: __init__
# 需要导入模块: from PySide.QtGui import QFrame [as 别名]
# 或者: from PySide.QtGui.QFrame import setLayout [as 别名]
class SubtransactionForm:
""" Represents the SubTransaction Form """
def __init__(self, parent):
""" Initialize the Subtransaction Form """
self.parent = parent
self.subtransactionTable = SubTransactionTableWidget(self.transaction, self)
self.subtransactionLabels = []
def setup(self):
""" Setup the Subtransactions for the Transaction Details """
self.subtransactionFrame = QFrame()
self.verticalLayout = QVBoxLayout(self.subtransactionFrame)
self.horizontalLayout = QHBoxLayout()
label = QLabel("<b>Subtransactions</b>")
self.horizontalLayout.addWidget(label)
button = QPushButton("Add New Subtransaction")
button.clicked.connect(self.addSubtransaction)
self.horizontalLayout.addWidget(button)
self.removeButton = QPushButton("Remove Subtransaction")
self.removeButton.clicked.connect(self.removeSubtransaction)
self.horizontalLayout.addWidget(self.removeButton)
self.removeButton.setEnabled(False)
self.verticalLayout.addLayout(self.horizontalLayout)
self.verticalLayout.addWidget(self.subtransactionTable)
self.verticalLayout.addStretch()
self.subtransactionFrame.setLayout(self.verticalLayout)
self.layout.addWidget(self.subtransactionFrame)
def addSubtransactionLabels(self):
""" Add Subtransaction Labels """
self.subtransactionLabels = []
if self.transaction is not None and self.transaction.subtransaction_set is not None:
for transaction in self.transaction.subtransaction_set.transactions:
if transaction is not self.transaction:
label = QLabel("{0}".format(transaction.description))
self.subtransactionLabels.append(label)
self.formLayout.insertRow(1, label)
def updateOnTransactionChange(self):
""" Update on a Transaction Change """
self.subtransactionTable.parent_transaction = self.transaction
self.subtransactionTable.updateTransactions()
def tabSelected(self):
""" Do nothing when selected """
def addSubtransaction(self, checked=False):
""" Add the new Subtransaction """
if self.transaction is not None:
transaction = CreateSubtransactionFromRelative(self.transaction)
TheBalanceHelper.setupBalancesForAccount(transaction.account)
self.subtransactionTable.updateTransactions()
if transaction.account is self.table.account:
self.table.insertRow(transaction, selectRow=False)
def removeSubtransaction(self, checked=False):
""" Remove the current Subtransaction """
subtransaction = self.subtransactionTable.currentSubtransaction
if subtransaction is not None:
subtransactionSet = subtransaction.subtransaction_set
if len(subtransactionSet.transactions) == 2:
SubtransactionSets.delete(subtransactionSet)
else:
subtransactionSet.transactions.remove(subtransaction)
SubtransactionSets.save()
row = self.subtransactionTable.currentRow()
self.subtransactionTable.removeRow(row)
def updateSubtransactionDetails(self):
""" Update the Form's Subtransaction Details """
subtransaction = self.subtransactionTable.currentSubtransaction
self.removeButton.setEnabled(subtransaction is not None)
@property
def layout(self):
return self.parent.layout
@property
def table(self):
return self.parent.table
@property
def transaction(self):
return self.parent.transaction
示例15: __create_ui
# 需要导入模块: from PySide.QtGui import QFrame [as 别名]
# 或者: from PySide.QtGui.QFrame import setLayout [as 别名]
def __create_ui(self):
""" Create main UI """
self.setWindowTitle(CREATE_NODE_TITLE)
# remove window decoration if path and type is set
if self.defined_path and self.defined_type:
self.setWindowFlags(Qt.FramelessWindowHint | Qt.Popup)
main_layout = QVBoxLayout(self)
main_layout.setSpacing(1)
main_layout.setContentsMargins(2, 2, 2, 2)
# content layout
content_layout = QVBoxLayout()
self.files_model = QFileSystemModel()
self.files_model.setNameFilterDisables(False)
self.files_list = MTTFileList()
self.files_list.setAlternatingRowColors(True)
self.files_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.files_list.selectionValidated.connect(self.do_validate_selection)
self.files_list.goToParentDirectory.connect(self.on_go_up_parent)
self.files_list.doubleClicked.connect(self.on_double_click)
self.files_list.setModel(self.files_model)
buttons_layout = QHBoxLayout()
content_layout.addLayout(self.__create_filter_ui())
content_layout.addWidget(self.files_list)
content_layout.addLayout(buttons_layout)
self.files_list.filter_line = self.filter_line
if not self.defined_path:
# path line
path_layout = QHBoxLayout()
# bookmark button
bookmark_btn = QPushButton('')
bookmark_btn.setFlat(True)
bookmark_btn.setIcon(QIcon(':/addBookmark.png'))
bookmark_btn.setToolTip('Bookmark this Folder')
bookmark_btn.setStatusTip('Bookmark this Folder')
bookmark_btn.clicked.connect(self.on_add_bookmark)
# path line edit
self.path_edit = QLineEdit()
self.path_edit.editingFinished.connect(self.on_enter_path)
# parent folder button
self.parent_folder_btn = QPushButton('')
self.parent_folder_btn.setFlat(True)
self.parent_folder_btn.setIcon(QIcon(':/SP_FileDialogToParent.png'))
self.parent_folder_btn.setToolTip('Parent Directory')
self.parent_folder_btn.setStatusTip('Parent Directory')
self.parent_folder_btn.clicked.connect(self.on_go_up_parent)
# browse button
browse_btn = QPushButton('')
browse_btn.setFlat(True)
browse_btn.setIcon(QIcon(':/navButtonBrowse.png'))
browse_btn.setToolTip('Browse Directory')
browse_btn.setStatusTip('Browse Directory')
browse_btn.clicked.connect(self.on_browse)
# parent widget and layout
path_layout.addWidget(bookmark_btn)
path_layout.addWidget(self.path_edit)
path_layout.addWidget(self.parent_folder_btn)
path_layout.addWidget(browse_btn)
main_layout.addLayout(path_layout)
# bookmark list
bookmark_parent_layout = QHBoxLayout()
bookmark_frame = QFrame()
bookmark_frame.setFixedWidth(120)
bookmark_layout = QVBoxLayout()
bookmark_layout.setSpacing(1)
bookmark_layout.setContentsMargins(2, 2, 2, 2)
bookmark_frame.setLayout(bookmark_layout)
bookmark_frame.setFrameStyle(QFrame.Sunken)
bookmark_frame.setFrameShape(QFrame.StyledPanel)
self.bookmark_list = MTTBookmarkList()
self.bookmark_list.bookmarkDeleted.connect(self.do_delete_bookmark)
self.bookmark_list.setAlternatingRowColors(True)
self.bookmark_list.dragEnabled()
self.bookmark_list.setAcceptDrops(True)
self.bookmark_list.setDropIndicatorShown(True)
self.bookmark_list.setDragDropMode(QListView.InternalMove)
self.bookmark_list_sel_model = self.bookmark_list.selectionModel()
self.bookmark_list_sel_model.selectionChanged.connect(
self.on_select_bookmark)
bookmark_layout.addWidget(self.bookmark_list)
bookmark_parent_layout.addWidget(bookmark_frame)
bookmark_parent_layout.addLayout(content_layout)
main_layout.addLayout(bookmark_parent_layout)
self.do_populate_bookmarks()
else:
main_layout.addLayout(content_layout)
if not self.defined_type:
# type layout
self.types = QComboBox()
self.types.addItems(self.supported_node_type)
#.........这里部分代码省略.........