When running IPyhton qtconsole, how can the number of columns be determined for maximizing text display so that it looks good in the current setting ?
Asked
Active
Viewed 587 times
4
-
related: [How to get console window width in python](http://stackoverflow.com/q/566746/4279) – jfs Jan 07 '15 at 05:58
-
It can't. We know that's not ideal for some situations, but it's part of a general principle that code shouldn't know too much about what may currently be displaying its output. – Thomas K Jan 09 '15 at 01:06
-
it looks like the code is out there in the qtconsole (ConsoleWidget.sizeHint()), but I can't figure out how to get to that from the script running underneath the qtconsole – KevinP Jan 11 '15 at 04:23
2 Answers
0
Try to change the width and height in ipython_qtconsole_config.py
# c.IPythonWidget.width = 81
# c.IPythonWidget.height = 25

c_w
- 1
0
sizeHint() didn't work well for me (didn't resize with the window), but size() worked fine.
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:
globals()['obj'] = self
In my case, the qtconsole is launched from IDA, so I can then access via:
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()

Orwellophile
- 13,235
- 3
- 69
- 45