def do_this_onClose(): if yesno("Close", "Do you want to close the app?"): app.destroy() #GUI zero app = App(title="JWS translate", width=450, height=350, layout="grid") choice = Combo(app, options=[ "Auto", "English", "Korean", "Chinese", "Spanish", "Japanese", "Vietnamese", "French", "Thai", "Arabic", "Russian", "German", "Italian", "Greek" ], grid=[1, 0], align="left") description = Text(app, text="Select the Language: ", grid=[0, 0]) check = TextBox(app, text="", grid=[1, 1], width=35, height=6, scrollbar=True, multiline=True) descripChek = Text(app, text="Content: ", grid=[0, 1], align="left") buttons = Combo(app, options=[ "English", "Korean", "Chinese", "Spanish", "Japanese", "Vietnamese", "French", "Thai", "Arabic", "Russian", "German", "Italian", "Greek" ], grid=[1, 3],
def DisplayTwo(): button15.enable() button18.enable() button16.enable() button21.enable() checkbox.clear() #Clears Textboxes checkbox2.clear() checkbox3.clear() checkbox4.clear() checkbox5.clear() checkbox6.clear() suite1 = random.randint(0, 3) #Define suites randomly33 suite2 = random.randint(0, 3) suite3 = random.randint(0, 3) suite4 = random.randint(0, 3) random.shuffle(RDiamo) #Shuffle each suite random.shuffle(RHeart) random.shuffle(BClove) random.shuffle(BSpade) cardno1 = cardList[suite1][0] #choose cards cardno2 = cardList[suite2][1] cardno3 = cardList[suite3][2] cardno4 = cardList[suite4][3] card1val = cardno1 + 13 * (suite1) #display card as the suite card2val = cardno2 + 13 * (suite2) card3val = cardno3 + 13 * (suite3) card4val = cardno4 + 13 * (suite4) randCard1 = "Images/" + str( card1val) + ".png" #define what card is going to be displayed randCard2 = "Images/" + str(card2val) + ".png" randCard3 = "Images/" + str(card3val) + ".png" randCard4 = "Images/" + str(card4val) + ".png" Text(window5, text=" ", color="#000000", size="10", grid=[0, 5]) Text(window4, text=" ", color="#000000", size="10", grid=[0, 5]) Title = Text(window6, text="Correct! ", color="#000000", font="Ariel", size="25", grid=[1, 1]) Title = Text(window8, text="Results ", color="#000000", font="Ariel", size="25", grid=[0, 0]) picture1 = Picture(window2, image=randCard1, grid=[0, 1]) #define the picture picture2 = Picture(window2, image=randCard2, grid=[0, 2]) picture3 = Picture(window3, image=randCard1, grid=[0, 1]) picture4 = Picture(window3, image=randCard2, grid=[0, 2]) picture5 = Picture(window4, image=randCard1, grid=[0, 1]) picture6 = Picture(window4, image=randCard2, grid=[0, 2]) picture7 = Picture(window4, image=randCard3, grid=[2, 1]) picture8 = Picture(window4, image=randCard4, grid=[2, 2]) picture9 = Picture(window5, image=randCard1, grid=[0, 1]) picture10 = Picture(window5, image=randCard2, grid=[0, 2]) picture11 = Picture(window5, image=randCard3, grid=[2, 1]) picture12 = Picture(window5, image=randCard4, grid=[2, 2]) global total, inputcheck, p1field, p2field, p1total, p2total, cards, score, p1score, p2score, p1dis, p2dis #Globally define variables if players == 1: #Determine Total for one player game cards -= 2 if addcheck == True: #Addition gamemode total = cardList[suite1][0] + cardList[suite2][1] ShowWTwo() inputcheck = checkbox if subcheck == True: #Subtraction gamemode total = cardList[suite1][0] - cardList[suite2][1] ShowWThr() inputcheck = checkbox2 if cards == 0 or cards <= 0: reset() score = score Title = Text(window6, text="Final Score (Out Of Cards)", color="#000000", font="Ariel", size="50", grid=[1, 1]) window6.show() button16.disable() print("Single Player Total: ", total) if players == 2: #Determine Total's for two player game cards -= 4 if addcheck == True: #Addition Gamemode p1total = cardList[suite1][0] + cardList[suite2][1] p2total = cardList[suite3][2] + cardList[suite4][3] ShowWFou() p1field = checkbox3 p2field = checkbox4 if subcheck == True: #Subtraction Gamemode p1total = cardList[suite1][0] - cardList[suite2][1] p2total = cardList[suite3][2] - cardList[suite4][3] ShowWFiv() p1field = checkbox5 p2field = checkbox6 if cards == 0 or cards <= 0: reset() p1score = p1score p2score = p2score Title = Text(window8, text="Results (Out Of Cards)", color="#000000", font="Ariel", size="25", grid=[0, 0]) window8.show() button21.disable() print("Player 1: ", p1total) print("Player 2: ", p2total) scoremsg = ("Your Score Is: " + str(score)) p1dis = ("Player One Scored: " + str(p1score)) p2dis = ("Player Two Scored: " + str(p2score)) Dis = Text(window8, text=p1dis, color="#000000", font="Ariel", size="10", grid=[0, 1]) Dis1 = Text(window8, text=p2dis, color="#000000", font="Ariel", size="10", grid=[0, 2]) Score = Text(window6, text=scoremsg, color="#000000", font="Ariel", size="25", grid=[1, 3]) Score1 = Text(window7, text=scoremsg, color="#000000", font="Ariel", size="25", grid=[1, 3])
from guizero import App, PushButton, Slider, Text from pymongo import MongoClient #https://lawsie.github.io/guizero/alerts/ c = MongoClient() db = c["mydatabase"] article = db.articles app = App(title="PosNews") i = 0 find_data = article.find({'source': 'CNBC'}) obj = next(find_data, None) while (obj): Text(app, text=obj['title']) obj = next(find_data, None) i = i + 1 if (i == 11): break #message = Text(app, text="Welcome to the Hello world app!") app.display()
# # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this program. If not, see <http://www.gnu.org/licenses/>. # ################################################################################ from guizero import App, Text, PushButton import requests import json app = App("Blinkt Control", layout="grid") def blinkt_on(): r = requests.get('http://192.168.1.104:5000/blinkt/api/v1.0/on') def blinkt_off(): r = requests.get('http://192.168.1.104:5000/blinkt/api/v1.0/off') Text(app, "Blinkt", grid=[2, 2]) PushButton(app, command=blinkt_on, text="On", grid=[2, 3]) PushButton(app, command=blinkt_off, text="Off", grid=[2, 4]) app.display()
def change_color(value): t.text_color = value def update_text(): if mlistbox.value is None: t.value = "Its a ListBox" else: t.value = "Its a " + " ".join(mlistbox.value) + " ListBox" a = App() t = Text(a, text="Its a ListBox", color="black") listbox = ListBox(a, items=[ "red", "green", "blue", "yellow", "purple", "turquoise", "pink", "orange", "black", "brown", "cyan" ], selected="black", command=change_color, scrollbar=True) mlistbox = ListBox(a, items=[ "really", "slightly", "brilliant", "interesting", "but", "and", "rubbish", "stupid" ],
command=cartScreen, text="View Cart", align="right") menuButton = PushButton(buttonBox, command=menuScreen, text="Menu", align="left") addtocartButton = cartButton = PushButton(buttonBox, command=addtocart, text="Add to cart", align="right") #welcome welcomeMessage = Text(app, text="Welcome to the Pizza Place!", size=25, font="Times New Roman", color="black", align="top") pizzaGif = Picture(app, image="homer.gif") #menu menuMessage = Text(app, text="Main Menu", size=25, font="Times New Roman", color="black", align="top") menuMessage.hide() buttonsBox = Box(app, border=1, grid=[0, 1], align="top", layout="grid") buttonsBox.hide()
#https://projects.raspberrypi.org/en/projects/getting-started-with-guis/1 #Documentation: https://lawsie.github.io/guizero/ from guizero import App, Combo, Text, CheckBox, ButtonGroup, PushButton, info def doBooking(): info("Booking", "Thank you for booking") print(filmChoice.value) print(vipSeat.value) print(rowChoice.value) app = App(title="Second GUI app", width=300, height=200, layout="grid") #Grid 0,0 top left filmDescription = Text(app, text="Which Film?", grid=[0, 0], align='left') filmChoice = Combo(app, options=["Star Wars", "Frozen", "Lion King"], grid=[1, 0], align="left") seatDescription = Text(app, text="Seat type", grid=[0, 1], align='left') vipSeat = CheckBox(app, text="VIP Seat?", grid=[1, 1], align="left") rowDescription = Text(app, text="Seat Location", grid=[0, 2], align='left') rowChoice = ButtonGroup(app, options=[["Front", "F"], ["Middle", "M"], ["Back", "B"]], selected="M", horizontal=True, grid=[1, 2],
menubar = MenuBar(app, toplevel=["File", "Edit", "Settings"], options=[[["File option 1", DoSomething], ["File option 2", DoSomething]], [["Edit option 1", DoSomething], ["Edit option 2", DoSomething]], [["Settings option 1", DoSomething], ["Settings option 1", DoSomething]]]) textbox = TextBox(app, align="bottom") text = Text(app, align="top", text="Hello GUI", color="blue", font="Times New Roman", size="30") text1 = Text(app, align="bottom", text="General Kenobi") picture = Picture(app, image="picture1.png", width=300, height=300) picture1 = Picture(app, image="picture2.png", width=300, height=300) slider = Slider(app, align="bottom", command=SliderChanged) checkbox = CheckBox(app, text="Burn the Gays!", command=CheckBoxChanger) button = PushButton(app, text="Push me!", command=DoSomething) button.bg = "green" # text_color # text_size
# 05_thermometer_f.py # From the code for the Box 1 kit for the Raspberry Pi by MonkMakes.com from PiAnalog import * from guizero import App, Text import time p = PiAnalog() # Update the temperature reading def update_temp(): temperature = p.read_temp_f() temperature = "%.2f" % temperature # Round the temperature to 2 d.p. temp_text.value = temperature temp_text.after(1000, update_temp) # Create the GUI app = App(title="Thermometer", width="400", height="300") Text(app, text="Temp F", size=32) temp_text = Text(app, text="0.00", size=110) temp_text.after(1000, update_temp) # Used to update the temperature reading app.display()
from guizero import App, Text app = App(title='Hello GUI') message = Text(app, text='Hello I am some text!') app.display()
# # Basic Sample # from guizero import App, Text, Picture from guizero import system_config app = App(title="Hello World") app.bg = (251, 251, 208) message = Text(app, text="Deal with\nconfinement") message.text_size = 50 message.font = "Courier" print(system_config.supported_image_types) maze = Picture(app, image='./confinement.jpg') (width, height) = (maze.width // 6, maze.height // 6) maze = maze.resize(width=width, height=height) app.display()
def insultame(): palabra_a = random.choice(lista_a) palabra_b = random.choice(lista_b) palabra_c = random.choice(lista_c) insulto = "¡Tú " + palabra_a + " " + palabra_b + " " + palabra_c + "!" return insulto def nuevo_insulto(): nuevo_insulto = insultame() mensaje.value = nuevo_insulto lista_a = [] lista_b = [] lista_c = [] with open("insultos.csv", "r") as archivo: for linea in archivo: palabras = linea.split(",") lista_a.append(palabras[0]) lista_b.append(palabras[1]) lista_c.append(palabras[2].strip()) app = App("Generador de insultos Shakespearianos") mensaje = Text(app, insultame()) boton = PushButton(app, nuevo_insulto, text="Insúltame de nuevo") app.display()
control_app.tk.config(cursor='none') control_app.repeat(1000, thermalCountUp) # Feedback Window FeedbackWindow = Window(control_app) FeedbackWindow.text_size = 18 FeedbackWindow.font = 'Nexa Bold' FeedbackWindow.tk.attributes('-fullscreen',True) FeedbackWindow.height = 480 FeedbackWindow.width = 800 FeedbackWindow.hide() FeedbackWindow.bg = 'black' FeedbackWindow.tk.config(cursor='none') # buttons on feedback window gap = Text(FeedbackWindow,'') happy = Picture(FeedbackWindow, 'happy.gif') happy.when_clicked = goodFeedback gap = Text(FeedbackWindow,'') #happyText = Text(FeedbackWindow, text = 'I learned something\n new today!', grid = [1,0], color = 'white', align = 'left') confused = Picture(FeedbackWindow,'confused.gif') confused.when_clicked = badFeedback #confText = Text(FeedbackWindow, text = "I'm still not sure...", grid = [1,1], color = 'white', align = 'left') #smiley1 = PushButton(FeedbackWindow, text=':)', command=smiley1_callback) #smiley2 = PushButton(FeedbackWindow, text=':(', command=smiley2_callback) # Additional information window infoWindow = Window(control_app, layout='grid') infoWindow.hide() infoWindow.bg = 'black'
} if game in LOSSES: outcome = 'Better luck next time!' elif game in TIES: outcome = "It's a tie!" else: outcome = 'You win!' end_game_message = 'You picked {} and the computer picked {}. {}'.format(game['player'], game['computer'], outcome ) message.value = end_game_message throw.image = IMG_NAME button.text = 'Play again!' app = App(title='Rock Paper Scissors') content_box = Box(app, width='fill', align='top') message = Text(content_box, text="Ready to play?") throw = Picture(content_box, image='throw.jpg') button_box = Box(app, width='fill', align='bottom') # Wire the button to our play_game function button = PushButton(button_box, text='Play!', command=play_game) app.display()
def ende(x, y): if board[x, y].dotty == True: board[x, y].dotty = False board.set_pixel(x, y, "white") end = time.perf_counter() timeused = round((end - starttime) * 1000) / 1000 timedisplay = Text(app, text="Your reaction-time: " + str(timeused) + "s") timedisplay.text_color = "white" timedisplay.font = "Impact" board.update_command(ende) x, y = random.randint(0, 4), random.randint(0, 4) board[x, y].dotty = True board.set_pixel(x, y, "red") app = App(title="Reaktionstest") app.bg = "black" free = Text(app, text="\n\n\n\n\n\n") welcome_message = Text( app, text="Welcome to the reaction test. \nHere you can test your reaction.") welcome_message.text_color = "white" welcome_message.font = "Impact" free2 = Text(app, text="\n") button = PushButton(app, test, text="Start") button.text_color = "white" app.display()
if __name__ == '__main__': with open("insults.csv", "r") as f: for line in f: lineArr = line.rstrip().split(',') list_a.append(lineArr[0]) list_b.append(lineArr[1]) list_c.append(lineArr[2]) app = App(title="Shakespearean insult generator", width=450, height=300, layout="grid") message = Text(app, insult_me(), grid=[0, 0], align="left") rand_button = PushButton(app, new_insult, text="Insult me again", pady=5, padx=5, grid=[1, 0], align="left") menu1 = Combo(app, options=list_a, grid=[0, 2], align="top") menu2 = Combo(app, options=list_b, grid=[0, 3], align="top") menu3 = Combo(app, options=list_c, grid=[0, 4], align="top") use_button = PushButton(app, set_insult, text="Use insult",
# Method responsible for changing text size value def changeTextSize(sliderValue): welcomeMessage.size = sliderValue return # Set app name app = App(title="Hello world") # Widgets (text, text boxes, buttons, etc) # Text widget welcomeMessage = Text(app, text="Welcome to my app", size=40, font="Times New Roman", color="lightblue") # Text box widget myName = TextBox(app) # Update text button updateText = PushButton(app, command=displayMyName, text="Display my name") # Slider widget textSize = Slider(app, command=changeTextSize, start=10, end=80) # Picture widget image = Picture( app,
from guizero import App, Text, PushButton from random import choice # Functions ------------------ def choose_name(): #print("Button was pressed") first_names = [ "Barbara", "Woody", "Tiberius", "Smokey", "Jennifer", "Ruby" ] last_names = [ "Spindleshanks", "Mysterioso", "Dungeon", "Catseye", "Darkmeyer", "Flamingobreath" ] spy_name = choice(first_names) + " " + choice(last_names) #print(spy_name) name.value = spy_name # App ------------------------ app = App("Top Secret") # Widgets -------------------- title = Text(app, "Push the red button to find out your spy name") button = PushButton(app, choose_name, text="Tell me!") button.bg = "red" button.text_size = 30 name = Text(app, text="") # Display -------------------- app.display()
# to the bottom but also has a set height - it makes a nice space between the sliders and the output crop, that previously # were too close to each other influence_subArea = Box(influence_area, align="top", border=showBorders, width="fill") output_subArea = Box(influence_area, align="bottom", border=showBorders, width="fill", height=75) # Here's mostly your old code. I just replaced every `command = value` with loopUpdate command so we have everything streamlined # Changed also some namings and aligns so it fits better into boxes I made. I you want old monkey names back, just let me know # They were awesome. Oh, I also changed the master parameter (app) to appropriate boxes in which they are now seed_lable = Text(seedType_subArea, text="Seeds", align="top") seedbox = ButtonGroup(seedType_subArea, options=[ "Nothing", "Cereal", "Cabbage", "Cotton", "Corn", "Potato", "Pumpkin", "Tobacco" ], command=loopUpdate, align="top") # I added a parameter to pumpkin_stage so it is drawn in horizontal button group which looks nicer pumkin_lable = Text(pumpTier_subArea, text="Pumpkin Stage", align="top", height="fill") pumkin_stage = ButtonGroup(pumpTier_subArea, options=["1", "2", "3"],
def push_stop(): stream.stop_stream() def change_gain(): global audio_gain audio_gain = slider_gain.value / 100 ##### <<<<<<<<< SETUP AUDIO STREAM >>>>>>>>> ##### p = pyaudio.PyAudio() stream = p.open(format=pyaudio.paInt16, channels=output_channels, rate=fs, output=True, stream_callback=playingCallback, output_device_index=output_index, frames_per_buffer=frame_size) stream.stop_stream() ##### <<<<<<<<< CONFIGURE GUI >>>>>>>>> ##### playback_app = App(title="Playback App") play_button = PushButton(playback_app, command=push_play, text="Play the Tune") play_button = PushButton(playback_app, command=push_stop, text="Stop the Tune") annotation = Text(playback_app, text="Adjust the Volume", size=20) slider_gain = Slider(playback_app, command=change_gain) conv_flag = CheckBox(playback_app, text="Filtering?") playback_app.display()
from threading import Thread from time import sleep class UpdateThread(Thread): def __init__(self, FLMessage): Thread.__init__(self) self.FLMessage = FLMessage self.count = 0 def run(self): while True: self.count = self.count + 1 self.FLMessage.value = str(self.count) sleep(1.0) app = App(title="Thunderbird 2", layout="grid") top_message = Text(app, text="ToF Sensor Output", grid=[1, 0]) front_left_message = Text(app, text="0.0", grid=[1, 1], align="left") front_right_message = Text(app, text="0.0", grid=[1, 1], align="right") left_message = Text(app, text="0.0", grid=[0, 2], align="right") tb2 = Picture(app, image="TB2Top.png", grid=[1, 2]) left_message = Text(app, text="0.0", grid=[2, 2], align="left") updater = UpdateThread(front_left_message) updater.daemon = True updater.start() app.display()
import dbus import bluetooth #discovering BT devices #bus = dbus.SystemBus() #hal_manager_object = bus.get_object('org.bluez', '/org/bluez/hci1/dev_48_13_7E_BC_48_A4') #hal_manager_media_interface = dbus.Interface(hal_manager_object, 'org.bluez.MediaControl1') app = App(layout="grid", bg="white", title="Bluetooth Player", width=490, height=300) result = Text(app, grid=[0, 0]) result.value = '' map_devices = {} hal_manager_media_interface = None sms_interface = None def play(): print(hal_manager_media_interface) hal_manager_media_interface.Play() def pause(): hal_manager_media_interface.Pause()
wiki_text.clear() wiki_text.append(updated_text) wiki_text.disable() # Create the application app = App(title='Amazing Image Identifier') # Create an invisible box to hold the title — useful for setting up complex layouts title_box = Box(app, width='fill', align='top') # Create the title and centre it in the application title = Text(title_box, text="Amazing Image Identifier") # Create an invisible box to hold the image and article text content_box = Box(app, width='fill', align='top') # Create an invisible box to hold the image picture_box = Box(content_box, align='left') # Create the image and set it to the start.jpg file included in this directory display_image = Picture(picture_box, image=generate_display_picture('start.jpg', DISPLAY_IMAGE_SIZE)) # Create the text box for article text wiki_text = TextBox(content_box, multiline=True, enabled=False, scrollbar=True, text="Please choose an image to identify.",
a2 = int(a2_box.value) a3 = int(a3_box.value) f1 = m1 * a1 f2 = m1 * a2 f3 = m1 * a3 f1_text.value = " F1 : " + str(round(f1, 5)) f2_text.value = " F2 : " + str(round(f2, 5)) f3_text.value = " F3 : " + str(round(f3, 5)) print("pressed") app = App(title="Program Speed Tracker", width=350, height=730, layout="auto") text = Text(app, text="________________________________________") text = Text(app, text="TABEL WAKTU") text = Text(app, text="---------------------") box1 = Box(app, layout="grid") text = Text(box1, text="No", grid=[0, 0]) text = Text(box1, text="t (sec)", grid=[1, 0]) #text = Text(box1, text="s (cm)", grid=[2,0]) text = Text(box1, text="------", grid=[0, 1]) text = Text(box1, text="------", grid=[1, 1]) #text = Text(box1, text="------",grid=[2,1]) text = Text(box1, text="1", grid=[0, 2]) text = Text(box1, text=t1, grid=[1, 2]) #text = Text(box1, text=s1, grid=[2,2]) text = Text(box1, text="2", grid=[0, 3])
title="Score The Cards", height=360, width=520, layout="grid", bg="#FFA500") window8 = Window(app, title="Score The Cards", height=360, width=520, layout="grid", bg="#FFA500") #Main Menu Title = Text(app, text="Score the Cards!", color="#000000", font="Ariel", size="25", align="top") Formatting = Text(app, text="LLLLLLL", color="#00FFFF", font="Ariel", size="10", align="left") Formatting2 = Text(app, text="LLLLLLL", color="#00FFFF", font="Ariel", size="10", align="right") Addbut = PushButton(app, command=Addition, align="left", text="Addition")
from guizero import App, Text app = App(title="this is my first GUI") # first message, blue and big message = Text(app, text="guis are cool!", size=40, color="blue") # second message, black message_2 = Text(app, text="another message") # displays GUI app.display()
def Check(): global scoremsg, score, p1dis, p2dis, p1score, p2score if players == 1: try: test = int(inputcheck.value) except: reset() window7.show() else: if int(inputcheck.value) == total: score = score + 1 reset() window6.show() elif int(inputcheck.value) != total: score = score reset() window7.show() scoremsg = ("Your Score Is: " + str(score)) Score = Text(window6, text=scoremsg, color="#000000", font="Ariel", size="25", grid=[1, 3]) Score1 = Text(window7, text=scoremsg, color="#000000", font="Ariel", size="25", grid=[1, 3]) if players == 2: try: test = int(p1field.value) test = int(p2field.value) except: Text(window5, text="One or Both of the inputs are invalid", color="#000000", size="10", grid=[0, 5]) Text(window4, text="One or Both of the inputs are invalid", color="#000000", size="10", grid=[0, 5]) else: if int(p1field.value) == p1total: p1score = p1score + 1 if int(p2field.value) == p2total: p2score = p2score + 1 if int(p1field.value) != p1total: p1score = p1score if int(p2field.value) != p2total: p2score = p2score p1dis = ("Player One Scored: " + str(p1score)) p2dis = ("Player Two Scored: " + str(p2score)) Dis = Text(window8, text=p1dis, color="#000000", font="Ariel", size="10", grid=[0, 1]) Dis1 = Text(window8, text=p2dis, color="#000000", font="Ariel", size="10", grid=[0, 2]) reset() window8.show()
def ex(): size = 10 def ret_txt(): txt = "" num = 1 for l in data[val.value * size:size + val.value * size]: txt += str(num) + " :" + split(l, "/")[0] + "\n" num += 1 return txt file_name = "authors.txt" def go_next(): val.value = val.value + 1 text.clear() text.append(ret_txt()) prev.enable() if val.value * size + size > lenght: next_b.disable() refresh_butt(1) def go_prev(): val.value = val.value - 1 text.clear() text.append(ret_txt()) if val.value == 0: prev.disable() next_b.enable() refresh_butt() file = open(file_name, "r") data = file.readlines(1) file.close() lenght = len(data) def refresh_butt(a): if (slid.value + val.value * size) - 1 < lenght: button1.enable() else: button1.disable() def exit(): ap_ab.destroy() def a_auth(): file = open("albumes.txt", "r") authors = file.readlines() file.close() alb_name = replace(input_box.get(), " ", "_") check = False for i in authors[:]: if i[0:-1].lower() == alb_name.lower(): err_text.clear() err_text.append("Album xa engadido") check = True break if (slid.value + val.value * size) - 1 < lenght: auth_name = split(data[(slid.value + val.value * size) - 1], "/")[0] xen_name = split(data[(slid.value + val.value * size) - 1], "/")[1][:-1] else: check = True if check == False: file = open("albumes.txt", "r") act_data = file.read() file.close() os.mkdir("songs/" + xen_name + "/" + auth_name + "/" + alb_name) file = open("albumes.txt", "w") file.write(act_data + alb_name + "/" + auth_name + "/" + xen_name + "\n") file.close err_text.clear() err_text.append("Album correctamente anhadido") ap_ab = App(title="Anhadir album", layout="grid", height=400, width=350) input_box = TextBox(ap_ab, grid=[1, 0], width=30) n_text = Text(ap_ab, grid=[0, 0], text="Album: ", align="left") button1 = PushButton(ap_ab, text="Anhadir", command=a_auth, grid=[0, 1]) button2 = PushButton(ap_ab, text="Close", command=exit, grid=[1, 1]) slid = Slider(ap_ab, start=1, end=10, grid=[0, 2], horizontal=False, command=refresh_butt) prev = PushButton(ap_ab, command=go_prev, text="Prev", grid=[0, 3]) next_b = PushButton(ap_ab, command=go_next, text="Next", grid=[1, 3]) text = Text(ap_ab, grid=[1, 2]) val = Text(ap_ab, grid=[10, 10]) val.hide() val.value = 0 text.append(ret_txt()) err_text = Text(ap_ab, grid=[3, 0], align="left") ap_ab.display()
from guizero import App from guizero import App from guizero import App, Combo from guizero import App, Text from guizero import App, CheckBox from guizero import App, ButtonGroup from guizero import App, PushButton from guizero import App, info from guizero import App, Slider from guizero import App, Picture from guizero import App, TextBox app = App(title="Survey", width=900, height=400) welocome = Text(app, text="Welcome. Please fill out the survey below.") space = Text(app, text=" ") questions_1 = Text(app, text="Do you enjoy my projects?", grid=[1, 0]) questions = ButtonGroup(app, options=[["No", "N"], ["Middle", "M"], ["Yes", "Y"]], selected="M", horizontal=True, grid=[1, 1], align="left") space1 = Text(app, text=" ") questions_12 = Text(app, text="Am I improving?", grid=[1, 0])
blazersWereHomeTeam = homeTeamName == "Trail Blazers" homeTeamWon = int(float(homeTeamScore)) > int(float(awayTeamScore)) if (homeTeamWon and blazersWereHomeTeam) or (not homeTeamWon and not blazersWereHomeTeam): if awayTeamName == "Lakers": time.value = "SUCK IT LLLAKERS!" else: time.value = "BLAZERS WIN!" else: time.value = "FINAL" updateTime = 1000 if not liveGame: updateTime = 60000 if not newGame: newGame = True logoSrc = gameDom.xpath('//img[@class="team-logo"]//@src') urllib.request.urlretrieve(logoSrc[0], "away_team.png") urllib.request.urlretrieve(logoSrc[1], "home_team.png") awayTeamLogo.value = "away_team.png" homeTeamLogo.value = "home_team.png" score.after(updateTime, main) outerBox = Box(app, height="fill") innerBox = Box(outerBox, align="right") scoreBox = Box(innerBox) timeBox = Box(innerBox) homeTeamLogo = Picture(scoreBox, image="home_team.png", align="left") score = Text(scoreBox, "", size="30", align="left") awayTeamLogo = Picture(scoreBox, image="away_team.png", align="left") time = Text(timeBox, "", size=20) score.after(1000, main) app.display()