Matrix block

369 views
Skip to first unread message

Merlin04

unread,
Oct 13, 2020, 10:47:46 PM10/13/20
to Blockly
Does anyone have a matrix block with adjustable dimensions that I can use? Making lists of lists gets really annoying. I saw something a bit like what I want at https://fr.vittascience.com/python/ but I can't find the source code anywhere and the width of the matrix always matches the height of it.

feni...@google.com

unread,
Oct 16, 2020, 6:05:27 PM10/16/20
to Blockly
It looks like you can create that block with a https://developers.google.com/blockly/guides/create-custom-blocks/extensions fairly trivially. You'll have to keep track of your rows and columns to make sure you know what to add and delete, but that's fine--you can use input and field names that include the index.

Rachel

Léo Briand

unread,
Oct 17, 2020, 10:40:29 AM10/17/20
to Blockly
Hi,
I'm Leo, CEO at Vittascience (https://fr.vittascience.com/python/)
If you want I can send you the code we wrote for the python matrix and you can try to adapt it to custom rows and columns sizes?
Best,
Leo

Merlin04

unread,
Oct 17, 2020, 3:00:30 PM10/17/20
to Blockly
That would be amazing, thank you!

feni...@google.com

unread,
Oct 19, 2020, 4:01:12 PM10/19/20
to Blockly
Thanks Leo!

Cheers,
Rachel
On Saturday, October 17, 2020 at 7:40:29 AM UTC-7 leobr...@gmail.com wrote:

Léo Meillier

unread,
Oct 28, 2020, 8:04:47 AM10/28/20
to Blockly
Hi Rachel, Merlin,
Let's see source code of matrix block matrix_block.js  from Numpy category : (https://fr.vittascience.com/python/)
cheers,
Léo  

Merlin04

unread,
Nov 7, 2020, 12:43:52 PM11/7/20
to Blockly
Hi,

I am working on integrating your matrix block code with my code, I installed the blockly plus minus package and added the import line to the top of the file: "import  '@blockly/block-plus-minus';" however, I am getting the error Uncaught Error: Error: Extension "block_buttons_plus_minus" not found. Is there a different package I should be using?

Thanks for the help.

Léo Meillier

unread,
Nov 8, 2020, 4:58:00 PM11/8/20
to Blockly
Hi,

We don't use blockly package for integrating plus and minus in blocks. 
I just modified matrix_blocks.js file with plus and minus code extension at the end of file.

Feel free to ask me other questions.


Merlin04

unread,
Nov 10, 2020, 9:07:05 PM11/10/20
to Blockly
Ok, thank you so much, I was able to get it to work and modify it to support non-square matrixes and to keep the existing values when being resized.

Merlin04

unread,
Nov 10, 2020, 9:08:53 PM11/10/20
to Blockly
I tried including an image and it didn't work, let's see if this will work:
Screenshot from 2020-11-10 18-05-51.png

C Ben

unread,
Nov 18, 2020, 5:44:06 PM11/18/20
to Blockly
Hello,
This table/matrix block could be very useful ! How do you implement multiples +/- buttons.
Moreover, I've tried to implement the matrix.js file shared by Leo from VITTASCIENCE, but the function
update_: function(update) {
        return Blockly.matrix.UPDATE_BLOCK_MUTATOR_MIXIN(this, update);
    }, doesn't work because UPDATE_BLOCK_MUTATOR_MIXIN is not present in the source file.
What the update_ is supposed to do/trigger in general ?
I have to say that Mutator is quite stuff to implement/understand ...

Thanks,
Chris

Merlin04

unread,
Nov 18, 2020, 6:20:35 PM11/18/20
to Blockly

I had to copy UPDATE_BLOCK_MUTATOR_MIXIN from the Vittascience website. The code generation in that file uses some things specific to my project but it shouldn't be too difficult to recreate.

C Ben

unread,
Nov 25, 2020, 1:15:12 PM11/25/20
to Blockly
Thanks a lot, it works like a charm.
To go  further, do you imagine it could be possible to implement a matrix that acccepts other blocks instead of number, to put it shortly a matrix with the same behavior than the list block which accepts any kind of blocks.
I've  naively optimistic tried to change the appendField(new Blockly.FieldTextInput()...) into appendValueInput(...) as it looks like in the blockly's list block but no success.
Chris

Beka Westberg

unread,
Nov 25, 2020, 6:23:54 PM11/25/20
to blo...@googlegroups.com
Hello,

Currently there's no way to have inline inputs on multiple different rows, but there is a feature request to include that! If this is a feature that is important to you I would suggest giving that issue a thumbs up, or leaving a comment explaining your use case. Input on issues, and info about what things are most important to you are always appreciated =)

Best,
Beka

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/0fb80a2b-4c3b-406e-b0ee-b5401325ed5en%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages