本文整理汇总了Python中PyQt5.Qt.QMainWindow.setCentralWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QMainWindow.setCentralWidget方法的具体用法?Python QMainWindow.setCentralWidget怎么用?Python QMainWindow.setCentralWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QMainWindow
的用法示例。
在下文中一共展示了QMainWindow.setCentralWidget方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from PyQt5.Qt import QMainWindow [as 别名]
# 或者: from PyQt5.Qt.QMainWindow import setCentralWidget [as 别名]
def test(scale=0.5):
from PyQt5.Qt import QLabel, QApplication, QPixmap, QMainWindow, QWidget, QScrollArea, QGridLayout
app = QApplication([])
mi = Metadata('xxx', ['Kovid Goyal', 'John Q. Doe', 'Author'])
mi.series = 'A series of styles'
m = QMainWindow()
sa = QScrollArea(m)
w = QWidget(m)
sa.setWidget(w)
l = QGridLayout(w)
w.setLayout(l), l.setSpacing(30)
labels = []
for r, color in enumerate(sorted(default_color_themes)):
for c, style in enumerate(sorted(all_styles())):
mi.series_index = c + 1
mi.title = 'An algorithmic cover [%s]' % color
prefs = override_prefs(cprefs, override_color_theme=color, override_style=style)
for x in ('cover_width', 'cover_height', 'title_font_size', 'subtitle_font_size', 'footer_font_size'):
prefs[x] = int(scale * prefs[x])
img = generate_cover(mi, prefs=prefs, as_qimage=True)
la = QLabel()
la.setPixmap(QPixmap.fromImage(img))
l.addWidget(la, r, c)
labels.append(la)
m.setCentralWidget(sa)
w.resize(w.sizeHint())
m.show()
app.exec_()
示例2: test
# 需要导入模块: from PyQt5.Qt import QMainWindow [as 别名]
# 或者: from PyQt5.Qt.QMainWindow import setCentralWidget [as 别名]
def test(scale=0.25):
from PyQt5.Qt import QLabel, QPixmap, QMainWindow, QWidget, QScrollArea, QGridLayout
from calibre.gui2 import Application
app = Application([])
mi = Metadata('Unknown', ['Kovid Goyal', 'John & Doe', 'Author'])
mi.series = 'A series & styles'
m = QMainWindow()
sa = QScrollArea(m)
w = QWidget(m)
sa.setWidget(w)
l = QGridLayout(w)
w.setLayout(l), l.setSpacing(30)
scale *= w.devicePixelRatioF()
labels = []
for r, color in enumerate(sorted(default_color_themes)):
for c, style in enumerate(sorted(all_styles())):
mi.series_index = c + 1
mi.title = 'An algorithmic cover [%s]' % color
prefs = override_prefs(cprefs, override_color_theme=color, override_style=style)
scale_cover(prefs, scale)
img = generate_cover(mi, prefs=prefs, as_qimage=True)
img.setDevicePixelRatio(w.devicePixelRatioF())
la = QLabel()
la.setPixmap(QPixmap.fromImage(img))
l.addWidget(la, r, c)
labels.append(la)
m.setCentralWidget(sa)
w.resize(w.sizeHint())
m.show()
app.exec_()
示例3: test
# 需要导入模块: from PyQt5.Qt import QMainWindow [as 别名]
# 或者: from PyQt5.Qt.QMainWindow import setCentralWidget [as 别名]
def test():
from PyQt5.Qt import QApplication, QMainWindow
app = QApplication([])
w = QMainWindow()
cf = CoverFlow()
cf.resize(int(available_width()/1.5), available_height()-60)
w.resize(cf.size()+QSize(30, 20))
model = DummyImageList()
cf.setImages(model)
cf.setCurrentSlide(39000)
w.setCentralWidget(cf)
w.show()
cf.setFocus(Qt.OtherFocusReason)
sys.exit(app.exec_())
示例4: available_height
# 需要导入模块: from PyQt5.Qt import QMainWindow [as 别名]
# 或者: from PyQt5.Qt.QMainWindow import setCentralWidget [as 别名]
cf.resize(int(available_width()/1.5), available_height()-60)
w.resize(cf.size()+QSize(30, 20))
model = DummyImageList()
cf.setImages(model)
cf.setCurrentSlide(39000)
w.setCentralWidget(cf)
w.show()
cf.setFocus(Qt.OtherFocusReason)
sys.exit(app.exec_())
def main(args=sys.argv):
return 0
if __name__ == '__main__':
from PyQt5.Qt import QApplication, QMainWindow
app = QApplication([])
w = QMainWindow()
cf = CoverFlow()
cf.resize(int(available_width()/1.5), available_height()-60)
w.resize(cf.size()+QSize(30, 20))
path = sys.argv[1]
model = FileSystemImages(sys.argv[1])
cf.currentChanged[int].connect(model.currentChanged)
cf.setImages(model)
w.setCentralWidget(cf)
w.show()
cf.setFocus(Qt.OtherFocusReason)
sys.exit(app.exec_())
示例5: isinstance
# 需要导入模块: from PyQt5.Qt import QMainWindow [as 别名]
# 或者: from PyQt5.Qt.QMainWindow import setCentralWidget [as 别名]
data.append(serialize_string('FOLDER', initial_folder))
if filename:
if isinstance(filename, bytes):
filename = filename.decode(filesystem_encoding)
data.append(serialize_string('FILENAME', filename))
loop = Loop()
h = Helper(subprocess.Popen(
[HELPER], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE),
data, loop.dialog_closed.emit)
h.start()
loop.exec_(QEventLoop.ExcludeUserInputEvents)
if h.rc != 0:
raise Exception('File dialog failed: ' + h.stderrdata.decode('utf-8'))
if not h.stdoutdata:
return ()
return tuple(x.decode('utf-8') for x in h.stdoutdata.split(b'\0'))
if __name__ == '__main__':
HELPER = sys.argv[-1]
app = QApplication([])
q = QMainWindow()
def clicked():
print(run_file_dialog(b, 'Testing dialogs', save_as=True, save_path='~/xxx.fdgdfg')), sys.stdout.flush()
b = QPushButton('click me')
b.clicked.connect(clicked)
q.setCentralWidget(b)
q.show()
app.exec_()