简体   繁体   English

在 IPython qtconsole 中确定终端宽度

[英]Determining terminal width in IPython qtconsole

运行 IPyhton qtconsole 时,如何确定列数以最大化文本显示,使其在当前设置中看起来不错?

Try to change the width and height in ipython_qtconsole_config.py尝试更改 ipython_qtconsole_config.py 中的宽度和高度

# c.IPythonWidget.width = 81
# c.IPythonWidget.height = 25

sizeHint() didn't work well for me (didn't resize with the window), but size() worked fine. sizeHint() 对我来说效果不佳(没有随窗口调整大小),但 size() 效果很好。

In [10]: ipyida.ida_plugin.obj.widget.parent.size()
Out[10]: PyQt5.QtCore.QSize(1241, 894)

To get access to the running instance, I had to patch the .py file that imported qtconsole and insert this:为了访问正在运行的实例,我必须修补导入 qtconsole 的 .py 文件并插入:

globals()['obj'] = self

In my case, the qtconsole is launched from IDA, so I can then access via:就我而言,qtconsole 是从 IDA 启动的,因此我可以通过以下方式访问:

instance be accessed via:   
    import ipyida           
    ipyida.ida_plugin.obj.* 

To calculate the number of character columns, you will have do something like this:要计算字符列的数量,您将执行以下操作:

f = ipyida.ida_plugin.obj.widget.parent.fontInfo()
f.pixelSize() # 11
w = ipyida.ida_plugin.obj.widget.parent.size().width() // f.pixelSize()

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

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