qzx
qzx

Reputation: 177

how do I increase the width of pandastable

I have the following in Python:

from tkinter import Tk, Frame
from pandastable import Table
import pandas as pd

xx = Tk()
xx.state('zoomed')
xx.title('The Sheet')
f = Frame(xx, width=800, height=400, bd=2)
f.place(x=20, y=20)

df = pd.DataFrame([], columns=['a', 'b', 'c', 'd', 'e', 'f'])
df = df.append({'a': 123, 'b': 'asdf ery', 'c': 345.1, 'd': 'qweqwe qweqwe', 'e': 123.2, 'f': 45646.4}, ignore_index=True)
df = df.append({'a': 234, 'b': 'qwersdfg sdfg', 'c': 7234.9, 'd': 'asd asd asdasd asd', 'e': 21.7, 'f': 1123.8}, ignore_index=True)
df = df.append({'a': 456, 'b': 'zxcv xcvb', 'c': 1209.3, 'd': 'zxc zxc zxc zxc zxc zxc', 'e': 1.298, 'f': 10023.6}, ignore_index=True)
pt = Table(f, dataframe=df, showtoolbar=False, showstatusbar=False)
pt.show()

xx.mainloop()

However, no matter how much I increased the Frame width, the displayed table remains the same size. I want to show all the six columns. How is this done?

Upvotes: 0

Views: 3545

Answers (1)

Chetan Vashisth
Chetan Vashisth

Reputation: 456

Try adding this to your code..

1.

f.pack(fill='both',expand=True)

2.

f.pack(fill='x',expand=True)  # Will best suit your case
# will expand the frame on x-axis

3.

f.pack(fill='y',expand=True)  # Will expand the frame in y axis

Hope this helps

Upvotes: 1

Related Questions