我不明白在课堂上使用“自我”,PyQt5问题

时间:2019-12-26 00:31:41

标签: python python-3.x pyqt5

我在使用PyQt5理解代码时遇到了一些麻烦,我设法解决了一些错误,但现在还不知道如何解决..(对不起,我仍然需要3周的编程时间..)在功能Buttons,labels和main_ui上。我不明白为什么我必须自我介绍。在我的台词乞求中,我看到了类似PyQt5的程序,这些程序没有自我。在每行的开头..这是什么意思,以及它如何反映在课堂上我没得到的下一件事。在使用lambda之前我遇到了错误:在40,45行,我做了一些搜索,结果发现我已经放置单行函数lambda来解决此问题的原因。

第40行,第45行评论如下。

from PyQt5.QtWidgets import QPushButton, QVBoxLayout, QFileDialog, QTextEdit
from PyQt5.QtWidgets import QMainWindow, QApplication, QLabel, QLineEdit
from PyQt5.QtWidgets import QHBoxLayout
import sys

folder_path = r""

class Window(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        self.main_ui()
        self.labels()
        self.Buttons()

    def main_ui(self):
        self.setWindowTitle("Files Organiser")
        self.setFixedSize(400, 400)




    def labels(self):
        self.text1 = QLabel("""         -The program organize your files according to it's extension.
        for example .txt files are moved to text folder and same for png and .. etc.

            How to use:
            1- Choose the location where you want to organize your files.
            2- Press RUN.
        """, self)
        self.text1.move(0, 140)
        self.text1.resize(400, 400)




    def Buttons(self):
        self.button_choose_folder = QPushButton("Choose a folder", self)
        self.button_choose_folder.setToolTip("Press to Choose a directory where you want to organize your file")
        self.button_choose_folder.move(150, 250)
#line40 self.button_choose_folder.clicked.connect(lambda: self.button_choose_folder_click())

        self.button_run = QPushButton("RUN", self)
        self.button_run.setToolTip("Press to RUN the program")
        self.button_run.move(0, 250)
#line45 self.button_run.clicked.connect(lambda: self.button_run_click())



    def button_choose_folder_click(self):
        global folder_path
        folder_path = QFileDialog.getExistingDirectory(self, r"Choose a directory")
        return folder_path


    def button_run_click(self):
        pass

0 个答案:

没有答案