W = root_window.tk.call

# change the font

font = 'mono 12'
fname,fsize = font.split()
root_window.tk.call('font','configure','TkDefaultFont','-family',fname,'-size',fsize)

# redo the text in tabs so they resize for the new default font

root_window.tk.call('.pane.top.tabs','itemconfigure','manual','-text',' Manual - F3 ')
root_window.tk.call('.pane.top.tabs','itemconfigure','mdi','-text',' MDI - F5 ')
root_window.tk.call('.pane.top.right','itemconfigure','preview','-text',' Preview ')
root_window.tk.call('.pane.top.right','itemconfigure','numbers','-text',' DRO ')

###############  choose/remove sliders ########################
#root_window.tk.call('grid','forget','.pane.top.feedoverride')
root_window.tk.call('grid','forget','.pane.top.rapidoverride')
#root_window.tk.call('grid','forget','.pane.top.spinoverride')
#root_window.tk.call('grid','forget','.pane.top.jogspeed')
root_window.tk.call('grid','forget','.pane.top.ajogspeed')
root_window.tk.call('grid','forget','.pane.top.maxvel')
############ remove active gcodes lable and codes ##########
root_window.tk.call('grid','forget','.pane.top.gcodel')
#root_window.tk.call('grid','forget','.pane.top.gcodes')

## -remove bottom frame -##
root_window.tk.call('pack','forget','.pane.bottom.t.text')
root_window.tk.call('pack','forget','.pane.bottom.t.sb')

###add common frame beside t.test
root_window.tk.call('labelframe','.pane.bottom.common')
root_window.tk.call('grid','.pane.bottom.common','-column','0','-row','1','-sticky','nw')
root_window.tk.call('grid','columnconfigure','.pane.bottom.common','0','-weight','1')

##### add userframe corrdinate display as baseline working test ######
W = root_window.tk.call
W('label','.pane.bottom.common.ucs','-text','G5x')
W('grid','.pane.bottom.common.ucs','-column','0','-row','0','-sticky','w')
 
#### add feedrate lable and grid into bottom.common ####################
W('label','.pane.bottom.common.feedrate-upm','-anchor','se','-width','5','-fg','blue')
W('label','.pane.bottom.common.feedrate-upmlab','-text','FEED','-anchor','w','-width','4')
W('grid','.pane.bottom.common.feedrate-upm','-row','1','-column','1','-rowspan','1','-sticky','se')
W('grid','.pane.bottom.common.feedrate-upmlab','-row','1','-column','0','-sticky','w')
##spindle-speed
W('label','.pane.bottom.common.spindle-speed2','-anchor','se','-width','5','-fg','blue')
W('label','.pane.bottom.common.spindle-speed2lab','-text','S','-anchor','w','-width','4')
W('grid','.pane.bottom.common.spindle-speed2','-row','2','-column','1','-rowspan','1','-sticky','se')
W('grid','.pane.bottom.common.spindle-speed2lab','-row','2','-column','0','-sticky','w')
## tool number
W('label','.pane.bottom.common.tool-number2','-anchor','se','-width','5','-fg','blue')
W('label','.pane.bottom.common.tool-numberlab','-text','T','-anchor','w','-width','4')
W('grid','.pane.bottom.common.tool-number2','-row','3','-column','1','-rowspan','1','-sticky','se')
W('grid','.pane.bottom.common.tool-numberlab','-row','3','-column','0','-sticky','w')


####### update feedrate
def user_live_update():
    root_window.tk.call('.pane.bottom.common.feedrate-upm','configure','-text','%3.0f' % (comp['feedrate-upm']))
    root_window.tk.call('.pane.bottom.common.spindle-speed2','configure','-text','%3.0f' % (comp['spindle-speed2']))
    root_window.tk.call('.pane.bottom.common.tool-number2','configure','-text','%3.0f' % (comp['tool-number2']))

    ###coordinate
    W('.pane.bottom.common.ucs','configure','-text','U:' + all_systems[o.last_g5x_index].split()[1])


def user_hal_pins():
    # create new hal pins
    #mycomp = hal.component('feed')
    comp.newpin('feedrate-upm', hal.HAL_FLOAT, hal.HAL_IN)
    comp.newpin('spindle-speed2', hal.HAL_FLOAT, hal.HAL_IN)
    comp.newpin('tool-number2', hal.HAL_U32, hal.HAL_IN)
    comp.ready()
    # create new signals and connect pins
    
    hal.new_sig('feedrate-upm',hal.HAL_FLOAT)
    #hal.connect('feedrate-upm','motion.feed-upm')
    #hal.connect('axisui.feedrate-upm','feedrate-upm')
##### end feed test




####  repack bottom ####
root_window.tk.call('pack','.pane.bottom.t.sb','-fill','y','-side','left')
root_window.tk.call('pack','.pane.bottom.t.text','-fill','both','-expand','1','-side','top')
root_window.tk.call('pack','.pane.bottom.t.text','-fill','both','-expand','1','-side','left')
########## resize bottom pane #######
root_window.tk.call('.pane','paneconfigure','.pane.bottom',"-stretch","always","-height","400",'-width','700');

#### end new common frame test #####




######### resize top pane ########
###### smaller manual frame /11 lines of gcode ########
root_window.tk.call('.pane','paneconfigure','.pane.top',"-stretch","never","-minsize","250");
##### bigger manual frame /7 lines of gcode #####
#root_window.tk.call('.pane','paneconfigure','.pane.top',"-stretch","never","-minsize","300");

########### window resize #########
#root_window.tk.call(".pane","configure","-height","350");

########### display z plane in preview  ###########
commands.set_view_z()

########### window resize ##################
#root_window.tk.call("wm","geometry",".","700x440")
#root_window.tk.call("wm","geometry",".","800x480")
#root_window.attributes("-fullscreen",1)





# disable the do you want to close dialog
root_window.tk.call("wm","protocol",".","WM_DELETE_WINDOW","destroy .")

# change dro screen
root_window.tk.call('.pane.top.right.fnumbers.text','configure','-foreground','limegreen','-background','black')


#modal text
root_window.tk.call('.pane.top.gcodes','configure'
,'-foreground','limegreen'
,"-font","mono 11 bold"
,'-background','black')


#gcode preview text
root_window.tk.call(pane_bottom+".t.text","configure"
,"-foreground","Limegreen"
,"-font","mono 11 "
,"-background","black")

#estop button
root_window.tk.call(".toolbar.machine_estop","configure"
,"-image",""
,"-text","ESTOP"
,"-activebackground","red"
,"-background","red"
,"-helptext","Toggle Emergency Stop [F1]"
,"-borderwidth","5"
,"-font","fixedsys 12 bold"
,"-height","2"
,"-width","6"
,"-highlightthickness", 1
,"-highlightcolor","black"
,"-highlightbackground","black"
,"-takefocus",0
,"-padx",5
,"-pady",5
);

#powerbutton
root_window.tk.call(".toolbar.machine_power","configure"
,"-image",""
,"-text","POWER"
,"-activebackground","green"
,"-background","green"
,"-helptext","Toggle Machine power [F2]"
,"-borderwidth","5"
,"-font","fixedsys 12 bold"
,"-height","2"
,"-width","6"
,"-highlightthickness", 1
,"-highlightcolor","black"
,"-highlightbackground","black"
,"-takefocus",0
,"-padx",5
,"-pady",5
);




