{"id":1530,"date":"2023-06-24T21:30:34","date_gmt":"2023-06-24T13:30:34","guid":{"rendered":"http:\/\/xinyixx.com\/?p=1530"},"modified":"2023-06-24T21:31:16","modified_gmt":"2023-06-24T13:31:16","slug":"python22","status":"publish","type":"post","link":"https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/","title":{"rendered":"python\u7a0b\u5e8f22\uff1a\u5199\u4e00\u4e2a\u7ecf\u5178\u6e38\u620f-\u8d2a\u5403\u86c7"},"content":{"rendered":"<p class=\"wp-block-paragraph\">\u60f3\u5fc5\u8d2a\u5403\u86c7\u8fd9\u4e2a\u6e38\u620f\u5927\u5bb6\u90fd\u73a9\u8fc7\uff0c\u90a3\u4e48\u8d2a\u5403\u86c7\u600e\u4e48\u5728python\u4ee3\u7801\u91cc\u5b9e\u73b0\u5462\uff1f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4eca\u5929\u9700\u8981\u5f15\u5165<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">PyQt5\u662f\u4e00\u4e2a\u57fa\u4e8eQt\u6846\u67b6\u7684Python GUI\u7f16\u7a0b\u5de5\u5177\u5305\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684Python\u6a21\u5757\uff0c\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u4f7f\u7528Python\u8bed\u8a00\u6765\u5f00\u53d1\u8de8\u5e73\u53f0\u7684\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002PyQt5\u662fQt\u5b98\u65b9\u63a8\u8350\u7684Python\u7ed1\u5b9a\u5de5\u5177\u4e4b\u4e00\uff0c\u5b83\u652f\u6301\u6700\u65b0\u7684Qt 5\u6846\u67b6\uff0c\u5e76\u4e14\u63d0\u4f9b\u4e86\u826f\u597d\u7684\u6587\u6863\u548c\u793a\u4f8b\u4ee3\u7801\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">PyQt5\u5305\u542b\u4e86\u5927\u91cf\u7684\u7c7b\u548c\u51fd\u6570\uff0c\u53ef\u4ee5\u7528\u4e8e\u521b\u5efa\u5404\u79cdGUI\u7ec4\u4ef6\uff0c\u5982\u7a97\u53e3\u3001\u6807\u7b7e\u3001\u6309\u94ae\u3001\u5217\u8868\u6846\u3001\u6587\u672c\u6846\u7b49\u7b49\u3002\u5b83\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e9b\u9ad8\u7ea7\u7ec4\u4ef6\uff0c\u5982\u56fe\u5f62\u573a\u666f\u3001\u7ed8\u56fe\u533a\u57df\u3001\u591a\u5a92\u4f53\u64ad\u653e\u5668\u7b49\u7b49\u3002\u6b64\u5916\uff0cPyQt5\u8fd8\u652f\u6301\u4e0eQt Designer\u96c6\u6210\uff0c\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u4f7f\u7528\u53ef\u89c6\u5316\u7684\u65b9\u5f0f\u8bbe\u8ba1\u548c\u5e03\u5c40\u754c\u9762\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6839\u636e\u9700\u6c42\u9700\u8981\u5f15\u7528\u5982\u4e0b\u7684\u7c7b\u548c\u51fd\u6570\uff1a<br>from PyQt5.QtWidgets import QApplication, QMainWindow, QDesktopWidget, QLabel, QPushButton, QGraphicsScene, QGraphicsView<br>from PyQt5.QtCore import Qt<br>from PyQt5.QtGui import QPainter<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b80\u5355\u4ecb\u7ecd\u8fd9\u4e9b\u7c7b\u548c\u51fd\u6570\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>QApplication<\/code>\uff1aQt\u5e94\u7528\u7a0b\u5e8f\u7c7b\uff0c\u7528\u4e8e\u7ba1\u7406\u5e94\u7528\u7a0b\u5e8f\u7684\u751f\u547d\u5468\u671f\u548c\u4e8b\u4ef6\u5faa\u73af\u3002<\/li>\n\n\n\n<li><code>QMainWindow<\/code>\uff1aQt\u4e3b\u7a97\u53e3\u7c7b\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5e26\u6709\u83dc\u5355\u680f\u3001\u5de5\u5177\u680f\u3001\u72b6\u6001\u680f\u7b49\u57fa\u672c\u754c\u9762\u7ec4\u4ef6\u7684\u7a97\u53e3\u3002<\/li>\n\n\n\n<li><code>QDesktopWidget<\/code>\uff1aQt\u684c\u9762\u7a97\u53e3\u7c7b\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e9b\u65b9\u6cd5\u6765\u83b7\u53d6\u684c\u9762\u7684\u5927\u5c0f\u548c\u5c4f\u5e55\u5206\u8fa8\u7387\u7b49\u4fe1\u606f\u3002<\/li>\n\n\n\n<li><code>QLabel<\/code>\uff1aQt\u6807\u7b7e\u7c7b\uff0c\u7528\u4e8e\u663e\u793a\u6587\u672c\u6216\u56fe\u50cf\u7b49\u5185\u5bb9\u3002<\/li>\n\n\n\n<li><code>QPushButton<\/code>\uff1aQt\u6309\u94ae\u7c7b\uff0c\u7528\u4e8e\u521b\u5efa\u53ef\u70b9\u51fb\u7684\u6309\u94ae\u3002<\/li>\n\n\n\n<li><code>QGraphicsScene<\/code>\uff1aQt\u56fe\u5f62\u573a\u666f\u7c7b\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4e8c\u7ef4\u56fe\u5f62\u573a\u666f\uff0c\u53ef\u4ee5\u5728\u5176\u4e2d\u6dfb\u52a0\u3001\u79fb\u52a8\u3001\u7f29\u653e\u548c\u65cb\u8f6c\u56fe\u5f62\u9879\u3002<\/li>\n\n\n\n<li><code>QGraphicsView<\/code>\uff1aQt\u56fe\u5f62\u89c6\u56fe\u7c7b\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4e8c\u7ef4\u56fe\u5f62\u89c6\u56fe\uff0c\u53ef\u4ee5\u5728\u5176\u4e2d\u663e\u793a<code>QGraphicsScene<\/code>\u4e2d\u7684\u56fe\u5f62\u9879\u3002<\/li>\n\n\n\n<li><code>QPainter<\/code>\uff1aQt\u7ed8\u56fe\u7c7b\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e9b\u65b9\u6cd5\u6765\u7ed8\u5236\u5404\u79cd\u56fe\u5f62\u3001\u6587\u672c\u548c\u56fe\u50cf\u7b49\u5185\u5bb9\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u6e90\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff08\u8be6\u7ec6\u6ce8\u91ca\u5df2\u5217\u51fa\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import sys\nimport random\nimport pygame\nfrom PyQt5.QtWidgets import QApplication, QMainWindow, QDesktopWidget, QLabel, QPushButton, QGraphicsScene, QGraphicsView\nfrom PyQt5.QtCore import Qt\nfrom PyQt5.QtGui import QPainter\n\n# \u6e38\u620f\u7a97\u53e3\u5927\u5c0f\nWINDOW_WIDTH = 800\nWINDOW_HEIGHT = 600\n\n# \u8d2a\u5403\u86c7\u65b9\u5757\u5927\u5c0f\nBLOCK_SIZE = 20\n\n# \u6e38\u620f\u533a\u57df\u5927\u5c0f\nGAME_AREA_WIDTH = WINDOW_WIDTH - BLOCK_SIZE * 2\nGAME_AREA_HEIGHT = WINDOW_HEIGHT - BLOCK_SIZE * 6\n\n# \u8d2a\u5403\u86c7\u521d\u59cb\u4f4d\u7f6e\nSNAKE_INIT_X = GAME_AREA_WIDTH \/\/ 2\nSNAKE_INIT_Y = GAME_AREA_HEIGHT \/\/ 2\n\n# \u8d2a\u5403\u86c7\u521d\u59cb\u79fb\u52a8\u65b9\u5411\nSNAKE_INIT_DIRECTION = 'right'\n\n# \u98df\u7269\u989c\u8272\nFOOD_COLOR = (255, 0, 0)\n\n# \u8d2a\u5403\u86c7\u989c\u8272\nSNAKE_COLOR = (0, 255, 0)\n\n# \u5206\u6570\u989c\u8272\nSCORE_COLOR = (255, 255, 255)\n\nclass SnakeGame:\n    def __init__(self):\n        # \u521d\u59cb\u5316Pygame\u5e93\n        pygame.init()\n\n        # \u521b\u5efa\u6e38\u620f\u7a97\u53e3\n        self.window = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))\n        pygame.display.set_caption('Snake Game')\n\n        # \u521b\u5efa\u6e38\u620f\u533a\u57df\u8868\u9762\n        self.game_area_surface = pygame.Surface((GAME_AREA_WIDTH, GAME_AREA_HEIGHT))\n\n        # \u521b\u5efa\u6e38\u620f\u533a\u57df\u77e9\u5f62\n        self.game_area_rect = pygame.Rect(BLOCK_SIZE, BLOCK_SIZE, GAME_AREA_WIDTH, GAME_AREA_HEIGHT)\n\n        # \u521b\u5efa\u8d2a\u5403\u86c7\u8868\u9762\n        self.snake_surface = pygame.Surface((BLOCK_SIZE, BLOCK_SIZE))\n\n        # \u521b\u5efa\u98df\u7269\u8868\u9762\n        self.food_surface = pygame.Surface((BLOCK_SIZE, BLOCK_SIZE))\n        self.food_surface.fill(FOOD_COLOR)\n\n        # \u521b\u5efa\u8d2a\u5403\u86c7\u521d\u59cb\u4f4d\u7f6e\u548c\u79fb\u52a8\u65b9\u5411\n        self.snake = [(SNAKE_INIT_X, SNAKE_INIT_Y)]\n        self.direction = SNAKE_INIT_DIRECTION\n\n        # \u521b\u5efa\u98df\u7269\u4f4d\u7f6e\n        self.food_pos = self.get_random_pos()\n\n        # \u521b\u5efa\u5206\u6570\n        self.score = 0\n\n    def start(self):\n        # \u521b\u5efa\u6e38\u620f\u65f6\u949f\n        clock = pygame.time.Clock()\n\n        # \u6e38\u620f\u5faa\u73af\n        while True:\n            # \u5904\u7406\u4e8b\u4ef6\n            for event in pygame.event.get():\n                if event.type == pygame.QUIT:\n                    pygame.quit()\n                    sys.exit()\n                elif event.type == pygame.KEYDOWN:\n                    if event.key == pygame.K_UP and self.direction != 'down':\n                        self.direction = 'up'\n                    elif event.key == pygame.K_DOWN and self.direction != 'up':\n                        self.direction = 'down'\n                    elif event.key == pygame.K_LEFT and self.direction != 'right':\n                        self.direction = 'left'\n                    elif event.key == pygame.K_RIGHT and self.direction != 'left':\n                        self.direction = 'right'\n\n            # \u79fb\u52a8\u8d2a\u5403\u86c7\n            head_x, head_y = self.snake[0]\n            if self.direction == 'up':\n                head_y -= BLOCK_SIZE\n            elif self.direction == 'down':\n                head_y += BLOCK_SIZE\n            elif self.direction == 'left':\n                head_x -= BLOCK_SIZE\n            elif self.direction == 'right':\n                head_x += BLOCK_SIZE\n\n            # \u5224\u65ad\u662f\u5426\u5403\u5230\u98df\u7269\n            if head_x == self.food_pos[0] and head_y == self.food_pos[1]:\n                self.snake.insert(0, (head_x, head_y))\n                self.food_pos = self.get_random_pos()\n                self.score += 10\n\n            else:\n                # \u5220\u9664\u8d2a\u5403\u86c7\u5c3e\u90e8\u65b9\u5757\n                self.snake.pop()\n\n                # \u5224\u65ad\u662f\u5426\u649e\u5899\u6216\u81ea\u649e\n                if not (BLOCK_SIZE &lt;= head_x &lt; GAME_AREA_WIDTH and BLOCK_SIZE &lt;= head_y &lt; GAME_AREA_HEIGHT) or (head_x, head_y) in self.snake:\n                    self.game_over()\n\n                else:\n                    # \u6dfb\u52a0\u8d2a\u5403\u86c7\u5934\u90e8\u65b9\u5757\n                    self.snake.insert(0, (head_x, head_y))\n\n            # \u7ed8\u5236\u6e38\u620f\u533a\u57df\u548c\u8d2a\u5403\u86c7\n            self.game_area_surface.fill((0, 0, 0))\n            for pos in self.snake:\n                pygame.draw.rect(self.game_area_surface, SNAKE_COLOR, (pos[0]-BLOCK_SIZE, pos[1]-BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE))\n            self.game_area_surface.blit(self.food_surface, (self.food_pos[0]-BLOCK_SIZE, self.food_pos[1]-BLOCK_SIZE))\n\n            # \u7ed8\u5236\u5206\u6570\n            font = pygame.font.SysFont(None, 36)\n            score_text = font.render(f'Score: {self.score}', True, SCORE_COLOR)\n            score_rect = score_text.get_rect()\n            score_rect.centerx = WINDOW_WIDTH \/\/ 2\n            score_rect.top = BLOCK_SIZE \/\/ 2\n            self.game_area_surface.blit(score_text, score_rect)\n\n            # \u5c06\u6e38\u620f\u533a\u57df\u8868\u9762\u7ed8\u5236\u5230\u6e38\u620f\u7a97\u53e3\u4e2d\u592e\u4f4d\u7f6e\n            window_centerx = WINDOW_WIDTH \/\/ 2\n            window_centery = WINDOW_HEIGHT \/\/ 2\n            game_area_centerx = BLOCK_SIZE + GAME_AREA_WIDTH \/\/ 2\n            game_area_centery = BLOCK_SIZE + GAME_AREA_HEIGHT \/\/ 2\n            x_offset = window_centerx - game_area_centerx\n            y_offset = window_centery - game_area_centery\n            self.window.fill((0, 0, 0))\n            self.window.blit(self.game_area_surface, (x_offset, y_offset))\n\n            # \u5237\u65b0\u5c4f\u5e55\u5e76\u63a7\u5236\u5e27\u7387\n            pygame.display.update()\n            clock.tick(10)\n\n    def get_random_pos(self):\n        x = random.randint(BLOCK_SIZE, GAME_AREA_WIDTH - BLOCK_SIZE)\n        y = random.randint(BLOCK_SIZE, GAME_AREA_HEIGHT - BLOCK_SIZE)\n        return (x \/\/ BLOCK_SIZE * BLOCK_SIZE, y \/\/ BLOCK_SIZE * BLOCK_SIZE)\n\n    def game_over(self):\n        print('Game over!')\n        pygame.quit()\n        sys.exit()\n\nclass SnakeWindow(QMainWindow):\n    def __init__(self):\n        super().__init__()\n\n        # \u8bbe\u7f6e\u7a97\u53e3\u6807\u9898\u548c\u5927\u5c0f\n        self.setWindowTitle('Snake Game')\n        self.setFixedSize(WINDOW_WIDTH, WINDOW_HEIGHT)\n\n        # \u8bbe\u7f6e\u7a97\u53e3\u5c45\u4e2d\u663e\u793a\n        screen_rect = QDesktopWidget().availableGeometry(self)\n        window_rect = self.frameGeometry()\n        window_rect.moveCenter(screen_rect.center())\n        self.move(window_rect.topLeft())\n\n        # \u521b\u5efa\u6e38\u620f\u573a\u666f\u548c\u89c6\u56fe\n        scene = QGraphicsScene()\n        view = QGraphicsView(scene)\n        view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)\n        view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)\n        view.setRenderHint(QPainter.Antialiasing)\n        view.setViewportUpdateMode(QGraphicsView.FullViewportUpdate)\n        view.setFixedSize(WINDOW_WIDTH, WINDOW_HEIGHT)\n\n        # \u521b\u5efa\u6e38\u620f\u6807\u7b7e\u548c\u6309\u94ae\n        label = QLabel('Snake Game', view)\n        label.setAlignment(Qt.AlignCenter)\n        label.setGeometry(0, 50, WINDOW_WIDTH, 100)\n\n        button_start = QPushButton('Start', view)\n        button_start.setGeometry(150, 200, 100, 50)\n        button_start.clicked.connect(self.start_game)\n\n        button_exit = QPushButton('Exit', view)\n        button_exit.setGeometry(550, 200, 100, 50)\n        button_exit.clicked.connect(self.close)\n\n        # \u5c06\u89c6\u56fe\u8bbe\u7f6e\u4e3a\u4e3b\u7a97\u53e3\u7684\u4e2d\u5fc3\u90e8\u4ef6\n        self.setCentralWidget(view)\n\n    def start_game(self):\n        # \u521b\u5efaSnakeGame\u5bf9\u8c61\u5e76\u5f00\u59cb\u6e38\u620f\u5faa\u73af\n        game = SnakeGame()\n        game.start()\n\nif __name__ == '__main__':\n    app = QApplication(sys.argv)\n    window = SnakeWindow()\n    window.show()\n    sys.exit(app.exec_())<\/pre>\n\n\n\n<pre id=\"block-b2307838-76b6-4971-93d4-bb53ed1eca4f\" class=\"wp-block-preformatted\">\n<\/pre>\n\n\n\n<pre id=\"block-39a8bb5e-3e76-4766-b876-73a44786e54c\" class=\"wp-block-preformatted\">\u6211\u4eec\u8fd0\u884c\u6d4b\u8bd5\u4e00\u4e0b\uff1a<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><noscript><img decoding=\"async\" width=\"868\" height=\"701\" src=\"http:\/\/xinyixx.com\/wp-content\/uploads\/2023\/06\/image-123.png\" alt class=\"wp-image-1532\" srcset=\"https:\/\/www.xinyixx.com\/wp-content\/uploads\/2023\/06\/image-123.png 868w, https:\/\/www.xinyixx.com\/wp-content\/uploads\/2023\/06\/image-123-300x242.png 300w, https:\/\/www.xinyixx.com\/wp-content\/uploads\/2023\/06\/image-123-768x620.png 768w\" sizes=\"(max-width: 868px) 100vw, 868px\"><\/noscript><img decoding=\"async\" width=\"868\" height=\"701\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20868%20701%22%3E%3C%2Fsvg%3E\" alt class=\"wp-image-1532 lazyload\" srcset=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20868%20701%22%3E%3C%2Fsvg%3E 868w\" sizes=\"(max-width: 868px) 100vw, 868px\" data-srcset=\"https:\/\/www.xinyixx.com\/wp-content\/uploads\/2023\/06\/image-123.png 868w, https:\/\/www.xinyixx.com\/wp-content\/uploads\/2023\/06\/image-123-300x242.png 300w, https:\/\/www.xinyixx.com\/wp-content\/uploads\/2023\/06\/image-123-768x620.png 768w\" data-src=\"http:\/\/xinyixx.com\/wp-content\/uploads\/2023\/06\/image-123.png\"><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><noscript><img decoding=\"async\" width=\"854\" height=\"760\" src=\"http:\/\/xinyixx.com\/wp-content\/uploads\/2023\/06\/image-122.png\" alt class=\"wp-image-1531\" srcset=\"https:\/\/www.xinyixx.com\/wp-content\/uploads\/2023\/06\/image-122.png 854w, https:\/\/www.xinyixx.com\/wp-content\/uploads\/2023\/06\/image-122-300x267.png 300w, https:\/\/www.xinyixx.com\/wp-content\/uploads\/2023\/06\/image-122-768x683.png 768w\" sizes=\"(max-width: 854px) 100vw, 854px\"><\/noscript><img decoding=\"async\" width=\"854\" height=\"760\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20854%20760%22%3E%3C%2Fsvg%3E\" alt class=\"wp-image-1531 lazyload\" srcset=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20854%20760%22%3E%3C%2Fsvg%3E 854w\" sizes=\"(max-width: 854px) 100vw, 854px\" data-srcset=\"https:\/\/www.xinyixx.com\/wp-content\/uploads\/2023\/06\/image-122.png 854w, https:\/\/www.xinyixx.com\/wp-content\/uploads\/2023\/06\/image-122-300x267.png 300w, https:\/\/www.xinyixx.com\/wp-content\/uploads\/2023\/06\/image-122-768x683.png 768w\" data-src=\"http:\/\/xinyixx.com\/wp-content\/uploads\/2023\/06\/image-122.png\"><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u91cc\u98df\u7269\u5728\u7a97\u53e3\u5185\u968f\u673a\u751f\u6210\uff0c\u5f53\u86c7\u5403\u5165\u98df\u7269\u4ee5\u540e\u81ea\u5df1\u7684\u8eab\u957f\u4f1a\u589e\u52a0\u4e00\u683c\uff0c\u968f\u4e4b\u5206\u6570\u4f1a\u589e\u52a0\u3002\u5f53\u86c7\u81ea\u5df1\u78b0\u649e\u5230\u81ea\u5df1\u8eab\u4f53\u6216\u8005\u649e\u5230\u7a97\u53e3\u8fb9\u7f18\u5219\u4f1a\u6e38\u620f\u7ed3\u675f\u3002\u611f\u5174\u8da3\u7684\u540c\u5b66\u5728pycharm\u91cc\u5c1d\u8bd5\u4e00\u4e0b\u5427\uff0c\u6709\u4e0d\u7406\u89e3\u7684\u6b22\u8fce\u5728\u8bc4\u8bba\u533a\u7559\u8a00\u8ba8\u8bba\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u60f3\u5fc5\u8d2a\u5403\u86c7\u8fd9\u4e2a\u6e38\u620f\u5927\u5bb6\u90fd\u73a9\u8fc7\uff0c\u90a3\u4e48\u8d2a\u5403\u86c7\u600e\u4e48\u5728python\u4ee3\u7801\u91cc\u5b9e\u73b0\u5462\uff1f \u4eca\u5929\u9700\u8981\u5f15\u5165 PyQt5\u662f\u4e00\u4e2a\u57fa\u4e8eQ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[15,10],"tags":[71,130,77],"class_list":["post-1530","post","type-post","status-publish","format-standard","hentry","category-games","category-coding","tag-python","tag-130","tag-coding","entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>python\u7a0b\u5e8f22\uff1a\u5199\u4e00\u4e2a\u7ecf\u5178\u6e38\u620f-\u8d2a\u5403\u86c7 - \u5fc3\u4e00\u4fe1\u606f<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"python\u7a0b\u5e8f22\uff1a\u5199\u4e00\u4e2a\u7ecf\u5178\u6e38\u620f-\u8d2a\u5403\u86c7 - \u5fc3\u4e00\u4fe1\u606f\" \/>\n<meta property=\"og:description\" content=\"\u60f3\u5fc5\u8d2a\u5403\u86c7\u8fd9\u4e2a\u6e38\u620f\u5927\u5bb6\u90fd\u73a9\u8fc7\uff0c\u90a3\u4e48\u8d2a\u5403\u86c7\u600e\u4e48\u5728python\u4ee3\u7801\u91cc\u5b9e\u73b0\u5462\uff1f \u4eca\u5929\u9700\u8981\u5f15\u5165 PyQt5\u662f\u4e00\u4e2a\u57fa\u4e8eQ [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/\" \/>\n<meta property=\"og:site_name\" content=\"\u5fc3\u4e00\u4fe1\u606f\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-24T13:30:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-24T13:31:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.xinyixx.com\/wp-content\/uploads\/2023\/06\/image-123.png\" \/>\n\t<meta property=\"og:image:width\" content=\"868\" \/>\n\t<meta property=\"og:image:height\" content=\"701\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"zentorno\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"zentorno\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/index.php\\\/2023\\\/06\\\/24\\\/python22\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/index.php\\\/2023\\\/06\\\/24\\\/python22\\\/\"},\"author\":{\"name\":\"zentorno\",\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/#\\\/schema\\\/person\\\/f6d999c2e397b7909f2a3490b537b8ee\"},\"headline\":\"python\u7a0b\u5e8f22\uff1a\u5199\u4e00\u4e2a\u7ecf\u5178\u6e38\u620f-\u8d2a\u5403\u86c7\",\"datePublished\":\"2023-06-24T13:30:34+00:00\",\"dateModified\":\"2023-06-24T13:31:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/index.php\\\/2023\\\/06\\\/24\\\/python22\\\/\"},\"wordCount\":46,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/index.php\\\/2023\\\/06\\\/24\\\/python22\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/xinyixx.com\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/image-123.png\",\"keywords\":[\"python\",\"\u6e38\u620f\",\"\u7f16\u7a0b\"],\"articleSection\":[\"\u6e38\u620f\",\"\u7f16\u7a0b\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.xinyixx.com\\\/index.php\\\/2023\\\/06\\\/24\\\/python22\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/index.php\\\/2023\\\/06\\\/24\\\/python22\\\/\",\"url\":\"https:\\\/\\\/www.xinyixx.com\\\/index.php\\\/2023\\\/06\\\/24\\\/python22\\\/\",\"name\":\"python\u7a0b\u5e8f22\uff1a\u5199\u4e00\u4e2a\u7ecf\u5178\u6e38\u620f-\u8d2a\u5403\u86c7 - \u5fc3\u4e00\u4fe1\u606f\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/index.php\\\/2023\\\/06\\\/24\\\/python22\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/index.php\\\/2023\\\/06\\\/24\\\/python22\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/xinyixx.com\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/image-123.png\",\"datePublished\":\"2023-06-24T13:30:34+00:00\",\"dateModified\":\"2023-06-24T13:31:16+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/index.php\\\/2023\\\/06\\\/24\\\/python22\\\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.xinyixx.com\\\/index.php\\\/2023\\\/06\\\/24\\\/python22\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/index.php\\\/2023\\\/06\\\/24\\\/python22\\\/#primaryimage\",\"url\":\"http:\\\/\\\/xinyixx.com\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/image-123.png\",\"contentUrl\":\"http:\\\/\\\/xinyixx.com\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/image-123.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/index.php\\\/2023\\\/06\\\/24\\\/python22\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\\\/\\\/www.xinyixx.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"python\u7a0b\u5e8f22\uff1a\u5199\u4e00\u4e2a\u7ecf\u5178\u6e38\u620f-\u8d2a\u5403\u86c7\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/#website\",\"url\":\"https:\\\/\\\/www.xinyixx.com\\\/\",\"name\":\"\u5fc3\u4e00\u4fe1\u606f\",\"description\":\"\u5b66\u4e60\u3001\u8bb0\u5f55\u3001\u5206\u4eab\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.xinyixx.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/#organization\",\"name\":\"\u5fc3\u4e00\u4fe1\u606f\",\"url\":\"https:\\\/\\\/www.xinyixx.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"http:\\\/\\\/www.xinyixx.com\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/11-1.png\",\"contentUrl\":\"http:\\\/\\\/www.xinyixx.com\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/11-1.png\",\"width\":1024,\"height\":1024,\"caption\":\"\u5fc3\u4e00\u4fe1\u606f\"},\"image\":{\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.xinyixx.com\\\/#\\\/schema\\\/person\\\/f6d999c2e397b7909f2a3490b537b8ee\",\"name\":\"zentorno\",\"sameAs\":[\"http:\\\/\\\/www.xinyixx.com\"],\"url\":\"https:\\\/\\\/www.xinyixx.com\\\/index.php\\\/author\\\/gorgegao\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"python\u7a0b\u5e8f22\uff1a\u5199\u4e00\u4e2a\u7ecf\u5178\u6e38\u620f-\u8d2a\u5403\u86c7 - \u5fc3\u4e00\u4fe1\u606f","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/","og_locale":"zh_CN","og_type":"article","og_title":"python\u7a0b\u5e8f22\uff1a\u5199\u4e00\u4e2a\u7ecf\u5178\u6e38\u620f-\u8d2a\u5403\u86c7 - \u5fc3\u4e00\u4fe1\u606f","og_description":"\u60f3\u5fc5\u8d2a\u5403\u86c7\u8fd9\u4e2a\u6e38\u620f\u5927\u5bb6\u90fd\u73a9\u8fc7\uff0c\u90a3\u4e48\u8d2a\u5403\u86c7\u600e\u4e48\u5728python\u4ee3\u7801\u91cc\u5b9e\u73b0\u5462\uff1f \u4eca\u5929\u9700\u8981\u5f15\u5165 PyQt5\u662f\u4e00\u4e2a\u57fa\u4e8eQ [&hellip;]","og_url":"https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/","og_site_name":"\u5fc3\u4e00\u4fe1\u606f","article_published_time":"2023-06-24T13:30:34+00:00","article_modified_time":"2023-06-24T13:31:16+00:00","og_image":[{"width":868,"height":701,"url":"https:\/\/www.xinyixx.com\/wp-content\/uploads\/2023\/06\/image-123.png","type":"image\/png"}],"author":"zentorno","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"zentorno","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/#article","isPartOf":{"@id":"https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/"},"author":{"name":"zentorno","@id":"https:\/\/www.xinyixx.com\/#\/schema\/person\/f6d999c2e397b7909f2a3490b537b8ee"},"headline":"python\u7a0b\u5e8f22\uff1a\u5199\u4e00\u4e2a\u7ecf\u5178\u6e38\u620f-\u8d2a\u5403\u86c7","datePublished":"2023-06-24T13:30:34+00:00","dateModified":"2023-06-24T13:31:16+00:00","mainEntityOfPage":{"@id":"https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/"},"wordCount":46,"commentCount":0,"publisher":{"@id":"https:\/\/www.xinyixx.com\/#organization"},"image":{"@id":"https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/#primaryimage"},"thumbnailUrl":"http:\/\/xinyixx.com\/wp-content\/uploads\/2023\/06\/image-123.png","keywords":["python","\u6e38\u620f","\u7f16\u7a0b"],"articleSection":["\u6e38\u620f","\u7f16\u7a0b"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/","url":"https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/","name":"python\u7a0b\u5e8f22\uff1a\u5199\u4e00\u4e2a\u7ecf\u5178\u6e38\u620f-\u8d2a\u5403\u86c7 - \u5fc3\u4e00\u4fe1\u606f","isPartOf":{"@id":"https:\/\/www.xinyixx.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/#primaryimage"},"image":{"@id":"https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/#primaryimage"},"thumbnailUrl":"http:\/\/xinyixx.com\/wp-content\/uploads\/2023\/06\/image-123.png","datePublished":"2023-06-24T13:30:34+00:00","dateModified":"2023-06-24T13:31:16+00:00","breadcrumb":{"@id":"https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/#primaryimage","url":"http:\/\/xinyixx.com\/wp-content\/uploads\/2023\/06\/image-123.png","contentUrl":"http:\/\/xinyixx.com\/wp-content\/uploads\/2023\/06\/image-123.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.xinyixx.com\/index.php\/2023\/06\/24\/python22\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.xinyixx.com\/"},{"@type":"ListItem","position":2,"name":"python\u7a0b\u5e8f22\uff1a\u5199\u4e00\u4e2a\u7ecf\u5178\u6e38\u620f-\u8d2a\u5403\u86c7"}]},{"@type":"WebSite","@id":"https:\/\/www.xinyixx.com\/#website","url":"https:\/\/www.xinyixx.com\/","name":"\u5fc3\u4e00\u4fe1\u606f","description":"\u5b66\u4e60\u3001\u8bb0\u5f55\u3001\u5206\u4eab","publisher":{"@id":"https:\/\/www.xinyixx.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.xinyixx.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Organization","@id":"https:\/\/www.xinyixx.com\/#organization","name":"\u5fc3\u4e00\u4fe1\u606f","url":"https:\/\/www.xinyixx.com\/","logo":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.xinyixx.com\/#\/schema\/logo\/image\/","url":"http:\/\/www.xinyixx.com\/wp-content\/uploads\/2023\/05\/11-1.png","contentUrl":"http:\/\/www.xinyixx.com\/wp-content\/uploads\/2023\/05\/11-1.png","width":1024,"height":1024,"caption":"\u5fc3\u4e00\u4fe1\u606f"},"image":{"@id":"https:\/\/www.xinyixx.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.xinyixx.com\/#\/schema\/person\/f6d999c2e397b7909f2a3490b537b8ee","name":"zentorno","sameAs":["http:\/\/www.xinyixx.com"],"url":"https:\/\/www.xinyixx.com\/index.php\/author\/gorgegao\/"}]}},"_links":{"self":[{"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/posts\/1530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/comments?post=1530"}],"version-history":[{"count":0,"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/posts\/1530\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/media?parent=1530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/categories?post=1530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/tags?post=1530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}