Skip to main content

tinui高级滑动条

Project description

TinUISlider

TinUI的高级滑动条控件。

[!NOTE]

tinuislider提供sliderlightsliderdark两种样式配色


CenterSlider

tinuislider.centerslider.CenterSlider

CenterSlider(
    canvas: BasicTinUI,
    pos: tuple,
    width=200,
    fg="#4554dc",
    activefg="#4554dc",
    bg="#868686",
    buttonbg="#ffffff",
    buttonoutline="#cccccc",
    data=(1, 2, 3, 4, 5),
    start=None, # 默认为中间索引
    direction="x",
    anchor="nw",
    command=None,
)

参数与TinUI原生scalebar一致。

注意start是索引,不是值。

[!tip]

通过CenterSlider.uid获取控件标识符,用于TinUI面板布局。其对面板布局的响应与原生scalebar一致。

select(num)

选中某一项索引

disable(sign='#C8C8C8')

禁用,sign为禁用时标识色。

active_state()

激活控件。

get()

获取当前选中值

set(value)

选中某一项,需要在data中。

示例

from tkinter import Tk
from tinui import ExpandPanel, VerticalPanel
def on_resize(event):
    rp.update_layout(10,10,event.width-10,event.height-10)
r=Tk()

ui=BasicTinUI(r)
ui.pack(fill='both',expand=True)

slider = CenterSlider(
    canvas=ui,
    pos=(0, 100),
    width=200,
    data=range(-10,11),
    start=3, # start是索引,不是值,所以这里是选中数据中的第4项
    anchor="center",
    command=lambda v: print(f"Selected: {v}")
)

# 获取当前值
val = slider.get()
print(f"Current value: {val}")
slider.set(5)  # 设置选中值为 5
print(f"Value after set: {slider.get()}")

rp = ExpandPanel(ui)
vp = VerticalPanel(ui)
rp.set_child(vp)

ep1 = ExpandPanel(ui)
vp.add_child(ep1, weight=1)
ep1.set_child(slider.uid)

ui.bind("<Configure>", on_resize)

r.mainloop()

RangeSlider

tinuislider.rangeslider.RangSlider

RangeSlider(
    canvas: BasicTinUI,
    pos: tuple,
    width=200,
    fg="#4554dc",
    activefg="#4554dc",
    bg="#868686",
    buttonbg="#ffffff",
    buttonoutline="#cccccc",
    data=(1, 2, 3, 4, 5),
    start_left=None,
    start_right=None,
    direction="x",
    anchor="nw",
    command=None,
)
  • start_left::小段索引
  • start_right::大端索引

disable(sign='#C8C8C8')

禁用。

active_state()

激活控件。

get()

获取当前大小两端选值

set(left=None, right=None)

设置大小两端选值,需要在data中。可单独设置。

示例

from tkinter import Tk
from tinui import ExpandPanel, VerticalPanel
def on_resize(event):
    rp.update_layout(10,10,event.width-10,event.height-10)
def on_change(val):
    print("Range:", val)

root = Tk()
root.geometry("400x200")

ui = BasicTinUI(root)
ui.pack(fill="both", expand=True)

slider = RangeSlider(
    canvas=ui,
    pos=(100, 100),
    width=250,
    data=list(range(0, 101, 10)),
    start_left=2,
    start_right=7,
    anchor="center",
    direction='y',
    command=on_change,
)

rp = ExpandPanel(ui)
vp = VerticalPanel(ui)
rp.set_child(vp)

ep1 = ExpandPanel(ui)
vp.add_child(ep1, weight=1)
ep1.set_child(slider.uid)

ui.bind("<Configure>", on_resize)

root.mainloop()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tinuislider-1.2.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tinuislider-1.2.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file tinuislider-1.2.0.tar.gz.

File metadata

  • Download URL: tinuislider-1.2.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for tinuislider-1.2.0.tar.gz
Algorithm Hash digest
SHA256 d5a419d185f6d6cf95b32ef2a9088329139daa022c306052f25acdb6b9a31892
MD5 d62a335c97c9559c45692227eb2cf18a
BLAKE2b-256 fad1c0503914d5fec345db7764898d4eacb8a10b99e1762c15a99e0be93ffc8a

See more details on using hashes here.

File details

Details for the file tinuislider-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: tinuislider-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for tinuislider-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8b0fa3b722176ee8b8f399bc2a3706c69455c0b4794dca01206b665708df660
MD5 5978dd4936a7e840debb3d7530d1ec6e
BLAKE2b-256 5db878112bbbb63a3c5864aff14e53cc398da74e4ca2fac48ea1675531335be7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page