-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
108 lines (86 loc) · 3.02 KB
/
main.py
File metadata and controls
108 lines (86 loc) · 3.02 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
from kivy.app import App
from kivy.core.window import Window
from kivy.config import Config
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty, NumericProperty, StringProperty
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.splitter import Splitter
from kivy.uix.scrollview import ScrollView
from kivy.uix.slider import Slider
from CodePiece import CodePiece, CodePieceGenerator, CodePieceGeneratorLimited, DragSilhouette
from CodeSpace import CodeLine, CodeSpace, BlockSpace, CodeLinePlus
from MenuBar import MenuBar
from BlockMaker import BlockMaker
from RunCode import CodeRunner
class Appspace(FloatLayout):
dragcontroller = ObjectProperty(None)
workspace = ObjectProperty(None)
menubar = ObjectProperty(None)
def __init__(self, **kw):
super(Appspace, self).__init__(**kw)
class Workspace(BoxLayout):
fontsize = NumericProperty(24)
fontname = StringProperty('Consolas')
codespace = ObjectProperty(None)
blockspace = ObjectProperty(None)
blockmaker = ObjectProperty(None)
def __init__(self, **kw):
super(Workspace, self).__init__(**kw)
self.blockspace = BlockSpace(workspace = self)
splitter = Splitter(sizable_from = 'bottom')
scrollerleft = ScrollView()
scrollerleft.add_widget(self.blockspace)
self.blockbox = BoxLayout(orientation = 'vertical')
self.blockmaker = BlockMaker(workspace = self)
self.blockbox.add_widget(scrollerleft)
splitter.add_widget(self.blockbox)
self.add_widget(splitter)
self.codespace = CodeSpace(workspace = self)
scrollerright = ScrollView()
scrollerright.add_widget(self.codespace)
self.add_widget(scrollerright)
for x in range(15) :
self.codespace.add_widget(CodeLinePlus(fontsize = self.fontsize))
self.codespace.updateLineNums()
def updateFontSize(self, size):
self.fontsize = size
self.blockspace.fontsize = size
# update all generators in blockspace
for gen in self.blockspace.children:
gen.font_size = size
# update all codelines and pieces in codespace
for codelineplus in self.codespace.children:
codelineplus.fontsize = size
codeline = codelineplus.codeline
for piece in codeline.children:
piece.font_size = size
def updateVersion(self):
self.parent.menubar.updateVersion()
def getCode(self):
text = ''
for child in self.codespace.children:
text = child.getLineText() + '\n' + text
return text
def getCodeLines(self):
text = []
for child in self.codespace.children:
text.insert(0,child.getLineText())
return text
def toggleBlockMaker(self):
if (self.blockmaker in self.blockbox.children):
self.blockbox.remove_widget(self.blockmaker)
else:
self.blockbox.add_widget(self.blockmaker, index=1)
class DragController(Widget):
pass
class FontSizeSlider(Slider):
pass
class PythonPiecesApp(App):
def build(self):
Window.set_icon('icons/Large-Python-icon.png')
self.title = 'Python Pieces'
Config.set('input', 'mouse', 'mouse,disable_multitouch')
# self.icon = 'icons/Large-Python-icon'
if __name__ == '__main__':
PythonPiecesApp().run()