How to edit tool table without using glade tool table widget

More
03 Aug 2018 14:06 - 03 Aug 2018 15:39 #115518 by cgibbons
I am trying to display and update the table table values in individual text editor boxes as opposed to the tool table edit widget supplied with GladeVCP. I have tried two approaches to this.

1)
I have followed the python interface documentation. I have used the tool_table command to access the data in the tool table and display it in my individual labels and text edit boxes. I have then made an update button which tried to assign the new values in these text edit boxes/ labels by assigning the tool_table element to the content of these. I'll give you an example of this to help explain my efforts.
        tool = self.stat.tool_table[1].id
	self.widgets.test.set_text(tool.diameter)

    def on_update_clicked(self, widget, data=None):
	tool.diameter = self.widgets.test.get_text()

This displays the values correctly but does not update them as I get an error saying that tool.diameter is read only

2)
I followed how the tooledit1 widget was edited and updated in gmoccapy. Using get_toolinfo() and the toolinfo array. Again I will show you an example of this to help explain.
        tool = self.stat.tool_table[var].id
	toolinfo = self.widgets.tooledit1.get_toolinfo( tool )
        self.widgets.test.set_text(toolinfo[12])

    def on_update_clicked(self, widget, data=None):
	var = 1
	tool = self.stat.tool_table[var].id
	toolinfo = self.widgets.tooledit1.get_toolinfo( tool )
	toolinfo[12] = self.widgets.test.get_text()
This method successfully displayed all values, the update method correctly updated toolinfo[12] and the toolinfo array. However, even after clicking the tooledit table apply and reload buttons, this did not update the tool table. I cannot think of any other way to update the tool table.

Any help would be greatly appreciated.
Attachments:
Last edit: 03 Aug 2018 15:39 by cgibbons.

Please Log in or Create an account to join the conversation.

More
03 Aug 2018 21:43 #115555 by cmorley
#1 won't work because linuxcnc doesn't have a mechanism to update the tool file in this way - one must update the actual tool file and tell linuxcnc to reload it.

#2
self.widgets.tooledit1.get_toolinfo() returns a list array of tool info from the parsed toolfile. it is not automatically saved to the tool file.
In fact in that list array it is only used to update the GTK's liststore object.
The liststore object is what is parsed and saved to the file.

Todo what you want I believe you could:
1) update tooledits' liststore model and then resave the tool file
You need to study the tooledit widget reload() to do this.
roughly you clear the model and parse the individual tool info, add it to the model
with self.add(), untill the whole file is done. then save()

or
2) you may be able to programmically edit the model directly using col_editted()
The problem is you won't know what row to update.

3) create your own functions to update the toolfile from your widgets
This avoids the tooledit's model but possibly breaks things because of it.
If you are going to do 3 you might as well make your own widget to do it.

Chris M

Please Log in or Create an account to join the conversation.

Moderators: newbynobiHansU
Time to create page: 0.208 seconds
Powered by Kunena Forum