|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
from SubApplication import Ui_Form as AppUi
from SubSetting import Ui_Form as SetUi
class SubApplication(AppUi, QWidget):
def __init__(self, parent=AppUi):
super().__init__(parent=parent)
self.setupUi(self)
self.pBtnOpen.clicked.connect(self.open_img)
self.pBtnResule.clicked.connect(self.show_result)
class SubSetting(SetUi, QWidget):
def __init__(self, parent=SetUi):
super().__init__(parent=parent)
self.setupUi(self)
self.pBtn_Font.clicked.connect(self.choose_font)
class Window(MSFluentWindow):
def __init__(self):
super().__init__()
# create sub interface
self.homeInterface = Widget('Home Interface', self)
self.appInterface = SubApplication(self)
self.settingInterface = SubSetting(self)
#self.readInterface = Widget('Read Mode', self)
#self.bookshelfInterface = Widget('书架UI', self)
self.libraryInterface = Widget('library ', self)
self.initNavigation()
self.initWindow()
def initNavigation(self):
# HOME_FILL表示点击后变成另一个图标
self.addSubInterface(self.homeInterface, FIF.HOME, '主页', FIF.HOME_FILL)
self.addSubInterface(self.appInterface, FIF.APPLICATION, '应用')
self.addSubInterface(self.settingInterface, FIF.BASKETBALL, '设置')
#self.addSubInterface(self.readInterface, FIF.QUICK_NOTE, '阅读')
#self.addSubInterface(self.bookshelfInterface, FIF.BOOK_SHELF, '书架')
self.addSubInterface(self.libraryInterface, FIF.DEVELOPER_TOOLS, 'library', position=NavigationItemPosition.BOTTOM)
self.navigationInterface.addItem(
routeKey='Help',
icon=FIF.HELP,
text='帮助',
onClick=self.showMessageBox,
selectable=False,
position=NavigationItemPosition.BOTTOM,
)
self.navigationInterface.setCurrentItem(self.homeInterface.objectName())
def initWindow(self):
self.resize(1200, 800)
self.setWindowIcon(QIcon(':/qfluentwidgets/images/logo.png'))
self.setWindowTitle('OCR-Title--PyQt-Fluent-Widgets')
#获取用户屏幕尺寸
desktop = QApplication.screens()[0].availableGeometry()
w, h = desktop.width(), desktop.height()
self.move(w//2 - self.width()//2, h//2 - self.height()//2)
def showMessageBox(self):
w = MessageBox(
'Messagetitle',
'MessageContent',
self
)
w.yesButton.setText('确定')
w.cancelButton.setText('退出')
if __name__ == '__main__':
# setTheme(Theme.DARK)
app = QApplication(sys.argv)
w = Window()
w.show()
app.exec()
运行后SubApplication和SubSetting谁在前面实例化就显示谁。另外一个就不显示(左侧导航栏连图标都没有),如下图,我把SubApplication(self)注释掉,SubSetting就可以正常显示,说明SubSetting页面本身是不存在问题的
|
|