From 1029729173a525cdc309efb39be5d0d002b2b9da Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Sun, 8 Dec 2019 16:53:46 -0500 Subject: [PATCH] Added battleship mockup and changed video font size to fit phone's screen --- .../PyDroid3/Demo_Game_Frontend_Battleship.py | 32 +++++++++++++++++++ .../PyDroid3/Demo_OpenCV_Webcam_ASCII.py | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 DemoPrograms/PyDroid3/Demo_Game_Frontend_Battleship.py diff --git a/DemoPrograms/PyDroid3/Demo_Game_Frontend_Battleship.py b/DemoPrograms/PyDroid3/Demo_Game_Frontend_Battleship.py new file mode 100644 index 00000000..e1b11f56 --- /dev/null +++ b/DemoPrograms/PyDroid3/Demo_Game_Frontend_Battleship.py @@ -0,0 +1,32 @@ +import tkinter +import PySimpleGUI as sg +from random import randint + +def Battleship(): + sg.change_look_and_feel('Dark Blue 3') + MAX_ROWS = MAX_COL = 8 + + # Start building layout with the top 2 rows that contain Text elements + layout = [[sg.Text('BATTLESHIP', font='Default 12')], + [sg.Text(size=(15,1), key='-MESSAGE-', font='any 8')]] + # Add the board, a grid a buttons + layout += [[sg.Button(str('O'), size=(1, 1), pad=(0,0), border_width=0, font='any 8',key=(row,col)) for col in range(MAX_COL)] for row in range(MAX_ROWS)] + # Add the exit button as the last row + layout += [[sg.Button('Exit', button_color=('white', 'red'))]] + + window = sg.Window('Battleship', layout, location=(0,0)) + + while True: # The Event Loop + event, values = window.read() + print(event, values) + if event in (None, 'Exit'): + break + if randint(1,10) < 5: # simulate a hit or a miss + window[event].update('H', button_color=('white','red')) + window['-MESSAGE-'].update('Hit') + else: + window[event].update('M', button_color=('white','black')) + window['-MESSAGE-'].update('Miss') + window.close() + +Battleship() diff --git a/DemoPrograms/PyDroid3/Demo_OpenCV_Webcam_ASCII.py b/DemoPrograms/PyDroid3/Demo_OpenCV_Webcam_ASCII.py index c06f9580..0905756e 100644 --- a/DemoPrograms/PyDroid3/Demo_OpenCV_Webcam_ASCII.py +++ b/DemoPrograms/PyDroid3/Demo_OpenCV_Webcam_ASCII.py @@ -4,7 +4,7 @@ from PIL import Image import numpy as np import PySimpleGUI as sg -font_size = 4 +font_size = 3 CAMERA_FRONT = 1 CAMERA_REAR = 0