<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># keep track of the tool
my_tool = 0

# new set_view_y3 function for GlNavBase
def glnav_set_view_y3(self):
    self.reset
    glRotatef(-90, 0, 1, 0)
    glRotatef(-90, 0, 0, 0)
    mid, size = self.extents_info()
    glTranslatef(-mid[0], -mid[1], -mid[2])
    self.set_eyepoint_from_extents(size[0], size[2])
    self.perspective = False
    # lat and lon values don't seem to be doing anything
    self.lat = -90
    self.lon = 0
    self.redraw()

# new set_view_y3 function for tcl commands
def set_view_y3(event=None):
    widgets.view_z.configure(relief="link")
    widgets.view_z2.configure(relief="link")
    widgets.view_x.configure(relief="link")
    widgets.view_y.configure(relief="link")
    widgets.view_y2.configure(relief="sunken")
    widgets.view_p.configure(relief="link")
    vars.view_type.set(6)
    o.set_view_y3()

# add glnav_set_view_y3 to GlNavBase as set_view_y3
GlNavBase.set_view_y3 = glnav_set_view_y3

# add set_view_y3 to the tcl commands
TclCommands.set_view_y3 = set_view_y3
commands = TclCommands(root_window)

# add Y3 view to the View menu
root_window.eval(f".menu.view insert 5 radiobutton \
                   -variable view_type \
                   -value 6 \
                   -command set_view_y3 \
                   -accelerator V \
                   -label {{{_('Custom Y3 view')}}}")

# change command for Y2 button to the new Y3 view
root_window.eval(f".toolbar.view_y2 configure -command set_view_y3")

# repopulate the right side of the toolbar
tButtons = ["view_p","rotate","rule12","clear_plot"]
for tButton in tButtons:
    root_window.eval(f"pack forget .toolbar.{tButton}")
root_window.eval(f"pack .toolbar.view_y2 -side left")
for tButton in tButtons:
    padding = "-padx 4 -pady 4 -fill y" if tButton == 'rule12' else ""
    root_window.eval(f"pack .toolbar.{tButton} -side left {padding}")

# runs every GUI cycle
def user_live_update():
    global my_tool
    # set the view to Y3 if tool #2 is in the spindle
    if my_tool != s.tool_in_spindle:
        my_tool = s.tool_in_spindle
        if my_tool == 2:
            commands.set_view_y3()
        else:
            commands.set_view_p()
</pre></body></html>