我一直在寻找一阵子是否有人遇到此错误,但无济于事。我最近将网站升级到Angular 8,并开始使用Angular CLI而不是webpack。最后,我使用--aot标志运行了一个生产版本,发现Angular Material Labels并非像往常那样浮动,这有些奇怪的行为。我的浏览器中也没有任何控制台错误。
import tkinter as tk
from tkinter import *
from PIL import ImageTk, Image
HEIGHT = 600
WIDTH = 900
h = 6.63e-34
c = 3.00e+8
def on_select(value):
if value == OPTIONS[0]:
label_enter_what['text'] = 'Enter wavelength in chosen unit below'
label_unit['text'] = 'Enter what unit \n of wavelength'
unit_set.set(OPTIONS_UNITS[1])
elif value == OPTIONS[1]:
label_enter_what['text'] = 'Enter wavelength in chosen unit below'
label_unit['text'] = 'Enter what unit \n of wavelength'
unit_set.set(OPTIONS_UNITS[1])
elif value == OPTIONS[2]:
label_enter_what['text'] = 'Enter energy in chosen unit below'
label_unit['text'] = 'Enter what unit of energy'
unit_set.set(OPTIONS_UNITS[3])
root = tk.Tk()
root.title("Photon property calculator")
canvas = tk.Canvas(root, height=HEIGHT, width=WIDTH)
canvas.pack()
background_image = ImageTk.PhotoImage(Image.open('interference.jpg'))
background_label = tk.Label(root, image=background_image)
background_label.place(relheight=1, relwidth=1)
frame = tk.Frame(root, bg='#3E3E3E', bd=5)
frame.place(relx=0.5, rely=0.1, relheight=0.1, relwidth=0.75, anchor='n')
entry_value = tk.Entry(frame, font=40, bg='white')
entry_value.place(relx=0.175, rely=0, relheight=1, relwidth=0.4)
frame_upper = tk.Frame(root, bg='#3E3E3E', bd=2.5)
frame_upper.place(relx=0.5, rely=0.03, relheight=0.06, relwidth=0.75, anchor='n')
label_what_to_calc = tk.Label(frame_upper, bg='white', text='Enter what \n to calculate')
label_what_to_calc.place(relx=0, rely=0, relheight=1, relwidth=0.15)
label_enter_what = tk.Label(frame_upper, bg='white', text='Select an option')
label_enter_what.place(relx=0.175, relheight=1, relwidth=0.4)
label_unit = tk.Label(frame_upper, bg='white', text='Enter what unit \n of wavelength')
label_unit.place(relx=0.6, relheight=1, relwidth=0.21)
lower_frame = tk.Frame(root, bg='#60A8FF', bd=10)
lower_frame.place(relx=0.5, rely=0.3, relheight=0.5, relwidth=0.75, anchor='n')
OPTIONS = [
"Energy",
"Frequency",
"Wavelength"
]
value_var = tk.StringVar(value=OPTIONS[0])
drop = tk.OptionMenu(frame, value_var, *OPTIONS, command=on_select)
drop.place(relx=0, rely=0, relheight=1, relwidth=0.15)
OPTIONS_UNITS = ["μm",
"nm",
"pm",
"aJ",
"zJ",
]
unit_set = tk.StringVar(value=OPTIONS_UNITS[0])
drop_units = tk.OptionMenu(frame, unit_set, *OPTIONS_UNITS)
drop_units.place(relx=0.6, rely=0, relheight=1, relwidth=0.09)
def do_operation(f_num):
if value_var.get() == OPTIONS_UNITS[0] and unit_set.get() == OPTIONS_UNITS[0]:
new_num = f_num*10e-28
return h*c/new_num
def get_value():
first_number = entry_value.get()
global f_num
f_num = float(first_number)
entry_value.delete(0, END)
print(do_operation(f_num))
button = tk.Button(frame, text='Calculate!', font=40, bg="#F96612", fg='black', command=lambda: do_operation(f_num))
button.place(relx=0.7, relheight=1, relwidth=0.3)
label = tk.Label(lower_frame, bg='white', text='1')
label.place(relheight=1, relwidth=1)
root.mainloop()
答案 0 :(得分:0)
我最终通过将build-> options-> extractCss的angular.json文件设置更改为false来解决了自己的问题。
看到这解决了问题之后,我对该特定标志进行了更多研究,发现它与Angular CLI已有相当长的一段时间了,在此处记录-> https://github.com/angular/angular-cli/issues/8577