滚动条位于我的应用程序的底部,而不是覆盖整个选项卡,实际上滚动条不起作用。我应该改变什么?
我在tkinter制作了这个应用程序,但它看起来并不像我希望的那样。下面的代码显示了它的外观,并在链接中放置了我的应用程序的屏幕
import tkinter as tk
from tkinter import ttk
from tkinter import scrolledtext
from tkinter import Menu
from functools import partial
from math import sqrt, erfc, pi
from scipy.integrate import quad ## funkcja calkujaca
import numpy as np
from matplotlib import cm
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
win = tk.Tk()
win.title("Aplikacja do projektowania")
tabControl = ttk.Notebook(win) # Create Tab Control
tab1 = ttk.Frame(tabControl) # Create a tab
tabControl.add(tab1, text='Obliczenia poglądowe') # Add the tab
tab2 = ttk.Frame(tabControl) # Add a second tab
tabControl.add(tab2, text='Obliczenia zaawansowane') # Make second tab visible
tabControl.pack(expand=1, fill="both") # Pack to make visible
dane = ttk.LabelFrame(tab1, text=' Wstaw dane ')
dane.grid(column=0, row=0, padx=8, pady=2)
dane2 = ttk.LabelFrame(tab2, text=' Wartości: ')
dane2.grid(column=0, row=0, padx=5, pady=4)
dane2 = ttk.LabelFrame(tab2, text=' Wartości: ')
dane2.grid(column=0, row=0, padx=5, pady=4)
我想问题是由下面的代码,但我不知道如何改变它
scrollbar = tk.Scrollbar(win)
scrollbar.pack(side = tk.RIGHT, fill = tk.Y)
scrollbar.config(command = dane2.config)
a0_label = ttk.Label(dane2, text=" ")
a0_label.grid(column=0, row=0, sticky='W')
a1_label = ttk.Label(dane2, text="Maksymalne godzinowe obciążenie gruntu: [W] ")
a1_label.grid(column=0, row=1, sticky='W')
win.mainloop()
如果有人知道如何处理这个错误,我将非常感激
它看起来如何:
你告诉tkinter打包tabControl并使用所有可用空间。在打包tabControl之前创建并打包滚动条,以便您希望滚动条使用的空间不可用。
import tkinter as tk
from tkinter import ttk
win = tk.Tk()
win.title("Aplikacja do projektowania")
tabControl = ttk.Notebook(win) # Create Tab Control
tab1 = ttk.Frame(tabControl) # Create a tab
tabControl.add(tab1, text='Obliczenia poglądowe') # Add the tab
tab2 = ttk.Frame(tabControl) # Add a second tab
tabControl.add(tab2, text='Obliczenia zaawansowane') # Make second tab visible
# Packing the scrollbar before the tabControl
scrollbar = tk.Scrollbar(win)
scrollbar.pack(side = tk.RIGHT, fill = tk.Y)
tabControl.pack(expand=1, fill="both") # Pack to make visible
dane = ttk.LabelFrame(tab1, text=' Wstaw dane ')
dane.grid(column=0, row=0, padx=8, pady=2)
dane2 = ttk.LabelFrame(tab2, text=' Wartości: ')
dane2.grid(column=0, row=0, padx=5, pady=4)
dane2 = ttk.LabelFrame(tab2, text=' Wartości: ')
dane2.grid(column=0, row=0, padx=5, pady=4)
a0_label = ttk.Label(dane2, text=" ")
a0_label.grid(column=0, row=0, sticky='W')
a1_label = ttk.Label(dane2, text="Maksymalne godzinowe obciążenie gruntu: [W] ")
a1_label.grid(column=0, row=1, sticky='W')
scrollbar.config(command = dane2.config)
win.mainloop()