最近用Tk写了个UI,发现TK里面的scrollbar并不像Java里面可以attach到各种组件,只能attach到诸如frame和canvas等少量组件,如果想实现一个带scrollbar的text area或者checkbox list就需要额外实现,而且对于鼠标的滚轮动作默认不感知,也需要额外实现。总之,python的TK开发起来还是挺烦的,没有事件监听,很多地方都需要用TK var...
7. bind_mouse_scroll 8. set_scrollregion 总结 直接继承tk.Frame类,可以带横向和竖向的滚动条。 1. __init__ class TkScrollableFrame(tk.Frame): """ A frame with one or two scrollbars. Used to make Columns with scrollbars """ def __init__(self, master, vertical_only, element, window,...
tkinter中的widget主要有Button(按钮), Checkbutton(复选按钮),Canvas(画布),Entry(条目), Frame(框架), Label(标签), LabelFrame(标签框架),Listbox(列表框),menu(菜单),Menubutton(菜单按钮),Message (消息),OptionMenu(选项菜单),PanedWindow(中分栏窗口), Radiobutton(单选按钮), Scale(刻度条), Scrollbar(...
root.geometry("300x200") frame = tkinter.Frame(root) frame.pack() rSlider = tkinter.Scale(frame, from_=0, to=255, command=show) gSlider = tkinter.Scale(frame, from_=0, to=255, command=show) bSlider = tkinter.Scale(frame, from_=0, to=255, command=show) rSlider.grid(row=0, co...
calc = Button(frame_output,text='计算', command=Answ) cle = Button(frame_output,text='清除', command=Clea) #---滑动Scrollbar--- scr1 = Scrollbar(frame_input) lb.configure(yscrollcommand = scr1.set) scr1['command']=lb.yview scr2 = Scrollbar(frame...
frame=tk.Frame(root,bg="#f0f0f0") frame.pack(padx=10,pady=10) label=tk.Label(frame,text="ClipboardContents:",bg="#f0f0f0") label.grid(row=0,column=0) scrollbar=tk.Scrollbar(root) scrollbar.pack(side=tk.RIGHT,fill=tk.Y) ...
scrollbar.config(command=listbox.yview) listbox.bind("<MouseWheel>", scroll) listbox.pack() root.mainloop() 8、为Canvas组件(画布)绑定回调函数 import tkinter as tk def draw_line(event): canvas.create_line(0, 0, event.x, event.y) ...
_init__(parent)banklistframe=LabelFrame(self,width=350,height=350,text="银行列表")banklistframe.grid(row=0,column=1,sticky=E+W)cardnolistframe=Frame(self,width=350,height=350)cardnolistframe.grid(row=0,column=2,sticky=E+W)xscrollbar=Scrollbar(banklistframe,orient='horizontal')yscrollbar...
This was replaced with attk.Labelto ensure it matched the frame. We also did away with the 1990's sunken "3d" look. label = ttk.Label(self) Last but not least, we can replace the original Tk scrollbar with the newerttk.Scrollbarwidget. ...
Many applications require a listbox or text widget that displays a scrollbar when the number of lines displayed exceeds the widget height. Tk supports merging of several widgets into a larger widget that can be reused in other applications. These compound widget interfaces are commonly called mega...