Best Python code snippet using playwright-python
Rosewell BASIC GUI.py
Source:Rosewell BASIC GUI.py  
...92global note93note = ''94def atsciiprint2():95      for i in range(157):96        shell.insert_text(saves[i], end=''); time.sleep(0.000000000000000001)97colorhelp = '''-----Background Color Help-----98Here's what to type in for changing the Background Colors99[1] DEFAULT or BASIC BLUE100[2] Special Edition; Commodore 64101[3] RED or DARK RED102[4] BLUE or DARK BLUE103[5] TEAL104[6] ORANGE105[7] GREEN106[8] GRAY - Only Available in Gray plus white text. DOES NOT REQUIRE TYPING 'WHITE' 107[9] PURPLE108[10] YELLOW - 'white' will make the text black for this color109[11] PINK - 'white' will make the text black for this color110[12] WHITE - no 'white' needed, uses Black text111[13] BLACK - no 'white' needed, uses White text112[14] AMBER - No White text available113[15] Special Edition; Commodore Vic-20114[16] Special Edition; Commodore Plus-4115[17] Special Edition; Commodore 128116[18] Special Edition; Commodore PET117[19] Special Edition; Gameboy Peasoup118[20] Special Edition; Gameboy Light119[21] Navy - With Yellow Text120Type 'white' in the fullsize text or 'w' in the abrivations to get the color backgound you want plus white text121Ex.122Red is:123Red white or rw124NOTE: All unsaved work will be lost, this is because the process is destroyed when another window is created.125Ready'''126helps = '''-----Help Commands-----127GoTo (num) - runs and repeats code (num) amount of times128Help - list all the features of BASIC129Save - Allows you to save BASIC programs to a file130Run - allows you to run BASIC programs131Quit - Quits Rosewell BASIC132List - list the PROGRAM saved in memory133Load - loads an external PROGRAM from the Same folder134Load 8 - Loads a program from an External Disk135Clear - Allows you to clear your PROGRAM code from memory136Dir - Lists the PROGRAM Directory137ATSCII - Prints the Built-in ATSCII characters for poke/peek commands138all chr - Prints all of the characters at once139Repeat Chr - can print All Chr PROGRAM if given a number140Poke - Print an ATSCII Character to the Screen141Peek - Return the value of an ATSCII Character142Music - Opens the Music Menu to play Background Music of your Choice143Note - Opens the Note Built in menu144Time/Date/Calendar/Clock - Tells the current time and date145Text To Speech - Opens the Text To Speach App146Speach Recognition - Opens the Speech Recognition App147Modules - Checks all of the modules to see if they are installed on your computer148Color - You can now change the background color for the app in use149Color Help - Get help with selecting background colors150New Window - Opens a new window of Rosewell BASIC151Restart - Restarts the App back to the DEFAULT color and all unsaved files will be deleted152Contact Us - Larn how to contact Rosewell Software15349 Bytes - Means that the SYSTYEM MEMORY or any other BASIC MEMORY is empty.(Don't know why it says 49 for 0)154Enough BASIC Bytes Free - This means all of the modules that Rosewell BASIC uses, were imported successfully155?Syntax Error? - means something was typed in wrong156?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.'''157musix = '''-----Music Menu-----158[1] Play Background Music159[2] Stop Background Music160[3] Pause Background Music161[4] UnPause Background Music162[5] Add To Queue163[6] Play Without Loop164Enter a Number to Continue:'''165def helpz():166    shell.insert_text('Help Menu', end='''167''')168    shell.insert_text(helps, end='''169''')170    shell.insert_text('Ready', end='''171''')172    return173def colorz():174    shell.insert_text('Help Menu', end='''175''')176    shell.insert_text(colorhelp, end='''177''')178    return179def menuload():180    shell.insert_text('File Menu', end='''181''')182    shell.insert_text('loading from the Menu Bar, PRESS ENTER ONCE BEFORE TYPING YOUR PROGRAM NAME.',end='''183''')184    185    shell.insert_text("Enter PROGRAM Name to Load [Type 'Quit' or 'Exit' to quit]:", end='\n')186    try:187        shell.saveTF = True188        shell.mode = 'load'189    except:190        shell.insert_text("?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.", end='''191''')192        shell.insert_text("Ready", end='''193''')194      195def menusave():196    shell.insert_text('File Menu', end='''197''')198    shell.insert_text('Saving from the Menu Bar, PRESS ENTER ONCE BEFORE TYPING YOUR PROGRAM NAME.',end='''199''')200    shell.insert_text("Enter new PROGRAM Name to Save [Type 'Quit' or 'Exit' to quit]:", end='\n')201    shell.insert_text("Don't Forget to type '.py' to save as a python file. If your saving in the app, your file will be saved in the app ready to go!", end='\n')202      203      204    try:      205        shell.saveTF = True206        shell.mode = 'save'207    except:208        shell.insert_text("?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.", end='''209''')210        shell.insert_text("Ready", end='''211''')212def menuload8():213    shell.insert_text('File Menu',end='''214''')215    shell.insert_text("Enter External Disk Name [Type 'Quit' or 'Exit' to quit/ if left blank, the prompt defaults to UNTITLED.]:", end='''216''')217    try:218            219        shell.saveTF = True220        shell.mode = 'load, 8'221    except:222        shell.insert_text("?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.", end='''223''')224        shell.insert_text("Ready", end='''225''')226      227      228     229      230secondscreen = """import tkinter as tk231global root232root = tk.Tk()233axio = 0234modwell = '''--The Following Modules Couldn't be imorted--235'''236try:237      import sys, io, os, builtins238except:239      modwell = modwell + '''Sys240Io241Os242Builtins243'''244      axio = axio + 1245try:246      247      from pathlib import Path248except:249      modwell = modwell + '''Pathlib250'''251      axio = axio + 1252try:253      import subprocess as subp254except:255      modwell = modwell + '''Subprocess256'''257      axio = axio + 1258try:259      from contextlib import redirect_stdout260except:261      modwell = modwell + '''Contextlib262'''263      axio = axio + 1264try:265      from tkinter import *266      from tkinter import ttk267      from tkinter.font import Font268except:269      modwell = modwell + '''Tkinter270'''271      axio = axio + 1272try:273      from datetime import date274      today = date.today()275except:276      modwell = modwell + '''Datetime277'''278      axio = axio + 1279try:280      import time, calendar281except:282      modwell = modwell + '''Time283Calendar284'''285      axio = axio + 1286try:287      import pygame288      from pygame import mixer289except:290      modwell = modwell + '''Pygame291'''292      axio = axio + 1293loadx = ''294loadz = ''295try:296      import speech_recognition as sr297except:298      modwell = modwell + '''SpeechRecognition299'''300      axio = axio + 1301try:302      from pydub import AudioSegment303      from pydub.silence import split_on_silence304except:305      modwell = modwell + '''Pydub306'''307      axio = axio + 1308try:309      import sounddevice as sd310except:311      modwell = modwell + '''Sounddevice312'''313      axio = axio + 1314try:315      import numpy as np316except:317      modwell = modwell + '''Numpy318'''319      axio = axio + 1320try:321      import wavio322except:323      modwell = modwell + 'Wavio'324      axio = axio + 1325global rosewellbasic2326rosewellbasic2 = ""327global rosewellbasic3328rosewellbasic3 = ""329global rosewellbasic330rosewellbasic = ''331rosecount = 0332global rgbcount333rgbcount = 0334global note335note = ''336def atsciiprint2():337      for i in range(157):338        shell.insert_text(saves[i], end=''); time.sleep(0.000000000000000001)339colorhelp = '''-----Background Color Help-----340Here's what to type in for changing the Background Colors341[1] DEFAULT or BASIC BLUE342[2] Special Edition; Commodore 64343[3] RED or DARK RED344[4] BLUE or DARK BLUE345[5] TEAL346[6] ORANGE347[7] GREEN348[8] GRAY - Only Available in Gray plus white text. DOES NOT REQUIRE TYPING 'WHITE' 349[9] PURPLE350[10] YELLOW - 'white' will make the text black for this color351[11] PINK - 'white' will make the text black for this color352[12] WHITE - no 'white' needed, uses Black text353[13] BLACK - no 'white' needed, uses White text354[14] AMBER - No White text available355[15] Special Edition; Commodore Vic-20356[16] Special Edition; Commodore Plus-4357[17] Special Edition; Commodore 128358[18] Special Edition; Commodore PET359[19] Special Edition; Gameboy Peasoup360[20] Special Edition; Gameboy Light361[21] Navy - With Yellow Text362Type 'white' in the fullsize text or 'w' in the abrivations to get the color backgound you want plus white text363Ex.364Red is:365Red white or rw366NOTE: All unsaved work will be lost, this is because the process is destroyed when another window is created.367Ready'''368helps = '''-----Help Commands-----369GoTo (num) - runs and repeats code (num) amount of times370Help - list all the features of BASIC371Save - Allows you to save BASIC programs to a file372Run - allows you to run BASIC programs373Quit - Quits Rosewell BASIC374List - list the PROGRAM saved in memory375Load - loads an external PROGRAM from the Same folder376Load 8 - Loads a program from an External Disk377Clear - Allows you to clear your PROGRAM code from memory378Dir - Lists the PROGRAM Directory379ATSCII - Prints the Built-in ATSCII characters for poke/peek commands380all chr - Prints all of the characters at once381Repeat Chr - can print All Chr PROGRAM if given a number382Poke - Print an ATSCII Character to the Screen383Peek - Return the value of an ATSCII Character384Music - Opens the Music Menu to play Background Music of your Choice385Note - Opens the Note Built in menu386Time/Date/Calendar/Clock - Tells the current time and date387Text To Speech - Opens the Text To Speach App388Speach Recognition - Opens the Speech Recognition App389Modules - Checks all of the modules to see if they are installed on your computer390Color - You can now change the background color for the app in use391Color Help - Get help with selecting background colors392New Window - Opens a new window of Rosewell BASIC393Restart - Restarts the App back to the DEFAULT color and all unsaved files will be deleted394Contact Us - Larn how to contact Rosewell Software39549 Bytes - Means that the SYSTYEM MEMORY or any other BASIC MEMORY is empty.(Don't know why it says 49 for 0)396Enough BASIC Bytes Free - This means all of the modules that Rosewell BASIC uses, were imported successfully397?Syntax Error? - means something was typed in wrong398?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.'''399musix = '''-----Music Menu-----400[1] Play Background Music401[2] Stop Background Music402[3] Pause Background Music403[4] UnPause Background Music404[5] Add To Queue405[6] Play Without Loop406Enter a Number to Continue:'''407def helpz():408    shell.insert_text('Help Menu', end='''409''')410    shell.insert_text(helps, end='''411''')412    shell.insert_text('Ready', end='''413''')414    return415def colorz():416    shell.insert_text('Help Menu', end='''417''')418    shell.insert_text(colorhelp, end='''419''')420    return421def menuload():422    shell.insert_text('File Menu', end='''423''')424    shell.insert_text('loading from the Menu Bar, PRESS ENTER ONCE BEFORE TYPING YOUR PROGRAM NAME.',end='''425''')426    427    shell.insert_text("Enter PROGRAM Name to Load [Type 'Quit' or 'Exit' to quit]:", end='''428''')429    try:430        shell.saveTF = True431        shell.mode = 'load'432    except:433        shell.insert_text("?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.", end='''434''')435        shell.insert_text("Ready", end='''436''')437def menusave():438    shell.insert_text('File Menu', end='''439''')440    shell.insert_text('Saving from the Menu Bar, PRESS ENTER ONCE BEFORE TYPING YOUR PROGRAM NAME.',end='''441''')442    shell.insert_text("Enter new PROGRAM Name to Save [Type 'Quit' or 'Exit' to quit]:", end='''443''')444    shell.insert_text("Don't Forget to type '.py' to save as a python file. If your saving in the app, your file will be saved in the app ready to go!", end='''445''')446      447      448    try:      449        shell.saveTF = True450        shell.mode = 'save'451    except:452        shell.insert_text("?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.", end='''453''')454        shell.insert_text("Ready", end='''455''')456def menuload8():457    shell.insert_text('File Menu',end='''458''')459    shell.insert_text("Enter External Disk Name [Type 'Quit' or 'Exit' to quit/ if left blank, the prompt defaults to UNTITLED.]:", end='''460''')461    try:462            463        shell.saveTF = True464        shell.mode = 'load, 8'465    except:466        shell.insert_text("?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.", end='''467''')468        shell.insert_text("Ready", end='''469''')470      471      472def textts():473    shell.insert_text('File Menu',end='''474''')475    shell.insert_text('Before using text to speech, PRESS ENTER ONCE BEFORE TYPING TEXT TO SPEAK', end='''476''')477    shell.insert_text('© Blake Gouthro | Text To Speech App | V1.1 | Rosewell Software | 2022 - ' + str(today.year) +' ©', end='''478''')479    shell.insert_text('Enter Text To Speak:',end='''480''')481    482    shell.saveTF = True483    shell.mode = 'voice'484def rst():485    global shell486    shell.destroy()487    shell = Shell(root, insertbackground="#78DAFC", highlightbackground ="#0F5FB4",highlightcolor="#0F5FB4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#78DAFC", bg="#0F5FB4")488    shell.pack(fill=tk.BOTH, expand=1)489    490    root.update()491def atprint():492    shell.insert_text('-----List of Built-in ATSCII Characters-----', end='''493''')494    shell.insert_text('Built-in ATSCII Characters are based off of Unicode Characters. Useful for Poke and Peek commands.', end='''495''')496    for k, v in atscii.items():497        shell.insert_text(f"{k} : {v}", end='''498''')499    shell.insert_text('Ready', end='''500''')501def aprint():502    atsciiprint2()503def rprint():504    shell.insert_text("File Menu", end='''505''')506    shell.insert_text("Before typing answer for repeat chr, PRESS ENTER BEFORE TYPING", end='''507''')508    shell.insert_text("Enter Numbrer to Repeat 'All chr' [Type 'Quit' or 'Exit' to quit]:", end='''509''')510    try:511    512        shell.saveTF = True513        shell.mode = 'repeat'514    except:515        shell.insert_text("?Syntax Error?")516            517def runs():518    shell.insert_text("File Menu", end='''519''')520    f = io.StringIO()521    with redirect_stdout(f):522        try:523            exec(shell.save, globals())524            shell.insert_text(f.getvalue(), end='')525            shell.insert_text('Ready', end='''526''')527        except Exception as e:528            shell.insert_text('?Syntax Error? - means something was typed in wrong', end='''529''')530            shell.insert_text("Ready", end='''531''')532        return533    534def lists():535    536    shell.insert_text("File Menu", end='''537''')538    shell.insert_text(shell.save, end='''539''')540    shell.insert_text("Ready", end='''541''')542def clearz():543    shell.insert_text("File Menu", end='''544''')545    shell.insert_text("Before Answering, PRESS ENTER BEFOR TYPING.", end='''546''')547    shell.insert_text("Would you like to clear SYSTEM MEMORY?", end='''548''')549    shell.saveTF = True550    shell.mode = 'clear'551def musiz():552    shell.insert_text("Before Typing answer, PRESS ENTER ONCE BEFORE TYPING FIRST ANSWER", end='''553''')554    shell.insert_text("File Menu", end='''555''')556    shell.insert_text(musix, end='''557''')558        559          560    shell.saveTF = True561    shell.mode = 'music'562    563    564def donothing():565    x=0566    567def default2():568    global shell569    shell.destroy()570    shell = Shell(root, insertbackground="#78DAFC", highlightbackground ="#0F5FB4",highlightcolor="#0F5FB4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#78DAFC", bg="#0F5FB4")571    shell.pack(fill=tk.BOTH, expand=1)572    573    root.update()574    575    576def c642():577    global shell578    shell.destroy()579    shell = Shell(root,insertbackground="#6f6ed1", highlightbackground ="#6f6ed1",highlightcolor="#6f6ed1", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#6f6ed1", bg="#3F359B")580    581    shell.pack(fill=tk.BOTH, expand=1)582    583    root.update()584    585def c64w2():586    global shell587    shell.destroy()588    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#6f6ed1",highlightcolor="#6f6ed1", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#3F359B")589    590    shell.pack(fill=tk.BOTH, expand=1)591    root.update()    592def red2():593    global shell594    shell.destroy()595    shell = Shell(root,insertbackground="#E39693", highlightbackground ="#8B0D0D",highlightcolor="#8B0D0D", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#E39693", bg="#8B0D0D")596    597    shell.pack(fill=tk.BOTH, expand=1)598    root.update()599def redw2():600    global shell601    shell.destroy()602    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#8B0D0D",highlightcolor="#8B0D0D", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#8B0D0D")603    604    shell.pack(fill=tk.BOTH, expand=1)605    root.update()606def bluew2():607    global shell608    shell.destroy()609    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#10145A",highlightcolor="#10145A", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#10145A")610    611    shell.pack(fill=tk.BOTH, expand=1)612    root.update()613def blue2():614    global shell615    shell.destroy()616    shell = Shell(root,insertbackground="#8A8FEA", highlightbackground ="#10145A",highlightcolor="#10145A", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#8A8FEA", bg="#10145A")617    618    shell.pack(fill=tk.BOTH, expand=1)619    root.update()620def teal2():621    global shell622    shell.destroy()623    shell = Shell(root,insertbackground="#52FFC5", highlightbackground ="#008080",highlightcolor="#008080", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#52FFC5", bg="#008080")624    625    shell.pack(fill=tk.BOTH, expand=1)626    root.update()627    628def tealw2():629    global shell630    shell.destroy()631    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#008080",highlightcolor="#008080", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#008080")632    633    shell.pack(fill=tk.BOTH, expand=1)634    root.update()635def orange2():636    global shell637    shell.destroy()638    shell = Shell(root,insertbackground="#955E00", highlightbackground ="#ff8c00",highlightcolor="#ff8c00", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#955E00", bg="#ff8c00")639    640    shell.pack(fill=tk.BOTH, expand=1)641    root.update()642def orangew2():643    global shell644    shell.destroy()645    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#ff8c00",highlightcolor="#ff8c00", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#ff8c00")646    647    shell.pack(fill=tk.BOTH, expand=1)648    root.update()649def green2():650    global shell651    shell.destroy()652    shell = Shell(root,insertbackground="#A4EB99", highlightbackground ="#247618",highlightcolor="#247618", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#38D738", bg="#247618")653    654    shell.pack(fill=tk.BOTH, expand=1)655    root.update()656def greenw2():657    global shell658    shell.destroy()659    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#247618",highlightcolor="#247618", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#247618")660    661    shell.pack(fill=tk.BOTH, expand=1)662    root.update()663def gray2():664    global shell665    shell.destroy()666    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#525252",highlightcolor="#525252", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#525252")667    668    shell.pack(fill=tk.BOTH, expand=1)669    root.update()670def purple2():671    global shell672    shell.destroy()673    shell = Shell(root,insertbackground="#B770E9", highlightbackground ="#6A19A4",highlightcolor="#6A19A4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#B770E9", bg="#6A19A4")674    675    shell.pack(fill=tk.BOTH, expand=1)676    root.update()677def purplew2():678    global shell679    shell.destroy()680    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#6A19A4",highlightcolor="#6A19A4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#6A19A4")681    682    shell.pack(fill=tk.BOTH, expand=1)683    root.update()684def yellow2():685    global shell686    shell.destroy()687    shell = Shell(root,insertbackground="#687312", highlightbackground ="#BCFE54",highlightcolor="#BCFE54", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#687312", bg="#BCFE54")688    689    shell.pack(fill=tk.BOTH, expand=1)690    root.update()691def yelloww2():692    global shell693    shell.destroy()694    shell = Shell(root,insertbackground="#000000", highlightbackground ="#BCFE54",highlightcolor="#BCFE54", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#000000", bg="#BCFE54")695    696    shell.pack(fill=tk.BOTH, expand=1)697    root.update()698def pink2():699    global shell700    shell.destroy()701    shell = Shell(root,insertbackground="#900D74", highlightbackground ="#ED33C4",highlightcolor="#ED33C4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#900D74", bg="#ED33C4")702    703    shell.pack(fill=tk.BOTH, expand=1)704    root.update()705def pinkw2():706    global shell707    shell.destroy()708    shell = Shell(root,insertbackground="#000000", highlightbackground ="#ED33C4",highlightcolor="#ED33C4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#000000", bg="#ED33C4")709    710    shell.pack(fill=tk.BOTH, expand=1)711    root.update()712def white2():713    global shell714    shell.destroy()715    shell = Shell(root,insertbackground="#000000", highlightbackground ="#F6F6F6",highlightcolor="#F6F6F6", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#000000", bg="#F6F6F6")716    717    shell.pack(fill=tk.BOTH, expand=1)718    root.update()719def black2():720    global shell721    shell.destroy()722    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#000000",highlightcolor="#000000", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#000000")723    724    shell.pack(fill=tk.BOTH, expand=1)725    root.update()726def vic202():727    global shell728    shell.destroy()729    shell = Shell(root,insertbackground="#061FEE", highlightbackground ="#00F9F7",highlightcolor="#00F9F7", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#061FEE", bg="#F6F6F6")730    731    shell.pack(fill=tk.BOTH, expand=1)732    root.update()733def plus2():734    global shell735    shell.destroy()736    shell = Shell(root,insertbackground="#000000", highlightbackground ="#B69DF8",highlightcolor="#B69DF8", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#000000", bg="#F6F6F6")737    738    shell.pack(fill=tk.BOTH, expand=1)739    root.update()740def c1282():741    global shell742    shell.destroy()743    shell = Shell(root,insertbackground="#A1E08E", highlightbackground ="#A1E08E",highlightcolor="#A1E08E", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#A1E08E", bg="#555555")744    745    shell.pack(fill=tk.BOTH, expand=1)746    root.update()747def pet2():748    global shell749    shell.destroy()750    shell = Shell(root,insertbackground="#00FE52", highlightbackground ="#000000",highlightcolor="#000000", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#00FE52", bg="#000000")751    752    shell.pack(fill=tk.BOTH, expand=1)753    root.update()754def amber2():755    global shell756    shell.destroy()757    shell = Shell(root,insertbackground="#ff8c00", highlightbackground ="#000000",highlightcolor="#000000", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#ff8c00", bg="#000000")758    759    shell.pack(fill=tk.BOTH, expand=1)760    root.update()761def gameboy2():762    global shell763    shell.destroy()764    shell = Shell(root,insertbackground="#166228", highlightbackground ="#79AC00",highlightcolor="#79AC00", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#166228", bg="#79AC00")765    766    shell.pack(fill=tk.BOTH, expand=1)767    root.update()768def light2():769    global shell770    shell.destroy()771    shell = Shell(root,insertbackground="#005F66", highlightbackground ="#00CBB8",highlightcolor="#00CBB8", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#005F66", bg="#00CBB8")772    773    shell.pack(fill=tk.BOTH, expand=1)774    root.update()775def lb():776    global shell777    shell.destroy()778    shell = Shell(root,insertbackground="#c4ae3d", highlightbackground ="#003B62",highlightcolor="#003B62", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#c4ae3d", bg="#003B62")779    shell.pack(fill=tk.BOTH, expand=1)780    root.update()781atscii = dict(782    dice1 = u"\u2680",783    dice2 = u"\u2681",784    dice3 = u"\u2682",785    dice4 = u"\u2683",786    dice5 = u"\u2684",787    dice6 = u"\u2685",788    block = u"\u2588",789    at = u"\u0040",790    And = u'\u0026',791    hashtag = u'\u0023',792    space = u'\u0020',793    exclmark = u'\u0021',794    quotes = u'\u0022',795    dollar = u'\u0024',796    percent = u'\u0025',797    quote = u'\u2019',798    openbracket = u'\u0028',799    closebracket = u'\u0029',800    star = u'\u002A',801    plus = u'\u002B',802    comma = u'\u002C',803    minus = u'\u002D',804    period = u'\u002E',805    forwardslash = u'\u002F',806    zero = u'\u0030',807    one = u'\0031',808    two = u'\0032',809    three = u'\0033',810    four = u'\0034',811    five = u'\0035', 812    six = u'\0036',813    seven = u'\0037',814    eight = u'\0038',815    nine = u'\0039',816    colon = u'\u003a',817    semicolon = u'\u003B',818    lessthan = u'\u003C',819    equal = u'\u003D',820    greaterthan = u'\u003E',821    questionmark = u'\u003F',822    uppera = u'\u0041',823    upperb = u'\u0042',824    upperc = u'\u0043',825    upperd = u'\u0044',826    uppere = u'\u0045',827    upperf = u'\u0046',828    upperg = u'\u0047',829    upperh = u'\u0048',830    upperi = u'\u0049',831    upperj = u'\u004A',832    upperk = u'\u004B',833    upperl = u'\u004C',834    upperm = u'\u004D',835    uppern = u'\u004E',836    uppero = u'\u004F',837    upperp = u'\u0050',838    upperq = u'\u0051',839    upperr = u'\u0052',840    uppers = u'\u0053',841    uppert = u'\u0054',842    upperu = u'\u0055',843    upperv = u'\u0056',844    upperw = u'\u0057',845    upperx = u'\u0058',846    uppery = u'\u0059',847    upperz = u'\u005A',848    sqopen = u'\u005B',849    backslash = '\',850    sqclose = u'\u005D',851    upaccent = u'\u005E',852    lowline = u'\u005F',853    graveaccent = u'\u0060',854    lowera = u'\u0061',855    lowerb = u'\u0062',856    lowerc = u'\u0063',857    lowerd = u'\u0064',858    lowere = u'\u0065',859    lowerf = u'\u0066',860    lowerg = u'\u0067',861    lowerh = u'\u0068',862    loweri = u'\u0069',863    lowerj = u'\u006A',864    lowerk = u'\u006B',865    lowerl = u'\u006C',866    lowerm = u'\u006D',867    lowern = u'\u006E',868    lowero = u'\u006F',869    lowerp = u'\u0070',870    lowerq = u'\u0071',871    lowerr = u'\u0072',872    lowers = u'\u0073',873    lowert = u'\u0074',874    loweru = u'\u0075',875    lowerv = u'\u0076',876    lowerw = u'\u0077',877    lowerx = u'\u0078',878    lowery = u'\u0079',879    lowerz = u'\u007A',880    cropen = u'\u007B',881    verticalbar = u'\u007C',882    crclose = u'\u007D',883    tilde = u'\u007E',884    inexcelmark = u'\u00A1',885    cent = u'\u00A2',886    pound = u'\u00A3',887    currency = u'\u00A4',888    yen = u'\u00A5',889    brokenbar = u'\u00A6',890    sectionsign = u'\u00A7',891    diaeresis = u'\u00A8',892    copyrights = u'\u00A9',893    femord = u'\u00AA',894    leftquotes = u'\u00AB',895    notsign = u'\u00AC',896    registered = u'\u00AE',897    macron = u'\u00AF',898    degree = u'\u00B0',899    pilcrow = u'\u00B6',900    rightquotes = u'\u00BB',901    onedfour = u'\u00BC',902    onedtwo = u'\u00BD',903    threedfour = u'\u00BE',904    inquestionmark = u'\u00BF',905    multiply = u'\u00D7',906    divide = u'\u00F7',907    upperhalf = u'\u2580',908    loweronedeight = u'\u2581',909    loweronedfour = u'\u2582',910    lowerthreedeight = u'\u2583',911    lowerhalf = u'\u2584',912    lowerfivedeight = u'\u2585',913    lowerthreedfour = u'\u2586',914    lowersevendeight = u'\u2587',915    leftsevendeight = u'\u2589',916    leftthreedfour = u'\u258A',917    leftfivedeight = u'\u258B',918    lefthalf = u'\u258C',919    leftthreedeight = u'\u258D',920    leftonedfour = u'\u258E',921    leftonedeight = u'\u258F',922    righthalf = u'\u2590',923    lightshade = u'\u2591',924    mediumshade = u'\u2592',925    darkshade = u'\u2593',926    upperonedeight = u'\u2594',927    rightonedeight = u'\u2595',928    quadlowerleft = u'\u2596',929    quadlowerright = u'\u2597',930    quadupperleft = u'\u2598',931    quadulpllplr = u'\u2599',932    quadulplr = u'\u259A',933    quadulpurpll = u'\u259B',934    quadulpurplr = u'\u259C',935    quadupperright = u'\u259D',936    quadurpll = u'\u259E',937    quadurpllplr = u'\u259F'938    )939def findNum(word):940    for i in word:941        if i.isdigit():942            return True943    return False944try:945    from clrprint import *946  947except:948    print('The Clrprint Module could not be imported')949    print(' ')950saves = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' + u"\u2680" + u"\u2681" + u"\u2682" + u"\u2683" + u"\u2684" + u"\u2685" + u"\u2588" + "@&# !" + '"' + "$%'()*+,-./:;>=<?\[]{}^_" + u"\u0060" + "|~" + u"\u00A1" + u"\u00A2" + u"\u00A3" + u"\u00A4" + u"\u00A5" + u"\u00A6" + u"\u00A7" + u"\u00A8" + u"\u00A9" + u"\u00AA" + u"\u00AB" + u"\u00AC" + u"\u00AE" + u"\u00AF" + u"\u00B0" + u"\u00B6" + u"\u00BB" + u"\u00BC" + u"\u00BD" + u"\u00BE" + u"\u00BF" + u"\u00D7" + u"\u00F7" + u"\u2580" + u"\u2581" + u"\u2582" + u"\u2583" + u"\u2584" + u"\u2585" + u"\u2586" + u"\u2587" + u"\u2588" + u"\u2589" + u"\u258A" + u"\u258B" + u"\u258C" + u"\u258D" + u"\u258E" + u"\u258F" + u"\u2590" + u"\u2591" + u"\u2592" + u"\u2593" + u"\u2594" + u"\u2595" + u"\u2596" + u"\u2597" + u"\u2598" + u"\u2599" + u"\u259A" + u"\u259B" + u"\u259C" + u"\u259D" + u"\u259E" + u"\u259F"951rose = "© Blake Gouthro and JinHo Mo | Rosewell BASIC | V2.4.3 | Rosewell Software | 2021 - " + str(today.year) + " ©"952load = ''953def copyright():954    955    956    try:957        clrprint('© Blake Gouthro and JinHo Mo |' , 'Rosewell', 'B', 'A', 'S', 'I', 'C', '| V2.4.3 | Rosewell Software | 2021 - ' + str(today.year) + ' ©', clr=['blue', 'white', 'red', 'yellow', 'green', 'blue', 'purple', 'blue', 'blue'])958    except:959        print(rose)960class Shell(tk.Text):961  global loadx962  963  964  965  966  def __init__(self, parent, **kwargs):967    968    self.save = ''969    self.saveTF = False970    self.mode = ''971    972    tk.Text.__init__(self, parent, **kwargs)973    self.bind('<Key>', self.on_key) # setup handler to process pressed keys974    self.cmd = None975    self.insert_text(rose, end='''976''')977    self.insert_text("Today's Date: " + str(today), end='''978''')979    if axio != 0:980          self.insert_text(modwell, end='''981''')982    else:983          self.insert_text('Enough BASIC Bytes Free', end='''984''')985    self.insert_text('Ready', end='''986''')987    # hold the last command issued988    self.show_prompt()989    990  # to append given text at the end of Text box991  def insert_text(self, txt='', end='''992'''):993    self.insert(tk.END, txt+end)994    self.see(tk.END) # make sure it is visible995#Ready Prompt996  def show_prompt(self):997    self.insert_text('', end='')998    self.mark_set(tk.INSERT, tk.END) # make sure the input cursor is at the end999    self.cursor = self.index(tk.INSERT) # save the input position1000  # handler to process keyboard input1001  def on_key(self, event):1002    #print(event)1003    if event.keysym == 'Up':1004      if self.cmd:1005        # show the last command1006        self.delete(self.cursor, tk.END)1007        self.insert(self.cursor, self.cmd)1008      return "break" # disable the default handling of up key1009    if event.keysym == 'Down':1010      return "break" # disable the default handling of down key1011    if event.keysym in ('Left', 'BackSpace'):1012      current = self.index(tk.INSERT) # get the current position of the input cursor1013      if self.compare(current, '==', self.cursor):1014        # if input cursor is at the beginning of input (after the prompt), do nothing1015        return "break"1016    if event.keysym == 'Return':1017      # extract the command input1018      cmd = self.get(self.cursor, tk.END).strip()1019      self.insert_text() # advance to next line1020      if cmd.startswith('`'):1021        # it is an external command1022        self.system(cmd)1023      else:1024        # it is python statement1025        self.execute(cmd)1026      self.show_prompt()1027      return "break" # disable the default handling of Enter key1028    if event.keysym == 'Escape':1029      self.master.destroy() # quit the shell1030  # function to handle python statement input1031  1032  def execute(self, cmd):1033    1034    self.cmd = cmd  # save the command1035    global loadx1036    global loadz1037    loadx = ''1038    loadz = loadz1039    name = ''1040    1041    1042    def atsciiprint():1043      for i in range(157):1044        self.insert_text(saves[i], end=''); time.sleep(0.000000000000000001)1045    def repeatchr(num):1046      for i in range(num):1047        atsciiprint()1048    def Go(num):1049      f = io.StringIO()1050      for x in range(num):1051        with redirect_stdout(f):1052          try:1053            exec(self.save, globals())1054          except:1055            return False1056      self.insert_text(f.getvalue(), end='')1057    def repeatchr(num):1058        for i in range(num):1059            atsciiprint()1060    1061    1062    def poke(word):1063    1064        try:1065            1066            self.insert_text(atscii.get(word[0], "No Character to Poke"), end='''1067''')1068            1069        except Exception as e:1070            print(e)1071    1072    # use redirect_stdout() to capture the output of exec() to a string1073    #20211109 Secret1074    def default():1075      shell = Shell(root, insertbackground="#78DAFC", highlightbackground ="#0F5FB4",highlightcolor="#0F5FB4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#78DAFC", bg="#0F5FB4")1076      self.destroy()1077      shell.pack(fill=tk.BOTH, expand=1)1078      root.update()1079    def c64():1080      shell = Shell(root,insertbackground="#6f6ed1", highlightbackground ="#6f6ed1",highlightcolor="#6f6ed1", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#6f6ed1", bg="#3F359B")1081      self.destroy()1082      shell.pack(fill=tk.BOTH, expand=1)1083      root.update()1084    def c64w():1085      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#6f6ed1",highlightcolor="#6f6ed1", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#3F359B")1086      self.destroy()1087      shell.pack(fill=tk.BOTH, expand=1)1088      root.update()    1089    def red():1090      shell = Shell(root,insertbackground="#E39693", highlightbackground ="#8B0D0D",highlightcolor="#8B0D0D", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#E39693", bg="#8B0D0D")1091      self.destroy()1092      shell.pack(fill=tk.BOTH, expand=1)1093      root.update()1094    def redw():1095      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#8B0D0D",highlightcolor="#8B0D0D", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#8B0D0D")1096      self.destroy()1097      shell.pack(fill=tk.BOTH, expand=1)1098      root.update()1099    def bluew():1100      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#10145A",highlightcolor="#10145A", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#10145A")1101      self.destroy()1102      shell.pack(fill=tk.BOTH, expand=1)1103      root.update()1104    def blue():1105      shell = Shell(root,insertbackground="#8A8FEA", highlightbackground ="#10145A",highlightcolor="#10145A", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#8A8FEA", bg="#10145A")1106      self.destroy()1107      shell.pack(fill=tk.BOTH, expand=1)1108      root.update()1109    def teal():1110      shell = Shell(root,insertbackground="#52FFC5", highlightbackground ="#008080",highlightcolor="#008080", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#52FFC5", bg="#008080")1111      self.destroy()1112      shell.pack(fill=tk.BOTH, expand=1)1113      root.update()1114    1115    def tealw():1116      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#008080",highlightcolor="#008080", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#008080")1117      self.destroy()1118      shell.pack(fill=tk.BOTH, expand=1)1119      root.update()1120    def orange():1121      shell = Shell(root,insertbackground="#955E00", highlightbackground ="#ff8c00",highlightcolor="#ff8c00", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#955E00", bg="#ff8c00")1122      self.destroy()1123      shell.pack(fill=tk.BOTH, expand=1)1124      root.update()1125    def orangew():1126      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#ff8c00",highlightcolor="#ff8c00", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#ff8c00")1127      self.destroy()1128      shell.pack(fill=tk.BOTH, expand=1)1129      root.update()1130    def green():1131      shell = Shell(root,insertbackground="#A4EB99", highlightbackground ="#247618",highlightcolor="#247618", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#38D738", bg="#247618")1132      self.destroy()1133      shell.pack(fill=tk.BOTH, expand=1)1134      root.update()1135    def greenw():1136      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#247618",highlightcolor="#247618", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#247618")1137      self.destroy()1138      shell.pack(fill=tk.BOTH, expand=1)1139      root.update()1140    def gray():1141      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#525252",highlightcolor="#525252", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#525252")1142      self.destroy()1143      shell.pack(fill=tk.BOTH, expand=1)1144      root.update()1145    def purple():1146      shell = Shell(root,insertbackground="#B770E9", highlightbackground ="#6A19A4",highlightcolor="#6A19A4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#B770E9", bg="#6A19A4")1147      self.destroy()1148      shell.pack(fill=tk.BOTH, expand=1)1149      root.update()1150    def purplew():1151      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#6A19A4",highlightcolor="#6A19A4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#6A19A4")1152      self.destroy()1153      shell.pack(fill=tk.BOTH, expand=1)1154      root.update()1155    def yellow():1156      shell = Shell(root,insertbackground="#687312", highlightbackground ="#BCFE54",highlightcolor="#BCFE54", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#687312", bg="#BCFE54")1157      self.destroy()1158      shell.pack(fill=tk.BOTH, expand=1)1159      root.update()1160    def yelloww():1161      shell = Shell(root,insertbackground="#000000", highlightbackground ="#BCFE54",highlightcolor="#BCFE54", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#000000", bg="#BCFE54")1162      self.destroy()1163      shell.pack(fill=tk.BOTH, expand=1)1164      root.update()1165    def pink():1166      shell = Shell(root,insertbackground="#900D74", highlightbackground ="#ED33C4",highlightcolor="#ED33C4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#900D74", bg="#ED33C4")1167      self.destroy()1168      shell.pack(fill=tk.BOTH, expand=1)1169      root.update()1170    def pinkw():1171      shell = Shell(root,insertbackground="#000000", highlightbackground ="#ED33C4",highlightcolor="#ED33C4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#000000", bg="#ED33C4")1172      self.destroy()1173      shell.pack(fill=tk.BOTH, expand=1)1174      root.update()1175    def white():1176      shell = Shell(root,insertbackground="#000000", highlightbackground ="#F6F6F6",highlightcolor="#F6F6F6", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#000000", bg="#F6F6F6")1177      self.destroy()1178      shell.pack(fill=tk.BOTH, expand=1)1179      root.update()1180    def black():1181      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#000000",highlightcolor="#000000", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#000000")1182      self.destroy()1183      shell.pack(fill=tk.BOTH, expand=1)1184      root.update()1185    def vic20():1186      shell = Shell(root,insertbackground="#061FEE", highlightbackground ="#00F9F7",highlightcolor="#00F9F7", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#061FEE", bg="#F6F6F6")1187      self.destroy()1188      shell.pack(fill=tk.BOTH, expand=1)1189      root.update()1190    def plus():1191      shell = Shell(root,insertbackground="#000000", highlightbackground ="#B69DF8",highlightcolor="#B69DF8", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#000000", bg="#F6F6F6")1192      self.destroy()1193      shell.pack(fill=tk.BOTH, expand=1)1194      root.update()1195    def c128():1196      shell = Shell(root,insertbackground="#A1E08E", highlightbackground ="#A1E08E",highlightcolor="#A1E08E", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#A1E08E", bg="#555555")1197      self.destroy()1198      shell.pack(fill=tk.BOTH, expand=1)1199      root.update()1200    def pet():1201      shell = Shell(root,insertbackground="#00FE52", highlightbackground ="#000000",highlightcolor="#000000", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#00FE52", bg="#000000")1202      self.destroy()1203      shell.pack(fill=tk.BOTH, expand=1)1204      root.update()1205    def amber():1206      shell = Shell(root,insertbackground="#ff8c00", highlightbackground ="#000000",highlightcolor="#000000", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#ff8c00", bg="#000000")1207      self.destroy()1208      shell.pack(fill=tk.BOTH, expand=1)1209      root.update()1210    def gameboy():1211      shell = Shell(root,insertbackground="#166228", highlightbackground ="#79AC00",highlightcolor="#79AC00", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#166228", bg="#79AC00")1212      self.destroy()1213      shell.pack(fill=tk.BOTH, expand=1)1214      root.update()1215    def light():1216      shell = Shell(root,insertbackground="#005F66", highlightbackground ="#00CBB8",highlightcolor="#00CBB8", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#005F66", bg="#00CBB8")1217      self.destroy()1218      shell.pack(fill=tk.BOTH, expand=1)1219      root.update()1220    def lb2():1221      global shell1222      shell.destroy()1223      shell = Shell(root,insertbackground="#c4ae3d", highlightbackground ="#003B62",highlightcolor="#003B62", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#c4ae3d", bg="#003B62")1224      shell.pack(fill=tk.BOTH, expand=1)1225      root.update()1226    1227    if cmd == '20211109':1228        self.insert_text('Hello User! You have found the November 9th 2021 Secret! The Creation Date of Rosewell OS Happened on this date! We are talking about Rosewell OS not Rosewell BASIC. Never Forget it JinHo Mo or Blake Gouthro', end='''1229''')1230        self.insert_text('Ready', end='''1231''')1232    #Color Help1233    elif cmd in ['Color Help','color help','COLOR HELP','Color help','color Help','ch','CH','Ch','cH','color h','COLOR h','Color h','COLOR H','Color H','color H']:1234        self.insert_text(colorhelp, end='''1235''')1236        return1237    #Color Changing Feature1238    elif "color" in cmd.lower():1239        colors = str(cmd.split()[-1:][0])1240        if colors in ['BASIC','Basic','basic','Default','default','DEFAULT','B','b','d','D']:1241            default()1242        1243        if colors in ['c64','C64','Commodore 64','commodore 64','COMMODORE 64','C','c','64']:        1244            c64()1245        if colors in ['c64 white','C64 white','Commodore 64 white','commodore 64 white','COMMODORE 64 white','Cw','cw','64w']:1246            c64w()1247        if colors in ['Red','RED','red','Dark Red','DARK RED','dark red','Dark red','dark Red','R','r','DR','dr','Dr','dR']:1248            red()1249        if colors in ['Red white','RED white','red white','Dark Red white','DARK RED white','dark red white','Dark red white','dark Red white','Rw','rw','DRw','drw','Drw','dRw']:1250            redw()1251        if colors in ['Blue white','blue white','BLUE white','Dark Blue white','Dark blue white','dark Blue white','DARK BLUE white','dark blue white','DBw','dbw','Dbw','dBw']:1252            blue()1253        if colors in ['Blue','blue','BLUE','Dark Blue','Dark blue','dark Blue','DARK BLUE','dark blue','DB','db','Db','dB']:1254            bluew()   1255        if colors in ['Teal','teal','TEAL','T','t']:1256            teal()1257        if colors in ['Teal white','teal white','TEAL white','Tw','tw']:1258            tealw()1259        if colors in ['Orange','orange','ORANGE','O','o']:1260            orange()1261        if colors in ['Orange white','orange white','ORANGE white','Ow','ow']:1262            orangew()1263        if colors in ['green','GREEN','Green','G','g',]:1264            green()1265        if colors in ['green white','GREEN white','Green white','Gw','gw',]:1266            greenw()1267        if colors in ['gray','GRAY','Gray','GR','gr','Gr','gR']:1268            gray()1269        if colors in ['purple','PURPLE','Purple','P','p']:1270            purple()1271        if colors in ['purple white','PURPLE white','Purple white','Pw','pw']:1272            purplew()1273        if colors in ['yellow','YELLOW','Yellow','y','Y']:1274            yellow()1275        if colors in ['yellow white','YELLOW white','Yellow white','yw','Yw']:1276            yellow()1277        if colors in ['PINK','pink','Pink','pi','PI','Pi','pI']:1278            pink()1279        if colors in ['PINK white','pink white','Pink white','pi white','PI white','Pi white','pI white']:1280            pinkw()1281        if colors in ['white','WHITE','White','w','W']:1282            white()1283        if colors in ['BLACK','black','Black']:1284            black()1285        if colors in ['vic20','Vic20','VIC20','vic-20','VIC-20','Vic-20','vic','VIC','Vic']:        1286            vic20()1287        if colors in ['plus','PLUS','Plus','Plus4','PLUS4','plus4','plus-4','PLUS-4','Plus-4']:        1288            plus()1289        if colors in ['128','c128','C128','COMMODORE128','commodore128','Commodore128','Commodore 128',' commodore 128','COMMODORE 128']:        1290            c128()1291        if colors in ['PET','pet','Pet','pEt','peT','PEt','pET','PeT','commodore pet','Commodore pet','COMMODORE pet','COMMODORE PET','Commodore PET','commodore PET']:        1292            pet()1293        if colors in ['Amber','AMBER','amber','A','a','Ab','aB','AB','ab']:1294            amber()1295        if colors in ['Gameboy','gameboy','GAMEBOY','GameBoy','gameBoy','Peasoup','PEASOUP','peasoup','GB','gb','Gb','gB']:1296            gameboy()1297        if colors in ['Light','light','LIGHT','Gameboy Light','gameboy light','GAMEBOY LIGHT','Gameboy light','gameboy Light','GameBoy Light','gameBoy Light','GameBoy light','GBL','gbl','GbL','GBl','gBL','Gbl','gBl','gbL']:1298            light()1299        if colors in ['Light Blue','light blue','LIGHT BLUE','Light blue','light Blue','lb','LB','lB','Lb']:1300            lb2()1301        1302        1303        1304        1305    if 'Help Menu' in cmd or 'File Menu' in cmd:1306        return1307         1308      # 20050421 Secret1309    if cmd == '20050421':1310        self.insert_text('Hi My name is CONRAD! You Look Familiar. Have we met somewhere? Whta is your name?', end='''1311''')1312        self.saveTF = True1313        self.mode = '20050421'1314        return1315    #Save Function1316    if self.saveTF:1317      user = cmd1318      1319      self.saveTF = False1320      if user in ['Quit', 'quit', 'QUIT', 'Q', 'q', 'Exit', 'exit', 'EXIT', 'E', 'e']:1321          self.insert_text('Back to BASIC', end='''1322''')1323      elif self.mode == 'save':1324          with open(cmd, 'w') as file:1325              file.write(self.save)1326          self.insert_text('Saving . . . . .', end='''1327''')1328          time.sleep(1)1329          self.insert_text('Your PROGRAM Has Been Saved!', end='''1330''')1331          self.insert_text('Ready', end='''1332''')1333      1334          1335      #Load Function   1336      elif self.mode == 'load':1337          try:1338              with open(cmd, "r") as file:1339                  self.save = "".join(file.readlines())1340              self.insert_text('Loading . . . . .', end='''1341''')1342              time.sleep(1)1343              self.insert_text('-----Directory-----', end='''1344''')1345              self.insert_text('Memory   PROGRAM   Ext', end='''1346''')1347              self.insert_text(str(sys.getsizeof(self.save)) + " Bytes" + "     System Memory.prg", end='''1348''')1349              if load != '':1350                  1351                  self.insert_text(str(sys.getsizeof(load)) + " Bytes" + '     ' + str(load), end='''1352''')1353              else:1354                  self.insert_text(str(sys.getsizeof(load)) + " Bytes" + '     ' + 'BASIC Memory.prg', end='''1355''')1356              self.insert_text('Ready', end='''1357''')1358          except:1359              self.insert_text("?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.", end='''1360''')1361      1362      #Repeat Function1363      elif self.mode == 'repeat':1364          try:1365              repeatchr(int(user))1366              self.insert_text('''1367Ready''', end='''1368''')1369          except:1370              self.insert_text("?Syntax Error? - means something was typed in wrong", end='''1371''')1372      #Music Function1373      elif 'music' in self.mode:1374          mixer.init()1375          1376          if user in ['1', 'one', 'One', 'ONE', 'O', 'o','Play','play','PLAY','P','p'] and self.mode == 'music':1377              self.insert_text("Enter Music name or music path name:", end='''1378''')1379              self.saveTF = True1380              self.mode = 'music1'1381              return1382          elif self.mode == 'music1':1383              mixer.music.load(cmd)1384              #Loops Music1385              mixer.music.play(-1)1386              self.insert_text("Background Music is Playing")1387          if user in ['2', 'Two','two','TWO','T','t','Stop','stop','STOP','S','s','PAUSE','pause','Pause']:1388              mixer.music.stop()1389              self.insert_text('Background Music has Stopped Playing', end='''1390''')1391          if user in ['3','Three','three','THREE','Pause','pause','PAUSE','P','p']:1392              mixer.music.pause()1393              self.insert_text('Background Music Has Been Paused', end='''1394''')1395          if user in ['4','Four','FOUR','F','f','four','Unpause','unpause','UNPAUSE','UnPause','up','UP','Up','uP']:1396              mixer.music.unpause()1397              self.insert_text('Background Music Has Been UnPaused', end='''1398''')1399          if user in ['5','Five','five','FIVE','Add','ADD','add','FI','fi','Fi','fI','A','a','Queue','queue','QUEUE','q','Q','Add To Queue','ADD TO QUEUE','add to queue','Add to queue','add To queue','add to Queue','Add To queue','add To Queue']:1400              self.insert_text('Enter the Path or Name of the Music you Would Like to Add to the Queue:', end='''1401''')1402              self.saveTF = True1403              self.mode = 'music2'1404              return1405          if user in ['6','six','SIX','Six','UnLoop','unloop','UNLOOP','Unloop','unLoop']:1406              self.insert_text('Enter Music Name or Path Name:', end='''1407''')1408              self.saveTF = True1409              self.mode = 'music3'1410              return1411          elif self.mode == 'music3':1412              mixer.music.load(cmd)1413              mixer.music.play()1414              self.insert_text('Background Music is Playing Without Loop', end='''1415''')1416          elif self.mode == 'music2':1417              mixer.music.queue(user)1418              self.insert_text('Music Has Been Added to the Queue', end='''1419''')1420              1421          self.insert_text('Ready', end='''1422''')1423      #Load, 8 Feature1424      elif 'load, 8' in self.mode:1425        1426        loadx = '/Volumes/'1427        1428        1429        if user != '' or user != ' ': 1430            loadx = loadx + user + '/'1431            1432        elif user == '' or user == ' ':1433            user = 'UNTITLED'1434            loadx = loadx + user + '/'1435        1436        self.insert_text("Enter PROGRAM Name and extension or path from External Disk to PROGRAM. [Type 'Quit' or 'Exit' to quit]:", end='''1437''')1438        loadz = loadx1439        self.saveTF = True1440        self.mode = 'load,82'1441        return1442            1443      elif 'load,82' in self.mode:1444          loadx = loadz1445          loadx = loadx + user1446          1447          try:1448            with open(loadx, "r") as file:1449              self.save = "".join(file.readlines())1450            time.sleep(1)1451          except:1452            self.insert_text('?Syntax Error? - This Means Something was Typed in Wrong', end='''1453''')1454          1455          self.insert_text('-----Directory-----', end='''1456''')1457          self.insert_text('Memory   PROGRAM   Ext', end='''1458''')1459          self.insert_text(str(sys.getsizeof(self.save)) + " Bytes" + "     SYSTEM Memory.prg", end='''1460''')1461          self.insert_text(str(sys.getsizeof(loadx)) + " Bytes" + '     ' + loadx, end='''1462''')1463        1464              1465          self.insert_text('Ready', end='''1466''')1467      # Clear System Memory1468      elif self.mode == 'clear':1469          if user in ['Yes','YES','yes','Y','y']:1470              self.save = ''1471              time.sleep(1)1472              self.insert_text('SYSTEM MEMORY Has Been Cleared!', end='''1473''')1474          if user in ['NO','No','no','n','N']:1475              self.save = self.save1476              self.insert_text('SYSTEM MEMORY Has Not Been Cleared.', end='''1477''')1478          self.insert_text('Ready', end='''1479''')1480      #Directory1481      elif self.mode == 'dir':1482          if user in ['', 'No','no','NO','N','n']:1483              user = 'BASIC Memory.prg'1484              programs = ''1485          else:1486              programs = user1487          self.insert_text('-----Directory-----', end='''1488''')1489          self.insert_text('Memory   PROGRAM   Ext', end='''1490''')1491          self.insert_text(str(sys.getsizeof(self.save)) + " Bytes" + "     SYSTEM Memory.prg", end='''1492''')1493          self.insert_text(str(sys.getsizeof(programs)) + " Bytes" + '     ' + user, end='''1494''')1495          self.insert_text('Ready', end='''1496''')1497      #Peek Function1498      elif self.mode =='peek':1499        sub = cmd.split()[-1]1500        try:1501          if user in ['1', 'One','ONE','one','O','o']:1502            for i in sub:1503               self.insert_text(ord(i), end = "''''")1504          if user in ['2','Two','TWO','two','T','t']:1505            for i in sub:1506               self.insert_text(chr(int(i)), end = "''''") 1507              1508        except:1509          self.insert_text('?Syntax Error? - means something was typed in wrong', end='''1510''')1511        self.insert_text('Ready', end='''1512''')1513      1514      #20050421 Secret Function1515      elif '20050421' in self.mode:1516          1517          name = cmd1518          1519          self.insert_text('''1520Welcome ''' + name + "! This Secret is Famillar because it is from Rosewell OS! Not Rosewell BASIC. Anyways Both Operating Systems are Cool Operating Systems.", end='''1521''')1522          self.insert_text(rose, end='''1523''')1524          self.insert_text("That is the Rosewell BASIC Copyright line. it is important that all of Blake's OSes have them. Rosewell OS was created on November 9th 2021.", end='''1525''')1526          self.insert_text('You can Contact the creator at: rosewellsoftware@Gmail.com', end='''1527''')1528          self.insert_text('''Brewing Coffee for Next Update . . . . .1529Have a Good Day ''' + name + '!', end='''1530''')1531          self.insert_text('Ready', end='''1532''')1533          cmd = ''1534          1535      1536          1537          1538          1539      #Notes Menu1540      elif 'Note' in self.mode:1541          global note1542          if user in ['1', 'One','one','ONE','New','NEW','new','N','n','o','O']:1543              self.insert_text('Are You Sure? This Action will Delete the Previous Note.[y/n]: ', end='''1544''')1545              self.saveTF = True1546              self.mode = 'note2'1547              return1548          if user in  ['2', 'Two', 'two', 'Review', 'review', 'r', 'R', 'Review Note', 'review Note', 'Review note', 'review note']:1549              self.insert_text('''-----Review Note-----1550Your Note Contains:1551''', end='''1552''')1553              self.insert_text(note, end='''1554''')1555              self.insert_text('Ready', end='''1556''')1557          if user in ['3', 'Add', 'add', 'A', 'a', 'Edit', 'edit', 'E', 'e', 'Add Note', 'Add note', 'add Note', 'add note', 'Edit Note', 'Edit note', 'edit Note', 'edit note']:1558              self.insert_text('''-----Add To Note-----1559Enter The Contents You Would Like to Add/[1 Line]''', end='''1560''')1561              self.saveTF = True1562              self.mode = 'note4'1563              return1564      elif 'note2' in self.mode:1565          if user in ['NO','no','No','n','N','quit','QUIT','Quit','q','Q','Exit','exit','EXIT','E','e']:1566              self.insert_text('Ready', end='''1567''')1568          else:1569              self.insert_text('''-----New Note-----1570Enter Your New Note Contents.[1 line]''', end='''1571''')1572              self.saveTF = True1573              self.mode = 'note3'1574              return1575      elif 'note3' in self.mode:1576          1577          note = user + "''''"1578          self.insert_text('Saving Note . . . . .', end='''1579''')1580          time.sleep(1)1581          self.insert_text('Your Note Has Been Saved! . . . . .', end='''1582''')1583          self.insert_text('Ready', end='''1584''')1585      elif 'note4' in self.mode:1586          1587          note += user + "''''"1588          self.insert_text('Saving Note . . . . .', end='''1589''')1590          time.sleep(1)1591          self.insert_text('Your Note Has Been Saved!', end='''1592''')1593          self.insert_text('Ready', end='''1594''')1595      elif 'voice' in self.mode:1596          os.system( " say " + cmd  + " " )1597          self.insert_text('Ready', end='''1598''')1599      elif 'restart' in self.mode:1600          if cmd in ['No','no','NO','n','N']:1601              self.insert_text('''The app will not be Restarted.1602Ready''', end='''1603''')1604          if cmd in ['Yes','yes','YES','Y','y']:1605              self.insert_text('Restarting App...', end='''1606''')1607              self.insert_text('Loading . . . . .', end='''1608''')1609              time.sleep(1)1610              shell = Shell(root, insertbackground="#78DAFC", highlightbackground ="#0F5FB4",highlightcolor="#0F5FB4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#78DAFC", bg="#0F5FB4")1611              self.destroy()1612              shell.pack(fill=tk.BOTH, expand=1)1613              root.update()1614      #Speech Recoginition1615      elif 'sr' in self.mode:1616            RECORD_SECONDS = int(cmd)1617            def rec():1618                self.insert_text('Recording . . . . .', end='''1619''')1620                self.update()1621                CHUNK = 10241622                FORMAT = pyaudio.paInt161623                CHANNELS = 21624                RATE = 441001625                  1626                def rec():1627                      self.insert_text('Recording . . . . .', end='''1628''')1629                      self.update()1630                      CHUNK = 10241631                      1632                      CHANNELS = 21633                      RATE = 441001634                        1635                  1636                      myrecording = sd.rec(int(duration * RATE), channels=2)1637                      sd.wait()1638                      1639                      1640                        # Record audio for the given number of seconds1641                      wavio.write(filename, myrecording, RATE, sampwidth=2)1642                      self.insert_text('Finished Recording', end='''1643''')1644                        #Second Half of Code1645                      r = sr.Recognizer()1646                      with sr.AudioFile(filename) as source:1647                            # listen for the data (load audio to memory)1648                        audio_data = r.record(source)1649                            # recognize (convert from speech to text)1650                        text = r.recognize_google(audio_data)1651                        self.insert_text(text,end='''1652''')1653                      os.remove(filename)1654            rec()1655            self.insert_text('Ready',end='''1656''')1657              1658 1659        1660      self.mode = ''1661      return1662    if len(cmd) == 0:1663      self.insert_text('', end='')1664    # Load, 81665    elif cmd in ['Load,8', 'LOAD, 8', 'LOAD,8', 'load,8', 'load, 8', 'Load, 8', 'l8', 'L8', 'Load*8', 'load*8', 'Load* 8' , 'load* 8', 'LOAD* 8', 'load$8', 'LOAD$8', 'Load$8', 'Load$ 8', 'load$ 8', 'LOAD$ 8', 'load$, 8', 'Load$, 8', 'LOAD$, 8', 'Load*, 8', 'load*, 8', 'LOAD*, 8']:1666        self.insert_text("Enter External Disk Name [Type 'Quit' or 'Exit' to quit/ if left blank, the prompt defaults to UNTITLED.]:", end='''1667''')1668        try:1669            1670            self.saveTF = True1671            self.mode = 'load, 8'1672        except:1673            self.insert_text("?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.", end='''1674''')1675    # All Chr  1676    elif cmd in ['All Chr', 'all chr', 'All chr', 'all Chr', 'ALL CHR', 'AC', 'ac', 'All Character', 'all character', 'All character', 'all Character', 'ALL CHARACTER', 'All Characters', 'all characters', 'all Characters', 'All characters', 'ALL CHARACTERS', 'ALL CHRS', 'all chrs', 'All chrs', 'all Chrs']:1677      atsciiprint()1678      self.insert_text('''1679Ready''', end='''1680''')1681    #Poke1682    elif 'poke' in cmd.lower():1683      pokes = cmd.split()[1:]1684      poke(pokes)1685      self.insert_text('Ready', end='''1686''')1687    #Peek1688    elif 'peek' in cmd.lower():1689        self.insert_text('Ord or Chr?[1/2]', end='''1690''')1691        self.insert_text("Return ATSCII Value or Printed ATSCII?", end='''1692''')1693        self.saveTF = True1694        self.mode = 'peek'1695    1696        1697    #Goto1698    elif "goto" in cmd.lower():1699      Go(int(cmd.split()[-1:][0]))1700      self.insert_text('Ready', end='''1701''')1702    #Saves to Variable1703    elif findNum(cmd):1704      1705      spaces = ''1706      space = ''1707      varc = ''1708      space = cmd.split()[0]1709      varc = str(space) + ' '1710      spaces = cmd.replace(varc, '')1711      self.save += spaces + "''''"1712    #list1713    elif cmd in ['list', 'List', 'LIST']:1714      time.sleep(0.1)1715      self.insert_text(self.save, end='''1716''')1717      self.insert_text('Ready', end='''1718''')1719    #Contact Us1720    elif cmd in ['Contact','contact','CONTACT','Contact Us','CONTACT US','contact us','Contact us','contact Us']:1721        self.insert_text('''Contact Us at:1722rosewellsoftware@Gmail.com''', end='''1723''')1724        self.insert_text('Ready', end='''1725''')1726    1727    #Run1728    elif cmd in ["Run", "run", 'RUN', 'R', 'r']:1729      f = io.StringIO()1730      with redirect_stdout(f):1731        try:1732          exec(self.save, globals())1733          self.insert_text(f.getvalue(), end='')1734          self.insert_text('Ready', end='''1735''')1736        except Exception as e:1737          self.insert_text('?Syntax Error? - means something was typed in wrong', end='''1738''')1739          self.insert_text("Ready", end='''1740''')1741    #Help1742    elif cmd in ['HELP', 'Help', 'help', 'H', 'h']:1743      self.insert_text(helps, end='''1744''')1745      self.insert_text('Ready', end='''1746''')1747    #Save1748    elif cmd in ['Save', 'save', 'SAVE', 's', 'S', 'Saves', 'saves', 'SAVES']:1749      self.insert_text("Enter new PROGRAM Name to Save [Type 'Quit' or 'Exit' to quit]:", end='''1750''')1751      self.insert_text("Don't Forget to type '.py' to save as a python file. If your saving in the app, your file will be saved in the app ready to go!", end='''1752''')1753      1754      try:1755          1756          self.saveTF = True1757          self.mode = 'save'1758          1759      except:1760          self.insert_text("?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.", end='''1761''')1762    #Text To Speech1763    elif cmd in ['speak','Speak','SPEAK','Speech','speech','SPEECH','Text To Speech','text to speech','TEXT TO SPEECH','Text to speech','text To speech','text to Speech',' Text To speech','text To Speech','Text to Speech','TTS','tts','Tts','tTs','ttS','TTs','tTS','TtS']:1764        self.insert_text('© Blake Gouthro | Text To Speech App | V1.1 | Rosewell Software | 2022 - ' + str(today.year) +' ©', end='''1765''')1766        1767        self.insert_text('Enter Text To Speak:', end='''1768''')1769        self.saveTF = True1770        self.mode = 'voice'1771        1772            1773    #music1774    elif cmd in ['Music', 'music', 'MUSIC', 'M', 'm', 'MM', 'mm', 'Mm', 'mM', 'Music Menu', 'MUSIC MENU', 'music menu', 'Music menu', 'music Menu']:1775        1776            1777        self.insert_text(musix, end='''1778''')1779        try:1780          1781          self.saveTF = True1782          self.mode = 'music'1783          1784          1785          1786        except:1787          self.insert_text("?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.", end='''1788''')1789    #Load1790    elif cmd in ['Load', 'load', 'L', 'l', 'LOAD']:1791        self.insert_text("Enter PROGRAM Name to Load [Type 'Quit' or 'Exit' to quit]:", end='''1792''')1793        try:1794            self.saveTF = True1795            self.mode = 'load'1796            1797            1798        except:1799          self.insert_text("?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.", end='''1800''')1801    #New Window1802    elif cmd in ['Window','window','WINDOW','W','w','New Window','new window','NEW WINDOW','New window','new Window','NW','nw','Nw','nW']:1803          newwindow()1804          1805    #Directory1806    elif cmd in ['DIR','Dir','dir','d','D','Directory','directory','DIRECTORY']:1807        self.insert_text("Load a File into the Directory? [Type 'Quit' or 'Exit' to exit]:", end='''1808''')1809        self.saveTF = True1810        self.mode = 'dir'1811    #Secrets Menu1812    elif cmd in ['Secrets', 'secret', 'S', 's', 'SECRET', 'Secret', 'SECRETS', 'secrets']:1813        self.insert_text('''-----Secrets Menu-----1814Rosewell BASIC - Lists Copyright and System Info181520050421 - Rosewell OS Secret181620211109 - Rosewell OS Secret181720221203 - Rosewell BASIC Secret1818Happy Birthday - Sings Happy Birthday to You!1819Dev - Opens the Credits Secret''', end='''1820''')1821        self.insert_text('Ready', end='''1822''')1823    #Devolper Menu1824    elif cmd in ['Dev', 'dev', 'D', 'd', 'developer', 'Developer', 'Credits', 'credits', 'Credit', 'credit', 'CREDIT', 'DEV', 'DEVELOPER']:1825        copyright()1826        self.insert_text(rose, end='''1827''')1828        self.insert_text('''-----Credits-----1829Blake Gouthro - Rosewell BASIC and Rosewell OS Developer, C.E.O of Rosewell Software, rosewellsoftware@Gmail.com account holder, Programmer, Writer, Graphical Devolper and Head of mangement for Rosewell Software.1830JinHo Mo - Rosewell BASIC and Rosewell OS Developer, Writer, Graphical Developer, Programmer, Writer, Graphical Developer, Rosewell Software Team Member.1831Beginner's All-Purpose Symbolic Instruction Code or BASIC.''', end='''1832''')1833        self.insert_text('Ready', end='''1834''')1835    #Happy Birthday Secret1836    elif cmd in ['Happy Birthday', 'happy Birthday', 'Happy birthday', 'happy birthday', 'HB', 'Hb', 'hB', 'hb']:1837        self.insert_text('''Congratulations! You have found the Happy Birthday Secret!1838''', end='''1839''')1840        self.insert_text('Happy Birthday to You!', end='''1841''')1842        os.system( "say Happy Birthday to You" )1843        self.insert_text('Happy Birthday to You!', end='''1844''')1845        os.system( "say Happy Birthday to You" )1846        self.insert_text('Happy Birthday User!', end='''1847''')1848        os.system( "say Happy Birthday User" )1849        self.insert_text('Happy Birthday to You!', end='''1850''')1851        os.system( "say Happy Birthday to You" )1852        self.insert_text('''1853Ready''', end='''1854''')1855    #Speech to Text1856    elif cmd in ['sr','SR','sR','Sr','STT','stt','st','ST','St','sT','STt','sTT','StT','Speech To Text','speech to text','Speech To text','speech To Text','Speech to Text','SPEECH RECOGNITION','Speech Recognition','Speech recognition','speech Recognition','speech recognition']:1857      self.insert_text('© Blake Gouthro | Speech Recognition App | V1.1 | Rosewell Software | 2022 - ' + str(today.year) +' ©', end='''1858''')1859      self.insert_text('Enter a number to Listen to Voice in Seconds?: ', end='''1860''')1861      self.saveTF = True1862      self.mode = 'sr' 1863    #Rosewell BASIC Secret1864    elif cmd in ['Rosewell', 'rosewell', 'BASIC', 'Basic', 'basic', 'Rosewell BASIC', 'rosewell BASIC', 'Rosewell Basic', 'rosewell Basic', 'Rosewell basic', 'rosewell basic', 'rb', 'Rb', 'rB', 'RB']:1865        copyright()1866        self.insert_text(rose, end='''1867''')1868        self.insert_text('''1869--Rosewell BASIC was created to be a Recreation of the older BASIC Operating Systems. This copy isn't as powerful yet but soon it will be.1870All files that BASIC can use must be run in the same folder.1871Basic Stands for;1872Beginner's All-Purpose Symbolic Instruction Code1873Hello From Nova Scotia!!1874Hello From Canada!!1875Brewing Coffee For Next Update. . . . .''', end='''1876''')1877        self.insert_text('Ready', end='''1878''')1879    #Repeat Chr1880    elif cmd in ['Repeat Character', 'Repeat Chr', 'repeat Character', 'repeat Chr', 'Repeat chr', 'Repeat character', 'repeat character', 'repeat chr', 'RC', 'rC', 'Rc', 'rc', 'REPEAT CHARACTER', 'REPEAT CHR', 'Repeat Characters', 'repeat characters', 'Repeat characters', 'repeat Characters', 'REPEAT CHARACTERS', 'RCS', 'Rcs', 'rcs', 'rCs', 'rcS', 'RCs', 'rCS', 'REPEAT CHRS', 'Repeat Chrs', 'repeat chrs', 'Repeat chrs', 'repeat Chrs']:1881        self.insert_text("Enter Numbrer to Repeat 'All chr' [Type 'Quit' or 'Exit' to quit]:", end='''1882''')1883        try:1884            self.saveTF = True1885            self.mode = 'repeat'1886            1887            1888        except:1889          self.insert_text("?Syntax Error? - means something was typed in wrong.", end='''1890''')1891    1892    #Clear System Memory1893    elif cmd in ['Clear', 'clear', 'CLEAR', 'C', 'c']:1894        self.insert_text("Would you like to clear SYSTEM MEMORY?", end='''1895''')1896        self.saveTF = True1897        self.mode = 'clear'1898    #Note Menu1899    elif cmd in ['Note', 'note', 'Notes', 'notes', 'n', 'N',]:1900        self.insert_text('''-----Notes Menu-----1901[1] New/Delete Note1902[2] Review Note1903[3] Add to/Open Note''', end='''1904''')1905        self.insert_text('''1906Enter a Number: ''', end='''1907''')1908        self.saveTF = True1909        self.mode = 'Note'1910        return1911    #Modules1912    elif cmd in ['Modules','modules','MODULES','MOD','mod','MOd','mOD','MoD','Check Modules','check modules','CHECK MODULES','Check modules','check Modules','CM','cm','Cm','cM','CMS','cms','CMs','cMS','CmS','Cms','cMs','cmS','Check Module','CHECK MODULE','check module','Check module','check Module']:1913          self.insert_text('''-----Modules Check List-----1914--Loaded Modules--1915''',end='''1916''')1917          #modr is installed1918          modr = []1919          #modz is not installed1920          modz = []1921          modulenames = set(sys.modules) & set(globals())1922          allmodules = [sys.modules[name] for name in modulenames]1923          for i in allmodules:1924            self.insert_text('{}'.format(i),end='')1925          self.insert_text('Ready',end='''1926''')1927    #ATSCII1928    elif cmd in ["ListPeek", "listPeek", 'Listpeek', 'listpeek', 'PETSCII', 'petscii', 'PetscII', 'Petscii', 'ATSCII', 'atscii', 'AtscII', 'Atscii']:1929        self.insert_text('-----List of Built-in ATSCII Characters-----', end='''1930''')1931        self.insert_text('Built-in ATSCII Characters are based off of Unicode Characters. Useful for Poke and Peek commands.', end='''1932''')1933        for k, v in atscii.items():1934            self.insert_text(f"{k} : {v}", end='''1935''')1936        self.insert_text('Ready', end='''1937''')1938    #Date/Time/Clock/Calendar1939    elif cmd in ['Date', 'date', 'Calender', 'calendar', 'Time', 'time', 'T', 't', 'Clock', 'clock', 'CLOCK', 'DATE', 'TIME', 'CALENDAR']:1940        self.insert_text("Today's Date: " + str(today), end='''1941''')1942        now = datetime.datetime.now()1943        self.insert_text(now.strftime("%a, %d, %B "), end='''1944''')1945        yy = today.year1946        mm = today.month1947        self.insert_text(calendar.month(yy,mm), end='''1948''')1949        current_time = time.strftime("%H:%M:%S", time.localtime())1950        self.insert_text('Current Time: ' + current_time, end='''1951''')1952        self.insert_text('Ready', end='''1953''')1954        1955    1956    1957    #Quit1958    elif cmd in ['Quit', 'quit', 'QUIT', 'Q', 'q', 'Exit', 'exit', 'EXIT', 'E', 'e']:1959        self.insert_text('GoodBye', end='''1960''')1961        time.sleep(1)1962        root.destroy()1963        sys.exit()1964    #Restart1965    elif cmd in ['Restart','restart','RESTART','R','r']:1966        self.insert_text('Are you sure you want to restart the app? [NOTE; All unsaved files will be deleted.]',end='''1967''')1968        self.saveTF = True1969        self.mode = 'restart'1970        return1971        1972        1973    #Syntax Error     1974    else:1975      self.insert_text("?Syntax Error?", end='''1976''')1977        1978    1979   1980    1981    1982    1983  # function to handle external command input1984  def system(self, cmd):1985    self.cmd = cmd  # save the command1986    try:1987      # extract the actual command1988      cmd = cmd[cmd.index('`')+1:cmd.rindex('`')]1989      proc = subp.Popen(cmd, stdout=subp.PIPE, stderr=subp.PIPE, text=True)1990      stdout, stderr = proc.communicate(5) # get the command output1991      # append the command output to Text box1992      self.insert_text(stdout)1993    except Exception as e:1994      self.insert_text(str(e))1995copyright()1996root.title('Rosewell BASIC')1997root.configure(bg="#0F5FB4")1998global shell1999shell = Shell(root, insertbackground="#78DAFC", highlightbackground ="#0F5FB4",highlightcolor="#0F5FB4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#78DAFC", bg="#0F5FB4")2000menubar = Menu(root)2001filemenu = Menu(menubar, tearoff=0)2002filemenu.add_command(label="Load", command=menuload)2003filemenu.add_command(label="Load, 8", command=menuload8)2004filemenu.add_command(label="Save", command=menusave)2005filemenu.add_command(label="Run", command =runs)2006filemenu.add_command(label="List", command =lists)2007filemenu.add_command(label="Clear", command =clearz)2008filemenu.add_command(label="Music", command =musiz)2009filemenu.add_command(label="Text to Speech", command=textts)2010filemenu.add_separator()2011filemenu.add_command(label="New Window", command=newwindow)2012filemenu.add_command(label='Restart', command=rst)2013filemenu.add_command(label="Quit", command=root.quit)2014menubar.add_cascade(label="File Menu", menu=filemenu)2015atsciimenu = Menu(menubar, tearoff=0)2016atsciimenu.add_command(label="Atscii Print", command=atprint)2017atsciimenu.add_command(label="All Chr", command=aprint)2018atsciimenu.add_command(label="Repeat Chr", command=rprint)2019menubar.add_cascade(label="ATSCII", menu=atsciimenu)2020helpmenu = Menu(menubar, tearoff=0)2021helpmenu.add_command(label="Help", command=helpz)2022helpmenu.add_command(label="Color Help", command=colorz)2023menubar.add_cascade(label="Help Menu", menu=helpmenu)2024colormenu = Menu(menubar, tearoff=0)2025colormenu.add_command(label="Default or BASIC Blue", command=default2)2026colormenu.add_command(label="Red or Dark Red", command=red2)2027colormenu.add_command(label="Red with White Text", command=redw2)2028colormenu.add_command(label="Blue or Dark Blue", command=blue2)2029colormenu.add_command(label="Blue with White Text", command=bluew2)2030colormenu.add_command(label="Teal", command=teal2)2031colormenu.add_command(label="Teal with White Text", command=tealw2)2032colormenu.add_command(label="Orange", command=orange2)2033colormenu.add_command(label="Orange with White Text", command=orangew2)2034colormenu.add_command(label="Green", command=green2)2035colormenu.add_command(label="Green with White Text", command=greenw2)2036colormenu.add_command(label="Gray", command=gray2)2037colormenu.add_command(label="Purple", command=purple2)2038colormenu.add_command(label="Purple with White Text", command=purplew2)2039colormenu.add_command(label="Yellow", command=yellow2)2040colormenu.add_command(label="Yellow with Black Text", command=yelloww2)2041colormenu.add_command(label="Pink", command=pink2)2042colormenu.add_command(label="Pink with White Text", command=pinkw2)2043colormenu.add_command(label="White", command=white2)2044colormenu.add_command(label="Black", command=black2)2045colormenu.add_command(label="Amber", command=amber2)2046colormenu.add_command(label="Navy", command=lb)2047colormenu.add_command(label="Special Edition; Commodore 64", command=c642)2048colormenu.add_command(label="Special Edition; Commodore 64 White Text", command=c64w2)2049colormenu.add_command(label="Special Edition; Commodore Vic-20", command=vic202)2050colormenu.add_command(label="Special Edition; Commodore Plus-4", command=plus2)2051colormenu.add_command(label="Special Edition; Commodore 128", command=c1282)2052colormenu.add_command(label="Special Edition; Commodore PET", command=pet2)2053colormenu.add_command(label="Special Edition; Gameboy Peasoup", command=gameboy2)2054colormenu.add_command(label="Special Edition; Gameboy Light", command=light2)2055menubar.add_cascade(label="Colors", menu=colormenu)2056shell.pack(fill=tk.BOTH, expand=1)2057shell.focus_set()2058root.config(menu=menubar)2059root.mainloop()2060"""2061def newwindow():2062      global rosecount2063      rosecount = rosecount + 12064      global secondscreen2065      secondscreen = secondscreen.replace("root","basic" + str(rosecount))2066      secondscreen = secondscreen.replace("shell","terminal" + str(rosecount))2067      exec(secondscreen)2068def textts():2069    shell.insert_text('File Menu',end='''2070''')2071    shell.insert_text('Before using text to speech, PRESS ENTER ONCE BEFORE TYPING TEXT TO SPEAK', end='''2072''')2073    shell.insert_text('© Blake Gouthro | Text To Speech App | V1.1 | Rosewell Software | 2022 - ' + str(today.year) +' ©', end='''2074''')2075    shell.insert_text('Enter Text To Speak:',end='''2076''')2077    2078    shell.saveTF = True2079    shell.mode = 'voice'2080def rst():2081    global shell2082    shell.destroy()2083    shell = Shell(root, insertbackground="#78DAFC", highlightbackground ="#0F5FB4",highlightcolor="#0F5FB4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#78DAFC", bg="#0F5FB4")2084    shell.pack(fill=tk.BOTH, expand=1)2085    2086    root.update()2087def atprint():2088    shell.insert_text('-----List of Built-in ATSCII Characters-----', end='''2089''')2090    shell.insert_text('Built-in ATSCII Characters are based off of Unicode Characters. Useful for Poke and Peek commands.', end='''2091''')2092    for k, v in atscii.items():2093        shell.insert_text(f"{k} : {v}", end='''2094''')2095    shell.insert_text('Ready', end='''2096''')2097def aprint():2098    atsciiprint2()2099def rprint():2100    shell.insert_text("File Menu", end='''2101''')2102    shell.insert_text("Before typing answer for repeat chr, PRESS ENTER BEFORE TYPING", end='''2103''')2104    shell.insert_text("Enter Numbrer to Repeat 'All chr' [Type 'Quit' or 'Exit' to quit]:", end='''2105''')2106    try:2107    2108        shell.saveTF = True2109        shell.mode = 'repeat'2110    except:2111        shell.insert_text("?Syntax Error?")2112            2113def runs():2114    shell.insert_text("File Menu", end='''2115''')2116    f = io.StringIO()2117    with redirect_stdout(f):2118        try:2119            exec(shell.save, globals())2120            shell.insert_text(f.getvalue(), end='')2121            shell.insert_text('Ready', end='''2122''')2123        except Exception as e:2124            shell.insert_text('?Syntax Error? - means something was typed in wrong', end='''2125''')2126            shell.insert_text("Ready", end='''2127''')2128        return2129    2130def lists():2131    2132    shell.insert_text("File Menu", end='''2133''')2134    shell.insert_text(shell.save, end='''2135''')2136    shell.insert_text("Ready", end='''2137''')2138def clearz():2139    shell.insert_text("File Menu", end='''2140''')2141    shell.insert_text("Before Answering, PRESS ENTER BEFOR TYPING.", end='''2142''')2143    shell.insert_text("Would you like to clear SYSTEM MEMORY?", end='''2144''')2145    shell.saveTF = True2146    shell.mode = 'clear'2147def musiz():2148    shell.insert_text("Before Typing answer, PRESS ENTER ONCE BEFORE TYPING FIRST ANSWER", end='''2149''')2150    shell.insert_text("File Menu", end='''2151''')2152    shell.insert_text(musix, end='''2153''')2154        2155          2156    shell.saveTF = True2157    shell.mode = 'music'2158    2159    2160def donothing():2161    x=02162    2163def default2():2164    global shell2165    shell.destroy()2166    shell = Shell(root, insertbackground="#78DAFC", highlightbackground ="#0F5FB4",highlightcolor="#0F5FB4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#78DAFC", bg="#0F5FB4")2167    shell.pack(fill=tk.BOTH, expand=1)2168    2169    root.update()2170    2171    2172def c642():2173    global shell2174    shell.destroy()2175    shell = Shell(root,insertbackground="#6f6ed1", highlightbackground ="#6f6ed1",highlightcolor="#6f6ed1", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#6f6ed1", bg="#3F359B")2176    2177    shell.pack(fill=tk.BOTH, expand=1)2178    2179    root.update()2180    2181def c64w2():2182    global shell2183    shell.destroy()2184    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#6f6ed1",highlightcolor="#6f6ed1", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#3F359B")2185    2186    shell.pack(fill=tk.BOTH, expand=1)2187    root.update()    2188def red2():2189    global shell2190    shell.destroy()2191    shell = Shell(root,insertbackground="#E39693", highlightbackground ="#8B0D0D",highlightcolor="#8B0D0D", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#E39693", bg="#8B0D0D")2192    2193    shell.pack(fill=tk.BOTH, expand=1)2194    root.update()2195def redw2():2196    global shell2197    shell.destroy()2198    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#8B0D0D",highlightcolor="#8B0D0D", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#8B0D0D")2199    2200    shell.pack(fill=tk.BOTH, expand=1)2201    root.update()2202def bluew2():2203    global shell2204    shell.destroy()2205    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#10145A",highlightcolor="#10145A", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#10145A")2206    2207    shell.pack(fill=tk.BOTH, expand=1)2208    root.update()2209def blue2():2210    global shell2211    shell.destroy()2212    shell = Shell(root,insertbackground="#8A8FEA", highlightbackground ="#10145A",highlightcolor="#10145A", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#8A8FEA", bg="#10145A")2213    2214    shell.pack(fill=tk.BOTH, expand=1)2215    root.update()2216def teal2():2217    global shell2218    shell.destroy()2219    shell = Shell(root,insertbackground="#52FFC5", highlightbackground ="#008080",highlightcolor="#008080", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#52FFC5", bg="#008080")2220    2221    shell.pack(fill=tk.BOTH, expand=1)2222    root.update()2223    2224def tealw2():2225    global shell2226    shell.destroy()2227    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#008080",highlightcolor="#008080", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#008080")2228    2229    shell.pack(fill=tk.BOTH, expand=1)2230    root.update()2231def orange2():2232    global shell2233    shell.destroy()2234    shell = Shell(root,insertbackground="#955E00", highlightbackground ="#ff8c00",highlightcolor="#ff8c00", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#955E00", bg="#ff8c00")2235    2236    shell.pack(fill=tk.BOTH, expand=1)2237    root.update()2238def orangew2():2239    global shell2240    shell.destroy()2241    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#ff8c00",highlightcolor="#ff8c00", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#ff8c00")2242    2243    shell.pack(fill=tk.BOTH, expand=1)2244    root.update()2245def green2():2246    global shell2247    shell.destroy()2248    shell = Shell(root,insertbackground="#A4EB99", highlightbackground ="#247618",highlightcolor="#247618", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#38D738", bg="#247618")2249    2250    shell.pack(fill=tk.BOTH, expand=1)2251    root.update()2252def greenw2():2253    global shell2254    shell.destroy()2255    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#247618",highlightcolor="#247618", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#247618")2256    2257    shell.pack(fill=tk.BOTH, expand=1)2258    root.update()2259def gray2():2260    global shell2261    shell.destroy()2262    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#525252",highlightcolor="#525252", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#525252")2263    2264    shell.pack(fill=tk.BOTH, expand=1)2265    root.update()2266def purple2():2267    global shell2268    shell.destroy()2269    shell = Shell(root,insertbackground="#B770E9", highlightbackground ="#6A19A4",highlightcolor="#6A19A4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#B770E9", bg="#6A19A4")2270    2271    shell.pack(fill=tk.BOTH, expand=1)2272    root.update()2273def purplew2():2274    global shell2275    shell.destroy()2276    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#6A19A4",highlightcolor="#6A19A4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#6A19A4")2277    2278    shell.pack(fill=tk.BOTH, expand=1)2279    root.update()2280def yellow2():2281    global shell2282    shell.destroy()2283    shell = Shell(root,insertbackground="#687312", highlightbackground ="#BCFE54",highlightcolor="#BCFE54", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#687312", bg="#BCFE54")2284    2285    shell.pack(fill=tk.BOTH, expand=1)2286    root.update()2287def yelloww2():2288    global shell2289    shell.destroy()2290    shell = Shell(root,insertbackground="#000000", highlightbackground ="#BCFE54",highlightcolor="#BCFE54", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#000000", bg="#BCFE54")2291    2292    shell.pack(fill=tk.BOTH, expand=1)2293    root.update()2294def pink2():2295    global shell2296    shell.destroy()2297    shell = Shell(root,insertbackground="#900D74", highlightbackground ="#ED33C4",highlightcolor="#ED33C4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#900D74", bg="#ED33C4")2298    2299    shell.pack(fill=tk.BOTH, expand=1)2300    root.update()2301def pinkw2():2302    global shell2303    shell.destroy()2304    shell = Shell(root,insertbackground="#000000", highlightbackground ="#ED33C4",highlightcolor="#ED33C4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#000000", bg="#ED33C4")2305    2306    shell.pack(fill=tk.BOTH, expand=1)2307    root.update()2308def white2():2309    global shell2310    shell.destroy()2311    shell = Shell(root,insertbackground="#000000", highlightbackground ="#F6F6F6",highlightcolor="#F6F6F6", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#000000", bg="#F6F6F6")2312    2313    shell.pack(fill=tk.BOTH, expand=1)2314    root.update()2315def black2():2316    global shell2317    shell.destroy()2318    shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#000000",highlightcolor="#000000", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#000000")2319    2320    shell.pack(fill=tk.BOTH, expand=1)2321    root.update()2322def vic202():2323    global shell2324    shell.destroy()2325    shell = Shell(root,insertbackground="#061FEE", highlightbackground ="#00F9F7",highlightcolor="#00F9F7", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#061FEE", bg="#F6F6F6")2326    2327    shell.pack(fill=tk.BOTH, expand=1)2328    root.update()2329def plus2():2330    global shell2331    shell.destroy()2332    shell = Shell(root,insertbackground="#000000", highlightbackground ="#B69DF8",highlightcolor="#B69DF8", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#000000", bg="#F6F6F6")2333    2334    shell.pack(fill=tk.BOTH, expand=1)2335    root.update()2336def c1282():2337    global shell2338    shell.destroy()2339    shell = Shell(root,insertbackground="#A1E08E", highlightbackground ="#A1E08E",highlightcolor="#A1E08E", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#A1E08E", bg="#555555")2340    2341    shell.pack(fill=tk.BOTH, expand=1)2342    root.update()2343def pet2():2344    global shell2345    shell.destroy()2346    shell = Shell(root,insertbackground="#00FE52", highlightbackground ="#000000",highlightcolor="#000000", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#00FE52", bg="#000000")2347    2348    shell.pack(fill=tk.BOTH, expand=1)2349    root.update()2350def amber2():2351    global shell2352    shell.destroy()2353    shell = Shell(root,insertbackground="#ff8c00", highlightbackground ="#000000",highlightcolor="#000000", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#ff8c00", bg="#000000")2354    2355    shell.pack(fill=tk.BOTH, expand=1)2356    root.update()2357def gameboy2():2358    global shell2359    shell.destroy()2360    shell = Shell(root,insertbackground="#166228", highlightbackground ="#79AC00",highlightcolor="#79AC00", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#166228", bg="#79AC00")2361    2362    shell.pack(fill=tk.BOTH, expand=1)2363    root.update()2364def light2():2365    global shell2366    shell.destroy()2367    shell = Shell(root,insertbackground="#005F66", highlightbackground ="#00CBB8",highlightcolor="#00CBB8", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#005F66", bg="#00CBB8")2368    2369    shell.pack(fill=tk.BOTH, expand=1)2370    root.update()2371def lb():2372    global shell2373    shell.destroy()2374    shell = Shell(root,insertbackground="#c4ae3d", highlightbackground ="#003B62",highlightcolor="#003B62", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#c4ae3d", bg="#003B62")2375    shell.pack(fill=tk.BOTH, expand=1)2376    root.update()2377atscii = dict(2378    dice1 = u"\u2680",2379    dice2 = u"\u2681",2380    dice3 = u"\u2682",2381    dice4 = u"\u2683",2382    dice5 = u"\u2684",2383    dice6 = u"\u2685",2384    block = u"\u2588",2385    at = u"\u0040",2386    And = u'\u0026',2387    hashtag = u'\u0023',2388    space = u'\u0020',2389    exclmark = u'\u0021',2390    quotes = u'\u0022',2391    dollar = u'\u0024',2392    percent = u'\u0025',2393    quote = u'\u2019',2394    openbracket = u'\u0028',2395    closebracket = u'\u0029',2396    star = u'\u002A',2397    plus = u'\u002B',2398    comma = u'\u002C',2399    minus = u'\u002D',2400    period = u'\u002E',2401    forwardslash = u'\u002F',2402    zero = u'\u0030',2403    one = u'\0031',2404    two = u'\0032',2405    three = u'\0033',2406    four = u'\0034',2407    five = u'\0035', 2408    six = u'\0036',2409    seven = u'\0037',2410    eight = u'\0038',2411    nine = u'\0039',2412    colon = u'\u003a',2413    semicolon = u'\u003B',2414    lessthan = u'\u003C',2415    equal = u'\u003D',2416    greaterthan = u'\u003E',2417    questionmark = u'\u003F',2418    uppera = u'\u0041',2419    upperb = u'\u0042',2420    upperc = u'\u0043',2421    upperd = u'\u0044',2422    uppere = u'\u0045',2423    upperf = u'\u0046',2424    upperg = u'\u0047',2425    upperh = u'\u0048',2426    upperi = u'\u0049',2427    upperj = u'\u004A',2428    upperk = u'\u004B',2429    upperl = u'\u004C',2430    upperm = u'\u004D',2431    uppern = u'\u004E',2432    uppero = u'\u004F',2433    upperp = u'\u0050',2434    upperq = u'\u0051',2435    upperr = u'\u0052',2436    uppers = u'\u0053',2437    uppert = u'\u0054',2438    upperu = u'\u0055',2439    upperv = u'\u0056',2440    upperw = u'\u0057',2441    upperx = u'\u0058',2442    uppery = u'\u0059',2443    upperz = u'\u005A',2444    sqopen = u'\u005B',2445    backslash = u'\u005C',2446    sqclose = u'\u005D',2447    upaccent = u'\u005E',2448    lowline = u'\u005F',2449    graveaccent = u'\u0060',2450    lowera = u'\u0061',2451    lowerb = u'\u0062',2452    lowerc = u'\u0063',2453    lowerd = u'\u0064',2454    lowere = u'\u0065',2455    lowerf = u'\u0066',2456    lowerg = u'\u0067',2457    lowerh = u'\u0068',2458    loweri = u'\u0069',2459    lowerj = u'\u006A',2460    lowerk = u'\u006B',2461    lowerl = u'\u006C',2462    lowerm = u'\u006D',2463    lowern = u'\u006E',2464    lowero = u'\u006F',2465    lowerp = u'\u0070',2466    lowerq = u'\u0071',2467    lowerr = u'\u0072',2468    lowers = u'\u0073',2469    lowert = u'\u0074',2470    loweru = u'\u0075',2471    lowerv = u'\u0076',2472    lowerw = u'\u0077',2473    lowerx = u'\u0078',2474    lowery = u'\u0079',2475    lowerz = u'\u007A',2476    cropen = u'\u007B',2477    verticalbar = u'\u007C',2478    crclose = u'\u007D',2479    tilde = u'\u007E',2480    inexcelmark = u'\u00A1',2481    cent = u'\u00A2',2482    pound = u'\u00A3',2483    currency = u'\u00A4',2484    yen = u'\u00A5',2485    brokenbar = u'\u00A6',2486    sectionsign = u'\u00A7',2487    diaeresis = u'\u00A8',2488    copyrights = u'\u00A9',2489    femord = u'\u00AA',2490    leftquotes = u'\u00AB',2491    notsign = u'\u00AC',2492    registered = u'\u00AE',2493    macron = u'\u00AF',2494    degree = u'\u00B0',2495    pilcrow = u'\u00B6',2496    rightquotes = u'\u00BB',2497    onedfour = u'\u00BC',2498    onedtwo = u'\u00BD',2499    threedfour = u'\u00BE',2500    inquestionmark = u'\u00BF',2501    multiply = u'\u00D7',2502    divide = u'\u00F7',2503    upperhalf = u'\u2580',2504    loweronedeight = u'\u2581',2505    loweronedfour = u'\u2582',2506    lowerthreedeight = u'\u2583',2507    lowerhalf = u'\u2584',2508    lowerfivedeight = u'\u2585',2509    lowerthreedfour = u'\u2586',2510    lowersevendeight = u'\u2587',2511    leftsevendeight = u'\u2589',2512    leftthreedfour = u'\u258A',2513    leftfivedeight = u'\u258B',2514    lefthalf = u'\u258C',2515    leftthreedeight = u'\u258D',2516    leftonedfour = u'\u258E',2517    leftonedeight = u'\u258F',2518    righthalf = u'\u2590',2519    lightshade = u'\u2591',2520    mediumshade = u'\u2592',2521    darkshade = u'\u2593',2522    upperonedeight = u'\u2594',2523    rightonedeight = u'\u2595',2524    quadlowerleft = u'\u2596',2525    quadlowerright = u'\u2597',2526    quadupperleft = u'\u2598',2527    quadulpllplr = u'\u2599',2528    quadulplr = u'\u259A',2529    quadulpurpll = u'\u259B',2530    quadulpurplr = u'\u259C',2531    quadupperright = u'\u259D',2532    quadurpll = u'\u259E',2533    quadurpllplr = u'\u259F'2534    )2535def findNum(word):2536    for i in word:2537        if i.isdigit():2538            return True2539    return False2540try:2541    from clrprint import *2542  2543except:2544    print('The Clrprint Module could not be imported')2545    print(' ')2546saves = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' + u"\u2680" + u"\u2681" + u"\u2682" + u"\u2683" + u"\u2684" + u"\u2685" + u"\u2588" + "@&# !" + '"' + "$%'()*+,-./:;>=<?\[]{}^_" + u"\u0060" + "|~" + u"\u00A1" + u"\u00A2" + u"\u00A3" + u"\u00A4" + u"\u00A5" + u"\u00A6" + u"\u00A7" + u"\u00A8" + u"\u00A9" + u"\u00AA" + u"\u00AB" + u"\u00AC" + u"\u00AE" + u"\u00AF" + u"\u00B0" + u"\u00B6" + u"\u00BB" + u"\u00BC" + u"\u00BD" + u"\u00BE" + u"\u00BF" + u"\u00D7" + u"\u00F7" + u"\u2580" + u"\u2581" + u"\u2582" + u"\u2583" + u"\u2584" + u"\u2585" + u"\u2586" + u"\u2587" + u"\u2588" + u"\u2589" + u"\u258A" + u"\u258B" + u"\u258C" + u"\u258D" + u"\u258E" + u"\u258F" + u"\u2590" + u"\u2591" + u"\u2592" + u"\u2593" + u"\u2594" + u"\u2595" + u"\u2596" + u"\u2597" + u"\u2598" + u"\u2599" + u"\u259A" + u"\u259B" + u"\u259C" + u"\u259D" + u"\u259E" + u"\u259F"2547rose = "© Blake Gouthro and JinHo Mo | Rosewell BASIC | V2.4.3 | Rosewell Software | 2021 - " + str(today.year) + " ©"2548load = ''2549def copyright():2550    2551    2552    try:2553        clrprint('© Blake Gouthro and JinHo Mo |' , 'Rosewell', 'B', 'A', 'S', 'I', 'C', '| V2.4.3 | Rosewell Software | 2021 - ' + str(today.year) + ' ©', clr=['blue', 'white', 'red', 'yellow', 'green', 'blue', 'purple', 'blue', 'blue'])2554    except:2555        print(rose)2556class Shell(tk.Text):2557  global loadx2558  2559  2560  2561  2562  def __init__(self, parent, **kwargs):2563    2564    self.save = ''2565    self.saveTF = False2566    self.mode = ''2567    2568    tk.Text.__init__(self, parent, **kwargs)2569    self.bind('<Key>', self.on_key) # setup handler to process pressed keys2570    self.cmd = None2571    self.insert_text(rose, end='''2572''')2573    self.insert_text("Today's Date: " + str(today), end='''2574''')2575    if axio != 0:2576          self.insert_text(modwell, end='''2577''')2578    else:2579          self.insert_text('Enough BASIC Bytes Free', end='''2580''')2581    self.insert_text('Ready', end='''2582''')2583    # hold the last command issued2584    self.show_prompt()2585    2586  # to append given text at the end of Text box2587  def insert_text(self, txt='', end='\n'):2588    self.insert(tk.END, txt+end)2589    self.see(tk.END) # make sure it is visible2590#Ready Prompt2591  def show_prompt(self):2592    self.insert_text('', end='')2593    self.mark_set(tk.INSERT, tk.END) # make sure the input cursor is at the end2594    self.cursor = self.index(tk.INSERT) # save the input position2595  # handler to process keyboard input2596  def on_key(self, event):2597    #print(event)2598    if event.keysym == 'Up':2599      if self.cmd:2600        # show the last command2601        self.delete(self.cursor, tk.END)2602        self.insert(self.cursor, self.cmd)2603      return "break" # disable the default handling of up key2604    if event.keysym == 'Down':2605      return "break" # disable the default handling of down key2606    if event.keysym in ('Left', 'BackSpace'):2607      current = self.index(tk.INSERT) # get the current position of the input cursor2608      if self.compare(current, '==', self.cursor):2609        # if input cursor is at the beginning of input (after the prompt), do nothing2610        return "break"2611    if event.keysym == 'Return':2612      # extract the command input2613      cmd = self.get(self.cursor, tk.END).strip()2614      self.insert_text() # advance to next line2615      if cmd.startswith('`'):2616        # it is an external command2617        self.system(cmd)2618      else:2619        # it is python statement2620        self.execute(cmd)2621      self.show_prompt()2622      return "break" # disable the default handling of Enter key2623    if event.keysym == 'Escape':2624      self.master.destroy() # quit the shell2625  # function to handle python statement input2626  2627  def execute(self, cmd):2628    2629    self.cmd = cmd  # save the command2630    global loadx2631    global loadz2632    loadx = ''2633    loadz = loadz2634    name = ''2635    2636    2637    def atsciiprint():2638      for i in range(157):2639        self.insert_text(saves[i], end=''); time.sleep(0.000000000000000001)2640    def repeatchr(num):2641      for i in range(num):2642        atsciiprint()2643    def Go(num):2644      f = io.StringIO()2645      for x in range(num):2646        with redirect_stdout(f):2647          try:2648            exec(self.save, globals())2649          except:2650            return False2651      self.insert_text(f.getvalue(), end='')2652    def repeatchr(num):2653        for i in range(num):2654            atsciiprint()2655    2656    2657    def poke(word):2658    2659        try:2660            2661            self.insert_text(atscii.get(word[0], "No Character to Poke"), end='''2662''')2663            2664        except Exception as e:2665            print(e)2666    2667    # use redirect_stdout() to capture the output of exec() to a string2668    #20211109 Secret2669    def default():2670      shell = Shell(root, insertbackground="#78DAFC", highlightbackground ="#0F5FB4",highlightcolor="#0F5FB4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#78DAFC", bg="#0F5FB4")2671      self.destroy()2672      shell.pack(fill=tk.BOTH, expand=1)2673      root.update()2674    def c64():2675      shell = Shell(root,insertbackground="#6f6ed1", highlightbackground ="#6f6ed1",highlightcolor="#6f6ed1", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#6f6ed1", bg="#3F359B")2676      self.destroy()2677      shell.pack(fill=tk.BOTH, expand=1)2678      root.update()2679    def c64w():2680      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#6f6ed1",highlightcolor="#6f6ed1", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#3F359B")2681      self.destroy()2682      shell.pack(fill=tk.BOTH, expand=1)2683      root.update()    2684    def red():2685      shell = Shell(root,insertbackground="#E39693", highlightbackground ="#8B0D0D",highlightcolor="#8B0D0D", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#E39693", bg="#8B0D0D")2686      self.destroy()2687      shell.pack(fill=tk.BOTH, expand=1)2688      root.update()2689    def redw():2690      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#8B0D0D",highlightcolor="#8B0D0D", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#8B0D0D")2691      self.destroy()2692      shell.pack(fill=tk.BOTH, expand=1)2693      root.update()2694    def bluew():2695      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#10145A",highlightcolor="#10145A", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#10145A")2696      self.destroy()2697      shell.pack(fill=tk.BOTH, expand=1)2698      root.update()2699    def blue():2700      shell = Shell(root,insertbackground="#8A8FEA", highlightbackground ="#10145A",highlightcolor="#10145A", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#8A8FEA", bg="#10145A")2701      self.destroy()2702      shell.pack(fill=tk.BOTH, expand=1)2703      root.update()2704    def teal():2705      shell = Shell(root,insertbackground="#52FFC5", highlightbackground ="#008080",highlightcolor="#008080", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#52FFC5", bg="#008080")2706      self.destroy()2707      shell.pack(fill=tk.BOTH, expand=1)2708      root.update()2709    2710    def tealw():2711      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#008080",highlightcolor="#008080", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#008080")2712      self.destroy()2713      shell.pack(fill=tk.BOTH, expand=1)2714      root.update()2715    def orange():2716      shell = Shell(root,insertbackground="#955E00", highlightbackground ="#ff8c00",highlightcolor="#ff8c00", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#955E00", bg="#ff8c00")2717      self.destroy()2718      shell.pack(fill=tk.BOTH, expand=1)2719      root.update()2720    def orangew():2721      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#ff8c00",highlightcolor="#ff8c00", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#ff8c00")2722      self.destroy()2723      shell.pack(fill=tk.BOTH, expand=1)2724      root.update()2725    def green():2726      shell = Shell(root,insertbackground="#A4EB99", highlightbackground ="#247618",highlightcolor="#247618", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#38D738", bg="#247618")2727      self.destroy()2728      shell.pack(fill=tk.BOTH, expand=1)2729      root.update()2730    def greenw():2731      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#247618",highlightcolor="#247618", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#247618")2732      self.destroy()2733      shell.pack(fill=tk.BOTH, expand=1)2734      root.update()2735    def gray():2736      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#525252",highlightcolor="#525252", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#525252")2737      self.destroy()2738      shell.pack(fill=tk.BOTH, expand=1)2739      root.update()2740    def purple():2741      shell = Shell(root,insertbackground="#B770E9", highlightbackground ="#6A19A4",highlightcolor="#6A19A4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#B770E9", bg="#6A19A4")2742      self.destroy()2743      shell.pack(fill=tk.BOTH, expand=1)2744      root.update()2745    def purplew():2746      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#6A19A4",highlightcolor="#6A19A4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#6A19A4")2747      self.destroy()2748      shell.pack(fill=tk.BOTH, expand=1)2749      root.update()2750    def yellow():2751      shell = Shell(root,insertbackground="#687312", highlightbackground ="#BCFE54",highlightcolor="#BCFE54", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#687312", bg="#BCFE54")2752      self.destroy()2753      shell.pack(fill=tk.BOTH, expand=1)2754      root.update()2755    def yelloww():2756      shell = Shell(root,insertbackground="#000000", highlightbackground ="#BCFE54",highlightcolor="#BCFE54", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#000000", bg="#BCFE54")2757      self.destroy()2758      shell.pack(fill=tk.BOTH, expand=1)2759      root.update()2760    def pink():2761      shell = Shell(root,insertbackground="#900D74", highlightbackground ="#ED33C4",highlightcolor="#ED33C4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#900D74", bg="#ED33C4")2762      self.destroy()2763      shell.pack(fill=tk.BOTH, expand=1)2764      root.update()2765    def pinkw():2766      shell = Shell(root,insertbackground="#000000", highlightbackground ="#ED33C4",highlightcolor="#ED33C4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#000000", bg="#ED33C4")2767      self.destroy()2768      shell.pack(fill=tk.BOTH, expand=1)2769      root.update()2770    def white():2771      shell = Shell(root,insertbackground="#000000", highlightbackground ="#F6F6F6",highlightcolor="#F6F6F6", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#000000", bg="#F6F6F6")2772      self.destroy()2773      shell.pack(fill=tk.BOTH, expand=1)2774      root.update()2775    def black():2776      shell = Shell(root,insertbackground="#F6F6F6", highlightbackground ="#000000",highlightcolor="#000000", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#F6F6F6", bg="#000000")2777      self.destroy()2778      shell.pack(fill=tk.BOTH, expand=1)2779      root.update()2780    def vic20():2781      shell = Shell(root,insertbackground="#061FEE", highlightbackground ="#00F9F7",highlightcolor="#00F9F7", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#061FEE", bg="#F6F6F6")2782      self.destroy()2783      shell.pack(fill=tk.BOTH, expand=1)2784      root.update()2785    def plus():2786      shell = Shell(root,insertbackground="#000000", highlightbackground ="#B69DF8",highlightcolor="#B69DF8", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#000000", bg="#F6F6F6")2787      self.destroy()2788      shell.pack(fill=tk.BOTH, expand=1)2789      root.update()2790    def c128():2791      shell = Shell(root,insertbackground="#A1E08E", highlightbackground ="#A1E08E",highlightcolor="#A1E08E", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#A1E08E", bg="#555555")2792      self.destroy()2793      shell.pack(fill=tk.BOTH, expand=1)2794      root.update()2795    def pet():2796      shell = Shell(root,insertbackground="#00FE52", highlightbackground ="#000000",highlightcolor="#000000", highlightthickness=30, borderwidth=14, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#00FE52", bg="#000000")2797      self.destroy()2798      shell.pack(fill=tk.BOTH, expand=1)2799      root.update()2800    def amber():2801      shell = Shell(root,insertbackground="#ff8c00", highlightbackground ="#000000",highlightcolor="#000000", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#ff8c00", bg="#000000")2802      self.destroy()2803      shell.pack(fill=tk.BOTH, expand=1)2804      root.update()2805    def gameboy():2806      shell = Shell(root,insertbackground="#166228", highlightbackground ="#79AC00",highlightcolor="#79AC00", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#166228", bg="#79AC00")2807      self.destroy()2808      shell.pack(fill=tk.BOTH, expand=1)2809      root.update()2810    def light():2811      shell = Shell(root,insertbackground="#005F66", highlightbackground ="#00CBB8",highlightcolor="#00CBB8", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#005F66", bg="#00CBB8")2812      self.destroy()2813      shell.pack(fill=tk.BOTH, expand=1)2814      root.update()2815    def lb2():2816      global shell2817      shell.destroy()2818      shell = Shell(root,insertbackground="#c4ae3d", highlightbackground ="#003B62",highlightcolor="#003B62", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#c4ae3d", bg="#003B62")2819      shell.pack(fill=tk.BOTH, expand=1)2820      root.update()2821    2822    2823    if cmd == '20211109':2824        self.insert_text('Hello User! You have found the November 9th 2021 Secret! The Creation Date of Rosewell OS Happened on this date! We are talking about Rosewell OS not Rosewell BASIC. Never Forget it JinHo Mo or Blake Gouthro', end='''2825''')2826        self.insert_text('Ready', end='''2827''')2828    #Color Help2829    elif cmd in ['Color Help','color help','COLOR HELP','Color help','color Help','ch','CH','Ch','cH','color h','COLOR h','Color h','COLOR H','Color H','color H']:2830        self.insert_text(colorhelp, end='''2831''')2832        return2833    #Color Changing Feature2834    elif "color" in cmd.lower():2835        colors = str(cmd.split()[-1:][0])2836        if colors in ['BASIC','Basic','basic','Default','default','DEFAULT','B','b','d','D']:2837            default()2838        2839        if colors in ['c64','C64','Commodore 64','commodore 64','COMMODORE 64','C','c','64']:        2840            c64()2841        if colors in ['c64 white','C64 white','Commodore 64 white','commodore 64 white','COMMODORE 64 white','Cw','cw','64w']:2842            c64w()2843        if colors in ['Red','RED','red','Dark Red','DARK RED','dark red','Dark red','dark Red','R','r','DR','dr','Dr','dR']:2844            red()2845        if colors in ['Red white','RED white','red white','Dark Red white','DARK RED white','dark red white','Dark red white','dark Red white','Rw','rw','DRw','drw','Drw','dRw']:2846            redw()2847        if colors in ['Blue white','blue white','BLUE white','Dark Blue white','Dark blue white','dark Blue white','DARK BLUE white','dark blue white','DBw','dbw','Dbw','dBw']:2848            blue()2849        if colors in ['Blue','blue','BLUE','Dark Blue','Dark blue','dark Blue','DARK BLUE','dark blue','DB','db','Db','dB']:2850            bluew()   2851        if colors in ['Teal','teal','TEAL','T','t']:2852            teal()2853        if colors in ['Teal white','teal white','TEAL white','Tw','tw']:2854            tealw()2855        if colors in ['Orange','orange','ORANGE','O','o']:2856            orange()2857        if colors in ['Orange white','orange white','ORANGE white','Ow','ow']:2858            orangew()2859        if colors in ['green','GREEN','Green','G','g',]:2860            green()2861        if colors in ['green white','GREEN white','Green white','Gw','gw',]:2862            greenw()2863        if colors in ['gray','GRAY','Gray','GR','gr','Gr','gR']:2864            gray()2865        if colors in ['purple','PURPLE','Purple','P','p']:2866            purple()2867        if colors in ['purple white','PURPLE white','Purple white','Pw','pw']:2868            purplew()2869        if colors in ['yellow','YELLOW','Yellow','y','Y']:2870            yellow()2871        if colors in ['yellow white','YELLOW white','Yellow white','yw','Yw']:2872            yellow()2873        if colors in ['PINK','pink','Pink','pi','PI','Pi','pI']:2874            pink()2875        if colors in ['PINK white','pink white','Pink white','pi white','PI white','Pi white','pI white']:2876            pinkw()2877        if colors in ['white','WHITE','White','w','W']:2878            white()2879        if colors in ['BLACK','black','Black']:2880            black()2881        if colors in ['vic20','Vic20','VIC20','vic-20','VIC-20','Vic-20','vic','VIC','Vic']:        2882            vic20()2883        if colors in ['plus','PLUS','Plus','Plus4','PLUS4','plus4','plus-4','PLUS-4','Plus-4']:        2884            plus()2885        if colors in ['128','c128','C128','COMMODORE128','commodore128','Commodore128','Commodore 128',' commodore 128','COMMODORE 128']:        2886            c128()2887        if colors in ['PET','pet','Pet','pEt','peT','PEt','pET','PeT','commodore pet','Commodore pet','COMMODORE pet','COMMODORE PET','Commodore PET','commodore PET']:        2888            pet()2889        if colors in ['Amber','AMBER','amber','A','a','Ab','aB','AB','ab']:2890            amber()2891        if colors in ['Gameboy','gameboy','GAMEBOY','GameBoy','gameBoy','Peasoup','PEASOUP','peasoup','GB','gb','Gb','gB']:2892            gameboy()2893        if colors in ['Light','light','LIGHT','Gameboy Light','gameboy light','GAMEBOY LIGHT','Gameboy light','gameboy Light','GameBoy Light','gameBoy Light','GameBoy light','GBL','gbl','GbL','GBl','gBL','Gbl','gBl','gbL']:2894            light()2895        if colors in ['Light Blue','light blue','LIGHT BLUE','Light blue','light Blue','lb','LB','lB','Lb','Navy','navy','NAVY','ny','NY','nY','Ny']:2896            lb2()2897        2898        2899        2900    if 'Help Menu' in cmd or 'File Menu' in cmd:2901        return2902         2903      # 20050421 Secret2904    if cmd == '20050421':2905        self.insert_text('Hi My name is CONRAD! You Look Familiar. Have we met somewhere? Whta is your name?', end='''2906''')2907        self.saveTF = True2908        self.mode = '20050421'2909        return2910    2911          2912    #Save Function2913    if self.saveTF:2914      user = cmd2915      2916      self.saveTF = False2917      if user in ['Quit', 'quit', 'QUIT', 'Q', 'q', 'Exit', 'exit', 'EXIT', 'E', 'e']:2918          self.insert_text('Back to BASIC', end='\n')2919      elif self.mode == 'save':2920          with open(cmd, 'w') as file:2921              file.write(self.save)2922          self.insert_text('Saving . . . . .', end='''2923''')2924          time.sleep(1)2925          self.insert_text('Your PROGRAM Has Been Saved!', end='''2926''')2927          self.insert_text('Ready', end='''2928''')2929      2930          2931      #Load Function   2932      elif self.mode == 'load':2933          try:2934              with open(cmd, "r") as file:2935                  self.save = "".join(file.readlines())2936              self.insert_text('Loading . . . . .', end='''2937''')2938              time.sleep(1)2939              self.insert_text('-----Directory-----', end='''2940''')2941              self.insert_text('Memory   PROGRAM   Ext', end='''2942''')2943              self.insert_text(str(sys.getsizeof(self.save)) + " Bytes" + "     System Memory.prg", end='''2944''')2945              if load != '':2946                  2947                  self.insert_text(str(sys.getsizeof(load)) + " Bytes" + '     ' + str(load), end='''2948''')2949              else:2950                  self.insert_text(str(sys.getsizeof(load)) + " Bytes" + '     ' + 'BASIC Memory.prg', end='''2951''')2952              self.insert_text('Ready', end='''2953''')2954          except:2955              self.insert_text("?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.", end='''2956''')2957      2958      #Repeat Function2959      elif self.mode == 'repeat':2960          try:2961              repeatchr(int(user))2962              self.insert_text('''2963Ready''', end='''2964''')2965          except:2966              self.insert_text("?Syntax Error? - means something was typed in wrong", end='''2967''')2968      2969      #Speech Recoginition2970      elif 'sr' in self.mode:2971            try:2972                  duration = int(user)2973                  def rec():2974                      self.insert_text('Recording . . . . .', end='''2975''')2976                      self.update()2977                      2978                      2979                      CHANNELS = 22980                      RATE = 441002981                        2982                  2983                      myrecording = sd.rec(int(duration * RATE), channels=2)2984                      sd.wait()2985                      2986                      2987                        # Record audio for the given number of seconds2988                      wavio.write(filename, myrecording, RATE, sampwidth=2)2989                      self.insert_text('Finished Recording', end='''2990''')2991                        #Second Half of Code2992                      r = sr.Recognizer()2993                      with sr.AudioFile(filename) as source:2994                            # listen for the data (load audio to memory)2995                        audio_data = r.record(source)2996                            # recognize (convert from speech to text)2997                        text = r.recognize_google(audio_data)2998                        self.insert_text(text,end='''2999''')3000                      os.remove(filename)3001                  rec()3002            except:3003                  self.insert_text("?Syntax Error? - means something was typed in wrong", end='''3004''')3005            self.insert_text('Ready',end='''3006''')3007      #Music Function3008      elif 'music' in self.mode:3009          mixer.init()3010          3011          if user in ['1', 'one', 'One', 'ONE', 'O', 'o','Play','play','PLAY','P','p'] and self.mode == 'music':3012              self.insert_text("Enter Music name or music path name:", end='\n')3013              self.saveTF = True3014              self.mode = 'music1'3015              return3016          elif self.mode == 'music1':3017              mixer.music.load(cmd)3018              #Loops Music3019              mixer.music.play(-1)3020              self.insert_text("Background Music is Playing")3021          if user in ['2', 'Two','two','TWO','T','t','Stop','stop','STOP','S','s','PAUSE','pause','Pause']:3022              mixer.music.stop()3023              self.insert_text('Background Music has Stopped Playing', end='''3024''')3025          if user in ['3','Three','three','THREE','Pause','pause','PAUSE','P','p']:3026              mixer.music.pause()3027              self.insert_text('Background Music Has Been Paused', end='''3028''')3029          if user in ['4','Four','FOUR','F','f','four','Unpause','unpause','UNPAUSE','UnPause','up','UP','Up','uP']:3030              mixer.music.unpause()3031              self.insert_text('Background Music Has Been UnPaused', end='''3032''')3033          if user in ['5','Five','five','FIVE','Add','ADD','add','FI','fi','Fi','fI','A','a','Queue','queue','QUEUE','q','Q','Add To Queue','ADD TO QUEUE','add to queue','Add to queue','add To queue','add to Queue','Add To queue','add To Queue']:3034              self.insert_text('Enter the Path or Name of the Music you Would Like to Add to the Queue:', end='''3035''')3036              self.saveTF = True3037              self.mode = 'music2'3038              return3039          if user in ['6','six','SIX','Six','UnLoop','unloop','UNLOOP','Unloop','unLoop']:3040              self.insert_text('Enter Music Name or Path Name:', end='''3041''')3042              self.saveTF = True3043              self.mode = 'music3'3044              return3045          elif self.mode == 'music3':3046              mixer.music.load(cmd)3047              mixer.music.play()3048              self.insert_text('Background Music is Playing Without Loop', end='''3049''')3050          elif self.mode == 'music2':3051              mixer.music.queue(user)3052              self.insert_text('Music Has Been Added to the Queue', end='''3053''')3054              3055          self.insert_text('Ready', end='''3056''')3057      #Load, 8 Feature3058      elif 'load, 8' in self.mode:3059        3060        loadx = '/Volumes/'3061        3062        3063        if user != '' or user != ' ': 3064            loadx = loadx + user + '/'3065            3066        elif user == '' or user == ' ':3067            user = 'UNTITLED'3068            loadx = loadx + user + '/'3069        3070        self.insert_text("Enter PROGRAM Name and extension or path from External Disk to PROGRAM. [Type 'Quit' or 'Exit' to quit]:", end='''3071''')3072        loadz = loadx3073        self.saveTF = True3074        self.mode = 'load,82'3075        return3076            3077      elif 'load,82' in self.mode:3078          loadx = loadz3079          loadx = loadx + user3080          3081          try:3082            with open(loadx, "r") as file:3083              self.save = "".join(file.readlines())3084            time.sleep(1)3085          except:3086            self.insert_text('?Syntax Error? - This Means Something was Typed in Wrong', end='''3087''')3088          3089          self.insert_text('-----Directory-----', end='''3090''')3091          self.insert_text('Memory   PROGRAM   Ext', end='''3092''')3093          self.insert_text(str(sys.getsizeof(self.save)) + " Bytes" + "     SYSTEM Memory.prg", end='''3094''')3095          self.insert_text(str(sys.getsizeof(loadx)) + " Bytes" + '     ' + loadx, end='''3096''')3097        3098              3099          self.insert_text('Ready', end='''3100''')3101      # Clear System Memory3102      elif self.mode == 'clear':3103          if user in ['Yes','YES','yes','Y','y']:3104              self.save = ''3105              time.sleep(1)3106              self.insert_text('SYSTEM MEMORY Has Been Cleared!', end='''3107''')3108          if user in ['NO','No','no','n','N']:3109              self.save = self.save3110              self.insert_text('SYSTEM MEMORY Has Not Been Cleared.', end='''3111''')3112          self.insert_text('Ready', end='''3113''')3114      #Directory3115      elif self.mode == 'dir':3116          if user in ['', 'No','no','NO','N','n']:3117              user = 'BASIC Memory.prg'3118              programs = ''3119          else:3120              programs = user3121          self.insert_text('-----Directory-----', end='''3122''')3123          self.insert_text('Memory   PROGRAM   Ext', end='''3124''')3125          self.insert_text(str(sys.getsizeof(self.save)) + " Bytes" + "     SYSTEM Memory.prg", end='''3126''')3127          self.insert_text(str(sys.getsizeof(programs)) + " Bytes" + '     ' + user, end='''3128''')3129          self.insert_text('Ready', end='''3130''')3131      #Peek Function3132      elif self.mode =='peek':3133        sub = cmd.split()[-1]3134        try:3135          if user in ['1', 'One','ONE','one','O','o']:3136            for i in sub:3137               self.insert_text(ord(i), end = "\n")3138          if user in ['2','Two','TWO','two','T','t']:3139            for i in sub:3140               self.insert_text(chr(int(i)), end = "\n") 3141              3142        except:3143          self.insert_text('?Syntax Error? - means something was typed in wrong', end='''3144''')3145        self.insert_text('Ready', end='''3146''')3147      3148      #20050421 Secret Function3149      elif '20050421' in self.mode:3150          3151          name = cmd3152          3153          self.insert_text('''3154Welcome ''' + name + "! This Secret is Famillar because it is from Rosewell OS! Not Rosewell BASIC. Anyways Both Operating Systems are Cool Operating Systems.", end='''3155''')3156          self.insert_text(rose, end='''3157''')3158          self.insert_text("That is the Rosewell BASIC Copyright line. it is important that all of Blake's OSes have them. Rosewell OS was created on November 9th 2021.", end='''3159''')3160          self.insert_text('You can Contact the creator at: rosewellsoftware@Gmail.com', end='''3161''')3162          self.insert_text('''Brewing Coffee for Next Update . . . . .3163Have a Good Day ''' + name + '!', end='''3164''')3165          self.insert_text('Ready', end='''3166''')3167          cmd = ''3168          3169      3170          3171          3172          3173      #Notes Menu3174      elif 'Note' in self.mode:3175          global note3176          if user in ['1', 'One','one','ONE','New','NEW','new','N','n','o','O']:3177              self.insert_text('Are You Sure? This Action will Delete the Previous Note.[y/n]: ', end='''3178''')3179              self.saveTF = True3180              self.mode = 'note2'3181              return3182          if user in  ['2', 'Two', 'two', 'Review', 'review', 'r', 'R', 'Review Note', 'review Note', 'Review note', 'review note']:3183              self.insert_text('''-----Review Note-----3184Your Note Contains:3185''', end='''3186''')3187              self.insert_text(note, end='''3188''')3189              self.insert_text('Ready', end='''3190''')3191          if user in ['3', 'Add', 'add', 'A', 'a', 'Edit', 'edit', 'E', 'e', 'Add Note', 'Add note', 'add Note', 'add note', 'Edit Note', 'Edit note', 'edit Note', 'edit note']:3192              self.insert_text('''-----Add To Note-----3193Enter The Contents You Would Like to Add/[1 Line]''', end='''3194''')3195              self.saveTF = True3196              self.mode = 'note4'3197              return3198      elif 'note2' in self.mode:3199          if user in ['NO','no','No','n','N','quit','QUIT','Quit','q','Q','Exit','exit','EXIT','E','e']:3200              self.insert_text('Ready', end='''3201''')3202          else:3203              self.insert_text('''-----New Note-----3204Enter Your New Note Contents.[1 line]''', end='''3205''')3206              self.saveTF = True3207              self.mode = 'note3'3208              return3209      elif 'note3' in self.mode:3210          3211          note = user + "\n"3212          self.insert_text('Saving Note . . . . .', end='''3213''')3214          time.sleep(1)3215          self.insert_text('Your Note Has Been Saved! . . . . .', end='''3216''')3217          self.insert_text('Ready', end='''3218''')3219      elif 'note4' in self.mode:3220          3221          note += user + "\n"3222          self.insert_text('Saving Note . . . . .', end='''3223''')3224          time.sleep(1)3225          self.insert_text('Your Note Has Been Saved!', end='''3226''')3227          self.insert_text('Ready', end='''3228''')3229      elif 'voice' in self.mode:3230          os.system( " say " + cmd  + " " )3231          self.insert_text('Ready', end='''3232''')3233      elif 'restart' in self.mode:3234          if cmd in ['No','no','NO','n','N']:3235              self.insert_text('''The app will not be Restarted.3236Ready''', end='''3237''')3238          if cmd in ['Yes','yes','YES','Y','y']:3239              self.insert_text('Restarting App...', end='''3240''')3241              self.insert_text('Loading . . . . .', end='''3242''')3243              time.sleep(1)3244              shell = Shell(root, insertbackground="#78DAFC", highlightbackground ="#0F5FB4",highlightcolor="#0F5FB4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#78DAFC", bg="#0F5FB4")3245              self.destroy()3246              shell.pack(fill=tk.BOTH, expand=1)3247              root.update()3248              3249 3250        3251      self.mode = ''3252      return3253    if len(cmd) == 0:3254      self.insert_text('', end='')3255    # Load, 83256    elif cmd in ['Load,8', 'LOAD, 8', 'LOAD,8', 'load,8', 'load, 8', 'Load, 8', 'l8', 'L8', 'Load*8', 'load*8', 'Load* 8' , 'load* 8', 'LOAD* 8', 'load$8', 'LOAD$8', 'Load$8', 'Load$ 8', 'load$ 8', 'LOAD$ 8', 'load$, 8', 'Load$, 8', 'LOAD$, 8', 'Load*, 8', 'load*, 8', 'LOAD*, 8']:3257        self.insert_text("Enter External Disk Name [Type 'Quit' or 'Exit' to quit/ if left blank, the prompt defaults to UNTITLED.]:", end='''3258''')3259        try:3260            3261            self.saveTF = True3262            self.mode = 'load, 8'3263        except:3264            self.insert_text("?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.", end='''3265''')3266    # All Chr  3267    elif cmd in ['All Chr', 'all chr', 'All chr', 'all Chr', 'ALL CHR', 'AC', 'ac', 'All Character', 'all character', 'All character', 'all Character', 'ALL CHARACTER', 'All Characters', 'all characters', 'all Characters', 'All characters', 'ALL CHARACTERS', 'ALL CHRS', 'all chrs', 'All chrs', 'all Chrs']:3268      atsciiprint()3269      self.insert_text('''3270Ready''', end='''3271''')3272    #Poke3273    elif 'poke' in cmd.lower():3274      pokes = cmd.split()[1:]3275      poke(pokes)3276      self.insert_text('Ready', end='''3277''')3278    #Peek3279    elif 'peek' in cmd.lower():3280        self.insert_text('Ord or Chr?[1/2]', end='''3281''')3282        self.insert_text("Return ATSCII Value or Printed ATSCII?", end='''3283''')3284        self.saveTF = True3285        self.mode = 'peek'3286    3287        3288    #Goto3289    elif "goto" in cmd.lower():3290      Go(int(cmd.split()[-1:][0]))3291      self.insert_text('Ready', end='\n')3292    #Saves to Variable3293    elif findNum(cmd):3294      3295      spaces = ''3296      space = ''3297      varc = ''3298      space = cmd.split()[0]3299      varc = str(space) + ' '3300      spaces = cmd.replace(varc, '')3301      self.save += spaces + "\n"3302    #list3303    elif cmd in ['list', 'List', 'LIST']:3304      time.sleep(0.1)3305      self.insert_text(self.save, end='''3306''')3307      self.insert_text('Ready', end='''3308''')3309    #Contact Us3310    elif cmd in ['Contact','contact','CONTACT','Contact Us','CONTACT US','contact us','Contact us','contact Us']:3311        self.insert_text('''Contact Us at:3312rosewellsoftware@Gmail.com''', end='''3313''')3314        self.insert_text('Ready', end='''3315''')3316    3317    #Run3318    elif cmd in ["Run", "run", 'RUN', 'R', 'r']:3319      f = io.StringIO()3320      with redirect_stdout(f):3321        try:3322          exec(self.save, globals())3323          self.insert_text(f.getvalue(), end='')3324          self.insert_text('Ready', end='''3325''')3326        except Exception as e:3327          self.insert_text('?Syntax Error? - means something was typed in wrong', end='''3328''')3329          self.insert_text("Ready", end='''3330''')3331    #Help3332    elif cmd in ['HELP', 'Help', 'help', 'H', 'h']:3333      self.insert_text(helps, end='''3334''')3335      self.insert_text('Ready', end='''3336''')3337    #Save3338    elif cmd in ['Save', 'save', 'SAVE', 's', 'S', 'Saves', 'saves', 'SAVES']:3339      self.insert_text("Enter new PROGRAM Name to Save [Type 'Quit' or 'Exit' to quit]:", end='\n')3340      self.insert_text("Don't Forget to type '.py' to save as a python file. If your saving in the app, your file will be saved in the app ready to go!", end='\n')3341      3342      try:3343          3344          self.saveTF = True3345          self.mode = 'save'3346          3347      except:3348          self.insert_text("?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.", end='''3349''')3350    #Text To Speech3351    elif cmd in ['speak','Speak','SPEAK','Speech','speech','SPEECH','Text To Speech','text to speech','TEXT TO SPEECH','Text to speech','text To speech','text to Speech',' Text To speech','text To Speech','Text to Speech','TTS','tts','Tts','tTs','ttS','TTs','tTS','TtS']:3352        self.insert_text('© Blake Gouthro | Text To Speech App | V1.1 | Rosewell Software | 2022 - ' + str(today.year) +' ©', end='''3353''')3354        3355        self.insert_text('Enter Text To Speak:', end='''3356''')3357        self.saveTF = True3358        self.mode = 'voice'3359    #Speech to Text3360    elif cmd in ['sr','SR','sR','Sr','STT','stt','st','ST','St','sT','STt','sTT','StT','Speech To Text','speech to text','Speech To text','speech To Text','Speech to Text','SPEECH RECOGNITION','Speech Recognition','Speech recognition','speech Recognition','speech recognition']:3361      self.insert_text('© Blake Gouthro | Speech Recognition App | V1.1 | Rosewell Software | 2022 - ' + str(today.year) +' ©', end='''3362''')3363      self.insert_text('Enter a number to Listen to Voice in Seconds?: ', end='''3364''')3365      self.saveTF = True3366      self.mode = 'sr'   3367    #music3368    elif cmd in ['Music', 'music', 'MUSIC', 'M', 'm', 'MM', 'mm', 'Mm', 'mM', 'Music Menu', 'MUSIC MENU', 'music menu', 'Music menu', 'music Menu']:3369        3370            3371        self.insert_text(musix, end='''3372''')3373        try:3374          3375          self.saveTF = True3376          self.mode = 'music'3377          3378          3379          3380        except:3381          self.insert_text("?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.", end='''3382''')3383    #Load3384    elif cmd in ['Load', 'load', 'L', 'l', 'LOAD']:3385        self.insert_text("Enter PROGRAM Name to Load [Type 'Quit' or 'Exit' to quit]:", end='''3386''')3387        try:3388            self.saveTF = True3389            self.mode = 'load'3390            3391            3392        except:3393          self.insert_text("?Dir Error? - The PROGRAM Either Doesn't Exist, or was Typed in Wrong or, is not in the same Folder.", end='''3394''')3395    #New Window3396    elif cmd in ['Window','window','WINDOW','W','w','New Window','new window','NEW WINDOW','New window','new Window','NW','nw','Nw','nW']:3397          newwindow()3398    #Directory3399    elif cmd in ['DIR','Dir','dir','d','D','Directory','directory','DIRECTORY']:3400        self.insert_text("Load a File into the Directory? [Type 'Quit' or 'Exit' to exit]:", end='''3401''')3402        self.saveTF = True3403        self.mode = 'dir'3404    #Secrets Menu3405    elif cmd in ['Secrets', 'secret', 'S', 's', 'SECRET', 'Secret', 'SECRETS', 'secrets']:3406        self.insert_text('''-----Secrets Menu-----3407Rosewell BASIC - Lists Copyright and System Info340820050421 - Rosewell OS Secret340920211109 - Rosewell OS Secret341020221203 - Rosewell BASIC Secret3411Happy Birthday - Sings Happy Birthday to You!3412Dev - Opens the Credits Secret''', end='''3413''')3414        self.insert_text('Ready', end='''3415''')3416    #Devolper Menu3417    elif cmd in ['Dev', 'dev', 'D', 'd', 'developer', 'Developer', 'Credits', 'credits', 'Credit', 'credit', 'CREDIT', 'DEV', 'DEVELOPER']:3418        copyright()3419        self.insert_text(rose, end='''3420''')3421        self.insert_text('''-----Credits-----3422Blake Gouthro - Rosewell BASIC and Rosewell OS Developer, C.E.O of Rosewell Software, rosewellsoftware@Gmail.com account holder, Programmer, Writer, Graphical Devolper and Head of mangement for Rosewell Software.3423JinHo Mo - Rosewell BASIC and Rosewell OS Developer, Writer, Graphical Developer, Programmer, Writer, Graphical Developer, Rosewell Software Team Member.3424Beginner's All-Purpose Symbolic Instruction Code or BASIC.''', end='''3425''')3426        self.insert_text('Ready', end='''3427''')3428    #Happy Birthday Secret3429    elif cmd in ['Happy Birthday', 'happy Birthday', 'Happy birthday', 'happy birthday', 'HB', 'Hb', 'hB', 'hb']:3430        self.insert_text('''Congratulations! You have found the Happy Birthday Secret!3431''', end='''3432''')3433        self.insert_text('Happy Birthday to You!', end='''3434''')3435        os.system( "say Happy Birthday to You" )3436        self.insert_text('Happy Birthday to You!', end='''3437''')3438        os.system( "say Happy Birthday to You" )3439        self.insert_text('Happy Birthday User!', end='''3440''')3441        os.system( "say Happy Birthday User" )3442        self.insert_text('Happy Birthday to You!', end='''3443''')3444        os.system( "say Happy Birthday to You" )3445        self.insert_text('''3446Ready''', end='''3447''')3448    #Rosewell BASIC Secret3449    elif cmd in ['Rosewell', 'rosewell', 'BASIC', 'Basic', 'basic', 'Rosewell BASIC', 'rosewell BASIC', 'Rosewell Basic', 'rosewell Basic', 'Rosewell basic', 'rosewell basic', 'rb', 'Rb', 'rB', 'RB']:3450        copyright()3451        self.insert_text(rose, end='''3452''')3453        self.insert_text('''3454--Rosewell BASIC was created to be a Recreation of the older BASIC Operating Systems. This copy isn't as powerful yet but soon it will be.3455All files that BASIC can use must be run in the same folder.3456Basic Stands for;3457Beginner's All-Purpose Symbolic Instruction Code3458Hello From Nova Scotia!!3459Hello From Canada!!3460Brewing Coffee For Next Update. . . . .''', end='''3461''')3462        self.insert_text('Ready', end='''3463''')3464    #Repeat Chr3465    elif cmd in ['Repeat Character', 'Repeat Chr', 'repeat Character', 'repeat Chr', 'Repeat chr', 'Repeat character', 'repeat character', 'repeat chr', 'RC', 'rC', 'Rc', 'rc', 'REPEAT CHARACTER', 'REPEAT CHR', 'Repeat Characters', 'repeat characters', 'Repeat characters', 'repeat Characters', 'REPEAT CHARACTERS', 'RCS', 'Rcs', 'rcs', 'rCs', 'rcS', 'RCs', 'rCS', 'REPEAT CHRS', 'Repeat Chrs', 'repeat chrs', 'Repeat chrs', 'repeat Chrs']:3466        self.insert_text("Enter Numbrer to Repeat 'All chr' [Type 'Quit' or 'Exit' to quit]:", end='''3467''')3468        try:3469            self.saveTF = True3470            self.mode = 'repeat'3471            3472            3473        except:3474          self.insert_text("?Syntax Error? - means something was typed in wrong.", end='''3475''')3476    3477    #Clear System Memory3478    elif cmd in ['Clear', 'clear', 'CLEAR', 'C', 'c']:3479        self.insert_text("Would you like to clear SYSTEM MEMORY?", end='''3480''')3481        self.saveTF = True3482        self.mode = 'clear'3483    #Note Menu3484    elif cmd in ['Note', 'note', 'Notes', 'notes', 'n', 'N',]:3485        self.insert_text('''-----Notes Menu-----3486[1] New/Delete Note3487[2] Review Note3488[3] Add to/Open Note''', end='''3489''')3490        self.insert_text('''3491Enter a Number: ''', end='''3492''')3493        self.saveTF = True3494        self.mode = 'Note'3495        return3496    #Modules3497    elif cmd in ['Modules','modules','MODULES','MOD','mod','MOd','mOD','MoD','Check Modules','check modules','CHECK MODULES','Check modules','check Modules','CM','cm','Cm','cM','CMS','cms','CMs','cMS','CmS','Cms','cMs','cmS','Check Module','CHECK MODULE','check module','Check module','check Module']:3498          self.insert_text('''-----Modules Check List-----3499--Loaded Modules--3500''',end='''3501''')3502          #modr is installed3503          modr = []3504          #modz is not installed3505          modz = []3506          modulenames = set(sys.modules) & set(globals())3507          allmodules = [sys.modules[name] for name in modulenames]3508          for i in allmodules:3509            self.insert_text(' {}\n'.format(i),end='')3510          self.insert_text('Ready',end='''3511''')3512                3513         3514          3515    #ATSCII3516    elif cmd in ["ListPeek", "listPeek", 'Listpeek', 'listpeek', 'PETSCII', 'petscii', 'PetscII', 'Petscii', 'ATSCII', 'atscii', 'AtscII', 'Atscii']:3517        self.insert_text('-----List of Built-in ATSCII Characters-----', end='''3518''')3519        self.insert_text('Built-in ATSCII Characters are based off of Unicode Characters. Useful for Poke and Peek commands.', end='''3520''')3521        for k, v in atscii.items():3522            self.insert_text(f"{k} : {v}", end='''3523''')3524        self.insert_text('Ready', end='''3525''')3526    #Date/Time/Clock/Calendar3527    elif cmd in ['Date', 'date', 'Calender', 'calendar', 'Time', 'time', 'T', 't', 'Clock', 'clock', 'CLOCK', 'DATE', 'TIME', 'CALENDAR']:3528        self.insert_text("Today's Date: " + str(today), end='''3529''')3530        now = datetime.datetime.now()3531        self.insert_text(now.strftime("%a, %d, %B "), end='''3532''')3533        yy = today.year3534        mm = today.month3535        self.insert_text(calendar.month(yy,mm), end='''3536''')3537        current_time = time.strftime("%H:%M:%S", time.localtime())3538        self.insert_text('Current Time: ' + current_time, end='''3539''')3540        self.insert_text('Ready', end='''3541''')3542        3543    3544    3545    #Quit3546    elif cmd in ['Quit', 'quit', 'QUIT', 'Q', 'q', 'Exit', 'exit', 'EXIT', 'E', 'e']:3547        self.insert_text('GoodBye', end='''3548''')3549        time.sleep(1)3550        root.destroy()3551        sys.exit()3552    #Restart3553    elif cmd in ['Restart','restart','RESTART','R','r']:3554        self.insert_text('Are you sure you want to restart the app? [NOTE; All unsaved files will be deleted.]',end='''3555''')3556        self.saveTF = True3557        self.mode = 'restart'3558        return3559        3560        3561    #Syntax Error     3562    else:3563      self.insert_text("?Syntax Error?", end='''3564''')3565        3566    3567   3568    3569    3570    3571  # function to handle external command input3572  def system(self, cmd):3573    self.cmd = cmd  # save the command3574    try:3575      # extract the actual command3576      cmd = cmd[cmd.index('`')+1:cmd.rindex('`')]3577      proc = subp.Popen(cmd, stdout=subp.PIPE, stderr=subp.PIPE, text=True)3578      stdout, stderr = proc.communicate(5) # get the command output3579      # append the command output to Text box3580      self.insert_text(stdout)3581    except Exception as e:3582      self.insert_text(str(e))3583copyright()3584root.title('Rosewell BASIC')3585root.configure(bg="#0F5FB4")3586global shell3587shell = Shell(root, insertbackground="#78DAFC", highlightbackground ="#0F5FB4",highlightcolor="#0F5FB4", borderwidth=10, width=69, height=30, font=('Atari-Basic.ttf', 14), fg="#78DAFC", bg="#0F5FB4")3588menubar = Menu(root)3589filemenu = Menu(menubar, tearoff=0)3590filemenu.add_command(label="Load", command=menuload)3591filemenu.add_command(label="Load, 8", command=menuload8)3592filemenu.add_command(label="Save", command=menusave)3593filemenu.add_command(label="Run", command =runs)3594filemenu.add_command(label="List", command =lists)3595filemenu.add_command(label="Clear", command =clearz)3596filemenu.add_command(label="Music", command =musiz)...FS7_KHERIWALA_JOSHUA_KOH.py
Source:FS7_KHERIWALA_JOSHUA_KOH.py  
...61    def draw(self,screen,text_colour,text_size):62        if self.image == None:63            pygame.draw.rect(screen, self.color, (self.x,self.y,self.width+2,self.height))64            pygame.display.update()65            insert_text(screen,self.text,'arial',text_size,text_colour,self.x+1,self.y)66            return self67        else:68            screen.blit(pygame.transform.scale(self.image, (self.width,self.height)), (self.x,self.y))69            insert_text(screen,self.text,'arial',text_size,text_colour,self.x+1,self.y)70            return self71    def isClicked(self, mousepos):72        #Pos is the mouse position or a tuple of (x,y) coordinates73        if (mousepos[0] > self.x) and (mousepos[0] < self.x + self.width):74            if (mousepos[1] > self.y) and (mousepos[1] < self.y + self.height):75                return True76        return False   77def insert_text(screen,text,font,size,colour,x_pos,y_pos):78    pygame.init()79    text_font = pygame.font.SysFont(font, size)80    text=text_font.render(text, True, colour)81    screen.blit(text,(x_pos,y_pos))82    return text.get_rect()83def bubble_sort(vec):84    l = len(vec)85    loop = False # Check whether we do any changes when we go through one loop86    for i in range(l):87        for j in range(l - i- 1):88            if vec[j] > vec[j+1]:89                temp =vec[j+1]90                vec[j+1] = vec[j]91                vec[j] = temp92                loop = True93        if not loop:#break the loop if we don't do any changes in 1 loop94                break95    return vec96def back_exit_clicked(screen):97    image_exit = pygame.image.load('exit.png')98    text_back = button((255,255,255),430,730,200,60,'',image_exit).draw(screen,(0,0,0),40)99    insert_text(menu_screen,'Back','arial',50,(255,255,255),480,730)100    text_quit = button((255,255,255),730,730,200,60,'',image_exit).draw(screen,(0,0,0),40)101    insert_text(menu_screen,'Exit','arial',50,(255,255,255),790,730)102    text_quit2 = button((211,211,211),900,730,0,0,'').draw(screen,(0,0,0),50)103    while True:104        for event in pygame.event.get():105            if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):106                return False 107            if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:108                mousepos = pygame.mouse.get_pos()109                if text_back.isClicked(mousepos):110                    display_menu(coordinates,price,food)111                    return True112                elif text_quit.isClicked(mousepos):113                    return False114                115#Main menu116def display_menu(coordinates,price,food):117    menu_screen = pygame.display.set_mode((1400,800))118    image_map = pygame.image.load('map.png')119    image_background = pygame.image.load('background1.png')120    image_bus = pygame.image.load('bus.png')121    image_update = pygame.image.load('update.png')122    image_canteen = pygame.image.load('canteen1.png')123    image_button = pygame.image.load('button.png')124    image_button1 = pygame.image.load('button1.png')125    image_location = pygame.image.load('location_bg.png')126    image_submit = pygame.image.load('submit_button.png')127    image_distance = pygame.image.load('distance.png')128    image_rank = pygame.image.load('rank.png')129    image_money = pygame.image.load('money.png')130    image_food = pygame.image.load('food.png')131    image_exit = pygame.image.load('exit.png')132    image_logo = pygame.image.load('ntulogo.png')133    menu_screen.blit(pygame.transform.scale(image_background, (1400, 800)), (0, 0))134    menu_screen.blit(pygame.transform.scale(image_logo, (150, 150)), (150, 25))135    menu_screen.blit(pygame.transform.scale(image_canteen, (110, 110)), (530, 220))136    menu_screen.blit(pygame.transform.scale(image_map, (100, 100)), (535, 370))137    menu_screen.blit(pygame.transform.scale(image_update, (100, 100)), (535, 590))138    menu_screen.blit(pygame.transform.scale(image_bus, (110, 110)), (535, 460))139    menu_screen.blit(pygame.transform.scale(image_distance, (100, 100)), (730, 210))140    menu_screen.blit(pygame.transform.scale(image_rank, (100, 100)), (730, 330))141    menu_screen.blit(pygame.transform.scale(image_money, (100, 100)), (730, 480))142    menu_screen.blit(pygame.transform.scale(image_food, (90, 90)), (730, 610))143    text_guide = insert_text(menu_screen,'NTU Food and Beverage Guide','bahnschrift',60,(255,255,255),350,40)144    145    text_canteens =     button((255,165,0),60,200,465,160,'',image_button).draw(menu_screen,(255,255,255),50)146    insert_text(menu_screen,'Display all canteens','arial',55,(0,0,0),85,240)147    148    text_transport =    button((255,165,0),60,480,465,100,'',image_button).draw(menu_screen,(255,255,255),50)149    insert_text(menu_screen,'Getting there','arial',55,(0,0,0),140,490)150    151    text_updateinfo =   button((255,165,0),60,590,465,100,'',image_button).draw(menu_screen,(255,255,255),50)152    insert_text(menu_screen,'Update canteen info','arial',55,(0,0,0),85,605)153    154    if coordinates == None:155            text_coordinates  = button((255,255,255),60,370,465,100,'',image_button).draw(menu_screen,(255,255,255),50)156            insert_text(menu_screen,'Get location coordinates','arial',50,(0,0,0),70,385)157    else:158        text_coordinates  = button((255,165,0),60,370,465,100,'',image_button).draw(menu_screen,(255,255,255),50)159        insert_text(menu_screen,'Location: (x- {}, y- {})'.format(coordinates[0],coordinates[1]),'arial',50,(0,0,0),63,385)160        161    if price == None:162        text_price =        button((211,211,211),850,480,365,80,'',image_button1).draw(menu_screen,(0,0,0),60)163        insert_text(menu_screen,'Search by price','arial',50,(0,0,0),890,490)164    else:165        text_price =        button((211,211,211),850,480,365,80,'',image_button1).draw(menu_screen,(0,0,0),60)166        insert_text(menu_screen,'Price: ${} - ${}'.format(price.split('-')[0],price.split('-')[1]),'arial',50,(0,0,0),860,490)167        168    text_distance =         button((211,211,211),850,220,365,80,'',image_button1).draw(menu_screen,(0,0,0),60)169    insert_text(menu_screen,'Sort by distance','arial',50,(0,0,0),880,230)170    text_rank =             button((211,211,211),850,350,365,80,'',image_button1).draw(menu_screen,(0,0,0),60)171    insert_text(menu_screen,'Sort by rank','arial',50,(0,0,0),900,360)172    if food == None:173        text_food =         button((211,211,211),850,600,365,80,'',image_button1).draw(menu_screen,(0,0,0),60)174        insert_text(menu_screen,'Search food','arial',50,(0,0,0),905,610)175    else:176        text_food =         button((211,211,211),850,600,365,80,'',image_button1).draw(menu_screen,(0,0,0),60)177        insert_text(menu_screen,'Food: {}'.format(food),'arial',50,(0,0,0),860,610)178    text_submit_food =      button((255,165,0),1230,610,150,50,'',image_submit).draw(menu_screen,(0,0,0),60)179    insert_text(menu_screen,'Submit','arial',40,(0,0,0),1250,610)180    text_submit_price =     button((255,165,0),1230,490,150,50,'',image_submit).draw(menu_screen,(0,0,0),60)181    insert_text(menu_screen,'Submit','arial',40,(0,0,0),1250,490)182    text_exit =             button((211,211,211),555,700,200,60,'',image_exit).draw(menu_screen,(0,0,0),60)183    insert_text(menu_screen,'Exit','arial',50,(255,255,255),620,700)184    pygame.display.update()185    return text_canteens,text_coordinates,text_price,text_distance,text_rank,text_food,text_submit_food,text_submit_price,text_exit,text_updateinfo,text_transport,menu_screen186    187#Display getting coordinates   188def get_user_location():189    pygame.init()190    coordinates_screen = pygame.display.set_mode((1400,800))191    image = pygame.image.load('ntucampus.png')192    image2 = pygame.image.load('location_bg.png')193    coordinates_screen.blit(pygame.transform.scale(image, (1000, 800)), (0, 0))194    coordinates_screen.blit(pygame.transform.scale(image2, (400, 800)), (1001, 0))195    text_guide = insert_text(coordinates_screen,'NTU F&B Guide','arial',60,(0,0,128),1020,100)196    click_location = insert_text(coordinates_screen,'Click on your location','arial',40,(0,0,128),1030,200)197    coordinates = insert_text(coordinates_screen,'Your coordinates: ','arial',35,(0,0,128),1070,300)198    pygame.display.update()199    200    #get coordinates201    while True:202        for event in pygame.event.get():203            if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:204                mousepos = pygame.mouse.get_pos()205                if mousepos[0]<=1000:206                    mark = insert_text(coordinates_screen,'x','arial',30,(0,0,0),mousepos[0]-5,mousepos[1]-20)207                    coordinates = insert_text(coordinates_screen,('X:{} , Y:{}'.format(mousepos[0],mousepos[1])),'arial',35,(0,0,0),1100,400)208                    exiting = insert_text(coordinates_screen,'exiting...','arial',35,(0,0,0),1120,500)209                    pygame.display.update()210                    return mousepos211#Display all canteens212def display_all_canteens(screen,coordinates,price,food):213    screen.fill((211,211,211))214    image = pygame.image.load('display_distance.png')215    screen.blit(pygame.transform.scale(image, (1400, 800)), (0, 0))216    i = 50217    insert_text(screen,'Name','arial',20,(0,0,0),30,10)218    insert_text(screen,'Rating','arial',20,(0,0,0),130,10)219    insert_text(screen,'Location','arial',20,(0,0,0),220,10)220    insert_text(screen,'Food','arial',20,(0,0,0),350,10)221    #display all canteens222    for canteen in canteenlist:223        name = '{}'.format(canteen['Name'])224        location = '{}'.format(canteen['Location'])225        rating = '{}'.format(canteen['Rating'])226        insert_text(screen,name,'arial',15,(0,0,0),30,i)227        insert_text(screen,rating,'arial',15,(0,0,0),135,i)228        insert_text(screen,location,'arial',15,(0,0,0),220,i)229        food_x_first = 350230        food_x_second = 350231        food_count = 0232        for foods in canteen['Food']:233            food_text = ('{} ({}) : ${}'.format(foods[1],foods[0],canteen['Food'][foods]))234            if food_count<=4:235                position = insert_text(screen,food_text,'arial',15,(0,0,0),food_x_first,i)236                food_x_first = food_x_first + position[2] + 20237            else:238                position = insert_text(screen,food_text,'arial',15,(0,0,0),food_x_second,i+30)239                food_x_second = food_x_second + position[2] + 20240            food_count += 1241        i = i +70242    243    return back_exit_clicked(screen)244#Updating Information245def get_food_result(): 246    global result247    canteen = variable_canteen.get()248    food_type = variable_type.get()249    food_name = food_text.get()250    food_cost = food_price.get()251    result = ('{},{},{},{}'.format(canteen,food_type,food_name,food_cost)).split(',')252    master.destroy()253    return result254def add_food_screen(): #Adding food screen255    global variable_canteen,food_text,food_price,master,variable_type256    canteen_list = []257    for canteen in canteenlist:258         canteen_list.append(canteen['Name'])259    master = tk.Tk()260    #canteen dropdown261    variable_canteen = tk.StringVar(master)262    variable_canteen.set("Chooose canteen") # default value263    canteen_menu = tk.OptionMenu(master, variable_canteen, *canteen_list)264    canteen_menu.grid(row= 0,column = 0,sticky = tk.NE)265    variable_type = tk.StringVar(master)266    variable_type.set("Chooose food type") # default value267    food_type = tk.OptionMenu(master, variable_type, 'halal','veg','non-halal')268    food_type.grid(row =0,column = 3)269    #food textfield270    food_text = tk.Entry(master,textvariable = tk.StringVar(),width = 40)271    food_text.insert(0,'Enter food here')272    food_text.grid(row= 0,column = 4)273    274    #price textfield275    food_price = tk.Entry(master,textvariable = tk.StringVar(),width = 20)276    food_price.insert(0,'Enter price here')277    food_price.grid(row= 0,column = 5)278    279    #submit button280    tk.Button(master, text='Submit', command = get_food_result).grid(row=0, column=6)281    master.mainloop()282    return result283def get_rating_result():284    global result285    canteen = variable.get()286    new_rating = rating_entry.get()287    result = ('{},{}'.format(canteen,new_rating)).split(',')288    master.destroy()289    return result290def update_rating_screen(): #Updating Rating screen291    global variable,rating_entry,master292    master = tk.Tk()293    canteen_list = []294    for canteen in canteenlist:295        canteen_list.append(canteen['Name'])296    variable = tk.StringVar(master)297    variable.set("Chooose canteen") # default value298    canteen_menu = tk.OptionMenu(master, variable, *canteen_list)299    canteen_menu.grid(row= 0,column = 0,sticky = tk.NE)300    rating_entry = tk.Entry(master,textvariable = tk.StringVar(),width = 20)301    rating_entry.insert(0,'Enter new rating: ')302    rating_entry.grid(row= 0,column = 1)303    tk.Button(master, text='Submit', command = get_rating_result).grid(row=0, column=5)304    master.mainloop()305    return result306def updatingFood(inputList):307  for eachCanteen in canteenlist:308    if eachCanteen['Name'] == inputList[0]:309      eachCanteen['Food'][str(inputList[1]),str(inputList[2])] = float(inputList[3])310      return eachCanteen['Food']311def updatingRating(inputList):312  for eachCanteen in canteenlist:313    if eachCanteen['Name'] == inputList[0]:314      eachCanteen['Rating'] = float('{:.1f}'.format((float(inputList[1]) + eachCanteen['Rating']) / 2))315      return eachCanteen['Rating']316    317def display_updateinfo(screen):318    screen.fill((211,211,211))319    image = pygame.image.load('display_distance.png')320    image_button = pygame.image.load('button.png')321    screen.blit(pygame.transform.scale(image, (1400, 800)), (0, 0))322    insert_text(screen,'Update Information','arial',70,(0,0,0),400,100)323    addfood_button = button((255,165,0),500,300,300,40,'',image_button).draw(screen,(0,0,255),40)324    insert_text(screen,'Add Food','arial',40,(0,0,0),570,298)325    updaterating_button = button((255,165,0),500,400,300,40,'',image_button).draw(screen,(0,0,255),40)326    insert_text(screen,'Give Rating','arial',40,(0,0,0),560,396)327    random_button = button((211,211,211),1000,600,0,0,'',None).draw(screen,(0,0,255),40)328    pygame.display.update()329    while True:330        mousepos = pygame.mouse.get_pos()331        for event in pygame.event.get():332            if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):333                return False334            elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:335                if addfood_button.isClicked(mousepos):336                    result = add_food_screen()337                    screen.fill((211,211,211))338                    screen.blit(pygame.transform.scale(image, (1400, 800)), (0, 0))339                    updatingFood(result)340                    insert_text(screen,'{} has been added to {}'.format(result[2],result[0]),'arial',40,(0,0,0),400,400)341                    return back_exit_clicked(screen)342                elif updaterating_button.isClicked(mousepos):343                    result = update_rating_screen()344                    newrating = updatingRating(result)345                    screen.fill((211,211,211))346                    screen.blit(pygame.transform.scale(image, (1400, 800)), (0, 0))347                    insert_text(screen,'Rating for {} has been updated.'.format(result[0]),'arial',40,(0,0,0),400,350)348                    insert_text(screen,'New rating is: {}'.format(newrating),'arial',40,(0,0,0),500,450)349                    return back_exit_clicked(screen)350#Sort by rank351def sort_by_rank(canteenlist):352    canteen = [i for i in canteenlist]353    rating = [i['Rating'] for i in canteen]354    sorted_rating = [i for i in rating]355    #Sort by using bubble algorithm356    sorted_rating = bubble_sort(sorted_rating)357    sorted_rating.reverse()358    359    results = {}360    361    #Sort the key from highest rating to lowest rating362    for i in range(len(rating)):363        index = rating.index(sorted_rating[i])364        temp = canteen[index]365        results.update({temp['Name']:(temp['Rating'], temp['Location'])})366        rating.pop(index)367        canteen.pop(index)368    return results369def display_sortedrank(screen,coordinates,price,food):370    #food_result = {'McDonalds': (4.9, (305, 279))}371    food_result = sort_by_rank(canteenlist)372    screen.fill((211,211,211))373    image = pygame.image.load('display_distance.png')374    screen.blit(pygame.transform.scale(image, (1400, 800)), (0, 0))375    insert_text(screen,'Canteens sorted by Rank','arial',60,(0,0,0),400,10)376    insert_text(screen,'Name','arial',40,(0,0,0),300,80)377    insert_text(screen,'Rating','arial',40,(0,0,0),600,80)378    insert_text(screen,'Location coordinates','arial',40,(0,0,0),900,80)379    height = 130380    for key in food_result:381        insert_text(screen,key,'arial',40,(0,0,0),300,height)382        insert_text(screen,str(food_result[key][0]),'arial',40,(0,0,0),620,height)383        insert_text(screen,str(food_result[key][1]),'arial',40,(0,0,0),950,height)384        height = height + 60385    return back_exit_clicked(screen)386#Sort by Distance387def distance_a_b(location_a, location_b): #Define function to calculate distance between 2 points388    #Change the type of variable into array389    location_a = numpy.array(location_a)390    location_b = numpy.array(location_b)391    delta = (location_a - location_b)392    #Calculate the distance393    distance = numpy.math.sqrt(numpy.dot(delta,delta))394    return distance395def sort_distance(user_location, canteenlist): #Define function to  sort distance from closest to farthest396    canteen = [i for i in canteenlist]397    #Creating a list of distance from user_location398    distance = [distance_a_b(user_location, i['Location']) for i in canteen]399    sorted_distance = [i for i in distance]400    #Perform bubble sort algorithm on the values401    sorted_distance = bubble_sort(sorted_distance)402    403    results = {}404    405    #sort the canteens name from the closest to the furthest from user location406    for i in range(len(distance)):407        index = distance.index(sorted_distance[i])408        temp = canteen[index]409        results.update({temp['Name']:(temp['Rating'], temp['Location'], distance[index])})410        distance.pop(index)411        canteen.pop(index)412        413    return results414def display_sordteddistance(screen,coordinates,price,food):415    #food_result = {'McDonalds': (4.9, (305, 279), 153.83757668398187}416    food_result = sort_distance(coordinates, canteenlist)417    image = pygame.image.load('display_distance.png')418    screen.blit(pygame.transform.scale(image, (1400, 800)), (0, 0))419    insert_text(screen,'Canteens sorted by Distance','arial',60,(0,0,0),400,10)420    insert_text(screen,'Name','arial',40,(0,0,0),220,80)421    insert_text(screen,'Rating','arial',40,(0,0,0),480,80)422    insert_text(screen,'Location','arial',40,(0,0,0),680,80)423    insert_text(screen,'Distance from user','arial',40,(0,0,0),880,80)424    height = 130425    for key in food_result:426        insert_text(screen,key,'arial',40,(0,0,0),220,height)427        insert_text(screen,str(food_result[key][0]),'arial',40,(0,0,0),500,height)428        insert_text(screen,str(food_result[key][1]),'arial',40,(0,0,0),670,height)429        insert_text(screen,'{:.2f} metres'.format(food_result[key][2]*3),'arial',40,(0,0,0),900,height)430        height = height + 60431    return back_exit_clicked(screen)  432#Search by Price433def search_by_price(priceRange, inputList):434    #output = {'KFC': [4.6, (319, 253), ('halal', 'Signature Grilled Chicken', 5.2), ('halal', 'Zinger Burger', 5.3)]435    try:436        result_Dict = {}437        for eachCanteen in inputList:438            canteenFood = eachCanteen['Food']439            canteenLocation = eachCanteen['Location']440            result_list = []441            count = 0442            for key0, key1 in canteenFood:443                if float(priceRange.split('-')[0]) <= canteenFood[key0,key1] <= float(priceRange.split('-')[1]):444                    canteenRating = eachCanteen['Rating']445                    canteenLocation = eachCanteen['Location']446                    if not canteenRating in result_list:447                        result_list.append(canteenRating)448                    if not canteenLocation in result_list:449                        result_list.append(canteenLocation)450                    result_list.append((key0,key1,canteenFood[key0,key1]))451                    count +=1452            if count>0:453                canteenName = eachCanteen['Name']454                result_Dict[canteenName] = result_list455        456        #Sort the key from lowest price to highest price457        for i in result_Dict:458            vec = result_Dict[i][2:]459            sorted_vec = []460            vec_price = [j[2] for j in vec]461            sorted_vec_price = [j for j in vec_price]462            sorted_vec_price = bubble_sort(sorted_vec_price)463          464            for j in range(len(vec)):465                index = vec_price.index(sorted_vec_price[j])466                sorted_vec.append(vec[index])467                vec_price.pop(index)468                vec.pop(index)469            result_Dict[i] = [result_Dict[i][0],result_Dict[i][1]]+sorted_vec470        return result_Dict471    except:472        print('Invalid Input')473        474def display_sortedprice(screen,coordinates,price,food):475    #food_result = {'KFC': [4.6, (319, 253), ('halal', 'Signature Grilled Chicken', 5.2), ('halal', 'Zinger Burger', 5.3)]476    food_result = search_by_price(price, canteenlist)477    image = pygame.image.load('display_distance.png')478    screen.blit(pygame.transform.scale(image, (1400, 800)), (0, 0))479    if len(food_result) == 0:480        insert_text(screen,'No food in the the price range: ${} - ${}'.format(price.split('-')[0],price.split('-')[1]),'arial',60,(0,0,0),200,400)481    else:482        insert_text(screen,'Food sorted by Price: ${} - ${}'.format(price.split('-')[0],price.split('-')[1]),'arial',60,(0,0,0),380,10)483        insert_text(screen,'Name','arial',30,(0,0,0),30,100)484        insert_text(screen,'Rating','arial',30,(0,0,0),150,100)485        insert_text(screen,'Location','arial',30,(0,0,0),300,100)486        insert_text(screen,'Food','arial',30,(0,0,0),470,100)487        height = 150488        for key in food_result:489            food_x_first = 470490            food_x_second = 470491            food_count = 0492            insert_text(screen,key,'arial',20,(0,0,0),30,height)493            insert_text(screen,str(food_result[key][0]),'arial',20,(0,0,0),160,height)494            insert_text(screen,str(food_result[key][1]),'arial',20,(0,0,0),300,height)495            for i in range(len(food_result[key][2:])):496                food_text = ('{} ({}) : ${}'.format(food_result[key][i+2][1],food_result[key][i+2][0],food_result[key][i+2][2]))497                if food_count<=3:498                    position = insert_text(screen,food_text,'arial',15,(0,0,0),food_x_first,height)499                    food_x_first = food_x_first + position[2] + 20500                    food_count += 1501                else:502                    position = insert_text(screen,food_text,'arial',15,(0,0,0),food_x_second,height+25)503                    food_x_second = food_x_second + position[2] + 20504            height = height + 60505    return back_exit_clicked(screen)506#Search by food507def search_by_food(foodName, inputList):508    #output = {'KFC': [4.6, (319, 253), ('halal', 'Zinger Burger', 5.3)}509    foodName = foodName.lower()510    try:511        result_Dict = {}512        for eachCanteen in inputList:513         canteenFood = eachCanteen['Food']514         result_list = []515         count = 0516         for key0, key1 in canteenFood:517           if foodName in key1.lower():518             canteenRating = eachCanteen['Rating']519             canteenLocation = eachCanteen['Location']520             if not canteenRating in result_list:521               result_list.append(canteenRating)522               result_list.append(canteenLocation)523             result_list.append((key0,key1,canteenFood[key0,key1]))524             count +=1525         if count>0:526           canteenName = eachCanteen['Name']527           result_Dict[canteenName] = result_list528        return result_Dict529    except:530        print('Invalid Input')531        532def display_searchfood(screen,coordinates,price,food):533    food_result = search_by_food(food,canteenlist)     #sample result = {'KFC': [4.6, (319, 253), ('halal', 'Zinger Burger', 5.3)}534    image = pygame.image.load('display_distance.png')535    screen.blit(pygame.transform.scale(image, (1400, 800)), (0, 0))536    if len(food_result) == 0:537        insert_text(screen,'No results found for: {}'.format(food),'arial',60,(0,0,0),400,400)538    else:539        insert_text(screen,'Name','arial',40,(0,0,0),30,100)540        insert_text(screen,'Rating','arial',40,(0,0,0),150,100)541        insert_text(screen,'Location','arial',40,(0,0,0),300,100)542        insert_text(screen,'Food','arial',40,(0,0,0),470,100)543        insert_text(screen,'Showing results for: {}'.format(food),'arial',60,(0,0,0),400,10)544        height = 180545        for key in food_result:546            food_x_first = 470547            food_x_second = 470548            food_count = 0549            insert_text(screen,key,'arial',20,(0,0,0),30,height)550            insert_text(screen,str(food_result[key][0]),'arial',20,(0,0,0),170,height)551            insert_text(screen,str(food_result[key][1]),'arial',20,(0,0,0),300,height)552            for i in range(len(food_result[key][2:])):553                food_text = ('{} ({}) : ${}'.format(food_result[key][i+2][1],food_result[key][i+2][0],food_result[key][i+2][2]))554                if food_count<=4:555                    position = insert_text(screen,food_text,'arial',15,(0,0,0),food_x_first,height)556                    food_x_first = food_x_first + position[2] + 20557                else:558                    position = insert_text(screen,food_text,'arial',15,(0,0,0),food_x_second,height+30)559                    food_x_second = food_x_second + position[2] + 20560                food_count += 1561            height = height + 50562    return back_exit_clicked(screen)563#Getting There564def display_gettingthere(screen,coordinates,canteen_name):565    image = pygame.image.load('display_distance.png')566    screen.blit(pygame.transform.scale(image, (1400, 800)), (0, 0))567    distance_user, stop_user, bus_type, stop_canteen, n, distance_canteen, canteenname,canteenlocation = (transport(coordinates,canteen_name))568    if n==0:569        instruction = 'Walk {:.2f} m to {}. There is no need to take bus'.format(3*distance_a_b(coordinates, canteenlocation),canteen_name['Name'])570        insert_text(screen,instruction,'arial',40,(0,0,0),300,400)571    else:572        insert_text(screen,'Directions to {}'.format(canteen_name['Name']),'centuryschoolbook',60,(0,0,0),300,50)573        insert_text(screen,'1) Walk {:.0f} m to bus stop: {}'.format(distance_user, stop_user),'arial',40,(0,0,0),300,200)574        insert_text(screen,'2) Take the {} bus'.format(bus_type),'arial',40,(0,0,0),300,300)575        insert_text(screen,'3) Alight after {} stops at: {}'.format(n,stop_canteen),'arial',40,(0,0,0),300,400)576        insert_text(screen,'4) Walk {:.0f} m to {}'.format(distance_canteen, canteenname),'arial',40,(0,0,0),300,500)577    return back_exit_clicked(screen)578    579def display_transport(screen,coordinates):580    image = pygame.image.load('display_distance.png')581    screen.blit(pygame.transform.scale(image, (1400, 800)), (0, 0))582    image_button1 = pygame.image.load('button.png')583    insert_text(screen,'Where would you like to go','centuryschoolbook',50,(0,0,0),323,70)584    kfc_button = button((255,165,0),300,200,300,40,'',image_button1).draw(screen,(0,0,255),40)585    insert_text(screen,'KFC','arial',40,(0,0,0),420,198)586    mac_button = button((255,165,0),300,300,300,40,'',image_button1).draw(screen,(0,0,255),40)587    insert_text(screen,'McDonalds','arial',40,(0,0,0),370,298)588    koufu_button = button((255,165,0),300,400,300,40,'',image_button1).draw(screen,(0,0,255),40)589    insert_text(screen,'Koufu','arial',40,(0,0,0),410,398)590    canteen1_button = button((255,165,0),300,500,300,40,'',image_button1).draw(screen,(0,0,255),40)591    insert_text(screen,'Food Court 1','arial',40,(0,0,0),360,498)592    canteen2_button = button((255,165,0),300,600,300,40,'',image_button1).draw(screen,(0,0,255),40)593    insert_text(screen,'Food Court 2','arial',40,(0,0,0),360,598)594    canteen9_button = button((255,165,0),700,200,300,40,'',image_button1).draw(screen,(0,0,255),40)595    insert_text(screen,'Food Court 9','arial',40,(0,0,0),760,198)596    canteen11_button = button((255,165,0),700,300,300,40,'',image_button1).draw(screen,(0,0,255),40)597    insert_text(screen,'Food Court 11','arial',40,(0,0,0),750,298)598    canteen13_button = button((255,165,0),700,400,300,40,'',image_button1).draw(screen,(0,0,255),40)599    insert_text(screen,'Food Court 13','arial',40,(0,0,0),750,398)600    canteen16_button = button((255,165,0),700,500,300,40,'',image_button1).draw(screen,(0,0,255),40)601    insert_text(screen,'Food Court 16','arial',40,(0,0,0),750,498)602    quad_button = button((255,165,0),700,600,300,40,'',image_button1).draw(screen,(0,0,255),40)603    insert_text(screen,'Quad Cafe','arial',40,(0,0,0),760,598)604    random_button = button((211,211,211),1000,600,0,0,'',image_button1).draw(screen,(0,0,255),40)605    pygame.display.update()606    while True:607        mousepos = pygame.mouse.get_pos()608        for event in pygame.event.get():609            if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):610                run = False611                pygame.quit()  612            elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:613                if kfc_button.isClicked(mousepos):614                    return display_gettingthere(screen,coordinates,kfc)615                if mac_button.isClicked(mousepos):616                    return display_gettingthere(screen,coordinates,mac)617                if koufu_button.isClicked(mousepos):...ui_base_3_to_4.py
Source:ui_base_3_to_4.py  
...81        self.text = text82        self.set_menu_and_entry_events_for_open_url(True)83        entry.bind("<ButtonPress-3>", self.show_menu)84        text.bind("<ButtonPress-3>", self.show_menu)85        self.insert_text(_START_TEXT)86        entry.focus_set()87        self.root = root88        self.contents = contents89        self.__help = None90        self.filespec = filespec91        if not isinstance(filespec, FileSpec):92            msg = "The database specification is not valid."93            tkinter.messagebox.showerror(94                title="Upgrade Database",95                message=msg,96            )97            self.insert_text("\n\n")98            self.insert_text(msg)99            self.insert_text("\n")100            self.insert_text("Nothing can, or will, be done.")101            self.insert_text("\n")102            self.insert_text(103                "".join(104                    (105                        "A FileSpec is expected but a ",106                        self.filespec.__class__.__name__,107                        " is given.",108                    )109                )110            )111            self.set_menu_and_entry_events_for_open_url(False)112            return113        if bsddb_dbe is None and sqlite_dbe is None:114            msg = "Unable to process SQLite or Berkeley DB databases."115            tkinter.messagebox.showinfo(116                title="Upgrade Database",117                message=msg,118            )119            self.insert_text("\n\n")120            self.insert_text(msg)121            self.insert_text("\n")122            self.insert_text(123                "".join(124                    (125                        "This Python has none of apsw, bsddb3, and sqlite3, ",126                        "installed.  Perhaps another Python has some or all of ",127                        "these installed.",128                    )129                )130            )131            self.insert_text("\n")132            self.insert_text("Berkeley DB databases need bsddb3.")133            self.insert_text("\n")134            self.insert_text("SQLite databases need apsw or sqlite3.")135            self.insert_text("\n")136            self.insert_text("On Pythons earlier than version 3.6 use apsw.")137            self.insert_text("\n")138        elif bsddb_dbe is None:139            msg = "Unable to process Berkeley DB databases."140            tkinter.messagebox.showinfo(141                title="Upgrade Database",142                message=msg,143            )144            self.insert_text("\n\n")145            self.insert_text(msg)146            self.insert_text("\n")147            self.insert_text(148                "".join(149                    (150                        "This Python does not have bsddb3 installed.  Perhaps ",151                        "another Python has this installed.",152                    )153                )154            )155            self.insert_text("\n")156            self.insert_text("Berkeley DB databases need bsddb3.")157            self.insert_text("\n\n")158            self.insert_text("SQLite databases can be upgraded.")159        elif sqlite_dbe is None:160            msg = "Unable to process SQLite databases."161            tkinter.messagebox.showinfo(162                title="Upgrade Database",163                message=msg,164            )165            self.insert_text("\n\n")166            self.insert_text(msg)167            self.insert_text("\n")168            self.insert_text(169                "".join(170                    (171                        "This Python has none of apsw, and sqlite3, installed.  ",172                        "Perhaps another Python has some or all of these installed.",173                    )174                )175            )176            self.insert_text("\n")177            self.insert_text("SQLite databases need apsw or sqlite3.")178            self.insert_text("\n")179            self.insert_text("On Pythons earlier than version 3.6 use apsw.")180            self.insert_text("\n\n")181            self.insert_text("Berkeley DB databases can be upgraded.")182        else:183            self.insert_text("\n\n")184            self.insert_text(185                "SQLite and Berkeley DB databases can be upgraded."186            )187        self.insert_text("\n")188        self.insert_text("DPT databases do not need upgrading.")189        if sqlite_dbe is not None:190            self.insert_text("\n\n")191            self.insert_text(192                "".join(193                    (194                        "SQLite upgrades are very quick because table and column ",195                        "name changes is all that happens.",196                    )197                )198            )199        if bsddb_dbe is not None:200            self.insert_text("\n\n")201            self.insert_text(202                "".join(203                    (204                        "Berkeley DB upgrades will take a long time, depending on ",205                        "the size of the database, because all data is moved to a ",206                        "new location.",207                    )208                )209            )210        if sqlite_dbe is not None:211            if sqlite_dbe.__name__ == "sqlite3":212                if _deny_sqlite3:213                    msg = "".join(214                        (215                            "Unable to process SQLite databases on this ",216                            "version of Python.",217                        )218                    )219                    tkinter.messagebox.showinfo(220                        title="Upgrade Database",221                        message=msg,222                    )223                    self.insert_text("\n\n")224                    self.insert_text(msg)225                    self.insert_text("\n")226                    self.insert_text(227                        "".join(228                            (229                                "Cannot use sqlite3 at Python ",230                                _PYTHON_VERSION,231                                " because definition of 'transaction' is ",232                                "not compatible with database being upgraded.",233                            )234                        )235                    )236                    self.insert_text("\n")237                    self.insert_text(238                        "".join(239                            (240                                "Use apsw, or Python 3.6 or later where sqlite3 ",241                                "definition of 'transaction' is compatible.",242                            )243                        )244                    )245    def insert_text(self, text):246        """Wrap Text widget insert with Enable and Disable state configure."""247        self.text.insert(tkinter.END, text)248    def show_menu(self, event=None):249        """Show the popup menu for widget."""250        self.__menu.tk_popup(*event.widget.winfo_pointerxy())251        self.__xy = event.x, event.y252        self.__menu = self.menu253    def close_url(self, event=None):254        """Close the URL."""255        if not tkinter.messagebox.askokcancel(256            title="Close URL", message="Please confirm close URL"257        ):258            return259        self.text.delete("1.0", tkinter.END)260        self.text.insert(tkinter.END, _START_TEXT)261        self.set_menu_and_entry_events_for_open_url(True)262    def browse_localhost_file(self, event=None):263        """Select a directory on localhost."""264        localfilename = tkinter.filedialog.askdirectory(265            parent=self.text,266            title="Select directory containing database to upgrade",267            initialdir="~",268        )269        if localfilename:270            self.contents.set(localfilename)271    def upgrade_database(self, event=None):272        """Upgrade the database in selected directory."""273        if self.contents.get().strip() == "":274            tkinter.messagebox.showerror(275                title="Upgrade Database",276                message="Please choose a database directory to upgrade",277            )278            return279        try:280            b34db = Base_3_to_4_db(281                self.filespec, self.contents.get(), bsddb_dbe282            )283            b34sqlite = Base_3_to_4_sqlite(284                self.filespec, self.contents.get(), sqlite_dbe285            )286        except Base_3_to_4Error as exc:287            tkinter.messagebox.showerror(288                title="Upgrade Database",289                message=str(exc),290            )291            self.insert_text("\n\n")292            self.insert_text("Attempt to upgrade database fails")293            self.insert_text("\n")294            self.insert_text(exc)295            return296        actual_files = set(os.listdir(b34db.database))297        existing_files = b34db.v3files.intersection(actual_files)298        if len(existing_files):299            if os.path.exists(b34db.database_path_v4):300                msg = "".join(301                    (302                        "Database directory contains pre-upgrade and ",303                        "post-upgrade database files.",304                    )305                )306                tkinter.messagebox.showerror(307                    title="Upgrade Database",308                    message=msg,309                )310                self.insert_text("\n\n")311                self.insert_text(msg)312                self.insert_text("\n\n")313                self.insert_text("The pre-upgrade files are:")314                for efname in sorted(existing_files):315                    self.insert_text("\n")316                    self.insert_text(efname)317                self.insert_text("\n\n")318                self.insert_text("The post-upgrade files are:")319                self.insert_text("\n")320                self.insert_text(b34db.database_path_v4)321                if b34db.database_path_v4 != b34sqlite.database_path:322                    if os.path.exists(b34sqlite.database_path):323                        self.insert_text("\n")324                        self.insert_text(b34db.database_path_v4)325                self.insert_text("\n\n")326                self.insert_text(327                    "".join(328                        (329                            "Either the pre-upgrade or the post-upgrade files ",330                            "must be moved out of the directory.",331                        )332                    )333                )334                return335            if os.path.exists(b34sqlite.database_path):336                msg = "".join(337                    (338                        "Database directory contains SQLite and pre-upgrade ",339                        "Berkeley DB database files.",340                    )341                )342                tkinter.messagebox.showerror(343                    title="Upgrade Database",344                    message=msg,345                )346                self.insert_text("\n\n")347                self.insert_text(msg)348                self.insert_text("\n\n")349                self.insert_text("The pre-upgrade files are:")350                for efname in sorted(existing_files):351                    self.insert_text("\n")352                    self.insert_text(efname)353                self.insert_text("\n\n")354                self.insert_text("The SQLite file is:")355                self.insert_text("\n")356                self.insert_text(b34sqlite.database_path)357                self.insert_text("\n\n")358                self.insert_text(359                    "".join(360                        (361                            "Either the SQLite or the pre-upgrade files ",362                            "must be moved out of the directory.",363                        )364                    )365                )366                return367            try:368                missing_tables = b34db.get_missing_v3_tables()369            except AttributeError as exc:370                msg = str(exc)371                if msg == "'NoneType' object has no attribute 'DB'":372                    tkinter.messagebox.showerror(373                        title="Upgrade Database",374                        message=msg,375                    )376                    self.insert_text("\n\n")377                    self.insert_text("Attempt to upgrade database fails.")378                    self.insert_text("\n")379                    self.insert_text("The reported exception is: ")380                    self.insert_text(msg)381                    self.insert_text("\n")382                    self.insert_text(383                        "".join(384                            (385                                "bsddb3 is not available to ",386                                "open a Berkeley DB database.",387                            )388                        )389                    )390                    return391                raise392            if missing_tables:393                msg = "".join(394                    (395                        "Database directory is missing some expected ",396                        "pre-upgrade database files.",397                    )398                )399                tkinter.messagebox.showerror(400                    title="Upgrade Database",401                    message=msg,402                )403                self.insert_text("\n\n")404                self.insert_text(msg)405                self.insert_text("\n\n")406                self.insert_text("The missing pre-upgrade files are:")407                for mtname in sorted(missing_tables):408                    self.insert_text("\n")409                    self.insert_text(mtname)410                return411            b34db.get_v3_segment_size()412            if b34db.segment_size is None:413                msg = "".join(414                    (415                        "Database not upgraded because segment size cannot be ",416                        "determined.",417                    )418                )419                tkinter.messagebox.showinfo(420                    title="Upgrade Database",421                    message=msg,422                )423                self.insert_text("\n\n")424                self.insert_text(msg)425                self.insert_text("\n")426                self.insert_text("Probably the database is empty.")427                self.insert_text("\n")428                self.insert_text(b34db.database_path_v3)429                return430            if b34db.segment_size > SegmentSize.db_segment_size_bytes_maximum:431                msg = "".join(432                    (433                        "Database not upgraded because segment size is bigger ",434                        "than maximum allowed on upgraded database.",435                    )436                )437                tkinter.messagebox.showinfo(438                    title="Upgrade Database",439                    message=msg,440                )441                self.insert_text("\n\n")442                self.insert_text(msg)443                self.insert_text("\n")444                self.insert_text(445                    "".join(446                        (447                            "Segment size is ",448                            str(b34db.segment_size),449                            " and mamimum allowed is ",450                            str(SegmentSize.db_segment_size_bytes_maximum),451                        )452                    )453                )454                return455            if b34db.segment_size < SegmentSize.db_segment_size_bytes_minimum:456                msg = "".join(457                    (458                        "Database not upgraded because segment size is smaller ",459                        "than minimum allowed on upgraded database.",460                    )461                )462                tkinter.messagebox.showinfo(463                    title="Upgrade Database",464                    message=msg,465                )466                self.insert_text("\n\n")467                self.insert_text(msg)468                self.insert_text("\n")469                self.insert_text(470                    "".join(471                        (472                            "Segment size is ",473                            str(b34db.segment_size),474                            " and minimum allowed is ",475                            str(SegmentSize.db_segment_size_bytes_minimum),476                        )477                    )478                )479                return480            # Do Berkeley DB upgrade.481            b34db.convert_v3_to_v4()482            msg = "Database upgraded."483            tkinter.messagebox.showinfo(484                title="Upgrade Database",485                message=msg,486            )487            self.insert_text("\n\n")488            self.insert_text(msg)489            self.insert_text("\n")490            self.insert_text("Upgraded database is:")491            self.insert_text("\n")492            self.insert_text(b34db.database_path_v4)493            return494        if os.path.exists(b34sqlite.database_path):495            if not os.path.isfile(b34sqlite.database_path):496                msg = "".join((b34sqlite.database_path, " is not a file."))497                tkinter.messagebox.showerror(498                    title="Upgrade Database",499                    message=msg,500                )501                self.insert_text("\n\n")502                self.insert_text("Attempt to upgrade database fails.")503                self.insert_text("\n")504                self.insert_text(msg)505                return506            try:507                missing_tables = b34sqlite.get_missing_v3_tables()508            except AttributeError as exc:509                msg = str(exc)510                if msg == "'NoneType' object has no attribute 'Connection'":511                    tkinter.messagebox.showerror(512                        title="Upgrade Database",513                        message=msg,514                    )515                    self.insert_text("\n\n")516                    self.insert_text("Attempt to upgrade database fails.")517                    self.insert_text("\n")518                    self.insert_text("The reported exception is: ")519                    self.insert_text(msg)520                    self.insert_text("\n")521                    self.insert_text(522                        "".join(523                            (524                                "Neither apsw nor sqlite3 is available to ",525                                "open a SQLite3 database.",526                            )527                        )528                    )529                    return530                raise531            except Exception as exc:532                msg = str(exc)533                if (534                    msg.startswith("file ")535                    or msg.startswith("NotADBError: file ")536                ) and msg.endswith(" is not a database"):537                    tkinter.messagebox.showerror(538                        title="Upgrade Database",539                        message=msg,540                    )541                    self.insert_text("\n\n")542                    self.insert_text("Attempt to upgrade database fails.")543                    self.insert_text("\n")544                    self.insert_text("The reported exception is: ")545                    self.insert_text(msg)546                    self.insert_text("\n")547                    self.insert_text(548                        "".join(549                            (550                                b34sqlite.database_path,551                                " may not be a SQLite database.",552                            )553                        )554                    )555                    return556                raise557            existing_tables = b34sqlite.get_existing_v4_tables()558            if missing_tables and existing_tables:559                msg = "".join(560                    (561                        "Some pre-upgrade tables are missing from, and some ",562                        "post-upgrade tables already exist in, the database ",563                        "file.",564                    )565                )566                tkinter.messagebox.showerror(567                    title="Upgrade Database",568                    message=msg,569                )570                self.insert_text("\n\n")571                self.insert_text(msg)572                self.insert_text("\n")573                self.insert_text("Has the database already been upgraded?")574                self.insert_text("\n\n")575                self.insert_text("The missing pre-upgrade tables are:")576                for mtname in sorted(missing_tables):577                    self.insert_text("\n")578                    self.insert_text(mtname)579                self.insert_text("\n\n")580                self.insert_text("The existing post-upgrade tables are:")581                for etname in sorted(existing_tables):582                    self.insert_text("\n")583                    self.insert_text(etname)584                return585            if missing_tables:586                msg = "".join(587                    (588                        "Some pre-upgrade tables are missing from the database ",589                        "file.",590                    )591                )592                tkinter.messagebox.showerror(593                    title="Upgrade Database",594                    message=msg,595                )596                self.insert_text("\n\n")597                self.insert_text(msg)598                self.insert_text("\n")599                self.insert_text("Is database one that should be upgraded?")600                self.insert_text("\n\n")601                self.insert_text("The missing pre-upgrade tables are:")602                for mtname in sorted(missing_tables):603                    self.insert_text("\n")604                    self.insert_text(mtname)605                return606            if existing_tables:607                msg = "".join(608                    (609                        "Some post-upgrade tables already exist in the database ",610                        "file, plus all the pre-upgrade tables which should ",611                        "exist.",612                    )613                )614                tkinter.messagebox.showerror(615                    title="Upgrade Database",616                    message=msg,617                )618                self.insert_text("\n\n")619                self.insert_text(msg)620                self.insert_text("\n\n")621                self.insert_text("The existing post-upgrade tables are:")622                for etname in sorted(existing_tables):623                    self.insert_text("\n")624                    self.insert_text(etname)625                return626            b34sqlite.get_v3_segment_size()627            if b34sqlite.segment_size is None:628                msg = "".join(629                    (630                        "Database not upgraded because segment size cannot be ",631                        "determined.",632                    )633                )634                tkinter.messagebox.showinfo(635                    title="Upgrade Database",636                    message=msg,637                )638                self.insert_text("\n\n")639                self.insert_text(msg)640                self.insert_text("\n")641                self.insert_text("Probably the database is empty.")642                self.insert_text("\n")643                self.insert_text(b34sqlite.database_path)644                return645            if (646                b34sqlite.segment_size647                > SegmentSize.db_segment_size_bytes_maximum648            ):649                msg = "".join(650                    (651                        "Database not upgraded because segment size is bigger ",652                        "than maximum allowed on upgraded database.",653                    )654                )655                tkinter.messagebox.showinfo(656                    title="Upgrade Database",657                    message=msg,658                )659                self.insert_text("\n\n")660                self.insert_text(msg)661                self.insert_text("\n")662                self.insert_text(663                    "".join(664                        (665                            "Segment size is ",666                            str(b34sqlite.segment_size),667                            " and mamimum allowed is ",668                            str(SegmentSize.db_segment_size_bytes_maximum),669                        )670                    )671                )672                return673            if (674                b34sqlite.segment_size675                < SegmentSize.db_segment_size_bytes_minimum676            ):677                msg = "".join(678                    (679                        "Database not upgraded because segment size is smaller ",680                        "than minimum allowed on upgraded database.",681                    )682                )683                tkinter.messagebox.showinfo(684                    title="Upgrade Database",685                    message=msg,686                )687                self.insert_text("\n\n")688                self.insert_text(msg)689                self.insert_text("\n")690                self.insert_text(691                    "".join(692                        (693                            "Segment size is ",694                            str(b34sqlite.segment_size),695                            " and minimum allowed is ",696                            str(SegmentSize.db_segment_size_bytes_minimum),697                        )698                    )699                )700                return701            # Do SQLite upgrade.702            sql = b34sqlite.compose_sql_to_convert_v3_to_v4()703            b34sqlite.convert_v3_to_v4(sql)704            msg = "Database upgraded."705            tkinter.messagebox.showinfo(706                title="Upgrade Database",707                message=msg,708            )709            self.insert_text("\n\n")710            self.insert_text(msg)711            self.insert_text("\n")712            self.insert_text("Upgraded database is:")713            self.insert_text("\n")714            self.insert_text(b34sqlite.database_path)715            return716        msg = "Selected directory does not contain an upgradable database."717        tkinter.messagebox.showerror(718            title="Upgrade Database",719            message=msg,720        )721        self.insert_text("\n\n")722        self.insert_text("Attempt to upgrade database fails.")723        self.insert_text("\n")724        self.insert_text(msg)725        self.insert_text("\n")726        self.insert_text(self.contents.get())727        return728    def set_menu_and_entry_events_for_open_url(self, active):729        """Turn database upgrade events on if active is True otherwise off."""730        menu = self.menu731        if active:732            menu.add_command(733                label="Upgrade Database",734                command=self.upgrade_database,735                accelerator="Alt F4",736            )737            menu.add_command(738                label="Select Database Directory",739                command=self.browse_localhost_file,740                accelerator="Alt F5",...dataio.py
Source:dataio.py  
1import re2import sys3from PIL import Image as PIL_Image4from PIL import ImageDraw as PIL_ImageDraw5from PIL import ImageFont as PIL_ImageFont6from .params import Cols, Paths7from .pdfio import Regaletiketten3X8YverDataFromPdf8from .sanity_checks import SanityTests, sanitize_data_decorator9from .db_utils import read_from_db_decorator, write_to_db_decorator10from .web_utils import ForstingerProduktSoup11def preis_helper(preis):12    preis = format(float(preis), '.2f')13    preis = str(preis).replace('.', ',')14    if len(preis.split(',')[0]) >= 4:15        preis = f'{preis[:-6]}.{preis[-6:]}'16    if preis.split(',')[1] == '00':17        preis = f"⬠{preis.split(',')[0]},-"18    else:19        preis = f'⬠{preis}'20    return preis21def index_helper(string='', length=0):22    string = ''.join([i for i in string if not i.isspace()])23    if not string:24        string = '0'25    else:26        if not re.match('^[0-9]+(?:[,-][0-9]+)*$', string):27            raise Exception('Nicht gut!')                                             # TODO! Exception!28    indices = string.split(',')29    ranges = [i.split('-') for i in indices if not i.isnumeric()]30    indices = set(int(i) for i in indices if i.isnumeric())31    for i in ranges:32        lower, upper = int(i[0]), int(i[1])33        if len(i) > 2 or lower >= upper:34            raise Exception('Nicht gut!')                                             # TODO! Exception!35        else:36            indices.update(range(lower, upper+1))37    if max(indices) > length:38        raise Exception('Nicht gut!')                                               # TODO! Exception!39    return sorted(indices)40class GenericData(SanityTests):41    global_vars = {}42    to_pdf_registry = {}43    types = {Cols.ARTTEXT1: '', 44            Cols.ARTTEXT2: '', 45            Cols.ARTNR: 0, 46            Cols.STATT: 0, 47            Cols.PREIS: 0}48    def __init_subclass__(cls, **kwargs):49        cls._name = kwargs.get('_name', cls.__name__)50        if cls.__dict__.get('from_pdf'):51            if not getattr(sys.modules[__name__], f'{cls.__name__}FromPdf'):52                raise NotImplementedError53        if cls.__dict__.get('to_pdf'):54            GenericData.types[cls._name] = False55            GenericData.to_pdf_registry[cls._name] = cls56        super().__init_subclass__()57    @read_from_db_decorator58    @sanitize_data_decorator59    def __init__(self, df_dict, *args, parent=None, **kwargs):60        self.df_dict = df_dict61        self.child = None62        if parent:63            self.parent = parent64            self.parent.child = self65    @classmethod66    def edit_df(cls, *args, user_input=None, parent=None, 67            df_dict=None, index=None, **kwargs):68        if not df_dict:69            raise Exception('Holla, holla!')                                          # TODO! Exception!70        user_input = user_input or dict()71        user_input = {key: user_input[key] for key in user_input if key in cls.types and user_input[key]}72        r = index_helper(index, max(map(len, df_dict.values()))-1)73        for key in cls.types:74            for i in r:75                df_dict[key][i] = user_input.get(key, df_dict[key][i])76        return cls(df_dict, parent=parent)77    @classmethod78    def from_input(cls, *args, user_input=None, parent=None, 79            df_dict=None, **kwargs):80        user_input = user_input or dict()81        df_dict = df_dict or {key: [] for key in cls.types}82        for key in cls.types:83            df_dict[key].append(user_input.get(key, cls.types[key]))84        return cls(df_dict, parent=parent)85    @classmethod86    def from_pdf(cls, *args, **kwargs):87        raise NotImplementedError88    @classmethod89    def from_web(cls, *args, user_input=None, parent=None, soup=None, 90            db_search=True, web_search=True, df_dict=None, artnr=None, **kwargs):91        if not artnr:92            raise Exception('Bruder, gib mir eine Artnr.!')                           # TODO! Exception!93        if not db_search and not web_search:94            raise Exception('Du hast die Suchfunktion deaktiviert!')                  # TODO! Exception!95        req = [i for i in (*cls.to_pdf_registry, Cols.ARTNR)]96        user_input = user_input or dict()97        user_input = {key: user_input[key] for key in user_input if key in req}98        df_dict = df_dict or {key: [] for key in cls.types}99        if web_search:100            soup = ForstingerProduktSoup(artnr)101        rstart = max(map(len, df_dict.values()))-1102        for key in cls.types:103            if key in user_input.keys():104                df_dict[key].append(user_input[key])105            else:106                find = getattr(soup, f'find_{key.lower()}', lambda i: i)107                df_dict[key].append(find(cls.types[key]))108        r = range(rstart+1, rstart, -1)109        return cls(df_dict, parent=parent, db_search=db_search, r=r, sanitize=True)110    @write_to_db_decorator111    def to_pdf(self, *args, df_dict=None, **kwargs):112        if not df_dict:113            raise Exception('Du hast nix eingespielt!')                               # TODO! Exception!114        pages = {cls_name: [] for cls_name in self.to_pdf_registry.keys()}115        cnt = {cls_name: 0 for cls_name in self.to_pdf_registry.keys()}116        keys = set(self.types.keys()) - set(self.to_pdf_registry.keys())117        for index in range(max(map(len, df_dict.values()))):118            for cls_name in self.to_pdf_registry.keys():119                if df_dict[cls_name][index]:120                    cls = self.to_pdf_registry.get(cls_name)121                    if not cnt[cls_name] % cls.max_tags:122                        pages[cls_name].append(PIL_Image.new('RGB', cls.dim, (255, 255, 255)))123                    insert_text = PIL_ImageDraw.Draw(pages[cls_name][-1])124                    cls.to_pdf(df_dict, index, keys, insert_text, cnt[cls_name])125                    cnt[cls_name] += 1126        return pages127class Regaletiketten3X8YverData(GenericData):128    @classmethod129    def from_pdf(cls, *args, user_input=None, parent=None, df_dict=None, 130            db_search=True, **kwargs):131        user_input = user_input or dict()132        user_input = {key: user_input[key] for key in user_input if key in cls.to_pdf_registry}133        df_dict = df_dict or {key: [] for key in cls.types}134        rstart = max(map(len, df_dict.values()))-1135        tags = getattr(sys.modules[__name__], f'{cls.__name__}FromPdf')()136        for tag in tags:137            for key in cls.types:138                if key in user_input.keys():139                    df_dict[key].append(user_input.get(key, cls.types[key]))140                else:141                    extract = getattr(tags, f'extract_{key.lower()}', lambda i,j: j)142                    df_dict[key].append(extract(tag, cls.types[key]))143        rstop = max(map(len, df_dict.values()))-1144        r = range(rstop, rstart, -1)145        return cls(df_dict, parent=parent, db_search=db_search, r=r)146class Preisschilder2X2YhorData(GenericData, _name='A6'):147    dim = (3508, 2480)148    margin = 165149    offset = ((0, 0), (0, 1240), (1754, 0), (1754, 1240))150    fonts = {Cols.ARTTEXT1: PIL_ImageFont.truetype(Paths.SUSE_SANS_BOLD, 95), 151            Cols.ARTTEXT2: PIL_ImageFont.truetype(Paths.SUSE_SANS, 70), 152            Cols.ARTNR: PIL_ImageFont.truetype(Paths.SUSE_SANS, 45), 153            Cols.STATT: PIL_ImageFont.truetype(Paths.SUSE_SANS, 45), 154            Cols.PREIS: PIL_ImageFont.truetype(Paths.SUSE_SANS_BOLD, 118)}155    yaxis = {Cols.ARTTEXT1: 508, 156            Cols.ARTTEXT2: 635, 157            Cols.ARTNR: 750, 158            Cols.STATT: 915, 159            Cols.PREIS: 985}160    max_tags = 4161    @classmethod162    def to_pdf(cls, df_dict, index, keys, insert_text, cnt, *args, **kwargs):163        cnt = cnt % cls.max_tags164        for key in keys:165            func = getattr(cls, f'insert_{key.lower()}')166            func(insert_text, key, df_dict[key][index], cnt)167    @classmethod168    def insert_arttext1(cls, insert_text, key, value, index, *args, **kwargs):169        x, y = cls.offset[index]170        koords = (cls.margin+x, cls.yaxis[key]+y)171        arttext1 = ' '.join([line.strip() for line in value.split('$')])172        insert_text.text(koords, arttext1, (0, 0, 0), font=cls.fonts[key])173    @classmethod174    def insert_arttext2(cls, insert_text, key, value, index, *args, **kwargs):175        x, y = cls.offset[index]176        koords = (cls.margin+x, cls.yaxis[key]+y)177        arttext2 = ' '.join([line.strip() for line in value.split('$')])178        insert_text.text(koords, arttext2, (0, 0, 0), font=cls.fonts[key])179    @classmethod180    def insert_artnr(cls, insert_text, key, value, index, *args, **kwargs):181        x, y = cls.offset[index]182        koords = (cls.margin+x, cls.yaxis[key]+y)183        insert_text.text(koords, f'Artnr.: {value}', (0, 0, 0), font=cls.fonts[key])184    @classmethod185    def insert_statt(cls, insert_text, key, value, index, *args, **kwargs):186        x, y = cls.offset[index]187        koords = (cls.margin+x, cls.yaxis[key]+y)188        if not value:189            insert_text.text(koords, 'Jetzt nur:', (0, 0, 0), font=cls.fonts[key])190        else:191            value = preis_helper(value)192            insert_text.text(koords, f'Statt: {value}', (0, 0, 0), font=cls.fonts[key]) 193    @classmethod194    def insert_preis(cls, insert_text, key, value, index, *args, **kwargs):195        x, y = cls.offset[index]196        koords = (cls.margin+x, cls.yaxis[key]+y)197        value = preis_helper(value)198        insert_text.text(koords, value, (0, 0, 0), font=cls.fonts[key])199class Preisschilder1X1YverData(GenericData, _name='A4'):200    dim = (2480, 3508)201    margin = 185202    fonts = {Cols.ARTTEXT1: PIL_ImageFont.truetype(Paths.SUSE_SANS_BOLD, 165), 203            Cols.ARTTEXT2: PIL_ImageFont.truetype(Paths.SUSE_SANS, 110), 204            Cols.ARTNR: PIL_ImageFont.truetype(Paths.SUSE_SANS, 45), 205            Cols.STATT: PIL_ImageFont.truetype(Paths.SUSE_SANS, 100), 206            Cols.PREIS: PIL_ImageFont.truetype(Paths.SUSE_SANS_BOLD, 280)}207    yaxis = {Cols.ARTTEXT1: [1700, 1900], 208            Cols.ARTTEXT2: [2120, 2250], 209            Cols.ARTNR: 2420, 210            Cols.STATT: 2780, 211            Cols.PREIS: 2950}212    max_tags = 1213    @classmethod214    def to_pdf(cls, df_dict, index, keys, insert_text, *args, **kwargs):215        for key in keys:216            func = getattr(cls, f'insert_{key.lower()}')217            func(insert_text, key, df_dict[key][index])218    @classmethod219    def insert_arttext1(cls, insert_text, key, value, *args, **kwargs):220        koords = [(cls.margin, i) for i in cls.yaxis[key]]221        arttext1 = value.split('$', maxsplit=1)222        for i, line in enumerate(arttext1[::-1]):223            insert_text.text(koords[i-1], line.strip(), (0, 0, 0), font=cls.fonts[key])224    @classmethod225    def insert_arttext2(cls, insert_text, key, value, *args, **kwargs):226        koords = [(cls.margin, i) for i in cls.yaxis[key]]227        arttext2 = value.split('$', maxsplit=1)228        for i, line in enumerate(arttext2):229            insert_text.text(koords[i], line.strip(), (0, 0, 0), font=cls.fonts[key])230    @classmethod231    def insert_artnr(cls, insert_text, key, value, *args, **kwargs):232        koords = (cls.margin, cls.yaxis[key])233        insert_text.text(koords, f'Artnr.: {value}', (0, 0, 0), font=cls.fonts[key])234    @classmethod235    def insert_statt(cls, insert_text, key, value, *args, **kwargs):236        koords = (cls.margin, cls.yaxis[key])237        if not value:238            insert_text.text(koords, 'Jetzt nur:', (0, 0, 0), font=cls.fonts[key])239        else:240            value = preis_helper(value)241            insert_text.text(koords, f'Statt: {value}', (0, 0, 0), font=cls.fonts[key]) 242    @classmethod243    def insert_preis(cls, insert_text, key, value, *args, **kwargs):244        koords = (cls.margin, cls.yaxis[key])245        value = preis_helper(value)...LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!
