Skip to main content

No project description provided

Project description

tkfly

基于tkintertcl / tk扩展的中型组件库

tkflytkinter插上翅膀飞翔,意为借助扩展的功能翱翔。

(tklib -大小约3.7MB)

(twapi -大小约2.06MB)

帮助你开发大型高级的程序

教程

开始

tkfly通过tkinter调用tcl导入tklib实现,可以实现tklib库所能实现的各种功能。

# 暂时处于预览版
python -m pip install tkfly --pre

工具提示

让我来运行一个最简单工具提示吧! (基于tklib/tooltip)

from tkinter import Tk, ttk
from tkfly import FlyToolTip

root = Tk()

tooltip = FlyToolTip()

button = ttk.Button()
tooltip.tooltip(button, "button1")
button.pack()

root.mainloop()

输入框小组件的历史记录功能

输入框没有历史记录功能一直是个遗憾,但是可以通过扩展组件实现 (基于tklib/history)

from tkinter import Tk, Entry, ttk
from tkfly import FlyHistory

root = Tk()

entry = ttk.Entry()
entry.pack()

history = FlyHistory(entry)
history.add(114514)
history.add(3.1415926)
history.up()

root.mainloop()

你可以通过按键盘上下键切换历史记录文本。

初始化

history.init() 

初始化时会有一个必选参数widget和一个可选参数lenwidget是目标组件,len是设定的长度。

初始化完成后,就可以通过上下键来切换了

添加记录

history.add() 

添加需要一行字串符参数,添加后可以用上下键切换找到记录

获取历史记录列表

history.get() 

你将会得到一个元组

日期输入框

可以通过上下键调整日期

from tkinter import Tk
from tkfly import FlyDateField

root = Tk()

datefield = FlyDateField()
datefield.pack()

datefield2 = FlyDateField(format="%Y-%m-%d")
datefield2.pack()

root.mainloop()

日期格式

可以通过format参数修改格式,示例"%Y-%m-%d",其中%Y是年号,%m是月份,%d是天。

tkscrollutil

实际上这就是作者我以前做过的一个项目。

ScrolllArea

可以快速地为水平滚动、垂直滚动组件设置滚动条

属性

autohidescrollbars 设置组件是否自动隐藏滚动条。布尔数值。默认False。也就是说,当你把鼠标指针放到滚动条上时,滚动条才会显示。

lockinterval 设置组件滚动条地锁定间隔。整数数值。默认300.

respectheader 仅当将嵌入到组件内地tablelist版本为6.5及以上版本时才能使用,后续等开发出tablelist的扩展库时补充

respecttitlecolumns 仅当将嵌入到组件内地tablelist版本为6.5及以上版本时才能使用,后续等开发出tablelist的扩展库时补充

xscrollbarmode 设置水平滚动条的模式。可选值为static dynamic none。默认nonestatic为常驻滚动条;dynamic为自动滚动条;none为没有滚动条

yscrollbarmode 设置垂直滚动条的模式。可选值为static dynamic none。默认staticstatic为常驻滚动条;dynamic为自动滚动条;none为没有滚动条

方法

setwidget 设置具有滚动条属性的组件,使组件快速设置滚动条。

示例

from tkinter import Tk, Listbox
from tkfly.tkscrollutil import ScrollArea

Window = Tk()

Area = ScrollArea(Window)
List = Listbox(Area)
for Item in range(50):
    List.insert(Item+1, Item+1)
Area.setwidget(List)
Area.pack(fill="both", expand="yes")

Window.mainloop()

ttkScrollArea

见上方。与ScrollArea不同的是,ttkScrollArea具有ttk组件的属性,并且ScrollAreattkScrollArea不能同时使用。

示例

from tkinter import Tk, Listbox
from tkfly.tkscrollutil import ttkScrollArea

Window = Tk()

Area = ttkScrollArea(Window)
List = Listbox(Area)
for Item in range(50):
    List.insert(Item+1, Item+1)
Area.setwidget(List)
Area.pack(fill="both", expand="yes")

Window.mainloop()

ScrollSync

同步滚动条,当其中一个滚动时,另一个也会跟随着移动起来。

方法

setwidgets 设置同步滚动的组件。需输入列表,如 [widget1, widget2] 。

widgets 获取同步滚动的组件。

示例

from tkinter import Tk, Listbox, Frame
from tkfly.tkscrollutil import ScrollArea, ScrollSync
Window = Tk()

Frame = Frame()

Area = ScrollArea(Frame, yscrollbarmode="static")
Sync = ScrollSync(Area)
Area.setwidget(Sync)

Area.pack(fill="y", side="right")

List1 = Listbox()
List1.pack(fill="both", side="left", expand="yes")
List2 = Listbox()
List2.pack(fill="both", side="right", expand="yes")

for Item in range(300):
    List1.insert(Item, Item)
    List2.insert(Item, Item)

Sync.setwidgets([List1, List2])

Frame.pack(fill="both", expand="yes")

Window.mainloop()

ttkScrollSync

见上方。与ScrollSync不同的是,ttkScrollSync具有ttk组件的属性,并且ScrollSyncttkScrollSync不能同时使用。

示例

from tkinter import Tk, Listbox, Frame
from tkfly.tkscrollutil import ttkScrollArea, ttkScrollSync
Window = Tk()

Frame = Frame()

Area = ttkScrollArea(Frame, yscrollbarmode="static")
Sync = ttkScrollSync(Area)
Area.setwidget(Sync)

Area.pack(fill="y", side="right")

List1 = Listbox()
List1.pack(fill="both", side="left", expand="yes")
List2 = Listbox()
List2.pack(fill="both", side="right", expand="yes")

for Item in range(300):
    List1.insert(Item, Item)
    List2.insert(Item, Item)

Sync.setwidgets([List1, List2])

Frame.pack(fill="both", expand="yes")

Window.mainloop()

ttkScrolledNoteBook

scrollutil本身不提供ScrolledNoteBook,只有ttk能够提供。

from tkinter import Tk, Frame
from tkfly.tkscrollutil import ttkScrolledNoteBook, addclosetab
Window = Tk()

NoteBook = ttkScrolledNoteBook(Window)

addclosetab("TNotebook")

NoteBook.add(Frame(NoteBook), text="Hello World")
NoteBook.pack(fill="both", expand="yes")

Window.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

tkfly-0.1.0a2.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

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

tkfly-0.1.0a2-py3-none-any.whl (2.2 MB view details)

Uploaded Python 3

File details

Details for the file tkfly-0.1.0a2.tar.gz.

File metadata

  • Download URL: tkfly-0.1.0a2.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.2 Windows/10

File hashes

Hashes for tkfly-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 8ee95a2af33bae5fcbe16f54a6f3fb8ef6ba713aa00106190427456002468cf4
MD5 caa21216a2652d05834e5255607acc86
BLAKE2b-256 85c888bea68ec4774cf24a8ceeff02d38dae31bb1afc6667eb87835adcf7117f

See more details on using hashes here.

File details

Details for the file tkfly-0.1.0a2-py3-none-any.whl.

File metadata

  • Download URL: tkfly-0.1.0a2-py3-none-any.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.2 Windows/10

File hashes

Hashes for tkfly-0.1.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 70b02c812beef628b12397c89f3ee7e794b95163b7a4b22af81f52febb8c4bd2
MD5 c991b5145b64734fa9784622c93e00cd
BLAKE2b-256 bdf948748889db068fa3211dccb8e8b7888033e1a30691799646a480468e6b21

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