提交 e431d69b 编写于 作者: 之一Yo's avatar 之一Yo

添加对话框 gallery 界面

上级 b9500857
......@@ -87,6 +87,7 @@ class BasicInputInterface(GalleryInterface):
radioLayout.addWidget(radioButton1)
radioLayout.addWidget(radioButton2)
radioLayout.addWidget(radioButton3)
radioButton1.click()
self.addExampleCard(
self.tr('A group of RadioButton controls in a button group'),
radioWidget,
......@@ -95,6 +96,7 @@ class BasicInputInterface(GalleryInterface):
slider = Slider(Qt.Horizontal)
slider.setRange(0, 100)
slider.setValue(30)
slider.setFixedWidth(200)
self.addExampleCard(
self.tr('A simple horizontal slider'),
......
# coding:utf-8
from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QWidget
from qfluentwidgets import PushButton, Dialog, MessageBox, ColorDialog
from ..common.translator import Translator
from .gallery_interface import GalleryInterface
class DialogInterface(GalleryInterface):
""" Dialog interface """
def __init__(self, parent=None):
t = Translator()
super().__init__(
title=t.dialogs,
subtitle='qfluentwidgets.components.dialog_box',
parent=parent
)
button = PushButton(self.tr('Show dialog'))
button.clicked.connect(self.showDialog)
self.addExampleCard(
self.tr('A frameless message box'),
button,
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/dialog/demo.py'
)
button = PushButton(self.tr('Show dialog'))
button.clicked.connect(self.showMessageDialog)
self.addExampleCard(
self.tr('A message box with mask'),
button,
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/message_dialog/demo.py'
)
button = PushButton(self.tr('Show dialog'))
button.clicked.connect(self.showColorDialog)
self.addExampleCard(
self.tr('A color dialog'),
button,
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/color_dialog/demo.py'
)
def showDialog(self):
title = self.tr('This is a frameless message dialog')
content = self.tr(
"If the content of the message box is veeeeeeeeeeeeeeeeeeeeeeeeeery long, it will automatically wrap like this.")
w = Dialog(title, content, self.window())
if w.exec():
print('Yes button is pressed')
else:
print('Cancel button is pressed')
def showMessageDialog(self):
title = self.tr('This is a frameless message dialog')
content = self.tr(
"If the content of the message box is veeeeeeeeeeeeeeeeeeeeeeeeeery long, it will automatically wrap like this.")
w = MessageBox(title, content, self.window())
if w.exec():
print('Yes button is pressed')
else:
print('Cancel button is pressed')
def showColorDialog(self):
w = ColorDialog(Qt.cyan, self.tr('Choose color'), self.window())
w.updateStyle()
w.colorChanged.connect(lambda c: print(c.name()))
w.exec()
\ No newline at end of file
......@@ -11,6 +11,7 @@ from qframelesswindow import FramelessWindow
from .title_bar import CustomTitleBar
from .setting_interface import SettingInterface, cfg
from .basic_input_interface import BasicInputInterface
from .dialog_interface import DialogInterface
from ..components.avatar_widget import AvatarWidget
from ..common.icon import Icon
......@@ -55,9 +56,11 @@ class MainWindow(FramelessWindow):
# create sub interface
self.basicInputInterface = BasicInputInterface(self)
self.dialogInterface = DialogInterface(self)
self.settingInterface = SettingInterface(self)
self.stackWidget.addWidget(self.basicInputInterface)
self.stackWidget.addWidget(self.dialogInterface)
self.stackWidget.addWidget(self.settingInterface)
# initialize layout
......@@ -84,6 +87,7 @@ class MainWindow(FramelessWindow):
def initNavigation(self):
self.basicInputInterface.setObjectName('basicInterface')
self.dialogInterface.setObjectName('dialogInterface')
self.settingInterface.setObjectName('settingsInterface')
self.navigationInterface.addItem(
......@@ -102,10 +106,10 @@ class MainWindow(FramelessWindow):
position=NavigationItemPostion.SCROLL
)
self.navigationInterface.addItem(
routeKey='Dialogs',
routeKey=self.dialogInterface.objectName(),
icon=Icon.MESSAGE,
text=self.tr('Dialogs'),
onClick=print,
onClick=lambda: self.switchTo(self.dialogInterface),
position=NavigationItemPostion.SCROLL
)
self.navigationInterface.addItem(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册