我正在查看from tkinter import *
from tkinter import ttk
from tkinter.scrolledtext import ScrolledText
import tkinter as tk
from tkinter import Menu, filedialog
root = Tk()
root.title('To - Do List')
root.state('zoomed')
rows = 0
while rows < 50:
root.rowconfigure(rows, weight = 1)
root.columnconfigure(rows, weight = 1)
rows = rows + 1
class Everything:
def __init__(self, font, justify, size):
self.font = font
self.justify = justify
self.size = size
def CreateNewTaskFunction(self):
ttk.frame()
Notebook.add(ttk.frame(), text = 'First Note')
# --------------------------------------------------------------------------------------------------------
x = 1
def NewInstance():
global x
NewTaskDictionary = {"Task1":"Task1", "Task2":"Task2", "Task2":"Task2", "Task3":"Task3", "Task4":"Task4", "Task5":"Task5", "Task6":"Task6", "Task7":"Task7", "Task8":"Task8"}
NewTaskDictionary["Task" + str(x)] = Notebook.add(ttk.Frame(), text = 'Welcome To Your Notes: Click Here')
NewTxtDictionary = {"Txt1":"Txt1", "Txt2":"Txt2", "Txt3":"Txt3", "Txt4":"Txt4", "Txt5":"Txt5", "Txt6":"Txt6", "Txt7":"Txt7", "Txt8":"Txt8"}
NewTxtDictionary["Txt" + str(x)] = tk.Text(NewTaskDictionary["Task" + str(x)])
NewTxtDictionary["Txt" + str(x)].grid(column = 1, row = 2, columnspan = 48, rowspan = 47, sticky = 'NESW')
NewScrollDictionary = {"Scroll1":"Scroll142432423", "Scroll2":"Scroll2", "Scroll3":"Scroll3", "Scroll4":"Scroll4", "Scroll5":"Scroll5", "Scroll6":"Scroll6"}
NewScrollDictionary["Scroll" + str(x)] = tk.Scrollbar(NewTaskDictionary["Task" + str(x)])
NewScrollDictionary["Scroll" + str(x)].grid(column = 50, row = 2, rowspan = 46, sticky = 'NESW')
NewTxtDictionary["Txt" + str(x)]['yscrollcommand'] = NewScrollDictionary["Scroll" + str(x)].set
print(NewScrollDictionary["Scroll" + str(x)])
NewScrollDictionary["Scroll" + str(1)] = "81290830912830912830912903"
y = NewScrollDictionary["Scroll1"]
print(y)
x += 1
style = ttk.Style()
current_theme =style.theme_use()
style.theme_settings(current_theme, {"TNotebook.Tab": {"configure": {"padding": [20, 5], "background" : "white"}}})
style.theme_settings(current_theme, {"TNotebook" : {"configure" : {"tabposition" : "wn", "padding" : (0, 5)}}})
style.theme_settings(current_theme, {"TNotebook.Window" : {"configure" : {"width" : 500}}})
Notebook = ttk.Notebook(root)
Notebook.grid(row = 1, column = 0, columnspan = 50, rowspan = 49, sticky = 'NESW')
Photo2 = PhotoImage(file="Add Task Image Button.png")
NewTaskButton = Button(root, image=Photo2, borderwidth=0, highlightthickness=0, command = NewInstance).grid(row=0, column=45, columnspan = 5, sticky="e", ipady = [5])
Photo1= PhotoImage(file="Final Logo.png")
Label(image=Photo1, borderwidth=0, highlightthickness=0).grid(row=0, column=0, sticky=W, ipady = [5])
# Defaults
root.mainloop()
的定义:
cong
而且我不明白为什么它的类型正确。特别是,似乎cong : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) {x y} → x ≡ y → f x ≡ f y
cong f refl = refl
的隐式参数必须同时为refl
和f x
。为了使事情更清楚,我编写了一个非隐式的相等版本,并尝试复制该证明:
f y
这会导致类型错误:
data Eq : (A : Set) -> A -> A -> Set where
refl : (A : Set) -> (x : A) -> Eq A x x
cong : (A : Set) -> (B : Set) -> (f : A -> B) ->
(x : A) -> (y : A) -> (e : Eq A x y) -> Eq B (f x) (f y)
cong A B f x y e = refl B (f x)
正如人们所期望的那样。除了x != y of type A when checking that the expression refl B (f x) has type Eq B (f x) (f y)
,我可能还有什么?我想念什么吗?
答案 0 :(得分:5)
为您提供的相关模式匹配。
如果我们在您的cong
上打了个洞
cong : (A : Set) -> (B : Set) -> (f : A -> B) ->
(x : A) -> (y : A) -> (e : Eq A x y) -> Eq B (f x) (f y)
cong A B f x y e = {!refl B (f x)!}
仔细研究,我们将会看到
Goal: Eq B (f x) (f y)
Have: Eq B (f x) (f x)
所以值的确不同。但是一旦您在e
上进行模式匹配,就可以:
cong : (A : Set) -> (B : Set) -> (f : A -> B) ->
(x : A) -> (y : A) -> (e : Eq A x y) -> Eq B (f x) (f y)
cong A B f x y (refl .A .x) = {!refl B (f x)!}
揭示了x
与y
相同的事实,并且上下文被无声重写:y
的每次出现都被x
代替,因此请仔细研究我们现在看到的洞
Goal: Eq B (f x) (f x)
Have: Eq B (f x) (f x)
请注意,我们可以写
cong A B f x .x (refl .A .x) = refl B (f x)
即根本不绑定y
,而只是通过点模式说它与x
相同。我们通过在e : Eq A x y
上进行模式匹配获得了这些信息,因为一旦执行了匹配,我们便知道实际上是e : Eq A x x
,因为这就是refl
的类型签名所说的。 Eq A x y
和Eq A x x
的统一得出了一个简单的结论:y
等于x
,并相应地调整了整个上下文。
与Haskell GADT的逻辑相同:
data Value a where
ValueInt :: Int -> Value Int
ValueBool :: Bool -> Value Bool
eval :: Value a -> a
eval (ValueInt i) = i
eval (ValueBool b) = b
当您在ValueInt
上匹配并获得类型i
的{{1}}时,您还会发现Int
等于a
并将此知识添加到上下文中(通过等式约束),使得Int
和a
在以后无法确定。结果就是我们能够返回Int
的原因:因为我们从上下文知道,所以类型签名中的i
和a
完美地结合在一起。