예제 #1
0
def speak():
    root8 = Tk()
    root8.geometry('420x100+550+200')
    lbl = Label(root8,
                text='''Если Вам интересны наши цены
    подойдите к табличке!''',
                font=("Cambria", 20),
                fg="DarkSlateBlue")
    lbl.place(x=1, y=15)
    root8.after(2000, lambda: root8.destroy())
    root8.mainloop()
예제 #2
0
 def stop_climbing():
     root6 = Tk()
     root6.geometry('600x130+400+300')
     story = Label(root6,
                   text='''Возможно у Вас недостаточно денег,
 для будущих покупок! Пройдите к кассе!''',
                   font=('Arial', 20),
                   fg='blue')
     story.place(x=5, y=20)
     root6.after(2000, lambda: root6.destroy())
     root6.mainloop()
예제 #3
0
 def how_much():
     window = Tk()
     window.geometry('300x250+530+180')
     lbl0 = Label(window,
                  text='У Вас примерно:',
                  font=("Cambria", 22),
                  fg="blue")
     lbl0.place(x=60, y=10)
     lbl = Label(window, text=[money], font=("Cambria", 40), fg="blue")
     lbl.place(x=100, y=60)
     lbl1 = Label(window, text='Грв.', font=("Cambria", 20), fg="blue")
     lbl1.place(x=100, y=150)
     window.after(2000, lambda: window.destroy())
     window.mainloop()
예제 #4
0
def no_product():
    root4 = Tk()
    root4.geometry('700x100+300+250')
    root4.title('Нет продукта')
    root4['bg'] = 'PapayaWhip'
    text2 = Label(root4,
                  text='Извините, такого продукта в нашем магазине нет!',
                  bg='PapayaWhip',
                  fg='Red',
                  font=('Comfortaa', 16))
    text2.place(x=30, y=20)

    root4.after(1000, lambda: root4.destroy())
    root4.mainloop()
예제 #5
0
def yes():
    global money
    money = float(entry_1.get())
    win = Tk()
    win.geometry('300x250+530+180')
    lbl0 = Label(win, text='У Вас с собой:', font=("Cambria", 20), fg="blue")
    lbl0.place(x=60, y=10)
    lbl = Label(win, text=[money], font=("Cambria", 40), fg="blue")
    lbl.place(x=100, y=60)
    lbl1 = Label(win, text='Грв.', font=("Cambria", 30), fg="blue")
    lbl1.place(x=100, y=150)
    root1.destroy()
    win.after(1000, lambda: win.destroy())
    win.mainloop()
    print(money)
예제 #6
0
def store_products():
    root7 = Tk()
    root7.geometry('830x300+300+230')
    story = Label(root7,
                  text='''В магазине сегодня распродажа!                    

    масло   -  54 грн           мясо    - 110 грн          капуста - 13 грн
    сахар   -  24.80 грн        рыба    - 80 грн           лук     - 12 грн
    молоко  -  26 грн           колбаса - 60 грн           хлеб    - 15 грн

    яйца    -  32.50 грн        рис     - 24.60 грн
    майонез -  28.90 грн        гречка  - 38.40 грн
                                                                                                    ''',
                  font=('Arial', 20),
                  fg='blue')
    story.pack()
    root7.after(4000, lambda: root7.destroy())
    root7.mainloop()
예제 #7
0
class Karaoke():
    def __init__(self):

        print('Pyhon version {}.{}.{}'.format(*sys.version_info))

        #     print(os.getenv('PATH')) # Get the environment path variable
        #     print(os.getcwd())

        # Placeholder
        #         self.currentSong = {'src' : 'musics/Vietnamese/Tre Productions - Nguoi Ay Va Toi Em Phai Cho Ai/Anh Co Quen Em - Cam Ly and VQL.vob', 'track' : 2}
        self.currentSong = {
            'src': 'musics/Vietnamese/Ai Lên Xứ Hoa Đào - Sơn Ca.VOB',
            'track': 2
        }

        # Init GUI
        self.gui = Tk()
        self.gui.protocol("WM_DELETE_WINDOW", self.onDeleteWindow)
        self.gui.geometry("450x450")
        self.gui.title(self.currentSong['src'] + ' Track : ' +
                       str(self.currentSong['track']))

        self.guiContainer = Frame(self.gui)
        self.guiContainer.pack()

        self.instance = vlc.Instance()
        self.player = self.instance.media_player_new()
        self.vlcEvents = self.player.event_manager()
        self.vlcEvents.event_attach(vlc.EventType.MediaPlayerEndReached,
                                    self.onEndReached)
        #         self.player.set_media(self.instance.media_new('../../../' + self.currentSong['src']))
        #         self.player.play()

        slider = Scale(self.gui,
                       orient=HORIZONTAL,
                       length=300,
                       width=20,
                       sliderlength=10,
                       from_=0,
                       to=1000,
                       tickinterval=100)
        slider.pack()

        nextBtn = Button(self.guiContainer)
        nextBtn['text'] = "Next"
        nextBtn.bind("<Button-1>", self.onNextClick)
        nextBtn.pack()

        toggleTrackBtn = Button(self.guiContainer,
                                text="Toggle Track",
                                command=self.onToggleTrackBtnClick)
        toggleTrackBtn.pack()

        #     print('Pyhon version {}.{}.{}' . format(*sys.version_info))
        def setInterval(func, sec):
            def funcWrapper():
                setInterval(func, sec)
                func()

            self.timer = Timer(sec, funcWrapper)
            self.timer.start()
            return self.timer

#         self.timer = setInterval(self.get_playlist, 2)

        self.iniVLC(self.currentSong)

        # Windows only thing
        self.gui.mainloop()  # Only for Windows user for now

    def get_playlist(self):
        #         print('Running')
        r = requests.get('https://karaoke.firebaseio.com/playlist.json')
        songDict = r.json()
        # Sort the list
        listSorted = sorted(songDict.keys())
        # Get the first song hash
        firstSongOjbKey = listSorted[0]
        # Get the first song data
        songObj = songDict[firstSongOjbKey]

        if songObj['src'] != self.currentSong['src']:
            # Play new song
            self.iniVLC(songObj)
        else:
            if songObj['track'] != self.currentSong['track']:
                self.currentSong['track'] = songObj['track']
                self.player.audio_set_track(songObj['track'])

        return self.currentSong

    def iniVLC(self, sObj):
        self.currentSong = sObj

        #         self.mediaListPlayer = vlc.MediaL

        # Init VLC
        self.player.stop()
        #         self.player.set_media(self.instance.media_new('../../../' + self.currentSong['src']))
        path = os.path.join('../../../', self.currentSong['src'])

        o = '../../../musics/Vietnamese/Ai Lên Xứ Hoa Đào - Sơn Ca.VOB'
        u = o.encode('utf-8', 'strict')
        d = str(u)  # Convert to String
        n = d.replace("b'", "'")
        n = n.replace("'", '')

        w = '../../../musics/Vietnamese/Ai L\xc3\xaan X\xe1\xbb\xa9 Hoa \xc4\x90\xc3\xa0o - S\xc6\xa1n Ca.VOB'  # utf-8 bytes as a string
        print('w', type(w), w)

        l = '../../../musics/Vietnamese/Ai Lên Xứ Hoa Đào - Sơn Ca.VOB'
        print('l', type(l), l)

        print(w == n)

        #         ../../../musics/Vietnamese/Ai L\xc3\xaan X\xe1\xbb\xa9 Hoa \xc4\x90\xc3\xa0o - S\xc6\xa1n Ca.VOB
        #         self.player.set_media(self.instance.media_new('../../../musics/Vietnamese/Ai L\\\\xc3\\\\xaan X\\\\xe1\\\\xbb\\\\xa9 Hoa \\\\xc4\\\\x90\\\\xc3\\\\xa0o - S\\\\xc6\\\\xa1n Ca.VOB'))
        self.player.set_media(self.instance.media_new())
        #         self.player.set_media(self.instance.media_new(ub))
        self.player.play()

#         if sys.platform == "linux2": # for Linux using the X Server
#             self.player.set_xwindow(guiContainer.winfo_id())
#         elif sys.platform == "win32": # for Windows
#             self.player.set_hwnd(guiContainer.winfo_id())
#         elif sys.platform == "darwin": # for MacOS
#             self.player.set_agl(guiContainer.winfo_id())
#

    def onToggleTrackBtnClick(self):
        audioTrack = self.player.audio_get_track()
        trackNum = 1 if int(audioTrack) == 2 else 2
        self.player.audio_set_track(trackNum)
        print('onToggleTrackBtn click')

    def onNextClick(self, event):
        self.gui.destroy()

    def onEndReached(self, evt):
        print(evt)

    def onPlay(self, evt):
        print('onPlay')

    def onDeleteWindow(self):
        print('exit')
        self.gui.destroy()
        self.timer.cancel()
        #         os.abort()
        sys.exit()
예제 #8
0
                     font=("Cambria", 20))
        lbl2 = Label(root9,
                     text="--------------------------------",
                     font=("Cambria", 20))
        lbl3 = Label(root9, text=f"{cart}", font=("Cambria", 20))
        lbl4 = Label(root9,
                     text="--------------------------------",
                     font=("Cambria", 20))
        lbl5 = Label(root9, text=f"Сдача: {money} грн.", font=("Cambria", 20))
        lbl.place(x=10, y=15)
        lbl1.place(x=10, y=55)
        lbl2.place(x=10, y=95)
        lbl3.place(x=10, y=130)
        lbl4.place(x=10, y=260)
        lbl5.place(x=10, y=300)
        root9.after(2000, lambda: root9.destroy())
        root9.mainloop()
        playerY += 45

        # # my_products_and_money()
        # for prod, price in buyin.items():
        #     print(f"{prod}  --- {price} грн.")
        # print('Приходите к нам ещё! :)')

    fpsClock.tick(FPS)
    screen.fill((33, 46, 123))
    screen.blit(floorImg, (0, 0))
    screen.blit(ball1Img, (x1, y1))
    Sman(SmanX, SmanY)
    cashbox(cashbX, cashbY)
    man(manX, manY)
예제 #9
0
class Karaoke():
    
    def __init__(self):
        
        print('Pyhon version {}.{}.{}' . format(*sys.version_info))
    
        #     print(os.getenv('PATH')) # Get the environment path variable
        #     print(os.getcwd())

        # Placeholder
#         self.currentSong = {'src' : 'musics/Vietnamese/Tre Productions - Nguoi Ay Va Toi Em Phai Cho Ai/Anh Co Quen Em - Cam Ly and VQL.vob', 'track' : 2}
        self.currentSong = {'src' : 'musics/Vietnamese/Ai Lên Xứ Hoa Đào - Sơn Ca.VOB', 'track' : 2}
        
        # Init GUI
        self.gui = Tk()
        self.gui.protocol("WM_DELETE_WINDOW", self.onDeleteWindow)
        self.gui.geometry("450x450")
        self.gui.title(self.currentSong['src'] + ' Track : ' + str(self.currentSong['track']))
        
        self.guiContainer = Frame(self.gui)
        self.guiContainer.pack()
        
        self.instance = vlc.Instance()
        self.player = self.instance.media_player_new()
        self.vlcEvents = self.player.event_manager()
        self.vlcEvents.event_attach(vlc.EventType.MediaPlayerEndReached, self.onEndReached)
#         self.player.set_media(self.instance.media_new('../../../' + self.currentSong['src']))
#         self.player.play()
        
        slider = Scale(self.gui,orient=HORIZONTAL,length=300,width=20,sliderlength=10,from_=0,to=1000,tickinterval=100)
        slider.pack()

        nextBtn = Button(self.guiContainer)
        nextBtn['text'] = "Next"
        nextBtn.bind("<Button-1>", self.onNextClick)
        nextBtn.pack()
        
        toggleTrackBtn = Button(self.guiContainer, text="Toggle Track", command=self.onToggleTrackBtnClick)
        toggleTrackBtn.pack()
        
    #     print('Pyhon version {}.{}.{}' . format(*sys.version_info))
        def setInterval(func, sec):
            def funcWrapper():
                setInterval(func, sec)
                func()
            self.timer = Timer(sec, funcWrapper)
            self.timer.start()
            return self.timer
            
#         self.timer = setInterval(self.get_playlist, 2)
        
        self.iniVLC(self.currentSong)
        
        
        # Windows only thing    
        self.gui.mainloop() # Only for Windows user for now
        
    def get_playlist(self):
#         print('Running')
        r = requests.get('https://karaoke.firebaseio.com/playlist.json')
        songDict = r.json()
        # Sort the list
        listSorted = sorted(songDict.keys())
        # Get the first song hash
        firstSongOjbKey = listSorted[0]
        # Get the first song data
        songObj = songDict[firstSongOjbKey]
        
        if songObj['src'] != self.currentSong['src'] :
            # Play new song
            self.iniVLC(songObj)
        else :
            if songObj['track'] != self.currentSong['track'] :
                self.currentSong['track'] = songObj['track'] 
                self.player.audio_set_track(songObj['track'])
        
        return self.currentSong
    
    def iniVLC(self, sObj):
        self.currentSong = sObj
        
#         self.mediaListPlayer = vlc.MediaL
        
        # Init VLC
        self.player.stop()
#         self.player.set_media(self.instance.media_new('../../../' + self.currentSong['src']))
        path = os.path.join('../../../', self.currentSong['src'])
        
        o = '../../../musics/Vietnamese/Ai Lên Xứ Hoa Đào - Sơn Ca.VOB'
        u = o.encode('utf-8', 'strict')
        d = str(u) # Convert to String
        n = d.replace("b'", "'")  
        n = n.replace("'", '') 
        
        w = '../../../musics/Vietnamese/Ai L\xc3\xaan X\xe1\xbb\xa9 Hoa \xc4\x90\xc3\xa0o - S\xc6\xa1n Ca.VOB' # utf-8 bytes as a string
        print('w', type(w), w)
        
        l = '../../../musics/Vietnamese/Ai Lên Xứ Hoa Đào - Sơn Ca.VOB'
        print('l', type(l), l)
        
        print (w == n)
        
#         ../../../musics/Vietnamese/Ai L\xc3\xaan X\xe1\xbb\xa9 Hoa \xc4\x90\xc3\xa0o - S\xc6\xa1n Ca.VOB
#         self.player.set_media(self.instance.media_new('../../../musics/Vietnamese/Ai L\\\\xc3\\\\xaan X\\\\xe1\\\\xbb\\\\xa9 Hoa \\\\xc4\\\\x90\\\\xc3\\\\xa0o - S\\\\xc6\\\\xa1n Ca.VOB'))
        self.player.set_media(self.instance.media_new())
#         self.player.set_media(self.instance.media_new(ub))
        self.player.play()
        
#         if sys.platform == "linux2": # for Linux using the X Server
#             self.player.set_xwindow(guiContainer.winfo_id())
#         elif sys.platform == "win32": # for Windows
#             self.player.set_hwnd(guiContainer.winfo_id())
#         elif sys.platform == "darwin": # for MacOS
#             self.player.set_agl(guiContainer.winfo_id())
#         
    def onToggleTrackBtnClick(self):
        audioTrack = self.player.audio_get_track()
        trackNum = 1 if int(audioTrack) == 2 else 2
        self.player.audio_set_track(trackNum)
        print('onToggleTrackBtn click')
            
    def onNextClick(self, event):
        self.gui.destroy()
            
    def onEndReached(self, evt):
        print(evt)
            
    def onPlay(self, evt):
        print('onPlay')
        
    def onDeleteWindow(self):
        print('exit')
        self.gui.destroy()
        self.timer.cancel()
#         os.abort()
        sys.exit()