由于某种原因,第二个选项卡上的按钮间隔太大,我花了相当多的时间尝试使用行配置和框架等随机内容来修复此问题,但它从来没有起作用。
import tkinter as tk
import tkinter.messagebox
from tkinter import *
from tkinter import ttk
import webbrowser
import time
import os
# Creating all the functions of the program
def Open_Discord():
webbrowser.open(url,new=new)
def biosite():
webbrowser.open(url2,new=new)
def mygithub():
webbrowser.open(url3, new=new)
def taskmgr():
time.sleep(0.3)
os.system("start taskmgr")
time.sleep(0.2)
tkinter.messagebox.showinfo(title="Multi Tool", message="Task Manager is Running!")
def ctrlpanel():
time.sleep(0.3)
os.system("start control")
time.sleep(0.2)
tkinter.messagebox.showinfo(title="Multi Tool", message="Control Panel is Running")
# Main settings of gui(title, size etc)
root = tk.Tk()
root.iconbitmap('C:/users/eac/Pictures/multitool.ico')
root.title("Multi Tool")
root.geometry("500x400")
# Choosing wether to open new tab or window then setting the actual url to goto
new = 1
url = "https://discord.gg/dbApbadrwD"
url2 = "https://fakecrime.bio/eac"
url3 = "https://github.com/BigDawgStepper"
# Creating main notebook
my_notebook = ttk.Notebook(root)
my_notebook.pack(expand=1, fill='both')
# Adding the tabs to the notebook/packing them
my_tab1 = ttk.Frame(my_notebook)
my_notebook.add(my_tab1, text="Welcome")
my_tab2 = ttk.Frame(my_notebook)
my_notebook.add(my_tab2, text="Tools")
# Tab 1 Labels
Label(my_tab1, text= "Welcome to BigDawgSteppers MultiTool", font= ('Helvetica 18 bold underline')).grid(row=0, column=0)
Label(my_tab1, text= "This Multi Tool has many features! Refer to the tabs at the top to locate tools!").grid(row=1, column=0)
Label(my_tab1, text= "Interested in my work or want to talk to me? Join the discord below!").grid(row=2, column=0)
Label(my_tab1, text= "You can join my disc using the button or copying this link! https://discord.gg/dbApbadrwD").grid(row=3, column=0)
Label(my_tab1, text= "Tool currently working for Win11 & Win10", font= ('Helvetica 18 bold')).grid(row=12, column=0)
Label(my_tab1, text= "Who is TheBigDawgStepper? Click the button below for more info...").grid(row=5, column=0)
Label(my_tab1, text= "This isnt the only tool ive made theres multiple version of this and more on my github!").grid(row=7, column=0)
Label(my_tab1, text= "^^^^AS OF 2024-05-22^^^^", font= ('Helvetica 18 bold')).grid(row=13, column=0)
# Tab 2 Labels
Label(my_tab2, text="Hey there this is the Tools Tab, have fun!", font= ('Helvetica 18 bold underline')).grid(row=0, column=0)
# Creating Frames
Frame(my_tab2, width=250, height=250).grid()
# Tab 1 Buttons
Button(my_tab1, text="Join my Discord Server Here!", padx=10, pady=10, command=Open_Discord).grid(row=8, column=0)
Button(my_tab1, text="Who even is TheBigDawgStepper?", padx=10, pady=10, command=biosite).grid(row=9, column=0)
Button(my_tab1, text="My github!", padx=10, pady=10, command=mygithub).grid(row=10, column=0)
# Tab 2 buttons
Button(my_tab2, text="Open Task Manager", command=taskmgr).grid(row=1, column=0)
Button(my_tab2, text="Open Control Panel", command=ctrlpanel).grid(row=2, column=0)
root.mainloop()
我尝试使用 rowconfigure 来设置大小,但它没有做任何事情我尝试使用 .pack 而不是网格然后程序甚至没有运行然后现在我尝试制作一个框架并将其放入框架中但没有运气
如果要将两个按钮放入高度为250的框架中,则需要将两个按钮的
parent
选项设置为该框架,而不是my_tab2
:
frame = Frame(my_tab2, width=250, height=250)
frame.grid()
Button(frame, text="Open Task Manager", command=taskmgr).pack()#grid(row=1, column=0)
Button(frame, text="Open Control Panel", command=ctrlpanel).pack()#grid(row=2, column=0)