Skip to content

Commit 31eee18

Browse files
committed
rename variable and use .formata() instead of percent string substitution
1 parent 275e013 commit 31eee18

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

PyPortal_User_Interface/code.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ def get_Temperature(source):
162162
set_backlight(0.3)
163163

164164
# We want three buttons across the top of the screen
165-
TAPS_Y = 0
166-
TAPS_HEIGHT = 40
167-
TAPS_WIDTH = int(screen_width / 3)
165+
TAB_BUTTON_Y = 0
166+
TAB_BUTTON_HEIGHT = 40
167+
TAB_BUTTON_WIDTH = int(screen_width / 3)
168168

169169
# We want two big buttons at the bottom of the screen
170170
BIG_BUTTON_HEIGHT = int(screen_height / 3.2)
@@ -232,8 +232,8 @@ def get_Temperature(source):
232232
button_view1 = Button(
233233
x=0, # Start at furthest left
234234
y=0, # Start at top
235-
width=TAPS_WIDTH, # Calculated width
236-
height=TAPS_HEIGHT, # Static height
235+
width=TAB_BUTTON_WIDTH, # Calculated width
236+
height=TAB_BUTTON_HEIGHT, # Static height
237237
label="View 1",
238238
label_font=font,
239239
label_color=0xFF7E00,
@@ -246,10 +246,10 @@ def get_Temperature(source):
246246
buttons.append(button_view1) # adding this button to the buttons group
247247

248248
button_view2 = Button(
249-
x=TAPS_WIDTH, # Start after width of a button
249+
x=TAB_BUTTON_WIDTH, # Start after width of a button
250250
y=0,
251-
width=TAPS_WIDTH,
252-
height=TAPS_HEIGHT,
251+
width=TAB_BUTTON_WIDTH,
252+
height=TAB_BUTTON_HEIGHT,
253253
label="View 2",
254254
label_font=font,
255255
label_color=0xFF7E00,
@@ -262,10 +262,10 @@ def get_Temperature(source):
262262
buttons.append(button_view2) # adding this button to the buttons group
263263

264264
button_view3 = Button(
265-
x=TAPS_WIDTH * 2, # Start after width of 2 buttons
265+
x=TAB_BUTTON_WIDTH * 2, # Start after width of 2 buttons
266266
y=0,
267-
width=TAPS_WIDTH,
268-
height=TAPS_HEIGHT,
267+
width=TAB_BUTTON_WIDTH,
268+
height=TAB_BUTTON_HEIGHT,
269269
label="View 3",
270270
label_font=font,
271271
label_color=0xFF7E00,
@@ -383,7 +383,7 @@ def switch_view(what_view):
383383

384384
# Set global button state
385385
view_live = what_view
386-
print("View %d On" % what_view)
386+
print("View {view_num:.0f} On".format(view_num=what_view))
387387

388388

389389
# pylint: enable=global-statement
@@ -444,7 +444,7 @@ def switch_view(what_view):
444444
# loop with buttons using enumerate() to number each button group as i
445445
for i, b in enumerate(buttons):
446446
if b.contains(touch): # Test each button to see if it was pressed
447-
print("button%d pressed" % i)
447+
print("button{} pressed".format(i))
448448
if i == 0 and view_live != 1: # only if view1 is visible
449449
pyportal.play_file(soundTab)
450450
switch_view(1)

0 commit comments

Comments
 (0)