This repository has been archived by the owner on Aug 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathKBControl.py
108 lines (77 loc) · 3.08 KB
/
KBControl.py
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
import pygame
from pygame.locals import *
import sys; sys.path.insert(0, "./lib/")
from pgu import gui
##
## KB Simulator Control
##
class KBSControl(gui.Table):
def __init__(self, sim):
gui.Table.__init__(self)
config = sim.config
def fullscreen(btn): pygame.display.toggle_fullscreen()
def designer(btn): sim.designerform = True
def restart(btn): sim.restartform = True
def fps_update(slider): sim.fps = slider.value
fg = config['uicolor']
self.tr()
self.td(gui.Label(" SIMULATION "))
td_left = {'padding_left': 25}
td_right = {'padding_right': 25}
btn = gui.Switch(value=False,name='fullscreen')
btn.connect(gui.CHANGE, fullscreen, btn)
self.td(gui.Label("full ",color=fg), align=1, style=td_left)
self.td(btn, align=-1, style=td_right)
td_styleb = {'padding_left': 5,
'padding_right':5,
'padding_top': 5,
'padding_bottom': 5}
btn = gui.Button("designer")
btn.connect(gui.CLICK, designer, btn)
self.td(btn, style=td_styleb)
btn = gui.Button("restart")
btn.connect(gui.CLICK, restart, btn)
self.td(btn, style=td_styleb)
self.td(gui.Label("FPS:"))
slider = gui.HSlider(value=sim.fps,min=25,max=config['fpsmax'],size=20,width=120,name='fps')
self.td(slider)
slider.connect(gui.CHANGE, fps_update, slider)
##
## KB Designer Control
##
class KBDControl(gui.Table):
def __init__(self, designer):
gui.Table.__init__(self)
config = designer.config
def fullscreen(btn): pygame.display.toggle_fullscreen()
def analyse(btn): designer.analyseform = True # TODO: this could/should be custom events
def connect(btn): designer.connectform = True
def execute(btn): designer.executeform = True
def clear(btn): designer.clearform = True
fg = config['uicolor']
self.tr()
self.td(gui.Label(" DESIGNER "))
td_left = {'padding_left': 25}
td_right = {'padding_right': 25}
btn = gui.Switch(value=False,name='fullscreen')
btn.connect(gui.CHANGE, fullscreen, btn)
self.td(gui.Label("full ",color=fg), align=1, style=td_left)
self.td(btn, align=-1, style=td_right)
td_styleb = {'padding_left': 5,
'padding_right':5,
'padding_top': 5,
'padding_bottom': 5}
btn = gui.Button("clear")
btn.connect(gui.CLICK, clear, btn)
self.td(btn, style=td_styleb)
"""
btn = gui.Button("analyse")
btn.connect(gui.CLICK, analyse, btn)
self.td(btn, style=td_styleb)
"""
btn = gui.Button("connect")
btn.connect(gui.CLICK, connect, btn)
self.td(btn, style=td_styleb)
btn = gui.Button("execute")
btn.connect(gui.CLICK, execute, btn)
self.td(btn, style=td_styleb)