python - 更改“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)
解决方案
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
推荐阅读
- javascript - TypeError:从类重构为函数组件后,Object(...) 不是函数
- r - R中for循环和ifelse的组合
- google-drive-api - 出现错误:已超出未经验证使用的每日限制。继续使用需要注册
- node.js - 使用 PayPal 从 nodejs 应用程序汇款
- django - 将对象添加到另一个模型上的 ManyToMany 字段后如何调用 post_save 信号
- video - 如何摆脱黑色边框(视频)?
- python - 包含“n”前行和“m”后行的熊猫滚动窗口
- php - 数组数组的php计数 - 与预期不同的值
- c - glibc 的 isalpha 函数和 en_US.UTF-8 语言环境
- python - Tkinter画布问题,3天前开始编码