本文整理汇总了Python中qt.QGridLayout.addMultiCellWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QGridLayout.addMultiCellWidget方法的具体用法?Python QGridLayout.addMultiCellWidget怎么用?Python QGridLayout.addMultiCellWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qt.QGridLayout
的用法示例。
在下文中一共展示了QGridLayout.addMultiCellWidget方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EditableRecordFrame
# 需要导入模块: from qt import QGridLayout [as 别名]
# 或者: from qt.QGridLayout import addMultiCellWidget [as 别名]
class EditableRecordFrame(QFrame):
def __init__(self, parent, fields, text=None, name='EditableRecordFrame'):
QFrame.__init__(self, parent, name)
numrows = len(fields) +2
numcols = 2
self.grid = QGridLayout(self, numrows, numcols, 1, -1, name)
self.fields = fields
self.entries = {}
self._setupfields()
self.grid.setSpacing(7)
self.grid.setMargin(10)
self.text_label = QLabel(text, self)
self.grid.addMultiCellWidget(self.text_label, 0, 0, 0, 1)
def _setupfields(self):
numfields = len(self.fields)
for fnum in range(numfields):
fname = self.fields[fnum]
entry = KLineEdit('', self)
self.entries[fname] = entry
self.grid.addWidget(entry, fnum + 1, 1)
label = QLabel(entry, fname, self, fname)
self.grid.addWidget(label, fnum + 1, 0)
self.insButton = KPushButton('insert/new', self)
self.updButton = KPushButton('update', self)
self.grid.addWidget(self.insButton, numfields, 0)
self.grid.addWidget(self.updButton, numfields, 1)
def get_data(self):
data = {}
for field in self.entries:
data[field] = str(self.entries[field].text())
return data
示例2: __init__
# 需要导入模块: from qt import QGridLayout [as 别名]
# 或者: from qt.QGridLayout import addMultiCellWidget [as 别名]
def __init__(self):
QWidget.__init__(self)
self.textBrowser = QTextBrowser(self)
self.textBrowser.setTextFormat(QTextBrowser.LogText)
self.lineEdit = QLineEdit(self)
self.startButton = QPushButton(self.tr("Start"), self)
self.stopButton = QPushButton(self.tr("Stop"), self)
self.stopButton.setEnabled(False)
self.connect(self.lineEdit, SIGNAL("returnPressed()"), self.startCommand)
self.connect(self.startButton, SIGNAL("clicked()"), self.startCommand)
self.connect(self.stopButton, SIGNAL("clicked()"), self.stopCommand)
layout = QGridLayout(self, 2, 3)
layout.setSpacing(8)
layout.addMultiCellWidget(self.textBrowser, 0, 0, 0, 2)
layout.addWidget(self.lineEdit, 1, 0)
layout.addWidget(self.startButton, 1, 1)
layout.addWidget(self.stopButton, 1, 2)
self.process = QProcess()
self.connect(self.process, SIGNAL("readyReadStdout()"), self.readOutput)
self.connect(self.process, SIGNAL("readyReadStderr()"), self.readErrors)
self.connect(self.process, SIGNAL("processExited()"), self.resetButtons)
示例3: BaseTagDialogFrame
# 需要导入模块: from qt import QGridLayout [as 别名]
# 或者: from qt.QGridLayout import addMultiCellWidget [as 别名]
class BaseTagDialogFrame(QFrame):
def __init__(self, parent, name='BaseEntityDataFrame'):
QFrame.__init__(self, parent, name)
self.entityid = None
numrows = 5
numcols = 1
margin = 0
space = 1
self.grid = QGridLayout(self, numrows, numcols,
margin, space, 'BaseEntityDataLayout')
self.app = get_application_pointer()
self.lbl = QLabel('Select the tags', self)
self.grid.addWidget(self.lbl, 0, 0)
self.listView = KListView(self)
self.listView.addColumn('tagname', -1)
self.listView.clear()
self.grid.addMultiCellWidget(self.listView, 1, 4, 0, 0)
示例4: BaseGuestWorksFrame
# 需要导入模块: from qt import QGridLayout [as 别名]
# 或者: from qt.QGridLayout import addMultiCellWidget [as 别名]
class BaseGuestWorksFrame(QFrame):
def __init__(self, parent, name='BaseGuestWorksFrame'):
QFrame.__init__(self, parent, name)
self.works_entries = []
margin = 0
space = 1
self.grid = QGridLayout(self, 2, 6, margin, space)
self.works_lbl = QLabel('Works', self)
self.grid.addMultiCellWidget(self.works_lbl, 0, 0, 0, 4)
self.add_works_btn = KPushButton('+', self, 'add_works_button')
self.add_works_btn.connect(self.add_works_btn,
SIGNAL('clicked()'),
self.add_works_entries)
self.grid.addWidget(self.add_works_btn, 0, 5)
def add_works_entries(self):
frame = BaseWorksEntryFrame(self)
row = len(self.works_entries) + 1
self.grid.addMultiCellWidget(frame, row, row, 0, -1)
self.works_entries.append(frame)
frame.show()
示例5: BaseGuestPictureFrame
# 需要导入模块: from qt import QGridLayout [as 别名]
# 或者: from qt.QGridLayout import addMultiCellWidget [as 别名]
class BaseGuestPictureFrame(QFrame):
def __init__(self, parent, name='BaseGuestPictureFrame'):
QFrame.__init__(self, parent, name)
margin = 0
space = 1
self.grid = QGridLayout(self, 2, 2, margin, space)
self.picture_lbl = QLabel('Picture', self)
self.picture_url = KLineEdit('', self)
self.picture_btn = KPushButton(KStdGuiItem.Open(),
'Browse for picture', self)
self.grid.addMultiCellWidget(self.picture_lbl, 0, 0, 0, 1)
self.grid.addWidget(self.picture_url, 0, 1)
self.grid.addWidget(self.picture_btn, 1, 1)
def get_data(self):
url = str(self.appearance_url.text())
return dict(url=url)
def set_data(self, data):
self.appearance_url.setText(data['url'])
示例6: BaseGuestDataFrame
# 需要导入模块: from qt import QGridLayout [as 别名]
# 或者: from qt.QGridLayout import addMultiCellWidget [as 别名]
class BaseGuestDataFrame(QFrame):
def __init__(self, parent, name='BaseGuestDataFrame'):
QFrame.__init__(self, parent, name)
self.guestid = None
numrows = 2
numcols = 2
margin = 0
space = 1
self.grid = QGridLayout(self, numrows, numcols,
margin, space, 'BaseGuestDataLayout')
self.app = get_application_pointer()
self.fname_lbl = QLabel('First Name', self)
self.fname_entry = KLineEdit('', self)
self.grid.addWidget(self.fname_lbl, 0, 0)
self.grid.addWidget(self.fname_entry, 1, 0)
self.lname_lbl = QLabel('Last Name', self)
self.lname_entry = KLineEdit('', self)
self.grid.addWidget(self.lname_lbl, 0, 1)
self.grid.addWidget(self.lname_entry, 1, 1)
self.title_lbl = QLabel('Title', self)
self.title_entry = KLineEdit('', self)
self.grid.addMultiCellWidget(self.title_lbl, 2, 2, 0, 1)
self.grid.addMultiCellWidget(self.title_entry, 3, 3, 0, 1)
self.desc_lbl = QLabel('Description', self)
self.desc_entry = KTextEdit(self, 'description_entry')
self.grid.addMultiCellWidget(self.desc_lbl, 4, 4, 0, 1)
self.grid.addMultiCellWidget(self.desc_entry, 5, 7, 0, 1)
#self.works_frame = BaseGuestWorksFrame(self)
#self.grid.addMultiCellWidget(self.works_frame, 8, 8, 0, 1)
def get_guest_data(self):
fname = str(self.fname_entry.text())
lname = str(self.lname_entry.text())
title = str(self.title_entry.text())
desc = str(self.desc_entry.text())
# take the newlines out for now
# until the sqlgen is fixed to work with sqlite
desc = desc.replace('\n', ' ')
data = dict(firstname=fname, lastname=lname,
description=desc, title=title)
if self.guestid is not None:
data['guestid'] = self.guestid
return data
def set_guest_data(self, data):
self.guestid = data['guestid']
self.fname_entry.setText(data['firstname'])
self.lname_entry.setText(data['lastname'])
if data['title']:
self.title_entry.setText(data['title'])
if data['description']:
desc = data['description']
desc = self.app.guests.unescape_text(desc)
self.desc_entry.setText(desc)
示例7: SDLConfigWidget
# 需要导入模块: from qt import QGridLayout [as 别名]
# 或者: from qt.QGridLayout import addMultiCellWidget [as 别名]
class SDLConfigWidget(BaseDosboxConfigWidget):
def __init__(self, parent, name='SDLConfigWidget'):
BaseDosboxConfigWidget.__init__(self, parent, name=name)
numrows = 2
numcols = 2
margin = 0
space = 1
self.grid = QGridLayout(self, numrows, numcols,
margin, space, 'SDLConfigWidgetLayout')
self.myconfig = self.app.myconfig
res = self.myconfig.get('dosbox_profiles', 'default_resolutions')
resolutions = [r.strip() for r in res.split(',')]
self._default_resolutions = ['original'] + resolutions
self._default_outputs = ['surface', 'overlay', 'opengl', 'openglnb', 'ddraw']
self._default_priorities = ['lowest', 'lower', 'normal', 'higher', 'highest']
self.new_stuff()
self.localconfig.add_section('sdl')
def new_stuff(self):
# fullscreen group
self.fullscreen_groupbox = VerticalGroupBox(self, 'Fullscreen Options')
self.fullscreen_groupbox.setColumns(2)
self.grid.addWidget(self.fullscreen_groupbox, 0, 0)
self.fullscreen_check = QCheckBox(self.fullscreen_groupbox)
self.fullscreen_check.setText('fullscreen')
self.tooltips.add(self.fullscreen_check, "Run dosbox in fullscreen")
self.fulldouble_check = QCheckBox(self.fullscreen_groupbox)
self.fulldouble_check.setText('full&double')
self.tooltips.add(self.fulldouble_check, "Use double buffering in fullscreen")
# resolution group
self.resolution_groupbox = VerticalGroupBox(self, 'Resolution Options')
self.resolution_groupbox.setColumns(4)
self.grid.addWidget(self.resolution_groupbox, 0, 1)
self.fullresolution_box = ConfigComboBoxWidget(self.resolution_groupbox,
'fullscreen resolution', self._default_resolutions)
self.tooltips.add(self.fullresolution_box, "Resolution when running in fullscreen")
self.windowresolution_box = ConfigComboBoxWidget(self.resolution_groupbox,
'windowed resolution', self._default_resolutions)
self.tooltips.add(self.windowresolution_box, "Resolution when running in a window")
# misc group
self.misc_groupbox = VerticalGroupBox(self, 'Misc. Options')
self.misc_groupbox.setColumns(3)
self.grid.addWidget(self.misc_groupbox, 1, 0)
self.output_box = ConfigComboBoxWidget(self.misc_groupbox,
'Output', self._default_outputs)
self.waitonerror_check = QCheckBox(self.misc_groupbox)
self.waitonerror_check.setText('Wait on error')
self.tooltips.add(self.waitonerror_check,
"Wait before closing window if dosbox has an error")
# mouse group
self.mouse_groupbox = VerticalGroupBox(self, 'Mouse Options')
self.mouse_groupbox.setColumns(3)
self.grid.addWidget(self.mouse_groupbox, 1, 1)
self.autolock_check = QCheckBox(self.mouse_groupbox)
self.autolock_check.setText('autolock')
self.tooltips.add(self.autolock_check,
"Clicking in the dosbox window automatically locks mouse")
self.sensitivity_box = ConfigSpinWidget(self.mouse_groupbox,
'Mouse sensitivity', min=1, max=100,
suffix='%')
self.tooltips.add(self.sensitivity_box, "How sensitive the mouse is")
# keyboard group
self.keyboard_groupbox = VerticalGroupBox(self, 'Keyboard Options')
self.keyboard_groupbox.setColumns(3)
# add to row 2, first two columns
self.grid.addMultiCellWidget(self.keyboard_groupbox, 2, 2, 0, 1)
self.usescancodes_check = QCheckBox(self.keyboard_groupbox)
self.usescancodes_check.setText('usescancodes')
self.tooltips.add(self.usescancodes_check,
"Avoid use of symkeys")
self.mapper_entry = ConfigKURLSelectWidget(self.keyboard_groupbox,
'mapperfile (File used for key mappings)')
self.tooltips.add(self.mapper_entry, "File used for key mappings")
# priority group
self.priority_groupbox = QGroupBox(self)
self.priority_groupbox.setTitle('Priority Options')
self.priority_groupbox.setColumns(2)
#self.grid.addWidget(self.priority_groupbox, 3, 0)
# add to row 3 first two columns
self.grid.addMultiCellWidget(self.priority_groupbox, 3, 3, 0, 1)
self.focused_box = ConfigComboBoxWidget(self.priority_groupbox,
'focused', self._default_priorities)
self.tooltips.add(self.focused_box, "Priority level for dosbox when focused")
self.unfocused_box = ConfigComboBoxWidget(self.priority_groupbox,
'unfocused', self._default_priorities)
self.tooltips.add(self.unfocused_box,
"Priority level for dosbox when unfocused or minimized")
def set_config(self, configobj):
self.mainconfig = configobj
# some assignments to help with typing
sdl = 'sdl'
cfg = self.mainconfig
#.........这里部分代码省略.........
示例8: BaseGameDataFrame
# 需要导入模块: from qt import QGridLayout [as 别名]
# 或者: from qt.QGridLayout import addMultiCellWidget [as 别名]
class BaseGameDataFrame(QFrame):
def __init__(self, parent, name='BaseGameDataFrame'):
QFrame.__init__(self, parent, name)
# there will be more than two rows, but we'll start with two
numrows = 2
# there should onlty be two columns
numcols = 2
margin = 0
space = 1
# add a grid layout to the frame
self.grid = QGridLayout(self, numrows, numcols,
margin, space, 'BaseGameDataLayout')
# make a couple of lists to point to the weblink entries
# order is important in these lists
self.weblink_site_entries = []
self.weblink_url_entries = []
# I may use dict[site] = (site_entry, url_entry)
# I haven't decided yet. It could always be formed by zipping the 2 lists above.
self.weblink_dict = {}
# setup app pointer
self.app = KApplication.kApplication()
self.myconfig = self.app.myconfig
# setup dialog pointers
self.select_launch_command_dlg = None
# Setup widgets
# setup name widgets
self.name_lbl = QLabel('<b>Name</b>', self)
self.name_entry = KLineEdit('', self)
# add name widgets to grid
self.grid.addWidget(self.name_lbl, 0, 0)
self.grid.addWidget(self.name_entry, 1, 0)
# setup fullname widgets
self.fullname_lbl = QLabel('<b>Full name</b>', self)
self.fullname_entry = KLineEdit('', self)
# add fullname widgets
self.grid.addWidget(self.fullname_lbl, 2, 0)
self.grid.addWidget(self.fullname_entry, 3, 0)
# setup description widgets
self.desc_lbl = QLabel('<b>Description</b>', self)
self.desc_entry = KTextEdit(self, 'description_entry')
# set plain text format for description entry
# we do this in case there are html tags in the entry
self.desc_entry.setTextFormat(self.PlainText)
# add description widgets
self.grid.addWidget(self.desc_lbl, 4, 0)
#self.addWidget(self.desc_entry, 5, 0)
# add the description as a multirow entity
# default from 5 to 15
# this allows for weblinks to be added
# (about 5)
# without the dialog looking ugly
# going to 15 won't force there to be that many rows
# until more enough widgets are added
self.grid.addMultiCellWidget(self.desc_entry, 5, 15, 0, 0)
# setup launch command widgets
self.launch_lbl = QLabel('<b>Launch command</b>', self)
self.launch_entry = KLineEdit('', self)
self.launch_dlg_button = KPushButton('...', self, 'launch_dlg_button')
self.launch_dlg_button.connect(self.launch_dlg_button, SIGNAL('clicked()'),
self.select_launch_command)
# add launch command widgets
self.grid.addWidget(self.launch_lbl, 0, 1)
self.grid.addWidget(self.launch_entry, 1, 1)
self.grid.addWidget(self.launch_dlg_button, 1, 2)
# setup dosboxpath widgets
self.dosboxpath_lbl = QLabel('<b>dosbox path</b>', self)
self.dosboxpath_entry = KLineEdit('', self)
# add dosboxpath widgets
self.grid.addWidget(self.dosboxpath_lbl, 2, 1)
self.grid.addWidget(self.dosboxpath_entry, 3, 1)
# setup main weblink widgets
self.weblinks_lbl = QLabel('<b>weblinks</b>', self)
self.weblinks_btn = KPushButton('+', self, 'add_weblink_button')
self.weblinks_btn.connect(self.weblinks_btn, SIGNAL('clicked()'),
self.add_weblink_entries)
# add main weblink widgets
self.grid.addWidget(self.weblinks_lbl, 4, 1)
self.grid.addWidget(self.weblinks_btn, 4, 2)
def select_launch_command(self):
if self.select_launch_command_dlg is None:
file_filter = "*.exe *.bat *.com|Dos Executables\n*|All Files"
dlg = KFileDialog(self.fullpath, file_filter, self, 'select_launch_command_dlg', True)
dlg.connect(dlg, SIGNAL('okClicked()'), self.launch_command_selected)
dlg.connect(dlg, SIGNAL('cancelClicked()'), self.destroy_select_launch_command_dlg)
dlg.connect(dlg, SIGNAL('closeClicked()'), self.destroy_select_launch_command_dlg)
dlg.show()
self.select_launch_command_dlg = dlg
else:
# we shouldn't need this with a modal dialog
KMessageBox.error(self, opendlg_errormsg)
def destroy_select_launch_command_dlg(self):
self.select_launch_command_dlg = None
def launch_command_selected(self):
dlg = self.select_launch_command_dlg
url = dlg.selectedURL()
fullpath = str(url.path())
launch_command = os.path.basename(fullpath)
#.........这里部分代码省略.........
示例9: SoundConfigWidget
# 需要导入模块: from qt import QGridLayout [as 别名]
# 或者: from qt.QGridLayout import addMultiCellWidget [as 别名]
class SoundConfigWidget(BaseDosboxConfigWidget):
def __init__(self, parent, name="SDLConfigWidget"):
BaseDosboxConfigWidget.__init__(self, parent, name=name)
numrows = 2
numcols = 3
margin = 10
space = 7
self._default_mpu401_types = ["none", "uart", "intelligent"]
self._default_midi_devices = ["default", "none", "alsa", "oss", "coreaudio", "win32"]
self._default_sbtypes = ["none", "sb1", "sb2", "sbpro1", "sbpro2", "sb16"]
self._default_tandyopts = ["auto", "on", "off"]
self.grid = QGridLayout(self, numrows, numcols, margin, space, "SDLConfigWidgetLayout")
for section in ["mixer", "midi", "sblaster", "gus", "speaker"]:
self.localconfig.add_section(section)
# mixer group
self.mixer_groupbox = VerticalGroupBox(self, "Mixer Options")
self.mixer_groupbox.setColumns(4)
self.grid.addWidget(self.mixer_groupbox, 0, 0)
self.nosound_check = QCheckBox(self.mixer_groupbox)
self.nosound_check.setText("Disable sound")
self.sample_rate_box = SampleRateOption(self.mixer_groupbox, "Sample rate")
# magic number for maximum block size
self.blocksize_box = ConfigSpinWidget(
self.mixer_groupbox, "Mixer block size", min=0, max=262144, suffix=" bytes"
)
# magic number for maximum prebuffer (10 secs)
self.prebuffer_box = ConfigSpinWidget(self.mixer_groupbox, "Prebuffer", min=0, max=10000, suffix=" msec")
# midi group
self.midi_groupbox = VerticalGroupBox(self, "MIDI Options")
self.midi_groupbox.setColumns(4)
self.grid.addWidget(self.midi_groupbox, 1, 1)
self.mpu401_box = ConfigComboBoxWidget(self.midi_groupbox, "mpu401 type", self._default_mpu401_types)
self.midi_device_box = ConfigComboBoxWidget(self.midi_groupbox, "MIDI device", self._default_midi_devices)
self.midi_config_box = ConfigLineEditWidget(self.midi_groupbox, "MIDI config")
# speaker group
self.speaker_groupbox = VerticalGroupBox(self, "PC Speaker Options")
self.speaker_groupbox.setColumns(5)
self.grid.addMultiCellWidget(self.speaker_groupbox, 1, 1, 0, 0)
self.enable_speaker_check = QCheckBox(self.speaker_groupbox)
self.enable_speaker_check.setText("Enable PC speaker emulation")
self.pc_rate_box = SampleRateOption(self.speaker_groupbox, "Sample rate of PC speaker")
self.enable_tandy_box = ConfigComboBoxWidget(
self.speaker_groupbox, "Enable Tandy Sound System emulation", self._default_tandyopts
)
self.tandy_rate_box = SampleRateOption(self.speaker_groupbox, "Sample rate of Tandy Sound System")
self.enable_disney_check = QCheckBox(self.speaker_groupbox)
self.enable_disney_check.setText("Enable Disney Sound Source emulation")
# sblaster group
self.sblaster_groupbox = VerticalGroupBox(self, "SoundBlaster Options")
self.sblaster_groupbox.setColumns(2)
# self.grid.addWidget(self.sblaster_groupbox, 0, 0)
self.grid.addMultiCellWidget(self.sblaster_groupbox, 0, 0, 0, 1)
self.sbtype_box = ConfigComboBoxWidget(self.sblaster_groupbox, "SoundBlaster type", self._default_sbtypes)
self.sblaster_hwopt_groupbox = VerticalGroupBox(self.sblaster_groupbox, "SoundBlaster Hardware Options")
self.sblaster_hwopt_groupbox.setColumns(1)
self.sblaster_hwopt_box = SoundBlasterHardwareOptions(self.sblaster_hwopt_groupbox)
self.sb_mixer_check = QCheckBox(self.sblaster_groupbox)
self.sb_mixer_check.setText("SoundBlaster modifies dosbox mixer")
self.sblaster_oplopt_groupbox = VerticalGroupBox(self.sblaster_groupbox, "SoundBlaster OPL Options")
self.sblaster_oplopt_groupbox.setColumns(1)
self.sblaster_oplopt_box = SoundBlasterOPLOptions(self.sblaster_oplopt_groupbox)
# gus group
self.gus_groupbox = VerticalGroupBox(self, "Gravis Ultrasound Options")
self.gus_groupbox.setColumns(5)
# self.grid.addWidget(self.gus_groupbox, 2, 1)
self.grid.addMultiCellWidget(self.gus_groupbox, 0, 1, 2, 2)
self.enable_gus_check = QCheckBox(self.gus_groupbox)
self.enable_gus_check.setText("Enable Gravis Ultrasound emulation")
self.gus_hwopt_groupbox = VerticalGroupBox(self.gus_groupbox, "Gravis Ultrasound hardware options")
self.gus_hwopt_groupbox.setColumns(1)
self.gus_hwopt_box = GusHardwareOptions(self.gus_hwopt_groupbox)
self.gus_rate_box = SampleRateOption(self.gus_groupbox)
self.gus_ultradir_box = ConfigKURLSelectWidget(self.gus_groupbox, "GUS patches directory", filetype="dir")
def set_config(self, configobj):
self.mainconfig = configobj
# some assignments to help with typing
mixer = "mixer"
midi = "midi"
sblaster = "sblaster"
gus = "gus"
speaker = "speaker"
cfg = self.mainconfig
# set the various config widgets
# mixer section
nosound = cfg.getboolean(mixer, "nosound")
self.nosound_check.setChecked(nosound)
rate = cfg.getint(mixer, "rate")
self.sample_rate_box.set_config_option(rate)
blocksize = cfg.getint(mixer, "blocksize")
self.blocksize_box.set_config_option(blocksize)
prebuffer = cfg.getint(mixer, "prebuffer")
self.prebuffer_box.set_config_option(prebuffer)
# midi section
#.........这里部分代码省略.........
示例10: BaseRecordFrame
# 需要导入模块: from qt import QGridLayout [as 别名]
# 或者: from qt.QGridLayout import addMultiCellWidget [as 别名]
class BaseRecordFrame(QFrame):
"""This is a class that is good for dialog windows
that display records.
fields is an ordered list of fields
the fields will be displayed in rows
record can either be a dictionary
or a database row (with dict access)
"""
def __init__(self, parent, fields, text=None,
record=None, name='BaseRecordFrame'):
QFrame.__init__(self, parent, name)
numrows = len(fields) + 1
numcols = 2
margin = 10
space = 7
self.grid = QGridLayout(self, numrows, numcols,
margin, space, name)
self.fields = fields
self.entries = {}
#self.grid.setSpacing(7)
#self.grid.setMargin(10)
self.record = record
# need to explain refbuttons and refdata somewhere
self._refbuttons = {}
self._setup_fields(text)
def _setup_fields(self, text):
if text is None:
text = '<b>insert a simple record</b>'
refdata = None
# check if the record has refdata
if self.record is not None and hasattr(self.record, '_refdata'):
refdata = self.record._refdata
for field_index in range(len(self.fields)):
field = self.fields[field_index]
# here we make either a label or button
if refdata is not None and field in refdata.cols:
button = KPushButton('select/create', self)
self._refbuttons[field] = button
# add button to grid (column 1)
self.grid.addWidget(button, field_index + 1, 1)
# make buddy the button
buddy = button
else:
record_value = ''
if self.record is not None:
record_value = self.record[field]
entry = KLineEdit(record_value, self)
self.entries[field] = entry
self.grid.addWidget(entry, field_index + 1, 1)
# make buddy the entry
buddy = entry
# make the label
lbl_text = '&%s' % field
lbl_name = '%sLabel' % field
# buddy may not be well defined, or appropriate here
label = QLabel(buddy, lbl_text, self, lbl_name)
self.grid.addWidget(label, field_index + 1, 0)
self.text_label = QLabel(text, self)
self.grid.addMultiCellWidget(self.text_label, 0, 0, 0, 1)
def getRecordData(self):
"""Returns a dictionary of the fields and entries.
All values will be python strings."""
entry_items = self.entries.items()
record_data = {}
for key, entry in entry_items:
record_data[key] = str(entry.text())
return record_data
def setRecordData(self, record_data):
"""This member sets the entries according to the
dictionary that is passed to it."""
for field, value in record_data.items():
self.entries[field].setText(value)
def setText(self, text):
"""Sets the text of the main label."""
self.text_label.setText(text)
示例11: BaseEntityDataFrame
# 需要导入模块: from qt import QGridLayout [as 别名]
# 或者: from qt.QGridLayout import addMultiCellWidget [as 别名]
class BaseEntityDataFrame(AppFrame):
def __init__(self, parent, name='BaseEntityDataFrame'):
AppFrame.__init__(self, parent, name)
self.entityid = None
numrows = 2
numcols = 1
margin = 3
space = 2
self.grid = QGridLayout(self, numrows, numcols,
margin, space, 'BaseEntityDataLayout')
self.app = get_application_pointer()
self.name_lbl = QLabel('Name', self)
self.name_entry = KLineEdit('', self)
self.grid.addWidget(self.name_lbl, 0, 0)
self.grid.addWidget(self.name_entry, 1, 0)
self.etype_lbl = QLabel('type', self)
self.etype_combo = KComboBox(self, 'etype_combo')
db = self.app.db
etypes = db.session.query(db.EntityType).all()
self.etype_combo.insertStrList([e.type for e in etypes])
self.connect(self.etype_combo, SIGNAL('activated(const QString &)'),
self.change_etype)
self.grid.addWidget(self.etype_lbl, 2, 0)
self.grid.addWidget(self.etype_combo, 3, 0)
self.url_lbl = QLabel('url', self)
self.url_entry = KLineEdit('', self)
self.grid.addWidget(self.url_lbl, 4, 0)
self.grid.addWidget(self.url_entry, 5, 0)
grid_rownum = 6
self.desc_lbl = QLabel('Description', self)
self.desc_entry = KTextEdit(self, 'description_entry')
self.desc_entry.setTextFormat(self.PlainText)
self.grid.addMultiCellWidget(self.desc_lbl, 6, 6, 0, 0)
self.grid.addMultiCellWidget(self.desc_entry, 7, 10, 0, 0)
#self.works_frame = BaseGuestWorksFrame(self)
#self.grid.addMultiCellWidget(self.works_frame, 8, 8, 0, 1)
def change_etype(self, etype):
print 'change_etype', etype
def get_data(self):
name = str(self.name_entry.text())
etype = str(self.etype_combo.currentText())
url = str(self.url_entry.text())
desc = str(self.desc_entry.text())
data = dict(name=name, type=etype,
url=url, desc=desc)
if self.entityid is not None:
data['entityid'] = self.entityid
return data
def set_entity(self, entity):
self.entity = entity
self.set_data(entity)
def set_data(self, entity):
self.entityid = entity.entityid
self.name_entry.setText(entity.name)
self.etype_combo.setCurrentText(entity.type)
self.url_entry.setText(entity.url)
self.desc_entry.setText(entity.desc)
示例12: MachineConfigWidget
# 需要导入模块: from qt import QGridLayout [as 别名]
# 或者: from qt.QGridLayout import addMultiCellWidget [as 别名]
class MachineConfigWidget(BaseDosboxConfigWidget):
def __init__(self, parent, name="SDLConfigWidget"):
BaseDosboxConfigWidget.__init__(self, parent, name=name)
numrows = 2
numcols = 3
margin = 10
space = 7
self._default_machines = ["vga", "cga", "tandy", "pcjr", "hercules"]
self._default_scalers = [
"none",
"normal2x",
"normal3x",
"advmame2x",
"advmame3x",
"advinterp2x",
"advinterp3x",
"tv2x",
"tv3x",
"rgb2x",
"rgb3x",
"scan2x",
"scan3x",
]
self._default_cores = ["simple", "normal", "full", "dynamic"]
for section in ["render", "cpu", "dosbox", "dos", "bios", "serial", "ipx"]:
self.localconfig.add_section(section)
self.grid = QGridLayout(self, numrows, numcols, margin, space, "MachineConfigWidgetLayout")
# render group
self.render_groupbox = VerticalGroupBox(self, "Render Options")
self.render_groupbox.setColumns(2)
self.grid.addWidget(self.render_groupbox, 0, 1)
self.frameskip_box = ConfigSpinWidget(self.render_groupbox, "Frame skip", suffix=" frames")
self.tooltips.add(self.frameskip_box, "How many frames to skip.")
self.aspect_check = QCheckBox(self.render_groupbox)
self.aspect_check.setText("Aspect correction")
self.tooltips.add(self.aspect_check, "Try to keep aspect ratio.")
self.scaler_box = ConfigComboBoxWidget(self.render_groupbox, "Scaler", self._default_scalers)
self.tooltips.add(self.scaler_box, "Select size and effect of video")
# cpu group
# make a big number for cycles that should never be needed
cyclemax = int(1e6)
self.cpu_groupbox = VerticalGroupBox(self, "CPU Options")
self.cpu_groupbox.setColumns(2)
self.grid.addWidget(self.cpu_groupbox, 0, 0)
self.core_box = ConfigComboBoxWidget(self.cpu_groupbox, "Core", self._default_cores)
self.tooltips.add(self.core_box, "Select type of cpu core")
self.cycles_box = ConfigSpinWidget(self.cpu_groupbox, "Cycles", max=cyclemax, suffix=" cycles")
tt = "The number of cycles to attempt to perform in a second"
self.tooltips.add(self.cycles_box, tt)
self.cycleup_box = ConfigSpinWidget(self.cpu_groupbox, "Cycle up increment", max=cyclemax, suffix=" cycles")
self.cycledown_box = ConfigSpinWidget(self.cpu_groupbox, "Cycle down increment", max=cyclemax, suffix=" cycles")
# dosbox group
self.dosbox_groupbox = VerticalGroupBox(self, "Dosbox Options")
self.dosbox_groupbox.setColumns(3)
# row 1, first two columns
# self.grid.addMultiCellWidget(self.dosbox_groupbox, 1, 1, 0, 1)
self.grid.addWidget(self.dosbox_groupbox, 1, 0)
self.language_entry = ConfigKURLSelectWidget(self.dosbox_groupbox, "Language file")
self.memsize_box = ConfigSpinWidget(self.dosbox_groupbox, "Memory size", suffix="MB")
self.captures_entry = ConfigKURLSelectWidget(self.dosbox_groupbox, "Captures directory", filetype="dir")
# dos group
self.dos_groupbox = VerticalGroupBox(self, "Dos Options")
self.dos_groupbox.setColumns(3)
self.grid.addWidget(self.dos_groupbox, 1, 1)
self.xms_check = QCheckBox(self.dos_groupbox)
self.xms_check.setText("Enable XMS support")
self.ems_check = QCheckBox(self.dos_groupbox)
self.ems_check.setText("Enable EMS support")
self.umb_check = QCheckBox(self.dos_groupbox)
self.umb_check.setText("Enable UMB support")
# peripheral options
self.peripheral_groupbox = VerticalGroupBox(self, "Peripheral Options")
self.peripheral_groupbox.setColumns(1)
# self.grid.addWidget(self.peripheral_groupbox, 2, 0)
self.grid.addMultiCellWidget(self.peripheral_groupbox, 2, 2, 0, 2)
# peripherals in bios section
self.bios_groupbox = VerticalGroupBox(self.peripheral_groupbox, "Bios Options")
self.bios_groupbox.setColumns(1)
joystick_types = ["none", "2axis", "4axis", "fcs", "ch"]
self.joysticktype_box = ConfigComboBoxWidget(self.bios_groupbox, "Joystick type", joystick_types)
# peripherals in serial section
self.serial_groupbox = VerticalGroupBox(self.peripheral_groupbox, "Serial Options")
self.serial_groupbox.setColumns(2)
self.serial_warning_lbl = QLabel("These options are", self.serial_groupbox)
self.serial_warning_lbl2 = QLabel("not fully suported yet.", self.serial_groupbox)
self.serial1_box = SerialPortOption(self.serial_groupbox, "Serial 1")
self.serial2_box = SerialPortOption(self.serial_groupbox, "Serial 2")
self.serial3_box = SerialPortOption(self.serial_groupbox, "Serial 3")
self.serial4_box = SerialPortOption(self.serial_groupbox, "Serial 4")
# ipx options
self.ipx_groupbox = VerticalGroupBox(self, "IPX Options")
self.ipx_groupbox.setColumns(1)
self.grid.addWidget(self.ipx_groupbox, 1, 2)
self.ipx_check = QCheckBox(self.ipx_groupbox)
self.ipx_check.setText("Enable ipx over UDP/IP emulation")
#.........这里部分代码省略.........
示例13: MachineConfigWidget
# 需要导入模块: from qt import QGridLayout [as 别名]
# 或者: from qt.QGridLayout import addMultiCellWidget [as 别名]
class MachineConfigWidget(BaseDosboxConfigWidget):
def __init__(self, parent, name='SDLConfigWidget'):
BaseDosboxConfigWidget.__init__(self, parent, name=name)
numrows = 2
numcols = 3
margin = 10
space = 7
self._default_machines = ['vga', 'cga', 'tandy', 'pcjr', 'hercules']
self._default_scalers = ['none', 'normal2x', 'normal3x', 'advmame2x', 'advmame3x',
'advinterp2x', 'advinterp3x', 'tv2x', 'tv3x',
'rgb2x', 'rgb3x', 'scan2x', 'scan3x']
self._default_cores = ['simple', 'normal', 'full', 'dynamic', 'auto']
for section in ['render', 'cpu', 'dosbox', 'dos', 'bios', 'serial', 'ipx']:
self.localconfig.add_section(section)
self.grid = QGridLayout(self, numrows, numcols,
margin, space, 'MachineConfigWidgetLayout')
# render group
self.render_groupbox = VerticalGroupBox(self, 'Render Options')
self.render_groupbox.setColumns(2)
self.grid.addWidget(self.render_groupbox, 0, 1)
self.frameskip_box = ConfigSpinWidget(self.render_groupbox,
'Frame skip', suffix=' frames')
self.tooltips.add(self.frameskip_box, 'How many frames to skip.')
self.aspect_check = QCheckBox(self.render_groupbox)
self.aspect_check.setText('Aspect correction')
self.tooltips.add(self.aspect_check, 'Try to keep aspect ratio.')
self.scaler_box = ConfigComboBoxWidget(self.render_groupbox,
'Scaler', self._default_scalers)
self.tooltips.add(self.scaler_box, 'Select size and effect of video')
# cpu group
# make a big number for cycles that should never be needed
cyclemax = int(1e6)
self.cpu_groupbox = VerticalGroupBox(self, 'CPU Options')
self.cpu_groupbox.setColumns(2)
self.grid.addWidget(self.cpu_groupbox, 0, 0)
self.core_box = ConfigComboBoxWidget(self.cpu_groupbox,
'Core', self._default_cores)
self.tooltips.add(self.core_box, 'Select type of cpu core')
self.cycles_box = ConfigSpinWidget(self.cpu_groupbox,
'Cycles', max=cyclemax, suffix=' cycles')
tt = 'The number of cycles to attempt to perform in a second'
self.tooltips.add(self.cycles_box, tt)
self.cycleup_box = ConfigSpinWidget(self.cpu_groupbox,
'Cycle up increment', max=cyclemax,
suffix=' cycles')
self.cycledown_box = ConfigSpinWidget(self.cpu_groupbox,
'Cycle down increment', max=cyclemax,
suffix=' cycles')
# dosbox group
self.dosbox_groupbox = VerticalGroupBox(self, 'Dosbox Options')
self.dosbox_groupbox.setColumns(3)
# row 1, first two columns
#self.grid.addMultiCellWidget(self.dosbox_groupbox, 1, 1, 0, 1)
self.grid.addWidget(self.dosbox_groupbox, 1, 0)
self.language_entry = ConfigKURLSelectWidget(self.dosbox_groupbox,
'Language file')
self.memsize_box = ConfigSpinWidget(self.dosbox_groupbox,
'Memory size', suffix='MB')
self.captures_entry = ConfigKURLSelectWidget(self.dosbox_groupbox,
'Captures directory', filetype='dir')
# dos group
self.dos_groupbox = VerticalGroupBox(self, 'Dos Options')
self.dos_groupbox.setColumns(3)
self.grid.addWidget(self.dos_groupbox, 1, 1)
self.xms_check = QCheckBox(self.dos_groupbox)
self.xms_check.setText('Enable XMS support')
self.ems_check = QCheckBox(self.dos_groupbox)
self.ems_check.setText('Enable EMS support')
self.umb_check = QCheckBox(self.dos_groupbox)
self.umb_check.setText('Enable UMB support')
# peripheral options
self.peripheral_groupbox = VerticalGroupBox(self, 'Peripheral Options')
self.peripheral_groupbox.setColumns(1)
#self.grid.addWidget(self.peripheral_groupbox, 2, 0)
self.grid.addMultiCellWidget(self.peripheral_groupbox, 2, 2, 0, 2)
# peripherals in bios section
self.bios_groupbox = VerticalGroupBox(self.peripheral_groupbox, 'Bios Options')
self.bios_groupbox.setColumns(1)
joystick_types = ['none', '2axis', '4axis', 'fcs', 'ch']
self.joysticktype_box = ConfigComboBoxWidget(self.bios_groupbox,
'Joystick type', joystick_types)
# peripherals in serial section
self.serial_groupbox = VerticalGroupBox(self.peripheral_groupbox, 'Serial Options')
self.serial_groupbox.setColumns(2)
self.serial_warning_lbl = QLabel('These options are',
self.serial_groupbox)
self.serial_warning_lbl2 = QLabel('not fully suported yet.', self.serial_groupbox)
self.serial1_box = SerialPortOption(self.serial_groupbox, 'Serial 1')
self.serial2_box = SerialPortOption(self.serial_groupbox, 'Serial 2')
self.serial3_box = SerialPortOption(self.serial_groupbox, 'Serial 3')
self.serial4_box = SerialPortOption(self.serial_groupbox, 'Serial 4')
# ipx options
self.ipx_groupbox = VerticalGroupBox(self, 'IPX Options')
self.ipx_groupbox.setColumns(1)
self.grid.addWidget(self.ipx_groupbox, 1, 2)
#.........这里部分代码省略.........
示例14: SettingsWidget
# 需要导入模块: from qt import QGridLayout [as 别名]
# 或者: from qt.QGridLayout import addMultiCellWidget [as 别名]
class SettingsWidget(BaseConfigWidget):
def __init__(self, parent, name='SettingsWidget'):
BaseConfigWidget.__init__(self, parent, name=name)
numrows = 2
numcols = 2
margin = 7
space = 10
self.grid = QGridLayout(self, numrows, numcols,
margin, space, 'SettingsWidgetLayout')
self.myconfig = self.app.myconfig
for section in ['filemanagement', 'dosbox', 'externalactions', 'mainwindow']:
self.localconfig.add_section(section)
# filemanagement area
self.filemanagement_groupbox = VerticalGroupBox(self, 'File Management')
self.filemanagement_groupbox.setColumns(4)
#self.grid.addWidget(self.filemanagement_groupbox, 0, 0)
self.grid.addMultiCellWidget(self.filemanagement_groupbox, 0, 0, 0, 1)
self.use_rdiff_backup_check = QCheckBox(self.filemanagement_groupbox)
self.use_rdiff_backup_check.setText('Use rdiff-backup')
self.use_rsync_check = QCheckBox(self.filemanagement_groupbox)
self.use_rsync_check.setText('Use rsync')
self.overwrite_extras_archives_check = QCheckBox(self.filemanagement_groupbox)
self.overwrite_extras_archives_check.setText('Overwrite extras archives')
self.archives_groupbox = VerticalGroupBox(self.filemanagement_groupbox,
'Archive Paths')
self.archives_groupbox.setColumns(2)
#self.grid.addWidget(self.archives_groupbox, 0, 1)
self.installed_archives_entry = ConfigKURLSelectWidget(self.archives_groupbox,
'Path to the "install" archives',
filetype='dir')
self.extras_archives_entry = ConfigKURLSelectWidget(self.archives_groupbox,
'Path to the "extras" archives',
filetype='dir')
# dosbox area
self.dosbox_groupbox = VerticalGroupBox(self, 'Dosbox Options')
self.dosbox_groupbox.setColumns(3)
#self.grid.addWidget(self.dosbox_groupbox, 1, 0)
self.grid.addMultiCellWidget(self.dosbox_groupbox, 1, 1, 0, 1)
self.main_dosbox_path_entry = ConfigKURLSelectWidget(self.dosbox_groupbox,
'Path to dosbox area',
filetype='dir')
self.dosbox_binary_entry = ConfigLineEditWidget(self.dosbox_groupbox,
'Dosbox executable')
self.cdrive_is_main_check = QCheckBox(self.dosbox_groupbox)
self.cdrive_is_main_check.setText('C: Drive is main dosbox path')
# externalactions area
self.externalactions_groupbox = VerticalGroupBox(self, 'External Actions')
self.externalactions_groupbox.setColumns(2)
self.grid.addWidget(self.externalactions_groupbox, 2, 0)
self.launch_weblinks_entry = ConfigLineEditWidget(self.externalactions_groupbox,
'Command to handle weblink clicks')
self.text_editor_entry = ConfigLineEditWidget(self.externalactions_groupbox,
'Text editor command')
# mainwindow area
self.mainwindow_groupbox = VerticalGroupBox(self, 'Main Window Options')
self.mainwindow_groupbox.setColumns(3)
self.grid.addWidget(self.mainwindow_groupbox, 2, 1)
self.mainwindow_size_box = ConfigWinSizeWidget(self.mainwindow_groupbox,
'Size of main window')
self.flat_tree_box = ConfigComboBoxWidget(self.mainwindow_groupbox,
'Game list style', ['flat', 'tree'])
self.name_title_box = ConfigComboBoxWidget(self.mainwindow_groupbox,
'Game list entries', ['name', 'title'])
def set_config(self, configobj):
self.mainconfig = configobj
# some assignments to help with typing
filemanagement = 'filemanagement'
dosbox = 'dosbox'
externalactions = 'externalactions'
mainwindow = 'mainwindow'
cfg = self.mainconfig
# set the various config widgets
# filemanagement section
use_rdiff_backup = cfg.getboolean(filemanagement, 'use_rdiff_backup')
self.use_rdiff_backup_check.setChecked(use_rdiff_backup)
use_rsync = cfg.getboolean(filemanagement, 'use_rsync')
self.use_rsync_check.setChecked(use_rsync)
overwrite_extras_archives = cfg.getboolean(filemanagement, 'overwrite_extras_archives')
self.overwrite_extras_archives_check.setChecked(overwrite_extras_archives)
installed_archives_path = cfg.get(filemanagement, 'installed_archives_path')
self.installed_archives_entry.set_config_option(installed_archives_path)
extras_archives_path = cfg.get(filemanagement, 'extras_archives_path')
self.extras_archives_entry.set_config_option(extras_archives_path)
# dosbox section
dosbox_binary = cfg.get(dosbox, 'dosbox_binary')
self.dosbox_binary_entry.set_config_option(dosbox_binary)
main_dosbox_path = cfg.get(dosbox, 'main_dosbox_path')
self.main_dosbox_path_entry.set_config_option(main_dosbox_path)
cdrive_is_main = cfg.getboolean(dosbox, 'cdrive_is_main_dosbox_path')
self.cdrive_is_main_check.setChecked(cdrive_is_main)
# externalactions section
launch_weblink = cfg.get(externalactions, 'launch_weblink')
self.launch_weblinks_entry.set_config_option(launch_weblink)
text_editor = cfg.get(externalactions, 'text_editor')
self.text_editor_entry.set_config_option(text_editor)
# mainwindow section
mainwindow_size = cfg.get(mainwindow, 'mainwindow_size')
self.mainwindow_size_box.set_config_option(mainwindow_size)
#.........这里部分代码省略.........