首页 > 解决方案 > 更改“py.exe”的窗口大小

问题描述

我正在读取文件并将文件写入“py.exe”屏幕。我有一个 *.py 脚本,我双击它会弹出“py.exe”窗口,我在其中进行操作。

一切都很好,但是默认的窗口尺寸有点横向,我想一直不用“windows+leftcursor”。

我想将 py.exe 窗口的默认尺寸更改为我想要的尺寸。

import easygui

filenames=easygui.fileopenbox('Welcome',default='c:\data\*.ers',multiple=True)

for filename in filenames:
    with open(filename) as f:
               print("\n\n" + filename + "\n\n", f)

我想更改其默认尺寸的 py.exe 窗口

标签: python

解决方案


import os
os.system("mode con cols=100 lines=300")

现在更好了,我使用 win32gui 将窗口定位在某个位置和大小

import win32gui
hwnd = win32gui.GetForegroundWindow()
win32gui.MoveWindow(hwnd, 100, 0, 1100, 1000, True)

你需要先安装pywin32

pip install pywin32

推荐阅读