def launch_hotstar(): # run www.hotsar.com popular movies on Chromium subprocess.call( 'chromium-browser https://www.hotstar.com/in/movies/languages/malayalam', shell=True) ### ------------------------------------- Main GUI interface ---------------------------------------- ### app = App(title="TV GUI", width=1920, height=1050) # not full HD dimensions to give space to the taskbar # Contains the buttons for the different channels channel_box = Box(app, width="fill", layout="grid", align="top", border=False) channel_box.bg = "#ecf0f1" # Defining the channel buttons button1 = PushButton(channel_box, command=load_channel_asianet, text="Asianet News", grid=[0, 0], width=27, height=5) button1.text_size = 19 button1.when_clicked = highlight1 button1.when_mouse_leaves = lowlight1 button2 = PushButton(channel_box, command=load_channel_manorama, text="Manorama News", grid=[1, 0], width=27,
app = App(title="Example", height=400, width=600) app.when_closed = destroy_app menubar = MenuBar(app, toplevel=["File", "Edit", "Help"], options=[[["Open", open_file_function], ["Save", save_file_function], ["Close", destroy_app]], [["Edit option 1", edit_function], ["Edit option 2", edit_function]], [["About", about_function]]]) toolbar_box = Box(app, width="fill", align="top") toolbar_box.bg = "#ffffff" new_button = PushButton(toolbar_box, command=new_file_function, align="left", text="New", image="./img/file.gif") open_button = PushButton(toolbar_box, command=open_file_function, align="left", text="Open", image="./img/folder-open.gif") save_button = PushButton(toolbar_box, command=save_file_function, align="left", text="Save", image="./img/content-save.gif")
def closing(mychat: ChatHandlerWS): if mychat.is_connected(): mychat.ws_disconnect() del mychat if __name__ == '__main__': app = App("Chat Companion :)", width=800, height=480, bg=base_color, layout="auto") button_box = Box(app, width="fill", height=40, align="bottom") message_box = Box(app, border=4, height="fill", width="fill") message_box.bg = (255, 255, 255) message = TextBox(message_box, multiline=True, width="fill", height=350, visible=True) message.text_size = 16 chat = ChatHandlerWS() btn_connect = PushButton(button_box, text="Connect", align="left", command=connection_button, args=[chat], width=20, height=30,
border=0, layout="grid", grid=[0, 0], height=30, width=500, align="top") tweet_output = Text( create_tweets, text= " Recent Tweets ", size=13, font="Comic Sans", color="black", grid=[3, 0], align="top") create_tweets.bg = "cornflower blue" make_tweets_box = Box(tweets_output_box, border=1, layout="grid", grid=[0, 1], height=40, width=499, align="top") #box to input tweets tweet_textbox = TextBox(make_tweets_box, grid=[1, 0], align="left", width=68, text="[Tweet something here]") add2_box = Box(make_tweets_box, border=0,
from guizero import App, TextBox, Text, ButtonGroup, PushButton, Combo, CheckBox, ListBox, Picture, Box import PIL # Sets up app app = App(title="Hero-o-matic") app.height = 400 app.width = 400 app.bg = 'black' box1 = Box(app, align='left') box1.bg = 'dark slate gray' box2 = Box(app, border=1) box2.bg = 'slategray3' box3 = Box(app) box3.bg = 'dark slate gray' box4 = Box(app, width='fill') box4.bg = 'green' box4.font = 'New Times Roman' """Event functions""" def make_hero_name(): adjective = cmb_adjective.value colour = txt_colour.value animal = cmb_animal.value surname = lst_surname.value hero = adjective + ' ' + colour + ' ' + animal + ' ' + surname if (chk_power1.value): power = chk_power1.text if (chk_power2.value): power = chk_power2.text
def startup(): HOME = str(Path.home()) HERE = os.path.dirname(os.path.realpath(__file__)) global NOHAT global ONEMU global tstamp tstamp = "" NOHAT = False ONEMU = False global framerate framerate = 1 def no_hat_check(): global NOHAT global ONEMU NOHAT = yesno( "No SenseHAT detected", "No SenseHat detected - Do you want to carry on anyway?") if NOHAT: if "arm" in os.uname().machine: ONEMU = yesno( "Looks like a Pi", "Do you want to try to run in the SenseHat emulator?") if ONEMU: if not os.path.isfile("/usr/bin/sense_emu_gui"): warn( "Sorry", "It doesn't look like the SenseHAT emulator is installed" ) sys.exit() else: warn( "No pi!", "It doesn't look like the you're on a Raspberry Pi. You can still save animations and images." ) else: sys.exit() global col col = (255, 255, 255) global blank_frame blank_frame = [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)] global frames frames = {1: blank_frame.copy()} global current_frame_number current_frame_number = 1 framerate = 1 # frames per second global looping looping = False def illum_pixel(x, y): global col #global NOHAT matrix.set_pixel(x, y, col) if not NOHAT: sh.set_pixel(x, y, col) def col_select(x, y): global col if y == 0: col = (255, 0, 0) button_clear.text_color = "black" elif y == 1: col = (0, 255, 0) button_clear.text_color = "black" elif y == 2: col = (0, 0, 255) button_clear.text_color = "white" elif y == 3: col = (255, 255, 0) button_clear.text_color = "black" elif y == 4: col = (80, 80, 80) button_clear.text_color = "white" elif y == 5: col = (255, 255, 255) button_clear.text_color = "black" elif y == 6: col = (255, 0, 255) button_clear.text_color = "black" elif y == 7: col = (255, 150, 0) button_clear.text_color = "black" button_clear.text_color = "black" elif y == 8: col = (0, 0, 0) button_clear.text_color = "white" elif y == 9: col = (66, 220, 240) button_clear.text_color = "black" box.bg = col button_clear.bg = col def hex_to_rgb(hex): return (tuple(int(hex[i:i + 2], 16) for i in (0, 2, 4))) def p_clicked(x, y): if (x <= 7) and (y <= 7): if matrix.get_pixel(x, y) == "black": illum_pixel(x, y) frames[current_frame_number][(y * 8) + x] = col elif hex_to_rgb(str(matrix.get_pixel(x, y).strip('#'))) == col: matrix.set_pixel(x, y, "black") sh.set_pixel(x, y, (0, 0, 0)) frames[current_frame_number][(y * 8) + x] = (0, 0, 0) else: illum_pixel(x, y) frames[current_frame_number][(y * 8) + x] = col def clear_matrix(): global NOHAT if not NOHAT: sh.clear(col) for x in range(8): for y in range(8): matrix.set_pixel(x, y, col) frames[current_frame_number][(y * 8) + x] = col def new_frame(): global current_frame_number global frames global blank_frame if current_frame_number != len(frames): # not last frame for f in range(len(frames), current_frame_number, -1): frames[f + 1] = frames[f].copy() frames[current_frame_number + 1] = blank_frame.copy() current_frame_number += 1 load_frame() def copy_frame(): global current_frame_number global frames if current_frame_number != len(frames): # not last frame for f in range(len(frames), current_frame_number, -1): frames[f + 1] = frames[f].copy() frames[current_frame_number + 1] = frames[current_frame_number].copy() current_frame_number += 1 load_frame() def delete_frame(): global current_frame_number global frames global blank_frame if current_frame_number != 1: if current_frame_number != len(frames): # not last frame for f in range(current_frame_number, len(frames)): frames[f] = frames[f + 1].copy() current_frame_number -= 1 del frames[len(frames)] load_frame() else: warn("Heads up", "Only one frame exits - you can't delete it") def load_frame(): global NOHAT frame_status_text.value = ("Frame " + str(current_frame_number).zfill(3) + " of " + str(len(frames)).zfill(3)) if not NOHAT: sh.set_pixels(frames[current_frame_number]) for x in range(8): for y in range(8): matrix.set_pixel(x, y, frames[current_frame_number][(y * 8) + x]) load_other_frames() def load_other_frames(): prev_matrix.color = "black" next_matrix.color = "black" if len(frames) == 2: if current_frame_number == 1: for x in range(8): for y in range(8): next_matrix.set_pixel( x, y, frames[current_frame_number + 1][(y * 8) + x]) for x in range(8): for y in range(8): prev_matrix.set_pixel(x, y, "grey") else: for x in range(8): for y in range(8): prev_matrix.set_pixel( x, y, frames[current_frame_number - 1][(y * 8) + x]) for x in range(8): for y in range(8): next_matrix.set_pixel(x, y, "grey") if len(frames) >= 3: if current_frame_number == 1: for x in range(8): for y in range(8): next_matrix.set_pixel( x, y, frames[current_frame_number + 1][(y * 8) + x]) for x in range(8): for y in range(8): prev_matrix.set_pixel(x, y, "grey") elif current_frame_number == len(frames): for x in range(8): for y in range(8): prev_matrix.set_pixel( x, y, frames[current_frame_number - 1][(y * 8) + x]) for x in range(8): for y in range(8): next_matrix.set_pixel(x, y, "grey") else: for x in range(8): for y in range(8): next_matrix.set_pixel( x, y, frames[current_frame_number + 1][(y * 8) + x]) for x in range(8): for y in range(8): prev_matrix.set_pixel( x, y, frames[current_frame_number - 1][(y * 8) + x]) def left(): global current_frame_number if current_frame_number > 1: current_frame_number -= 1 load_frame() def right(): global current_frame_number if current_frame_number < len(frames): current_frame_number += 1 load_frame() def right_play(tin): global tstamp global current_frame_number global stopped global looping if tstamp == tin: if (current_frame_number < len(frames)) and not stopped: current_frame_number += 1 load_frame() if (current_frame_number == len(frames)) and not stopped: button_play.enable() button_stop.disable() slider_framerate.enable() button_go_end.enable() button_go_start.enable() button_left.enable() button_right.enable() if checkbox_repeat.value == 1: looping = True current_frame_number = 0 play() else: stopped = True def go_end(): global current_frame_number global frames current_frame_number = len(frames) load_frame() def go_start(): global current_frame_number current_frame_number = 1 load_frame() def play(): global framerate global stopped global current_frame_number global looping global tstamp if len(frames) > 1: button_play.disable() button_stop.enable() button_go_end.disable() button_go_start.disable() button_go_end.disable() button_left.disable() button_right.disable() slider_framerate.disable() stopped = False tstamp = str(time.time()) t = int(1000 / framerate) if looping: for i in range( 1, len(frames) + 1 ): # because we set current_frame_number = 0 when looping we need an extra iteration frame_status_text.after(t * i, right_play, args=[tstamp]) else: for i in range(1, len(frames)): frame_status_text.after(t * i, right_play, args=[tstamp]) def stop(): global stopped stopped = True button_play.enable() button_stop.disable() slider_framerate.enable() button_go_end.enable() button_go_start.enable() button_left.enable() button_right.enable() #for i in range(len(frames)): # frame_status_text.cancel(right_play) def export_as_python(): global framerate filename = filedialog.asksaveasfilename( initialdir=HOME, title="Export file", filetypes=(("python files", "*.py"), ("all files", "*.*"))) if len(filename) != 0: with open(filename, "w") as export_file: export_file.write("# m8tricks output file \n") export_file.write("from sense_hat import SenseHat\n") export_file.write("from time import sleep\n") export_file.write("sh = SenseHat()\n") export_file.write("sh.clear(0,0,0)\n") for e in range(1, len(frames) + 1): export_file.write("sh.set_pixels(" + str(frames[e]) + ")\n") export_file.write("sleep(1/" + str(framerate) + ")\n") def import_python(): global framerate global current_frame_number current_frame_number = 1 filename = filedialog.askopenfilename(initialdir=HOME, title="Select file", filetypes=(("python files", "*.py"), ("all files", "*.*"))) if len(filename) != 0: with open(filename, "r") as import_file: line1 = import_file.readline() if line1 == "# m8tricks output file \n": #print("This looks like an 8x8 Grid Editor file") try: for line in import_file: if line.startswith("sh.set_pixels"): grid = line[14:-2] frames[ current_frame_number] = ast.literal_eval( grid) current_frame_number += 1 current_frame_number -= 1 load_frame() except: error("Import failed", "Sorry, that file could not be imported") else: not_our_file = yesno( "Uh-oh", "This doesn't look like a m8tricks file. Carry on trying to import it?" ) if not_our_file == True: try: for line in import_file: if line.startswith("sh.set_pixels"): grid = line[14:-2] frames[ current_frame_number] = ast.literal_eval( grid) current_frame_number += 1 current_frame_number -= 1 load_frame() except: error("Import failed", "Sorry, that file could not be imported") def set_framerate(): global framerate framerate = slider_framerate.value def sh_rotation(): sh.set_rotation(int(combo_rotation.value)) app = App(title="m8tricks", layout="grid", height=540, width=500) box_top = Box(app, layout="grid", grid=[0, 0, 5, 1]) button_go_start = PushButton(box_top, command=go_start, grid=[0, 0, 2, 1], text="<<", image=HERE + "/images/endl.png") button_left = PushButton(box_top, command=left, grid=[2, 0, 2, 1], text="<", image=HERE + "/images/left.png") button_play = PushButton(box_top, command=play, grid=[4, 0, 2, 1], text="PLAY", image=HERE + "/images/play.png") button_stop = PushButton(box_top, command=stop, grid=[6, 0, 2, 1], text="STOP", enabled=False, image=HERE + "/images/stop.png") button_right = PushButton(box_top, command=right, grid=[8, 0, 2, 1], text=">", image=HERE + "/images/right.png") button_go_end = PushButton(box_top, command=go_end, grid=[10, 0, 2, 1], text=">>", image=HERE + "/images/endr.png") checkbox_repeat = CheckBox(app, text=" Repeat", grid=[6, 0, 1, 1]) box_framerate = Box(app, layout="grid", grid=[7, 0, 2, 1]) box_framerate.set_border(0, "#ff0000") slider_framerate = Slider(box_framerate, command=set_framerate, grid=[0, 0], start=1, end=25) text_slider = Text(box_framerate, text="Framerate (fps)", grid=[0, 1], size=10) matrix = Waffle(app, height=8, width=8, dim=30, command=p_clicked, color="black", grid=[0, 1, 7, 7]) palette = Waffle(app, height=10, width=1, dim=20, command=col_select, grid=[7, 1, 1, 7]) palette.set_pixel(0, 0, "red") palette.set_pixel(0, 1, (0, 255, 0)) palette.set_pixel(0, 2, "blue") palette.set_pixel(0, 3, "yellow") palette.set_pixel(0, 4, (100, 100, 100)) palette.set_pixel(0, 5, "white") palette.set_pixel(0, 6, (255, 0, 255)) palette.set_pixel(0, 7, "orange") palette.set_pixel(0, 8, "black") palette.set_pixel(0, 9, (66, 220, 240)) box = Box(app, width=30, height=30, grid=[2, 10, 2, 1]) box.bg = col text_current_col = Text(app, text="Selected Colour:", grid=[0, 10, 3, 1]) text_rotation = Text(app, text="LED Rotation:", grid=[5, 10, 3, 1]) combo_rotation = Combo(app, options=["0", "90", "180", "270"], grid=[8, 10, 2, 1], command=sh_rotation) button_clear = PushButton(app, command=clear_matrix, grid=[8, 1], text="Clear") button_clear.bg = col frame_status_text = Text(app, text="Frame " + str(current_frame_number).zfill(3) + " of " + str(len(frames)).zfill(3), grid=[0, 11, 3, 1]) button_new_frame = PushButton(app, command=new_frame, grid=[3, 11, 2, 1], text="New", padx=28) button_new_frame = PushButton(app, command=copy_frame, grid=[5, 11, 2, 1], text="Duplicate") button_new_frame = PushButton(app, command=delete_frame, grid=[7, 11, 2, 1], text="Delete", padx=20) prev_matrix = Waffle(app, height=8, width=8, dim=8, color="grey", grid=[0, 13, 3, 3]) next_matrix = Waffle(app, height=8, width=8, dim=8, color="grey", grid=[7, 13, 3, 3]) menubar = MenuBar(app, toplevel=["File"], options=[[["Import file", import_python], ["Export as", export_as_python]]]) if os.path.isfile("/proc/device-tree/hat/product"): file = open("/proc/device-tree/hat/product", "r") hat = file.readline() if hat == "Sense HAT\x00": #print('Sense HAT detected') file.close() else: #print("No SenseHAT detected") no_hat_check() else: #print("No SenseHAT detected") no_hat_check() if not NOHAT: # SenseHat detected to run normally from sense_hat import SenseHat sh = SenseHat() sh.clear(0, 0, 0) else: if ONEMU: # No SenseHat - and we're on a Pi so try the emulator from sense_emu import SenseHat sh = SenseHat() sh.clear(0, 0, 0) NOHAT = False else: #Disable SenseHat functions text_rotation.disable() combo_rotation.disable() app.display()
queueInput.width -= stopQ queueInput.value = newValues print(q) dsApp = App(title="Data Structures", width=650, height=800, layout='grid') #Main Box inputBox = Box(dsApp, layout='grid', grid=[0, 0]) txtInput = TextBox(inputBox, text="", width=38, height=1, grid=[1, 0]) txtInput.text_size = 15 PushButton(inputBox, insertText, text="Add Data", grid=[0, 0]) PushButton(inputBox, deleteText, text="Remove Data", grid=[2, 0]) #STACK Box stackBox = Box(dsApp, layout='grid', grid=[0, 2]) stackBox.bg = "limegreen" Text(stackBox, text='Stack', grid=[0, 0]) stackInput = TextBox(stackBox, text="", width=20, height=1, grid=[0, 1], multiline=True) #QUEUE Box queueBox = Box(dsApp, layout='grid', grid=[0, 3]) queueBox.bg = "cyan" Text(queueBox, text='Queue', grid=[1, 0]) Text(queueBox, text='Back', grid=[2, 1]) queueInput = TextBox(queueBox, text="", width=20,