New side panel and axisui pins

More
6 years 1 day ago #187935 by cakeslob
The way the fanuc controller scrolls/searches through gcode and runs from line is something to be desired in linuxcnc, you can use the arrows to go up or down in the gcode, or use the arrows and search bar to to just forward and backwards to the next instance of a gcode, like scrolling through, looking for all the m6 commands. I use this feature every work day on the fanuc, so I though I would try to implement it. I almost have it, but im a bit stuck again, and need some guidance.
Code:
##### search function ######### def select_g3(event): # remove tag 'found' from index 1 to END t.tag_remove('found', '1.0', END) # returns to widget currently in focus s = "3" if (s): idx = '1.0' while 1: # searches for desried string from index 1 idx = t.search(s, idx, nocase = 1, forwards = 1, stopindex = END) if not idx: break # last index sum of current index and # length of text lastidx = '% s+% dc' % (idx, len(s)) # overwrite 'Found' at idx t.tag_add('found', idx, lastidx) idx = lastidx t.see(idx) # mark located string as red t.tag_config('found', foreground ='red') ###### gcode scroll ###### root_window.bind('<Key-1>', select_next) root_window.bind('<Key-2>', select_prev) root_window.bind('<Key-3>', rClicker) root_window.bind('<Key-4>', select_g3)


here is the farthest ive got with the search function. there is no entry widget, im just using key4 to search the file for "3". it works, but it finds them all at once and jumps to the very last found line, instead of one at a time. since that was as far as i could get function wise, i started packing widgets for the other part of it
Code:
####### add search_bar ######### ## add search entry widget ### W('entry','.pane.bottom.common.srch_bar','-width','15') W('button','.pane.bottom.common.srch_btn','-text','search') W('button','.pane.bottom.common.scrl_up','-text','^','-command','select_next') W('button','.pane.bottom.common.scrl_dwn','-text','V','-command','select_prev') #W('button','.pane.bottom.common.srch_btn','-text','search','-command','search_gcode') W('grid','.pane.bottom.common.srch_bar','-column','0','-row','4','-sticky','nw') W('grid','.pane.bottom.common.scrl_up','-column','3','-row','0','-sticky','ne') W('grid','.pane.bottom.common.srch_btn','-column','0','-row','5','-sticky','nw') W('grid','.pane.bottom.common.scrl_dwn','-column','3','-row','5','-sticky','ne') ##### search function ######### search = 'Entry','.pane.bottom.common.srch_bar' def search_gcode(event): # remove tag 'found' from index 1 to END t.tag_remove('found', '1.0', END) # returns to widget currently in focus s = search.get() if (s): idx = '1.0' while 1: # searches for desried string from index 1 idx = t.search(s, idx, nocase = 1, stopindex = END) if not idx: break # last index sum of current index and # length of text lastidx = '% s+% dc' % (idx, len(s)) # overwrite 'Found' at idx t.tag_add('found', idx, lastidx) idx = lastidx t.see(idx) # mark located string as red t.tag_config('found', foreground ='red') ###### gcode scroll ###### root_window.bind('<Key-1>', select_next) root_window.bind('<Key-2>', select_prev) root_window.bind('<Key-3>', rClicker) #root_window.bind('<Key-4>', select_g3) W('.pane.bottom.common.srch_btn','configure','-command','search_gcode') TclCommands.search_gcode = search_gcode commands = TclCommands(root_window) #### end search stuff #########

This file is usercommand_search, it has all the layout. But once i added the entry widget I started getting a bunch of errors with the search feature, like tuple and now it says Im not presenting an argument. Im a bit stuck here. Im also having a hard time binding these to buttons. binding them to keyboard commands works fine and easy but to do buttons it made a whole thing of it being events and such. the whole thing is pretty crude, but the main functions and widgets are all there.

so, what Im trying to get it to do in the very end
-put something in search
-search arrow next button jumps/highlights the closest line with that expression
-search arrow prev jumps backwards to the closest line
-hijack the run command to do something similar to fanuc, like, if not line 1 push button again to run from line

the tkinter text widget has a log of unused features. it looks like it has the ability to edit as well, here is my progress so far
The following user(s) said Thank You: phillc54

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

More
6 years 1 day ago #187938 by cakeslob
g code window line scroll and run from line keyboard keys

This part was much easier. In axis, there is already defined actions to scroll up and down g code as well as run from line. this is very handy for lots of reasons, mostly if you prefer keyboard only type setups. To transfer this to buttons is a bit more work and im not there yet. This was the first part of my test, since it was already included in axis.py, it just needed to be fixed
Code:
###### gcode scroll ###### root_window.bind('<Key-1>', select_next) root_window.bind('<Key-2>', select_prev) root_window.bind('<Key-3>', rClicker)
crude, but working example of gcode scroll line and run from line using the keyboard.
key 1 moves the highlighted line to the next spot
key 2 moves it to previous line
key 3 is supposed to run from line, but because the righclick dialog is part of it, it opens the dialog and i use arrow key to run from line
this is different from axis because this scrolls with the highlighted line

select_next and select_prev are already defined, but when I went looking, they dont seem to be tied to anything, so i bound them to some keys. select previous worked fine outta the box. select next always jumped back to line 1 and never advanced. so i had to change it a bit
Code:
def select_prev(event): if o.highlight_line is None: i = o.last_line else: i = max(1, o.highlight_line - 1) o.set_highlight_line(i) o.tkRedraw() def select_next(event): if o.highlight_line is None: i = 1 else: i = min(o.last_line, o.highlight_line + 1) o.set_highlight_line(i) o.tkRedraw()

Code:
def select_next(event): if o.highlight_line is None: i = 1 else: i = max(o.last_line, o.highlight_line + 1) o.set_highlight_line(i) o.tkRedraw()

I changed select_next from i = min to i = max and it now scrolls next correctly
The following user(s) said Thank You: phillc54

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

More
5 years 11 months ago - 5 years 11 months ago #188432 by cakeslob
[strike]I am stuck and need help.
I have the search part working, but I cannot send the text from the search entry to the search command. i just keeps searching for " '.pane.bottom.common.srch_bar.get()' " [/strike] ahh i got it, just have to figure out how to clear the entries/highlights
attached file "usercommand_search.py"
Code:
def search_gcode(event): # remove tag 'found' from index 1 to END #t.tag_remove('found', '1.0', END) s = W ('.pane.bottom.common.srch_bar','get') #s = "g3" if (s): line = o.get_highlight_line() idx = ("%d.0" % (line+1)) # searches for desried string from index highlighted line idx = t.search(s, idx, nocase = 1, forwards = 1, stopindex = END) # last index sum of current index and # length of text lastidx = '% s+% dc' % (idx, len(s)) # overwrite 'Found' at idx t.tag_add('found', idx, lastidx) idx = lastidx t.see(idx) # mark located string as red t.tag_config('found', background ='yellow') idxh = int(idx.split('.')[0]) o.set_highlight_line(idxh) o.tkRedraw() '.pane.bottom.common.srch_bar.set(" ")'


this is the working search command. it searches forward and highlights the line containing the search (g3) using key 4. then using key3 you can run from line or pressing 4 again searches for the next line with g3. attached file "usercommand_searchg3.py"

Code:
def select_g3(event): # remove tag 'found' from index 1 to END t.tag_remove('found', '1.0', END) # returns to widget currently in focus s = "G3" #lastidx = 1.0 if (s): # line = o.get_highlight_line() idx = ("%d.0" % (line+1)) # searches for desried string from index 1 idx = t.search(s, idx, nocase = 1, forwards = 1, stopindex = END) # last index sum of current index and # length of text lastidx = '% s+% sc' % (idx, len(s)) # overwrite 'Found' at idx t.tag_add('found', idx, lastidx) #t.tag_ranges('found') idx = lastidx t.see(idx) # mark located string as red t.tag_config('found', background ='yellow') idxh = int(idx.split('.')[0]) o.set_highlight_line(idxh) o.tkRedraw() ###### gcode scroll ###### root_window.bind('<Key-1>', select_next) root_window.bind('<Key-2>', select_prev) root_window.bind('<Key-3>', rClicker) root_window.bind('<Key-4>', select_g3)

known issues so far
-it searches the line numbers
-doesnt remove highlight even if you change search query
-it needs cleaning up for when no search entry, or end of search
-buttons dont work yet
Last edit: 5 years 11 months ago by cakeslob.

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

More
5 years 11 months ago #188478 by cakeslob



File Attachment:

File Name: usercomman..._tabs.py
File Size:13.71 KB


-add new tab to left side
not a fancy dynamic tab or glade, but like the manual tab
Code:
### ADD NEW TAB TO LEFT SIDE ####### W('.pane.top.tabs','insert','end', 'user', '-text','user') ########### add buttons to tab ######### W('grid','columnconfigure','.pane.top.tabs.fuser','0','-weight','1') W('button','.pane.top.tabs.fuser.scrl','-text','^','-command','select_next') W('grid','.pane.top.tabs.fuser.scrl','-column','1','-row','1','-sticky','ne') W('label','.pane.top.tabs.fuser.ucs','-text','G5x') W('grid','.pane.top.tabs.fuser.ucs','-column','0','-row','1','-sticky','nw')


-add buttons to preview frame
cant get it to go first, cant figure out how to forget the preview widget or what the name is

Code:
################### add button to preview ################## W('grid','columnconfigure','.pane.top.right.fpreview','0','-weight','1') W('button','.pane.top.right.fpreview.scrl','-text','^','-command','select_next') W('pack','.pane.top.right.fpreview.scrl','-side','left','-anchor','nw')

-expand widgets
press number 5 and 6 to toggle the 2 options
Code:
def toggle_show_bottom(*event): # need to toggle variable manually for keyboard shortcut if len(event) > 0: vars.show_pyvcppanel.set(not vars.show_pyvcppanel.get()) if vars.show_pyvcppanel.get(): root_window.tk.call('grid','.pane.top','-row','1') root_window.tk.call('.pane','paneconfigure','.pane.top',"-stretch","never","-minsize","350"); root_window.tk.call('grid','.pane.bottom','-row','2') root_window.tk.call('.pane','paneconfigure','.pane.bottom',"-stretch","always",'-width','500'); else: root_window.tk.call('grid','remove','.pane.top') root_window.tk.call('.pane','paneconfigure','.pane.top',"-stretch","always","-minsize","150"); root_window.tk.call('.pane','paneconfigure','.pane.bottom',"-stretch","never",'-width','500','-height','500'); o.tkRedraw() root_window.bind('<Key-5>', toggle_show_bottom) root_window.bind('<Key-6>', toggle_show_tabs) TclCommands.toggle_show_bottom = toggle_show_bottom TclCommands.toggle_show_tabs = toggle_show_tabs commands = TclCommands(root_window)


The following user(s) said Thank You: phillc54, reboots

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

More
1 year 5 months ago #328719 by Dave2024
Hey that is awesome how you customized the Axis interface like that. Is there a way I can get a copy of that to use on my machine? I really need a search feature in Axis for the GCode so I'm able to goto a specific line and rerun the cut. Like so Im able to search for M6 T1 or M6 T3, T4, T5, etc.... and then re-run the code from that line after changing the tool diameter and making fine tuning of the parts using cutter compensation and or fine tuning the coordinate shifts. Anyways cool! I need this too

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

More
1 year 5 months ago #329067 by cakeslob
Hey, you can try this one out, its still got some buts but it does the thing you want
github.com/cakeslob/regularmac_800/tree/search_gcode

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

Time to create page: 0.380 seconds
Powered by Kunena Forum