Gui: Set the width of a column in a table

Place to get help with not working mods / modding interface.
User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 239
Joined: Sat Nov 09, 2019 6:49 am
Contact:

Gui: Set the width of a column in a table

Post by picklock »

I am trying to set the width of a column in a table within my gui. I get the error message: xxy

I have tried to implement it with the following code:

Code: Select all

local myFrame = myGui.add{
type = "frame",
style = "inside_shallow_frame",
}.add{
	type = "table",
	style = "bordered_table",
	column_count = 3,
}
myFrame.style.column_alignments[3] = "right" --this works
myFrame.style.column_widths[3] = 200 --this throws error: LuaStyle doesn't contain key column_widths.
Now I'm a bit confused because setting the alignment with column_alignments works. But with the column_widths I used to set the column width I get the above error message. Both properties I used are from the TableStyleSpecification of the API Docs. I assumed that both properties can be called in the same way.
What am I doing wrong?
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters | Picklocks QuickBar Import/Export | Picklocks Nauvis Cliff-Explosives
User avatar
BraveCaperCat
Filter Inserter
Filter Inserter
Posts: 430
Joined: Mon Jan 15, 2024 10:10 pm
Contact:

Re: Gui: Set the width of a column in a table

Post by BraveCaperCat »

picklock wrote: Wed Nov 13, 2024 2:12 pm I am trying to set the width of a column in a table within my gui. I get the error message: xxy

I have tried to implement it with the following code:

Code: Select all

local myFrame = myGui.add{
type = "frame",
style = "inside_shallow_frame",
}.add{
	type = "table",
	style = "bordered_table",
	column_count = 3,
}
myFrame.style.column_alignments[3] = "right" --this works
myFrame.style.column_widths[3] = 200 --this throws error: LuaStyle doesn't contain key column_widths.
Now I'm a bit confused because setting the alignment with column_alignments works. But with the column_widths I used to set the column width I get the above error message. Both properties I used are from the TableStyleSpecification of the API Docs. I assumed that both properties can be called in the same way.
What am I doing wrong?
Not reading the docs properly.
This doesn't work:

Code: Select all

myFrame.style.column_widths[3] = 200
But this should:

Code: Select all

myFrame.style.column_widths[3].width = 200
Creator of multiple mods, including Quality Assurance - My most popular one.
Go check them out with the first and second links!
I'll probably be wanting or giving help with modding most of the time I spend here on the forum.
User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 239
Joined: Sat Nov 09, 2019 6:49 am
Contact:

Re: Gui: Set the width of a column in a table

Post by picklock »

BraveCaperCat wrote: Wed Nov 13, 2024 2:39 pm Not reading the docs properly.
This doesn't work:

Code: Select all

myFrame.style.column_widths[3] = 200
But this should:

Code: Select all

myFrame.style.column_widths[3].width = 200
Thanks for the quick reply.

Oh yes, I have read the documentation and also tried the code you suggested. The error occurred there too. Somehow it doesn't seem to recognise the property column_widths.

I have also tried it individually with the following lines. The result was always negative.

Code: Select all

myFrame.style.column_widths[3].minimal_width = 200
myFrame.style.column_widths[3].maximal_width = 200
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters | Picklocks QuickBar Import/Export | Picklocks Nauvis Cliff-Explosives
Post Reply

Return to “Modding help”