简体   繁体   English

我如何在 Visual Studio 代码中导入其他模块 class

[英]how can i import other module class in visual studio code

my problem is i use visual studio code to write python program, but i cannot import other module class(Ui_Form) to current module我的问题是我使用 Visual Studio 代码编写 python 程序,但我无法将其他模块类(Ui_Form)导入到当前模块

this is my current module:这是我当前的模块:

from PyQt5.QtWidgets import *
from HR_System.view.main_window import Ui_Form

    class MainWindow(QWidget,Ui_Form):
        def __init__(self):
            QWidget.__init__(self)
            self.setupUi(self)
    
    app = QApplication([])
    window=QWidget()
    window.show()
    app.exec()

the original modul(path:HR_System.view.main_window):原始模块(路径:HR_System.view.main_window):

from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(1024, 700)
        font = QtGui.QFont()
        font.setFamily("Terminal")

enter image description here在此处输入图像描述

enter image description here在此处输入图像描述

json launch: json 发射:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "pwa-msedge",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:8080",
            "webRoot": "${workspaceFolder}"
        }
    ]
}

why is no module??为什么没有模块?? i use python 3.8.6我使用 python 3.8.6

In launch.json , addlaunch.json中,添加

    "env": {
        "PYTHONPATH":"${workspaceFolder}"
    },

Then Run without Debugging , you can see the winform is shown:然后Run without Debugging ,可以看到 winform 显示:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM