Skip to content

Commit b6ad8a9

Browse files
committed
Pyglet 2.x update
1 parent 31b1251 commit b6ad8a9

File tree

1 file changed

+38
-40
lines changed

1 file changed

+38
-40
lines changed

brainworkshop.py

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ def get_argv(arg):
8080

8181
# Internal static options not available in config file.
8282
CONFIG_OVERWRITE_IF_OLDER_THAN = '4.8'
83-
NOVBO = True
8483
VSYNC = False
8584
DEBUG = False
8685
FOLDER_RES = 'res'
@@ -912,7 +911,6 @@ def update_check():
912911
# workaround for pyglet.gl.ContextException error on certain video cards.
913912
os.environ["PYGLET_SHADOW_WINDOW"] = "0"
914913
import pyglet
915-
if NOVBO: pyglet.options['graphics_vbo'] = False
916914
from pyglet.window import key
917915

918916
# shapes submodule is available with pyglet >=1.5.4
@@ -1640,31 +1638,31 @@ def create_batch(self):
16401638

16411639
pyglet.text.Label(graph_title,
16421640
batch=self.batch,
1643-
font_size=calc_fontsize(18), bold=True, color=cfg.COLOR_TEXT,
1641+
font_size=calc_fontsize(18), weight='bold', color=cfg.COLOR_TEXT,
16441642
x = center_x, y = top + scale_to_height(60),
16451643
anchor_x = 'center', anchor_y = 'center')
16461644

16471645
pyglet.text.Label(_('Date'),
16481646
batch=self.batch,
1649-
font_size=calc_fontsize(12), bold=True, color=cfg.COLOR_TEXT,
1647+
font_size=calc_fontsize(12), weight='bold', color=cfg.COLOR_TEXT,
16501648
x = center_x, y = bottom - scale_to_height(80),
16511649
anchor_x = 'center', anchor_y = 'center')
16521650

16531651
pyglet.text.Label(_('Maximum'), width=scale_to_width(1),
16541652
batch=self.batch,
1655-
font_size=calc_fontsize(12), bold=True, color=linecolor2+(255,),
1653+
font_size=calc_fontsize(12), weight='bold', color=linecolor2+(255,),
16561654
x = left - scale_to_width(60), y = center_y + scale_to_height(50),
16571655
anchor_x = 'right', anchor_y = 'center')
16581656

16591657
pyglet.text.Label(_('Average'), width=scale_to_width(1),
16601658
batch=self.batch,
1661-
font_size=calc_fontsize(12), bold=True, color=linecolor+(255,),
1659+
font_size=calc_fontsize(12), weight='bold', color=linecolor+(255,),
16621660
x = left - scale_to_width(60), y = center_y + scale_to_height(25),
16631661
anchor_x = 'right', anchor_y = 'center')
16641662

16651663
pyglet.text.Label(_('Score'), width=scale_to_width(1),
16661664
batch=self.batch,
1667-
font_size=calc_fontsize(12), bold=True, color=cfg.COLOR_TEXT,
1665+
font_size=calc_fontsize(12), weight='bold', color=cfg.COLOR_TEXT,
16681666
x = left - scale_to_width(60), y = center_y,
16691667
anchor_x = 'right', anchor_y = 'center')
16701668

@@ -1673,7 +1671,7 @@ def create_batch(self):
16731671
if len(dates) < 2:
16741672
pyglet.text.Label(_('Insufficient data: two days needed'),
16751673
batch=self.batch,
1676-
font_size=calc_fontsize(12), bold = True, color = axiscolor + (255,),
1674+
font_size=calc_fontsize(12), weight='bold', color = axiscolor + (255,),
16771675
x = center_x, y = center_y,
16781676
anchor_x = 'center', anchor_y = 'center')
16791677
return
@@ -1727,7 +1725,7 @@ def create_batch(self):
17271725
if not index % (skip_x + 1):
17281726
pyglet.text.Label(datestring, multiline=True, width=scale_to_width(12),
17291727
batch=self.batch,
1730-
font_size=calc_fontsize(8), bold=True, color=cfg.COLOR_TEXT,
1728+
font_size=calc_fontsize(8), weight='bold', color=cfg.COLOR_TEXT,
17311729
x=x, y=bottom - scale_to_height(15),
17321730
anchor_x='center', anchor_y='top')
17331731
if have_shapes:
@@ -1750,7 +1748,7 @@ def create_batch(self):
17501748
y = int((y_marking - ymin)/(ymax - ymin) * height + bottom)
17511749
pyglet.text.Label(str(round(y_marking, 2)),
17521750
batch=self.batch,
1753-
font_size=calc_fontsize(10), bold=False, color=cfg.COLOR_TEXT,
1751+
font_size=calc_fontsize(10), weight='normal', color=cfg.COLOR_TEXT,
17541752
x = left - scale_to_width(30), y = y + scale_to_width(1),
17551753
anchor_x = 'center', anchor_y = 'center')
17561754
if have_shapes:
@@ -1830,7 +1828,7 @@ def create_batch(self):
18301828

18311829
pyglet.text.Label(''.join(str_list),
18321830
batch=self.batch,
1833-
font_size=calc_fontsize(11), bold = False, color = cfg.COLOR_TEXT,
1831+
font_size=calc_fontsize(11), weight='normal', color = cfg.COLOR_TEXT,
18341832
x = width_center(), y = scale_to_width(20),
18351833
anchor_x = 'center', anchor_y = 'center')
18361834

@@ -1847,7 +1845,7 @@ def __init__(self, title='', text='', callback=None, catch=''):
18471845
self.textcolor = (255 * int(cfg.BLACK_BACKGROUND), )*3 + (255, )
18481846
self.batch = pyglet.graphics.Batch()
18491847
self.title = pyglet.text.Label(title, font_size=self.titlesize,
1850-
bold=True, color=self.textcolor, batch=self.batch,
1848+
weight='bold', color=self.textcolor, batch=self.batch,
18511849
x=width_center(), y=(window.height*9)/10,
18521850
anchor_x='center', anchor_y='center')
18531851
self.document = pyglet.text.document.UnformattedDocument()
@@ -1967,16 +1965,16 @@ def __init__(self, options, values=None, actions={}, names={}, title='',
19671965
self.batch = pyglet.graphics.Batch()
19681966

19691967
self.title = pyglet.text.Label(title, font_size=self.titlesize,
1970-
bold=True, color=self.textcolor, batch=self.batch,
1968+
weight='bold', color=self.textcolor, batch=self.batch,
19711969
x=width_center(), y=(window.height*9)/10,
19721970
anchor_x='center', anchor_y='center')
19731971
self.footnote = pyglet.text.Label(footnote, font_size=self.footnotesize,
1974-
bold=True, color=self.textcolor, batch=self.batch,
1972+
weight='bold', color=self.textcolor, batch=self.batch,
19751973
x=width_center(), y=from_bottom_edge(35),
19761974
anchor_x='center', anchor_y='center')
19771975

19781976
self.labels = [pyglet.text.Label('', font_size=self.choicesize,
1979-
bold=True, color=self.textcolor, batch=self.batch,
1977+
weight='bold', color=self.textcolor, batch=self.batch,
19801978
x=window.width/8, y=(window.height*8)/10 - i*(self.choicesize*3/2),
19811979
anchor_x='left', anchor_y='center', font_name=self.fontlist)
19821980
for i in range(self.pagesize)]
@@ -2203,7 +2201,7 @@ def __init__(self):
22032201
vals[m] = m in curmodes
22042202
Menu.__init__(self, options, vals, names=names, title=_('Choose your game mode'))
22052203
self.modelabel = pyglet.text.Label('', font_size=self.titlesize,
2206-
bold=False, color=(0,0,0,255), batch=self.batch,
2204+
weight='normal', color=(0,0,0,255), batch=self.batch,
22072205
x=width_center(), y=(window.height*1)/10,
22082206
anchor_x='center', anchor_y='center')
22092207
self.update_labels()
@@ -2490,11 +2488,11 @@ def __init__(self):
24902488
self.visible = False
24912489
self.label = pyglet.text.Label(
24922490
'',
2493-
font_size=field.size//6, bold=True,
2491+
font_size=field.size//6, weight='bold',
24942492
anchor_x='center', anchor_y='center', batch=batch)
24952493
self.variable_label = pyglet.text.Label(
24962494
'',
2497-
font_size=field.size//6, bold=True,
2495+
font_size=field.size//6, weight='bold',
24982496
anchor_x='center', anchor_y='center', batch=batch)
24992497

25002498
self.spr_square = [pyglet.sprite.Sprite(pyglet.image.load(path))
@@ -2741,15 +2739,15 @@ def __init__(self):
27412739
self.label = pyglet.text.Label(
27422740
'',
27432741
multiline = True, width = field.size//3 - 4, align='middle',
2744-
font_size=calc_fontsize(11), bold=True,
2742+
font_size=calc_fontsize(11), weight='bold',
27452743
color=(0, 128, 0, 255),
27462744
x=width_center(), y=field.center_x + field.size // 6,
27472745
anchor_x='center', anchor_y='center', batch=batch)
27482746
except:
27492747
self.label = pyglet.text.Label(
27502748
'',
27512749
multiline = True, width = field.size//3 - 4, halign='middle',
2752-
font_size=calc_fontsize(11), bold=True,
2750+
font_size=calc_fontsize(11), weight='bold',
27532751
color=(0, 128, 0, 255),
27542752
x=width_center(), y=field.center_x + field.size // 6,
27552753
anchor_x='center', anchor_y='center', batch=batch)
@@ -2802,7 +2800,7 @@ class JaeggiWarningLabel:
28022800
def __init__(self):
28032801
self.label = pyglet.text.Label(
28042802
'',
2805-
font_size=calc_fontsize(12), bold = True,
2803+
font_size=calc_fontsize(12), weight='bold',
28062804
color=(255, 0, 255, 255),
28072805
x=width_center(), y=field.center_x + field.size // 3 + 8,
28082806
anchor_x='center', anchor_y='center', batch=batch)
@@ -2819,7 +2817,7 @@ class KeysListLabel:
28192817
def __init__(self):
28202818
self.label = pyglet.text.Label(
28212819
'',
2822-
multiline = True, width = scale_to_width(300), bold = False,
2820+
multiline = True, width = scale_to_width(300), weight='normal',
28232821
font_size=calc_fontsize(9),
28242822
color=cfg.COLOR_TEXT,
28252823
x = scale_to_width(10), y = from_top_edge(30),
@@ -2880,12 +2878,12 @@ def __init__(self):
28802878
self.label = pyglet.text.Label(
28812879
_('Brain Workshop'),
28822880
#multiline = True, width = window.width // 2,
2883-
font_size=calc_fontsize(32), bold = True, color = cfg.COLOR_TEXT,
2881+
font_size=calc_fontsize(32), weight='bold', color = cfg.COLOR_TEXT,
28842882
x = width_center(), y = from_top_edge(25),
28852883
anchor_x = 'center', anchor_y = 'center')
28862884
self.label2 = pyglet.text.Label(
28872885
_('Version ') + str(VERSION),
2888-
font_size=calc_fontsize(14), bold = False, color = cfg.COLOR_TEXT,
2886+
font_size=calc_fontsize(14), weight='normal', color = cfg.COLOR_TEXT,
28892887
x = width_center(), y = from_top_edge(55),
28902888
anchor_x = 'center', anchor_y = 'center')
28912889

@@ -2912,13 +2910,13 @@ def __init__(self):
29122910
self.keys = pyglet.text.Label(
29132911
''.join(str_list),
29142912
multiline = True, width = scale_to_width(260),
2915-
font_size=calc_fontsize(12), bold = True, color = cfg.COLOR_TEXT,
2913+
font_size=calc_fontsize(12), weight='bold', color = cfg.COLOR_TEXT,
29162914
x = from_width_center(65), y = from_bottom_edge(230),
29172915
anchor_x = 'center', anchor_y = 'top')
29182916

29192917
self.space = pyglet.text.Label(
29202918
_('Press SPACE to enter the Workshop'),
2921-
font_size=calc_fontsize(20), bold = True, color = (32, 32, 255, 255),
2919+
font_size=calc_fontsize(20), weight='bold', color = (32, 32, 255, 255),
29222920
x = width_center(), y = from_bottom_edge(35),
29232921
anchor_x = 'center', anchor_y = 'center')
29242922
def draw(self):
@@ -2931,7 +2929,7 @@ class LogoUpperLabel:
29312929
def __init__(self):
29322930
self.label = pyglet.text.Label(
29332931
'Brain', # I think we shouldn't translate the program name. Yes?
2934-
font_size=calc_fontsize(11), bold = True,
2932+
font_size=calc_fontsize(11), weight='bold',
29352933
color=cfg.COLOR_TEXT,
29362934
x=field.center_x, y=field.center_y + scale_to_height(30),
29372935
anchor_x='center', anchor_y='center')
@@ -2943,7 +2941,7 @@ class LogoLowerLabel:
29432941
def __init__(self):
29442942
self.label = pyglet.text.Label(
29452943
'Workshop',
2946-
font_size=calc_fontsize(11), bold = True,
2944+
font_size=calc_fontsize(11), weight='bold',
29472945
color=cfg.COLOR_TEXT,
29482946
x=field.center_x, y=field.center_y - scale_to_height(27),
29492947
anchor_x='center', anchor_y='center')
@@ -3073,7 +3071,7 @@ def update(self):
30733071
self.label.text = ''
30743072
if cfg.SHOW_FEEDBACK and mode.inputs[self.modality]:
30753073
result = check_match(self.modality)
3076-
#self.label.bold = True
3074+
#self.label.weight='bold'
30773075
if result == 'correct':
30783076
self.label.color = cfg.COLOR_LABEL_CORRECT
30793077
elif result == 'unknown':
@@ -3084,10 +3082,10 @@ def update(self):
30843082
result = check_match(self.modality, check_missed=True)
30853083
if result == 'missed':
30863084
self.label.color = cfg.COLOR_LABEL_OOPS
3087-
#self.label.bold = True
3085+
#self.label.weight='bold'
30883086
else:
30893087
self.label.color = cfg.COLOR_TEXT
3090-
self.label.bold = False
3088+
self.label.weight='normal'
30913089

30923090
def delete(self):
30933091
self.label.delete()
@@ -3135,13 +3133,13 @@ def update(self):
31353133
result = check_match('arithmetic')
31363134
if result == _('correct'):
31373135
self.label.color = cfg.COLOR_LABEL_CORRECT
3138-
self.label.bold = True
3136+
self.label.weight='bold'
31393137
if result == _('incorrect'):
31403138
self.label.color = cfg.COLOR_LABEL_INCORRECT
3141-
self.label.bold = True
3139+
self.label.weight='bold'
31423140
else:
31433141
self.label.color = cfg.COLOR_TEXT
3144-
self.label.bold = False
3142+
self.label.weight='normal'
31453143

31463144
def parse_answer(self):
31473145
chars = ''.join(self.answer)
@@ -3195,11 +3193,11 @@ def update(self):
31953193
(mode.num_trials_total)))
31963194
def flash(self):
31973195
pyglet.clock.unschedule(sessionInfoLabel.unflash)
3198-
self.label.bold = True
3196+
self.label.weight='bold'
31993197
self.update()
32003198
pyglet.clock.schedule_once(sessionInfoLabel.unflash, 1.0)
32013199
def unflash(self, dt):
3202-
self.label.bold = False
3200+
self.label.weight='normal'
32033201
self.update()
32043202
# this is the text that shows the seconds per trial and the number of trials.
32053203

@@ -3226,7 +3224,7 @@ def __init__(self):
32263224
self.label = pyglet.text.Label(
32273225
'',
32283226
font_size=calc_fontsize(16),
3229-
bold=True,
3227+
weight='bold',
32303228
color=(32, 32, 255, 255),
32313229
x=width_center(), y=from_bottom_edge(62),
32323230
anchor_x='center', anchor_y='center', batch=batch)
@@ -3412,7 +3410,7 @@ def __init__(self):
34123410
self.label = pyglet.text.Label(
34133411
'',
34143412
font_size=calc_fontsize(10),
3415-
bold = True,
3413+
weight='bold',
34163414
color = cfg.COLOR_TEXT,
34173415
x = from_right_edge(30),
34183416
y = from_top_edge(85),
@@ -3488,7 +3486,7 @@ class AverageLabel:
34883486
def __init__(self):
34893487
self.label = pyglet.text.Label(
34903488
'',
3491-
font_size=calc_fontsize(10), bold=False,
3489+
font_size=calc_fontsize(10), weight='normal',
34923490
color=cfg.COLOR_TEXT,
34933491
x=from_right_edge(30), y=from_top_edge(70),
34943492
anchor_x='right', anchor_y='top', batch=batch)
@@ -3532,7 +3530,7 @@ class TrialsRemainingLabel:
35323530
def __init__(self):
35333531
self.label = pyglet.text.Label(
35343532
'',
3535-
font_size=calc_fontsize(12), bold = True,
3533+
font_size=calc_fontsize(12), weight='bold',
35363534
color=cfg.COLOR_TEXT,
35373535
x=from_right_edge(10), y=from_top_edge(5),
35383536
anchor_x='right', anchor_y='top', batch=batch)

0 commit comments

Comments
 (0)