-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlock_module.py
More file actions
126 lines (91 loc) · 3.86 KB
/
Block_module.py
File metadata and controls
126 lines (91 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import tkinter as tk
class Start:
def __init__(self,root):
self.x = 312
self.y = 35
self.w = 150
self.h = 30
self.root = root
self.canvas = tk.Canvas(self.root,width=self.w,height=self.h,bd=0, bg="grey")
self.canvas.place(x=self.x, y=self.y)
self.canvas.create_text((self.w/2, self.h/2), text="START", anchor=tk.CENTER)
class Print:
def __init__(self,root,startpos):
self.x = startpos[0]
self.y = startpos[1]
self.w = 150
self.h = 30
self.root = root
self.canvas = tk.Canvas(self.root,width=self.w,height=self.h,bd=0, cursor="fleur", bg="orange")
self.canvas.place(x=self.x, y=self.y)
self.canvas.create_text((10, self.h/2), text="Skriv", anchor=tk.W)
self.entry1 = tk.Entry(self.canvas)
entry = self.canvas.create_window(40, self.h/2, width=105, window=self.entry1, anchor=tk.W)
def translate(self):
entry = self.entry1.get()
if '{' in entry and '}' in entry:
code = 'print(f"{}")'.format(entry)
else:
code = 'print("{}")'.format(entry)
return code,0
class Forloop:
def __init__(self,root,startpos):
self.x = startpos[0]
self.y = startpos[1]
self.w = 150
self.h = 30
self.root = root
self.canvas = tk.Canvas(self.root,width=self.w,height=self.h,bd=0, cursor="fleur", bg="cyan")
self.canvas.place(x=self.x, y=self.y)
self.canvas.create_text((10, self.h/2), text="Gentag", anchor=tk.W)
self.canvas.create_text((80, self.h/2), text="gange", anchor=tk.W)
self.entry1 = tk.Entry(self.canvas)
entry = self.canvas.create_window(50, self.h/2, width=25, window=self.entry1, anchor=tk.W)
def translate(self):
code = "for i in range({}):".format(self.entry1.get())
return code,1
class Forloopslut:
def __init__(self,root,startpos):
self.x = startpos[0]
self.y = startpos[1]
self.w = 150
self.h = 30
self.root = root
self.canvas = tk.Canvas(self.root,width=self.w,height=self.h,bd=0, cursor="fleur", bg="cyan")
self.canvas.place(x=self.x, y=self.y)
self.canvas.create_text((10, self.h/2), text="Stop gentag", anchor=tk.W)
def translate(self):
return "#Gentag slut",-1
class Lav_var:
def __init__(self,root,startpos):
self.x = startpos[0]
self.y = startpos[1]
self.w = 150
self.h = 30
self.root = root
self.canvas = tk.Canvas(self.root,width=self.w,height=self.h,bd=0, cursor="fleur", bg="yellow")
self.canvas.place(x=self.x, y=self.y)
self.canvas.create_text((10, self.h/2), text="Ny variabel, navn:", anchor=tk.W)
self.entry1 = tk.Entry(self.canvas)
entry = self.canvas.create_window(105, self.h/2, width=40, window=self.entry1, anchor=tk.W)
def translate(self):
code = '{} = None'.format(self.entry1.get())
return code,0
class Sæt_var:
def __init__(self,root,startpos):
self.x = startpos[0]
self.y = startpos[1]
self.w = 150
self.h = 30
self.root = root
self.canvas = tk.Canvas(self.root,width=self.w,height=self.h,bd=0, cursor="fleur", bg="yellow")
self.canvas.place(x=self.x, y=self.y)
self.canvas.create_text((10, self.h/2), text="Sæt", anchor=tk.W)
self.entry1 = tk.Entry(self.canvas)
entry = self.canvas.create_window(35, self.h/2, width=40, window=self.entry1, anchor=tk.W)
self.canvas.create_text((80, self.h/2), text="til", anchor=tk.W)
self.entry2 = tk.Entry(self.canvas)
entry = self.canvas.create_window(95, self.h/2, width=40, window=self.entry2, anchor=tk.W)
def translate(self):
code = '{} = {}'.format(self.entry1.get(),self.entry2.get())
return code,0