[출처 : http://withrobot.tistory.com/136]


앞선 예제에서는 슬라이더의 눈금(tick)이 너무 조밀하게 나와서 별로 예쁘지가 않다. 원하는 간격으로 눈금을 출력하려면 SetTickFreq()를 사용한다. 

입력 파라미터는 두 개인데, 첫 번째 것은 간격이고, 두 번째 것은 사용하지 않는 파라미터로 1을 넣으면 된다.

사용자 삽입 이미지

SetTickFreq(10,1) 설정

#!/usr/bin/env python

"""10-2. Slider, tick frequency 설정 """

# http://withrobot.tistory.com
# 2007.11.26

import wx

class Frame(wx.Frame):
    def __init__(self, parent=None, id=-1, title='Slider'):
        wx.Frame.__init__(self, parent, id, title, size=(300,300), pos=(100,100) )
        panel = wx.Panel(self)

        mySlider = wx.Slider(panel,100,25,1,100,pos=(10,10),size=(250,-1),style=wx.SL_HORIZONTAL|wx.SL_AUTOTICKS |wx.SL_LABELS)
        mySlider.SetTickFreq(10,1)
        
class App(wx.App):
    def OnInit(self):
        self.frame = Frame()
        self.frame.Show()
        return True

def main():
    app = App()
    app.MainLoop()

if __name__ == '__main__':
    main()

+ Recent posts