def play(self):
        '''
        '''

        Cleaner.clean_wait_begin(self, self.check_begin)
        self.init_slot_descriptions()
        #change the picture
        self.background_wait_begin = Picture(self.app,
                                             image=PATH_RESSOURCES +
                                             "background_play.jpg",
                                             grid=[0, 0, 40, 40])
        response = str(
            requests.get(BASE_URL + '/play/round/1/hand/' +
                         self.token).content)[2:-1]
        datas = json.loads(response)
        self.cards = []
        idx_pos = 1
        for data in datas:
            self.cards.append(
                PushButton(self.app,
                           image=PATH_RESSOURCES + "cards_min/card_" +
                           data["image"] + "_min.png",
                           command=self.show_card,
                           args=[data],
                           grid=[idx_pos, 35]))
            idx_pos += 1
def fourcard():
    random.shuffle(mylist)  #randomly shuffer
    cardNum1 = mylist[0]  #define card Number to the first on the list
    cardNum2 = mylist[1]  # define card Number to the second on the list
    cardNum3 = mylist[2]  # define card Number to the third on the list
    cardNum4 = mylist[3]  # define card Number to the fourth on the list
    randCard1 = "PlayingCards/" + str(cardNum1) + ".png"
    randCard2 = "PlayingCards/" + str(cardNum2) + ".png"
    randCard3 = "PlayingCards/" + str(cardNum3) + ".png"
    randCard4 = "PlayingCards/" + str(
        cardNum4) + ".png"  #define rankcard as file directory of a card
    mylist.remove(cardNum1)  #Remove the card just used from list
    mylist.remove(cardNum2)
    mylist.remove(cardNum3)
    mylist.remove(cardNum4)
    picture1 = Picture(app, image=randCard1, grid=[2, 1])  #define the picture
    picture2 = Picture(app, image=randCard2, grid=[2, 2])  # define the picture
    picture3 = Picture(app, image=randCard3, grid=[2, 3])  # define the picture
    picture4 = Picture(app, image=randCard4, grid=[2, 4])  # define the picture
    total = cardNum1 + cardNum2 + cardNum3 + cardNum4
    Text(app, text=(total), grid=[6, 6])
    guessbox = TextBox(app, grid=[3, 0])
    if len(mylist) == 0:
        window.show()
        app.hide()
Beispiel #3
0
def check_input():
    if un_box.value == username and pw_box.value == password:
        message = Text(app, text='Correct')
        Picture(app, image="Kim.gif")
    else:
        message = Text(app, text='Virus Detected')
        Picture(app, image="giphy.gif")
Beispiel #4
0
class Gui(object):
    # text, picture = {}
    buttons = []

    # app = {}

    # The class "constructor" - It's actually an initializer
    def __init__(self, text, picture, buttons):
        self.app = App(title="guessthepartei")
        # self.app.on_close(exit(0))

        self.picture = Picture(self.app, image=picture)
        self.text = Text(self.app, text=text)
        print(buttons)
        self.buttonbox = Box(self.app, layout="grid")
        i = 0
        for x in buttons:
            print(x)
            self.buttons.append(
                PushButton(self.buttonbox,
                           command=x['command'],
                           grid=[i, 0],
                           text=x['text']))
            i += 1
        self.app.display()

    def set_picture(self, picture):
        self.picture.set(picture)

    def set_text(self, text):
        self.text.clear()
        self.text.append(text)

    def close(self):
        self.app.destroy()
Beispiel #5
0
 def __init__(self):
     self.app = App(title="guessthepartei")
     # self.app.on_close(exit(0))
     # self.game = game
     self.score = 0
     self.statusbox = Box(self.app, layout="grid", border=1)
     self.next_btn = PushButton(self.statusbox,
                                command=self.next,
                                width=34,
                                grid=[1, 0],
                                text='Next')
     self.status = Text(self.statusbox,
                        text="",
                        width=30,
                        height=5,
                        grid=[0, 0])
     self.scoretext = Text(self.statusbox,
                           text="Score: ",
                           width=33,
                           height=5,
                           grid=[2, 0])
     self.text = Text(self.app, text="", height=7)
     self.buttonbox = Box(self.app, layout="grid")
     self.add_buttons()
     Box(self.app, height=10, width=100, layout='grid')
     self.init()
     self.picture = Picture(self.app,
                            image=self.solution,
                            visible=False,
                            height=1000)
     self.app.display()
Beispiel #6
0
    def __init__(self, cam_control):
        # Configuring GUI application
        self.app = App('Pi-Snap', width=1920, height=1200)
        self.cam = Camera()

        self.cam_control = cam_control

        # Main page(frame)
        self.main = Box(self.app)
        self.main_img = Picture(self.main, image='./static/main.png')
        self.new_pic_btn = PushButton(self.main, cam_control, text='New pic')

        # Result page(frame)
        self.result = Box(self.app)
        self.title_txt = Text(self.result, text='Ta-da!', size=40, color='#1956b7')
        self.result_img = Picture(self.result)
        self.guide_txt = Text(
            self.result,
            text='If you want to receive this picture, Please enter your email :)',
            size=25
        )
        self.email_txt = TextBox(self.result, width=25)
        self.send_btn = PushButton(self.result, self.send_email, text='Send')
        self.cancel_btn = PushButton(self.result, self.go_to_main, text='Cancel')
        self.result.visible = False

        self.th = threading.Thread(target=self.read_button)
        self.th.daemon = True
    def __init__(self):
        # Variables definition
        self.volume = 0.1
        self.silence_frame = 50
        self.noise_value = 0
        self.db_value = 0
        self.state = False #  0 = Pause; 1 = play
        # ========== GUI =============
        # Create the GUI app
        self.app = App(title="Lombard effect on speech in Parkinson's disease App")
        # Energy detection option
        self.message = Text(self.app, text="Select threshold for voice detection")
        self.slider = Slider(self.app,start=0,end=6, command=self.slider_noise)
        # Noise characteristic option
        self.message2 = Text(self.app,text="Select noise in dB")
        self.slider2 = Slider(self.app,start=0,end=10,command=self.slider_db)
        # Play/pause button
        self.button = PushButton(self.app,text="Start/Stop", command=self.play_pause)
        self.state_text = Text(self.app, text="Off")
        logo1 = Picture(self.app, "./img/UZA.png")
        logo2 = Picture(self.app, "./img/inesc.png")
        # ========== Audio ===============
        # Initialization PyAudio Object
        pA = pyaudio.PyAudio()
        # Open microphine and heaset stream
        self.mic = pA.open(format=FORMAT, channels=CHANNELS,
                rate=SAMPLE_RATE, input=True,
                frames_per_buffer=PERIOD_SIZE_IN_FRAME)
        self.speak = pA.open(format=FORMAT, channels=CHANNELS,
                rate=SAMPLE_RATE, output=True)
        # Event loop
        self.app.repeat(10,self.loop_func) #here we made the loop function every 10ms

        # Display the app
        self.app.display()
Beispiel #8
0
def play_investigate():
    global coolcounter
    clean_contentlist()
    pick = random.randrange(0, len(chara_list))
    while chara_list[pick].status != 1:
        pick = random.randrange(0, len(chara_list))
    chara_invest = chara_list[pick].name
    chara_index = pick

    message_invest = random.choice(invest_list)
    if "{0}" in message_invest:
        # print(message_invest)
        content_list.append(
            Picture(content_box,
                    image=read_asimage(chara_list[chara_index].image,
                                       0).resize(size_icon, Image.LANCZOS),
                    grid=[0, 1]))
        content_list.append(
            Picture(content_box,
                    image=read_asimage(icon_invest,
                                       0).resize(size_icon, Image.LANCZOS),
                    grid=[1, 1]))
        message_invest = message_invest.format(chara_invest)
        place_x = 2
    else:
        content_list.append(
            Picture(content_box,
                    image=read_asimage(icon_invest,
                                       0).resize(size_icon, Image.LANCZOS),
                    grid=[0, 1]))
        place_x = 1
    content_list.append(
        Text(content_box,
             text=text_wrap(message_invest),
             grid=[0, 2, place_x, 1],
             size=10,
             color="blue"))

    coolcounter -= 1
    if coolcounter == 0:
        content_list.append(
            PushButton(content_box,
                       text="Continue",
                       grid=[0, 3, place_x, 1],
                       command=play_clue))
    else:
        content_list.append(
            PushButton(content_box,
                       text="Continue",
                       grid=[0, 3, place_x, 1],
                       command=play_investigate))

    content_list.append(
        Text(content_box,
             font="Constantia",
             text="Investigating",
             grid=[0, 0, place_x, 1],
             size=12,
             color="blue",
             width="fill"))
def check_input():
    if un_box.value == username and pw_box.value == password:
        message = Text(app, text='Correct')
        picture = Picture(app, image="thumbs_up.jpg")
    else:
        message = Text(app, text='Incorrect')
        picture = Picture(app, image="thumbs_down.png")
def check_input():
    if un_box.value == username and pw_box.value == password:
        #message = Text(app, text='Correct')
        Picture(app, image="Tick.png")
    else:
        #message = Text(app, text="Incorrect!")
        Picture(app, image="giphy.gif")
        app.warn(title='Warning Virus Detected', text="Virus Detected")
Beispiel #11
0
def picp():
    picw = Window(welcome, title="Debian Max Pictures")
    pithanks = Text(picw,
                    text="Made Possible by Raspberry Pi and Raspibian",
                    size=10,
                    font="Times New Roman",
                    color="red")
    pi = Picture(picw, image="1436.gif")
    raspb = Picture(picw, image="rasp.gif")
    def wait_begin(self):
        '''
        '''

        Cleaner.clean_choose_faction(self)
        #change the picture
        self.background_wait_begin = Picture(self.app,
                                             image=PATH_RESSOURCES +
                                             "background_waiting.png",
                                             grid=[0, 0, 20, 20])
        self.background_wait_begin.repeat(1000, self.check_begin)
Beispiel #13
0
    def add_weather_controls(self):
        weather_heading_text = Text(self.app, text='Horsham Weather')

        self.weather_pic = Picture(self.app, image='horsham_weather.jpg')
        self.weather_pic.height = int(self.horsham_pic.height)
        self.weather_pic.width = int(self.horsham_pic.width)

        weather_heading_text.hide()
        self.weather_pic.hide()
        self.controls_dic[CurrentDisplay.WEATHER] = [
            weather_heading_text, self.weather_pic
        ]
Beispiel #14
0
def test_grid_layout():
    a = App(layout="grid")

    w = Picture(a, grid=[1, 2])
    grid_layout_test(w, 1, 2, 1, 1, None)

    ws = Picture(a, grid=[1, 2, 3, 4])
    grid_layout_test(ws, 1, 2, 3, 4, None)

    wa = Picture(a, grid=[1, 2], align="top")
    grid_layout_test(wa, 1, 2, 1, 1, "top")

    a.destroy()
Beispiel #15
0
def test_getters_setters():
    a = App()
    p = Picture(a)

    assert p.image == None
    p.image = "../examples/guizero.gif"
    assert p.image == "../examples/guizero.gif"
    assert p._image.tk_image is not None
    p.width = 100
    assert p.width == 100
    p.height = 100
    assert p.height == 100

    a.destroy()
Beispiel #16
0
def showBoard():
   
    global board, tileButtonDict, tileList, gameBoard, difficulty
    createGame(difficulty)
    

    rowLabelCount = 0
    columnLabelCount = 0

    if len(tileList) > 256:
        
        rowLength = int(len(tileList)/16)

    else:

        rowLength = math.sqrt(len(tileList)) 
        
    rowCount = 0
    columnCount = 0
  
    for tile in tileList:

        if not tile.isMined:

            surroundingMines = Text(board, text=str(tile.surroundingMineCount), grid=[columnCount,rowCount])
            surroundingMines.height = 2
            surroundingMines.width = 3
            textDict[tile.label] = surroundingMines

        else:

            picture = Picture(board, image='bomb2.jpg', grid=[columnCount,rowCount])   
            picture.height = 25
            picture.width = 15
            mineDict[tile.label] = picture
        
        tileButton = PushButton(board, command=playGame, image = 'blank.jpg' , args=[tile], grid=[columnCount,rowCount], text='')#str(tile)#.isMined))#str(tile))
        tileButton.bg = 'gray60'
        #print ('button grid', tileButton.grid)
        tileButton.when_right_button_pressed = markTile
        tileButton.width = 32
        tileButton.height = 37
        tileButtonDict[tile.label] = tileButton
        columnCount += 1
            
        if columnCount == rowLength:

            rowCount += 1
            columnCount = 0
Beispiel #17
0
 def show_gallery(self):
     self.gallery = Window(self.app,
                           bg="white",
                           height=300,
                           width=460,
                           layout="grid",
                           title="Gallery")
     self.saved_pictures = glob.glob('/home/pi/Downloads/*.jpg')
     self.shown_picture = self.saved_pictures[self.picture_index]
     button_left = PushButton(self.gallery,
                              grid=[0, 0],
                              width=40,
                              height=50,
                              pady=50,
                              padx=10,
                              image="/home/pi/piDSLM/icon/left.png",
                              command=self.picture_left)
     self.picture_gallery = Picture(self.gallery,
                                    width=360,
                                    height=270,
                                    image=self.shown_picture,
                                    grid=[1, 0])
     button_right = PushButton(self.gallery,
                               grid=[2, 0],
                               width=40,
                               height=50,
                               pady=50,
                               padx=10,
                               image="/home/pi/piDSLM/icon/right.png",
                               command=self.picture_right)
     self.gallery.show()
Beispiel #18
0
 def display_qr(self, trash_type):
     if hasattr(self, 'qr_widget'):
         self.qr_widget.destroy()
     self.detected_widget.clear()
     if trash_type is not None:
         self.detected_widget.append("Detected %s" % trash_type)
         self.qr_widget = Picture(self.app, "temp/qr.png")
Beispiel #19
0
 def dashboard(self):
     dashboard_box = Box(self.app, layout='grid')
     Picture(dashboard_box, image="sutro.png", grid=[2, 0])
     PushButton(dashboard_box,
                text='pH Level',
                command=calculate,
                args=[99],
                grid=[1, 2],
                width=10,
                height=1).text_size = 15
     PushButton(dashboard_box,
                text='ORP',
                command=calculate,
                args=[98],
                grid=[2, 2],
                width=10,
                height=1).text_size = 15
     PushButton(dashboard_box,
                text='Temperature',
                command=calculate,
                args=[100],
                grid=[3, 2],
                width=10,
                height=1).text_size = 15
     pHVal = Text(dashboard_box, text='_ _ _ _', grid=[1, 4], size=25)
     orpVal = Text(dashboard_box, text='_ _ _ _', grid=[2, 4], size=25)
     tempVal = Text(dashboard_box, text='_ _ _ _', grid=[3, 4], size=25)
Beispiel #20
0
def check_user():
    if un_box.value == un and pw_box.value == pw:
        message = Text(app, text='Access Granted', color=(0, 255, 0))
        picture = Picture(app, image="Pictures\\Ford_MustangGT500.png")

    else:
        message = Text(app, text='Access Denied', color=(0, 255, 0))
def card():
    random.shuffle(mylist)  #randomly shuffer
    cardNum = mylist[0]  #define card Number to the first on the list
    randCard = "PlayingCards/" + str(
        cardNum) + ".png"  #define rankcard as file directory of a card
    picture = Picture(app, image=randCard, grid=[0, 1])  #define the picture
    mylist.remove(cardNum)
    def faction(self):
        '''
        '''

        Cleaner.clean_wait_player(self, self.check_players)
        self.background_faction = Picture(self.app,
                                          image=PATH_RESSOURCES +
                                          "background_faction.png",
                                          grid=[0, 0, 20, 20])
        self.button_faction_1 = PushButton(self.app,
                                           image=PATH_RESSOURCES +
                                           "faction1.png",
                                           command=self.choose_faction,
                                           args=[1],
                                           grid=[7, 12])
        self.button_faction_2 = PushButton(self.app,
                                           image=PATH_RESSOURCES +
                                           "faction2.png",
                                           command=self.choose_faction,
                                           args=[2],
                                           grid=[8, 12])
        self.button_faction_3 = PushButton(self.app,
                                           image=PATH_RESSOURCES +
                                           "faction3.png",
                                           command=self.choose_faction,
                                           args=[3],
                                           grid=[9, 12])
        self.button_faction_4 = PushButton(self.app,
                                           image=PATH_RESSOURCES +
                                           "faction4.png",
                                           command=self.choose_faction,
                                           args=[4],
                                           grid=[10, 12])
def threaded_function2():
    global app
    app = App(title="MSHD - Metereologic Sense Hat Device",
              height=900,
              width=1440)
    global welcome_message

    welcome_message = Text(app,
                           text="Know the weather",
                           size=25,
                           font="Times New Roman",
                           color="blue")

    text_size = Slider(app, command=change_text_size, start=30, end=100)

    weather = Picture(app, image="screen.gif")

    global weather_options
    weather_options = Combo(app,
                            options=[
                                "Air pressure", "Ambient Temperature",
                                "Ground Temperature", "Humidity", "Rainfall",
                                "Room Temperature", "Wind Speed"
                            ],
                            grid=[0, 1],
                            align="left")

    Run_app = PushButton(app,
                         show_weather,
                         text="select",
                         grid=[3, 1],
                         align="left")
    app.display()
    def show_card(self, card):
        '''
        '''

        if self.card_img_big is not None:
            Cleaner.clean_slot_descriptions(self)
        self.card_img_big = Picture(self.app,
                                    image=PATH_RESSOURCES + "cards/card_" +
                                    card["image"] + ".png",
                                    grid=[30, 5, 7, 19])
        self.name_card = Text(self.app,
                              text=card["name"],
                              font="Impact",
                              color="white",
                              size=20,
                              align="left",
                              grid=[30, 25, 10, 1])
        self.description_card = Text(self.app,
                                     text="\"" +
                                     self.cut_line(card["description"]) + "\"",
                                     font="Impact",
                                     color="white",
                                     size=18,
                                     align="left",
                                     grid=[30, 27, 10, 3])
        self.description_power_card = Text(self.app,
                                           text=self.cut_line(
                                               card["description_power"]),
                                           font="Impact",
                                           color="white",
                                           size=18,
                                           align="left",
                                           grid=[30, 31, 10, 3])
Beispiel #25
0
def CreatePressGraph():
    pressArray = []
    timeArray = []
    dateArray = []

    plt.clf()

    graphWindow = Window(app, title="Pressure Graph")
    graphWindow.width = 650
    graphWindow.height = 500

    record = connection.execute("SELECT * FROM WeatherData")
    for row in record:
        pressArray.append(row[3])
        timeArray.append(row[4])
        dateArray.append(row[5])

    endDate = len(dateArray) - 1

    plt.plot(timeArray, pressArray)
    plt.ylabel("Pressure")
    plt.xlabel("Time (HHMMSS) from " + str(dateArray[0]) + " to " +
               str(dateArray[endDate - 1]) + " (YYYYMMDD)")
    plt.savefig("pressGraph.png")

    graphImage = Picture(graphWindow, image="pressGraph.png")
Beispiel #26
0
def open_habitat_window():

    app.hide()  # hide main window

    #Habitat window code and widgets
    habitat_window = Window(app, title="Habitat")
    Text(habitat_window, text="")
    picture = Picture(habitat_window,
                      image="images/geograph-1619354-by-N-Chadwick.png")

    Text(habitat_window, text="")
    arrival_Button = PushButton(habitat_window,
                                text='Take an arrival card',
                                command=take_arrival_card)
    habitatList = (habitats(db))
    Text(habitat_window, text="Player #")
    player_num = Combo(habitat_window, options=[1, 2, 3, 4, 5, 6])
    Text(habitat_window, text="Select habitat")
    habitat_dropdown = Combo(habitat_window, options=habitatList)
    Text(habitat_window, text="Number of birds spotted: ")
    num_spottings = Combo(habitat_window, options=[3, 1, 2, 4, 5, 6])
    confirm_Button = PushButton(
        habitat_window,
        text='Start Spotting!',
        command=habitat_bird,
        args=[habitat_window, player_num, habitat_dropdown, num_spottings])
    cancel_Button = PushButton(habitat_window,
                               text='Cancel',
                               command=cancel_habitat_window,
                               args=[habitat_window])
Beispiel #27
0
def tasto2():
    plt.scatter(coordX,coordY)
    plt.plot(coordX,coordY)
    plt.ylabel('some numbers')
    plt.show()
    plt.savefig("grafico.png")
    picture = Picture(app, image="grafico.png")
    output.append(picture)
Beispiel #28
0
def check_user():
    if un_box.value == un and pw_box.value == pw:
        message = Picture(
            app,
            image="C:\\Users\\student\\Pictures\\Saved Pictures\\flower1.png")

    else:
        message = Text(app, text="Access Denied")
 def show_and_crop(image_name, output_dir=None):
     """
     Load an image, create the very simple GUI, crop when we have three clicks, then return
     """
     logging.info(
         'Pick three points - top left, top left + 1 square diagonally, then bottom right'
     )
     grid = ImageGrid(image_name, output_dir)
     app = App(title=f'Grid Finder - {image_name}',
               width=grid.im.width,
               height=grid.im.height,
               layout='auto')
     app.tk.resizable(False, False)
     picture = Picture(app, image=grid.im)
     picture.when_clicked = grid.handle_click()
     picture.tk.config(cursor='cross')
     app.display()
def show_picture():
    global box
    path = str(get_last_pic())
    picture = Picture(box,
                      image=path,
                      grid=[1, 2],
                      width=PICTURE_WIDTH,
                      height=PICTURE_HEIGHT)
Beispiel #31
0
        hltFlame.visible=False
        rimsFlame.visible=False
        bkFlame.visible=False
    return

app = App(title="Brew GUI", width=1280, height=768, layout="grid")
vertPad = Picture(app, image="blank_vert.gif", grid=[0,0])

hltBox = Box(app, layout="grid", grid=[1,0])
hltPad = Picture(hltBox, image="blank.gif", grid=[0,0])
hltTitle = Text(hltBox, text="HLT", grid=[0,1], align="top")
hltText = Text(hltBox, text="180", grid=[0,2], align="top")
hltSlider = Slider(hltBox, start=212, end=100, horizontal=False, grid=[0,3], align="top")
hltSlider.tk.config(length=500, width=50)
hltFlamePad = Picture(hltBox, image="blank_flame.gif", grid=[0,4])
hltFlame = Picture(hltBox, image="flame.gif", grid=[0,4])

rimsBox = Box(app, layout="grid", grid=[2,0])
rimsPad = Picture(rimsBox, image="blank.gif", grid=[0,0])
rimsTitle = Text(rimsBox, text="RIMS", grid=[0,1], align="top")
rimsText = Text(rimsBox, text="180", grid=[0,2], align="top")
rimsSlider = Slider(rimsBox, start=212, end=100, horizontal=False, grid=[0,3], align="top")
rimsSlider.tk.config(length=500, width=50)
rimsFlamePad = Picture(rimsBox, image="blank_flame.gif", grid=[0,4])
rimsFlame = Picture(rimsBox, image="flame.gif", grid=[0,4])

bkBox = Box(app, layout="grid", grid=[3,0])
bkPad = Picture(bkBox, image="blank.gif", grid=[0,0])
bkTitle = Text(bkBox, text="BK", grid=[0,1], align="top")
bkText = Text(bkBox, text="75", grid=[0,2], align="top")
bkSlider = Slider(bkBox, start=100, end=0, horizontal=False, grid=[0,3], align="top")