How can I replace division sign with slash in ticks of BarLegend

ticks = {π/6, π/3, π/2, 2 π/3};
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {π/6 - .1, 2 π/3 + .1}}, 
 LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"], 
 ColorFunctionScaling -> False, 
 "Ticks" -> Transpose[{#, # /. Times[Rational[a_, b_], Pi] :> Row[{a Pi, "/", b}]} &@
    ticks}], 
 LegendMarkerSize -> {30, 300}]

enter image description here

Alternatively, add the option "TickLabels":

BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {π/6 - .1, 2 π/3 + .1}}, 
 LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"], 
 ColorFunctionScaling -> False, "Ticks" -> ticks, 
 "TickLabels" -> (ticks /. Times[Rational[a_, b_], Pi] :> Row[{a Pi, "/", b}]), 
 LegendMarkerSize -> {30, 300}]

enter image description here


Something like this will work:

BarLegend[{
  Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {\[Pi]/6 - .1, 2 \[Pi]/3 + .1}
  },
 LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
 ColorFunctionScaling -> False, 
 Ticks -> ({#, InputForm@#} & /@ {\[Pi]/6, \[Pi]/3, \[Pi]/2, 
     2 \[Pi]/3})]

The idea is to pass a list like {{x1,label1},{x2,label2}...} to Ticks.

enter image description here

Since it seems like you know exactly what you want to put into your ticks, you could just put strings:

BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {\[Pi]/6 - .1, 
   2 \[Pi]/3 + .1}}, 
 LabelStyle -> 
  Directive[Black, Bold, Medium, FontFamily -> "Courier"], 
 ColorFunctionScaling -> False,
 Ticks -> 
  Transpose[{{\[Pi]/6, \[Pi]/3, \[Pi]/2, 2 \[Pi]/3}, {"\[Pi]/6", 
     "\[Pi]/3", "\[Pi]/2", "2\[Pi]/3"}}]]

enter image description here