KevinP
KevinP

Reputation: 313

Determining terminal width in IPython qtconsole

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 ?

Upvotes: 4

Views: 621

Answers (2)

Orwellophile
Orwellophile

Reputation: 13933

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()

Upvotes: 0

c_w
c_w

Reputation: 1

Try to change the width and height in ipython_qtconsole_config.py

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

Upvotes: 0

Related Questions