我正在处理这个tkinter项目..它目前不需要滚动条,但我想在添加更多按钮时添加一个。我希望滚动条滚动按钮,但不是顶部的徽标...(运行代码看看我的意思(虽然按钮会无用......)
(我已经开始制作了,但我不知道它是否不起作用,因为这些东西已经适合窗口,或者只是因为代码设置错误了?)
代码:
#~~~ PyKit ~~~#
dir = "./" #file directory
#~~~ IMPORT ~~~#
from tkinter import *
import sys
import os
import webbrowser
import subprocess
from subprocess import run
from subprocess import call
master = Tk()
master.title("PyKit")
master.geometry("670x443")
scrollbar = Scrollbar(master)
scrollbar.pack(side = RIGHT, fill = BOTH)
subprocess.run("start cmd ", cwd=dir, shell = True)
#~~~ DEFENITIONS ~~~#
def quit():
global master
master.destroy()
def tm():
global master
subprocess.run("start cmd /K" + 'tm.py', cwd=dir, shell = True)
def np():
global master
subprocess.run("start cmd /K " + 'np.py', cwd = dir, shell = True)
def cl():
global master
subprocess.run("start cmd /K " + 'cl.py', cwd = dir, shell = True)
def callback(event):
webbrowser.open_new(r"https://github.com/timmyiscool8/PyKit")
#~~IMAGE~~#
igm = PhotoImage(file=dir+"PyKitLogo.gif")
link = Label(master, image=igm, fg="blue", cursor="hand2")
link.pack()
link.bind("<Button-1>", callback)
#~~~ BUTTONS ~~~#
while True:
#FRAME#
f = Frame(master, height=300, width=300)
f.pack_propagate(0)
f.pack()
#ACTUAL BUTTONS#
button2 = Button(f, compound=CENTER, text="⌨Terminal⌨",font=('Helvetica', 12), command=tm).pack()
button3 = Button(f, compound=CENTER, text="✐NoteIt!✎", font=('Helvetica', 12), command=np).pack()
button4 = Button(f, compound=CENTER, text="×Calculator÷",font=('Helvetica', 12), command=cl).pack()
button5 = Button(f, compound=CENTER, text="✘Quit✘",font=('Helvetica', 12), command=quit).pack()
master.mainloop()