在根目录创建gui
包,包下会生成一个__init__.py
文件,然后在该包下创建目录preview
,并在目录中创建preview.py
,内容如下:
ui/preview/preview.pydef load_preview(main): """ 装载预览界面 :param main: :return: """ declaring_variable(main) init_preview(main) init_qgis_map(main) bind_func(main) def declaring_variable(main): main.preview_canvas = None main.preview_tool_pan = None main.preview_tool_zoom_in = None main.preview_tool_zoom_out = None
def init_preview(main): main.ui.splitter.setStretchFactor(0, 3) main.ui.splitter.setStretchFactor(1, 5)
def init_qgis_map(main): pass
def bind_func(main): pass
|
在ui
的__init__.py
文件中写入下面代码
ui/__init__.pyimport gui.preview.preview as GUIPreview
|
在main.py
中装载 preview 模块
main.pyimport gui as GUI
class PyQgisSEApp(QMainWindow, Ui_MainWindow): def __init__(self, app: QgsApplication): super(PyQgisSEApp, self).__init__() self.app = app self.ui = Ui_MainWindow() self.ui.setupUi(self)
GUI.GUIPreview.load_preview(self)
|